babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** 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 */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** 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 */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** 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 */
  640. static readonly GEQUAL: number;
  641. /** 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 */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /**
  946. * Gets or sets base Assets URL
  947. */
  948. static PARTICLES_BaseAssetsUrl: string;
  949. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  950. * Test order :
  951. * Is the bounding sphere outside the frustum ?
  952. * If not, are the bounding box vertices outside the frustum ?
  953. * It not, then the cullable object is in the frustum.
  954. */
  955. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  956. /** Culling strategy : Bounding Sphere Only.
  957. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  958. * It's also less accurate than the standard because some not visible objects can still be selected.
  959. * Test : is the bounding sphere outside the frustum ?
  960. * If not, then the cullable object is in the frustum.
  961. */
  962. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  963. /** Culling strategy : Optimistic Inclusion.
  964. * This in an inclusion test first, then the standard exclusion test.
  965. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  966. * 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.
  967. * Anyway, it's as accurate as the standard strategy.
  968. * Test :
  969. * Is the cullable object bounding sphere center in the frustum ?
  970. * If not, apply the default culling strategy.
  971. */
  972. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  973. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  974. * This in an inclusion test first, then the bounding sphere only exclusion test.
  975. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  976. * 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.
  977. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  978. * Test :
  979. * Is the cullable object bounding sphere center in the frustum ?
  980. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  981. */
  982. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  983. /**
  984. * No logging while loading
  985. */
  986. static readonly SCENELOADER_NO_LOGGING: number;
  987. /**
  988. * Minimal logging while loading
  989. */
  990. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  991. /**
  992. * Summary logging while loading
  993. */
  994. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  995. /**
  996. * Detailled logging while loading
  997. */
  998. static readonly SCENELOADER_DETAILED_LOGGING: number;
  999. }
  1000. }
  1001. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1002. import { Nullable } from "babylonjs/types";
  1003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1004. /**
  1005. * This represents the required contract to create a new type of texture loader.
  1006. */
  1007. export interface IInternalTextureLoader {
  1008. /**
  1009. * Defines wether the loader supports cascade loading the different faces.
  1010. */
  1011. supportCascades: boolean;
  1012. /**
  1013. * This returns if the loader support the current file information.
  1014. * @param extension defines the file extension of the file being loaded
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @param fallback defines the fallback internal texture if any
  1017. * @param isBase64 defines whether the texture is encoded as a base64
  1018. * @param isBuffer defines whether the texture data are stored as a buffer
  1019. * @returns true if the loader can load the specified file
  1020. */
  1021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1022. /**
  1023. * Transform the url before loading if required.
  1024. * @param rootUrl the url of the texture
  1025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1026. * @returns the transformed texture
  1027. */
  1028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1029. /**
  1030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1031. * @param rootUrl the url of the texture
  1032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1033. * @returns the fallback texture
  1034. */
  1035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1036. /**
  1037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1038. * @param data contains the texture data
  1039. * @param texture defines the BabylonJS internal texture
  1040. * @param createPolynomials will be true if polynomials have been requested
  1041. * @param onLoad defines the callback to trigger once the texture is ready
  1042. * @param onError defines the callback to trigger in case of error
  1043. */
  1044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1045. /**
  1046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param callback defines the method to call once ready to upload
  1050. */
  1051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1052. }
  1053. }
  1054. declare module "babylonjs/Engines/IPipelineContext" {
  1055. /**
  1056. * Class used to store and describe the pipeline context associated with an effect
  1057. */
  1058. export interface IPipelineContext {
  1059. /**
  1060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1061. */
  1062. isAsync: boolean;
  1063. /**
  1064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1065. */
  1066. isReady: boolean;
  1067. /** @hidden */
  1068. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1069. }
  1070. }
  1071. declare module "babylonjs/Meshes/dataBuffer" {
  1072. /**
  1073. * Class used to store gfx data (like WebGLBuffer)
  1074. */
  1075. export class DataBuffer {
  1076. /**
  1077. * Gets or sets the number of objects referencing this buffer
  1078. */
  1079. references: number;
  1080. /** Gets or sets the size of the underlying buffer */
  1081. capacity: number;
  1082. /**
  1083. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1084. */
  1085. is32Bits: boolean;
  1086. /**
  1087. * Gets the underlying buffer
  1088. */
  1089. readonly underlyingResource: any;
  1090. }
  1091. }
  1092. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1093. /** @hidden */
  1094. export interface IShaderProcessor {
  1095. attributeProcessor?: (attribute: string) => string;
  1096. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1097. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1098. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1099. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1100. lineProcessor?: (line: string, isFragment: boolean) => string;
  1101. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1102. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1103. }
  1104. }
  1105. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1106. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1107. /** @hidden */
  1108. export interface ProcessingOptions {
  1109. defines: string[];
  1110. indexParameters: any;
  1111. isFragment: boolean;
  1112. shouldUseHighPrecisionShader: boolean;
  1113. supportsUniformBuffers: boolean;
  1114. shadersRepository: string;
  1115. includesShadersStore: {
  1116. [key: string]: string;
  1117. };
  1118. processor?: IShaderProcessor;
  1119. version: string;
  1120. platformName: string;
  1121. lookForClosingBracketForUniformBuffer?: boolean;
  1122. }
  1123. }
  1124. declare module "babylonjs/Misc/stringTools" {
  1125. /**
  1126. * Helper to manipulate strings
  1127. */
  1128. export class StringTools {
  1129. /**
  1130. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static EndsWith(str: string, suffix: string): boolean;
  1136. /**
  1137. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1138. * @param str Source string
  1139. * @param suffix Suffix to search for in the source string
  1140. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1141. */
  1142. static StartsWith(str: string, suffix: string): boolean;
  1143. }
  1144. }
  1145. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1146. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1172. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1173. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1174. /** @hidden */
  1175. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1176. process(preprocessors: {
  1177. [key: string]: string;
  1178. }, options: ProcessingOptions): string;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1182. /** @hidden */
  1183. export class ShaderDefineExpression {
  1184. isTrue(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1190. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1191. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1192. /** @hidden */
  1193. export class ShaderCodeTestNode extends ShaderCodeNode {
  1194. testExpression: ShaderDefineExpression;
  1195. isValid(preprocessors: {
  1196. [key: string]: string;
  1197. }): boolean;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1201. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1213. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1224. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1225. /** @hidden */
  1226. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1235. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Misc/loadFileError" {
  1248. import { WebRequest } from "babylonjs/Misc/webRequest";
  1249. /**
  1250. * @ignore
  1251. * Application error to support additional information when loading a file
  1252. */
  1253. export class LoadFileError extends Error {
  1254. /** defines the optional web request */
  1255. request?: WebRequest | undefined;
  1256. private static _setPrototypeOf;
  1257. /**
  1258. * Creates a new LoadFileError
  1259. * @param message defines the message of the error
  1260. * @param request defines the optional web request
  1261. */
  1262. constructor(message: string,
  1263. /** defines the optional web request */
  1264. request?: WebRequest | undefined);
  1265. }
  1266. }
  1267. declare module "babylonjs/Offline/IOfflineProvider" {
  1268. /**
  1269. * Class used to enable access to offline support
  1270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1271. */
  1272. export interface IOfflineProvider {
  1273. /**
  1274. * Gets a boolean indicating if scene must be saved in the database
  1275. */
  1276. enableSceneOffline: boolean;
  1277. /**
  1278. * Gets a boolean indicating if textures must be saved in the database
  1279. */
  1280. enableTexturesOffline: boolean;
  1281. /**
  1282. * Open the offline support and make it available
  1283. * @param successCallback defines the callback to call on success
  1284. * @param errorCallback defines the callback to call on error
  1285. */
  1286. open(successCallback: () => void, errorCallback: () => void): void;
  1287. /**
  1288. * Loads an image from the offline support
  1289. * @param url defines the url to load from
  1290. * @param image defines the target DOM image
  1291. */
  1292. loadImage(url: string, image: HTMLImageElement): void;
  1293. /**
  1294. * Loads a file from offline support
  1295. * @param url defines the URL to load from
  1296. * @param sceneLoaded defines a callback to call on success
  1297. * @param progressCallBack defines a callback to call when progress changed
  1298. * @param errorCallback defines a callback to call on error
  1299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1300. */
  1301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1302. }
  1303. }
  1304. declare module "babylonjs/Misc/filesInputStore" {
  1305. /**
  1306. * Class used to help managing file picking and drag'n'drop
  1307. * File Storage
  1308. */
  1309. export class FilesInputStore {
  1310. /**
  1311. * List of files ready to be loaded
  1312. */
  1313. static FilesToLoad: {
  1314. [key: string]: File;
  1315. };
  1316. }
  1317. }
  1318. declare module "babylonjs/Misc/retryStrategy" {
  1319. import { WebRequest } from "babylonjs/Misc/webRequest";
  1320. /**
  1321. * Class used to define a retry strategy when error happens while loading assets
  1322. */
  1323. export class RetryStrategy {
  1324. /**
  1325. * Function used to defines an exponential back off strategy
  1326. * @param maxRetries defines the maximum number of retries (3 by default)
  1327. * @param baseInterval defines the interval between retries
  1328. * @returns the strategy function to use
  1329. */
  1330. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1331. }
  1332. }
  1333. declare module "babylonjs/Misc/fileTools" {
  1334. import { WebRequest } from "babylonjs/Misc/webRequest";
  1335. import { Nullable } from "babylonjs/types";
  1336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1338. /**
  1339. * @hidden
  1340. */
  1341. export class FileTools {
  1342. /**
  1343. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1344. */
  1345. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1346. /**
  1347. * Gets or sets the base URL to use to load assets
  1348. */
  1349. static BaseUrl: string;
  1350. /**
  1351. * Default behaviour for cors in the application.
  1352. * It can be a string if the expected behavior is identical in the entire app.
  1353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1354. */
  1355. static CorsBehavior: string | ((url: string | string[]) => string);
  1356. /**
  1357. * Gets or sets a function used to pre-process url before using them to load assets
  1358. */
  1359. static PreprocessUrl: (url: string) => string;
  1360. /**
  1361. * Removes unwanted characters from an url
  1362. * @param url defines the url to clean
  1363. * @returns the cleaned url
  1364. */
  1365. private static _CleanUrl;
  1366. /**
  1367. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1368. * @param url define the url we are trying
  1369. * @param element define the dom element where to configure the cors policy
  1370. */
  1371. static SetCorsBehavior(url: string | string[], element: {
  1372. crossOrigin: string | null;
  1373. }): void;
  1374. private static _ArrayBufferToBase64;
  1375. /**
  1376. * Loads an image as an HTMLImageElement.
  1377. * @param input url string, ArrayBuffer, or Blob to load
  1378. * @param onLoad callback called when the image successfully loads
  1379. * @param onError callback called when the image fails to load
  1380. * @param offlineProvider offline provider for caching
  1381. * @param mimeType optional mime type
  1382. * @returns the HTMLImageElement of the loaded image
  1383. */
  1384. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  1385. /**
  1386. * Loads a file
  1387. * @param fileToLoad defines the file to load
  1388. * @param callback defines the callback to call when data is loaded
  1389. * @param progressCallBack defines the callback to call during loading process
  1390. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1391. * @returns a file request object
  1392. */
  1393. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1394. /**
  1395. * Loads a file
  1396. * @param url url string, ArrayBuffer, or Blob to load
  1397. * @param onSuccess callback called when the file successfully loads
  1398. * @param onProgress callback called while file is loading (if the server supports this mode)
  1399. * @param offlineProvider defines the offline provider for caching
  1400. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1401. * @param onError callback called when the file fails to load
  1402. * @returns a file request object
  1403. */
  1404. 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;
  1405. /**
  1406. * Checks if the loaded document was accessed via `file:`-Protocol.
  1407. * @returns boolean
  1408. */
  1409. static IsFileURL(): boolean;
  1410. }
  1411. }
  1412. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1413. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1414. /** @hidden */
  1415. export class ShaderProcessor {
  1416. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1417. private static _ProcessPrecision;
  1418. private static _ExtractOperation;
  1419. private static _BuildSubExpression;
  1420. private static _BuildExpression;
  1421. private static _MoveCursorWithinIf;
  1422. private static _MoveCursor;
  1423. private static _EvaluatePreProcessors;
  1424. private static _PreparePreProcessors;
  1425. private static _ProcessShaderConversion;
  1426. private static _ProcessIncludes;
  1427. }
  1428. }
  1429. declare module "babylonjs/Maths/math.like" {
  1430. import { float, int, DeepImmutable } from "babylonjs/types";
  1431. /**
  1432. * @hidden
  1433. */
  1434. export interface IColor4Like {
  1435. r: float;
  1436. g: float;
  1437. b: float;
  1438. a: float;
  1439. }
  1440. /**
  1441. * @hidden
  1442. */
  1443. export interface IColor3Like {
  1444. r: float;
  1445. g: float;
  1446. b: float;
  1447. }
  1448. /**
  1449. * @hidden
  1450. */
  1451. export interface IVector4Like {
  1452. x: float;
  1453. y: float;
  1454. z: float;
  1455. w: float;
  1456. }
  1457. /**
  1458. * @hidden
  1459. */
  1460. export interface IVector3Like {
  1461. x: float;
  1462. y: float;
  1463. z: float;
  1464. }
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IVector2Like {
  1469. x: float;
  1470. y: float;
  1471. }
  1472. /**
  1473. * @hidden
  1474. */
  1475. export interface IMatrixLike {
  1476. toArray(): DeepImmutable<Float32Array>;
  1477. updateFlag: int;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IViewportLike {
  1483. x: float;
  1484. y: float;
  1485. width: float;
  1486. height: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IPlaneLike {
  1492. normal: IVector3Like;
  1493. d: float;
  1494. normalize(): void;
  1495. }
  1496. }
  1497. declare module "babylonjs/Materials/iEffectFallbacks" {
  1498. import { Effect } from "babylonjs/Materials/effect";
  1499. /**
  1500. * Interface used to define common properties for effect fallbacks
  1501. */
  1502. export interface IEffectFallbacks {
  1503. /**
  1504. * Removes the defines that should be removed when falling back.
  1505. * @param currentDefines defines the current define statements for the shader.
  1506. * @param effect defines the current effect we try to compile
  1507. * @returns The resulting defines with defines of the current rank removed.
  1508. */
  1509. reduce(currentDefines: string, effect: Effect): string;
  1510. /**
  1511. * Removes the fallback from the bound mesh.
  1512. */
  1513. unBindMesh(): void;
  1514. /**
  1515. * Checks to see if more fallbacks are still availible.
  1516. */
  1517. hasMoreFallbacks: boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1521. /**
  1522. * Class used to evalaute queries containing `and` and `or` operators
  1523. */
  1524. export class AndOrNotEvaluator {
  1525. /**
  1526. * Evaluate a query
  1527. * @param query defines the query to evaluate
  1528. * @param evaluateCallback defines the callback used to filter result
  1529. * @returns true if the query matches
  1530. */
  1531. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1532. private static _HandleParenthesisContent;
  1533. private static _SimplifyNegation;
  1534. }
  1535. }
  1536. declare module "babylonjs/Misc/tags" {
  1537. /**
  1538. * Class used to store custom tags
  1539. */
  1540. export class Tags {
  1541. /**
  1542. * Adds support for tags on the given object
  1543. * @param obj defines the object to use
  1544. */
  1545. static EnableFor(obj: any): void;
  1546. /**
  1547. * Removes tags support
  1548. * @param obj defines the object to use
  1549. */
  1550. static DisableFor(obj: any): void;
  1551. /**
  1552. * Gets a boolean indicating if the given object has tags
  1553. * @param obj defines the object to use
  1554. * @returns a boolean
  1555. */
  1556. static HasTags(obj: any): boolean;
  1557. /**
  1558. * Gets the tags available on a given object
  1559. * @param obj defines the object to use
  1560. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1561. * @returns the tags
  1562. */
  1563. static GetTags(obj: any, asString?: boolean): any;
  1564. /**
  1565. * Adds tags to an object
  1566. * @param obj defines the object to use
  1567. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1568. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1569. */
  1570. static AddTagsTo(obj: any, tagsString: string): void;
  1571. /**
  1572. * @hidden
  1573. */
  1574. static _AddTagTo(obj: any, tag: string): void;
  1575. /**
  1576. * Removes specific tags from a specific object
  1577. * @param obj defines the object to use
  1578. * @param tagsString defines the tags to remove
  1579. */
  1580. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1581. /**
  1582. * @hidden
  1583. */
  1584. static _RemoveTagFrom(obj: any, tag: string): void;
  1585. /**
  1586. * Defines if tags hosted on an object match a given query
  1587. * @param obj defines the object to use
  1588. * @param tagsQuery defines the tag query
  1589. * @returns a boolean
  1590. */
  1591. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1592. }
  1593. }
  1594. declare module "babylonjs/Maths/math.scalar" {
  1595. /**
  1596. * Scalar computation library
  1597. */
  1598. export class Scalar {
  1599. /**
  1600. * Two pi constants convenient for computation.
  1601. */
  1602. static TwoPi: number;
  1603. /**
  1604. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1605. * @param a number
  1606. * @param b number
  1607. * @param epsilon (default = 1.401298E-45)
  1608. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1609. */
  1610. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1611. /**
  1612. * Returns a string : the upper case translation of the number i to hexadecimal.
  1613. * @param i number
  1614. * @returns the upper case translation of the number i to hexadecimal.
  1615. */
  1616. static ToHex(i: number): string;
  1617. /**
  1618. * Returns -1 if value is negative and +1 is value is positive.
  1619. * @param value the value
  1620. * @returns the value itself if it's equal to zero.
  1621. */
  1622. static Sign(value: number): number;
  1623. /**
  1624. * Returns the value itself if it's between min and max.
  1625. * Returns min if the value is lower than min.
  1626. * Returns max if the value is greater than max.
  1627. * @param value the value to clmap
  1628. * @param min the min value to clamp to (default: 0)
  1629. * @param max the max value to clamp to (default: 1)
  1630. * @returns the clamped value
  1631. */
  1632. static Clamp(value: number, min?: number, max?: number): number;
  1633. /**
  1634. * the log2 of value.
  1635. * @param value the value to compute log2 of
  1636. * @returns the log2 of value.
  1637. */
  1638. static Log2(value: number): number;
  1639. /**
  1640. * Loops the value, so that it is never larger than length and never smaller than 0.
  1641. *
  1642. * This is similar to the modulo operator but it works with floating point numbers.
  1643. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1644. * With t = 5 and length = 2.5, the result would be 0.0.
  1645. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1646. * @param value the value
  1647. * @param length the length
  1648. * @returns the looped value
  1649. */
  1650. static Repeat(value: number, length: number): number;
  1651. /**
  1652. * Normalize the value between 0.0 and 1.0 using min and max values
  1653. * @param value value to normalize
  1654. * @param min max to normalize between
  1655. * @param max min to normalize between
  1656. * @returns the normalized value
  1657. */
  1658. static Normalize(value: number, min: number, max: number): number;
  1659. /**
  1660. * Denormalize the value from 0.0 and 1.0 using min and max values
  1661. * @param normalized value to denormalize
  1662. * @param min max to denormalize between
  1663. * @param max min to denormalize between
  1664. * @returns the denormalized value
  1665. */
  1666. static Denormalize(normalized: number, min: number, max: number): number;
  1667. /**
  1668. * Calculates the shortest difference between two given angles given in degrees.
  1669. * @param current current angle in degrees
  1670. * @param target target angle in degrees
  1671. * @returns the delta
  1672. */
  1673. static DeltaAngle(current: number, target: number): number;
  1674. /**
  1675. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1676. * @param tx value
  1677. * @param length length
  1678. * @returns The returned value will move back and forth between 0 and length
  1679. */
  1680. static PingPong(tx: number, length: number): number;
  1681. /**
  1682. * Interpolates between min and max with smoothing at the limits.
  1683. *
  1684. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1685. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1686. * @param from from
  1687. * @param to to
  1688. * @param tx value
  1689. * @returns the smooth stepped value
  1690. */
  1691. static SmoothStep(from: number, to: number, tx: number): number;
  1692. /**
  1693. * Moves a value current towards target.
  1694. *
  1695. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1696. * Negative values of maxDelta pushes the value away from target.
  1697. * @param current current value
  1698. * @param target target value
  1699. * @param maxDelta max distance to move
  1700. * @returns resulting value
  1701. */
  1702. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1703. /**
  1704. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1705. *
  1706. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1707. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1708. * @param current current value
  1709. * @param target target value
  1710. * @param maxDelta max distance to move
  1711. * @returns resulting angle
  1712. */
  1713. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1714. /**
  1715. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1716. * @param start start value
  1717. * @param end target value
  1718. * @param amount amount to lerp between
  1719. * @returns the lerped value
  1720. */
  1721. static Lerp(start: number, end: number, amount: number): number;
  1722. /**
  1723. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1724. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1725. * @param start start value
  1726. * @param end target value
  1727. * @param amount amount to lerp between
  1728. * @returns the lerped value
  1729. */
  1730. static LerpAngle(start: number, end: number, amount: number): number;
  1731. /**
  1732. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1733. * @param a start value
  1734. * @param b target value
  1735. * @param value value between a and b
  1736. * @returns the inverseLerp value
  1737. */
  1738. static InverseLerp(a: number, b: number, value: number): number;
  1739. /**
  1740. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1741. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1742. * @param value1 spline value
  1743. * @param tangent1 spline value
  1744. * @param value2 spline value
  1745. * @param tangent2 spline value
  1746. * @param amount input value
  1747. * @returns hermite result
  1748. */
  1749. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1750. /**
  1751. * Returns a random float number between and min and max values
  1752. * @param min min value of random
  1753. * @param max max value of random
  1754. * @returns random value
  1755. */
  1756. static RandomRange(min: number, max: number): number;
  1757. /**
  1758. * This function returns percentage of a number in a given range.
  1759. *
  1760. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1761. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1762. * @param number to convert to percentage
  1763. * @param min min range
  1764. * @param max max range
  1765. * @returns the percentage
  1766. */
  1767. static RangeToPercent(number: number, min: number, max: number): number;
  1768. /**
  1769. * This function returns number that corresponds to the percentage in a given range.
  1770. *
  1771. * PercentToRange(0.34,0,100) will return 34.
  1772. * @param percent to convert to number
  1773. * @param min min range
  1774. * @param max max range
  1775. * @returns the number
  1776. */
  1777. static PercentToRange(percent: number, min: number, max: number): number;
  1778. /**
  1779. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1780. * @param angle The angle to normalize in radian.
  1781. * @return The converted angle.
  1782. */
  1783. static NormalizeRadians(angle: number): number;
  1784. }
  1785. }
  1786. declare module "babylonjs/Maths/math.constants" {
  1787. /**
  1788. * Constant used to convert a value to gamma space
  1789. * @ignorenaming
  1790. */
  1791. export const ToGammaSpace: number;
  1792. /**
  1793. * Constant used to convert a value to linear space
  1794. * @ignorenaming
  1795. */
  1796. export const ToLinearSpace = 2.2;
  1797. /**
  1798. * Constant used to define the minimal number value in Babylon.js
  1799. * @ignorenaming
  1800. */
  1801. let Epsilon: number;
  1802. export { Epsilon };
  1803. }
  1804. declare module "babylonjs/Maths/math.viewport" {
  1805. /**
  1806. * Class used to represent a viewport on screen
  1807. */
  1808. export class Viewport {
  1809. /** viewport left coordinate */
  1810. x: number;
  1811. /** viewport top coordinate */
  1812. y: number;
  1813. /**viewport width */
  1814. width: number;
  1815. /** viewport height */
  1816. height: number;
  1817. /**
  1818. * Creates a Viewport object located at (x, y) and sized (width, height)
  1819. * @param x defines viewport left coordinate
  1820. * @param y defines viewport top coordinate
  1821. * @param width defines the viewport width
  1822. * @param height defines the viewport height
  1823. */
  1824. constructor(
  1825. /** viewport left coordinate */
  1826. x: number,
  1827. /** viewport top coordinate */
  1828. y: number,
  1829. /**viewport width */
  1830. width: number,
  1831. /** viewport height */
  1832. height: number);
  1833. /**
  1834. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1835. * @param renderWidth defines the rendering width
  1836. * @param renderHeight defines the rendering height
  1837. * @returns a new Viewport
  1838. */
  1839. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1840. /**
  1841. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1842. * @param renderWidth defines the rendering width
  1843. * @param renderHeight defines the rendering height
  1844. * @param ref defines the target viewport
  1845. * @returns the current viewport
  1846. */
  1847. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1848. /**
  1849. * Returns a new Viewport copied from the current one
  1850. * @returns a new Viewport
  1851. */
  1852. clone(): Viewport;
  1853. }
  1854. }
  1855. declare module "babylonjs/Misc/arrayTools" {
  1856. /**
  1857. * Class containing a set of static utilities functions for arrays.
  1858. */
  1859. export class ArrayTools {
  1860. /**
  1861. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1862. * @param size the number of element to construct and put in the array
  1863. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1864. * @returns a new array filled with new objects
  1865. */
  1866. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1867. }
  1868. }
  1869. declare module "babylonjs/Maths/math.vector" {
  1870. import { Viewport } from "babylonjs/Maths/math.viewport";
  1871. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1872. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1873. /**
  1874. * Class representing a vector containing 2 coordinates
  1875. */
  1876. export class Vector2 {
  1877. /** defines the first coordinate */
  1878. x: number;
  1879. /** defines the second coordinate */
  1880. y: number;
  1881. /**
  1882. * Creates a new Vector2 from the given x and y coordinates
  1883. * @param x defines the first coordinate
  1884. * @param y defines the second coordinate
  1885. */
  1886. constructor(
  1887. /** defines the first coordinate */
  1888. x?: number,
  1889. /** defines the second coordinate */
  1890. y?: number);
  1891. /**
  1892. * Gets a string with the Vector2 coordinates
  1893. * @returns a string with the Vector2 coordinates
  1894. */
  1895. toString(): string;
  1896. /**
  1897. * Gets class name
  1898. * @returns the string "Vector2"
  1899. */
  1900. getClassName(): string;
  1901. /**
  1902. * Gets current vector hash code
  1903. * @returns the Vector2 hash code as a number
  1904. */
  1905. getHashCode(): number;
  1906. /**
  1907. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1908. * @param array defines the source array
  1909. * @param index defines the offset in source array
  1910. * @returns the current Vector2
  1911. */
  1912. toArray(array: FloatArray, index?: number): Vector2;
  1913. /**
  1914. * Copy the current vector to an array
  1915. * @returns a new array with 2 elements: the Vector2 coordinates.
  1916. */
  1917. asArray(): number[];
  1918. /**
  1919. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1920. * @param source defines the source Vector2
  1921. * @returns the current updated Vector2
  1922. */
  1923. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1924. /**
  1925. * Sets the Vector2 coordinates with the given floats
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. * @returns the current updated Vector2
  1929. */
  1930. copyFromFloats(x: number, y: number): Vector2;
  1931. /**
  1932. * Sets the Vector2 coordinates with the given floats
  1933. * @param x defines the first coordinate
  1934. * @param y defines the second coordinate
  1935. * @returns the current updated Vector2
  1936. */
  1937. set(x: number, y: number): Vector2;
  1938. /**
  1939. * Add another vector with the current one
  1940. * @param otherVector defines the other vector
  1941. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1942. */
  1943. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1944. /**
  1945. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1946. * @param otherVector defines the other vector
  1947. * @param result defines the target vector
  1948. * @returns the unmodified current Vector2
  1949. */
  1950. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1951. /**
  1952. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1953. * @param otherVector defines the other vector
  1954. * @returns the current updated Vector2
  1955. */
  1956. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1957. /**
  1958. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1959. * @param otherVector defines the other vector
  1960. * @returns a new Vector2
  1961. */
  1962. addVector3(otherVector: Vector3): Vector2;
  1963. /**
  1964. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2
  1967. */
  1968. subtract(otherVector: Vector2): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Multiplies in place the current Vector2 coordinates by the given ones
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1994. /**
  1995. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns a new Vector2
  2006. */
  2007. multiplyByFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns a new Vector2
  2012. */
  2013. divide(otherVector: Vector2): Vector2;
  2014. /**
  2015. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2016. * @param otherVector defines the other vector
  2017. * @param result defines the target vector
  2018. * @returns the unmodified current Vector2
  2019. */
  2020. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2021. /**
  2022. * Divides the current Vector2 coordinates by the given ones
  2023. * @param otherVector defines the other vector
  2024. * @returns the current updated Vector2
  2025. */
  2026. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2027. /**
  2028. * Gets a new Vector2 with current Vector2 negated coordinates
  2029. * @returns a new Vector2
  2030. */
  2031. negate(): Vector2;
  2032. /**
  2033. * Multiply the Vector2 coordinates by scale
  2034. * @param scale defines the scaling factor
  2035. * @returns the current updated Vector2
  2036. */
  2037. scaleInPlace(scale: number): Vector2;
  2038. /**
  2039. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2040. * @param scale defines the scaling factor
  2041. * @returns a new Vector2
  2042. */
  2043. scale(scale: number): Vector2;
  2044. /**
  2045. * Scale the current Vector2 values by a factor to a given Vector2
  2046. * @param scale defines the scale factor
  2047. * @param result defines the Vector2 object where to store the result
  2048. * @returns the unmodified current Vector2
  2049. */
  2050. scaleToRef(scale: number, result: Vector2): Vector2;
  2051. /**
  2052. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2053. * @param scale defines the scale factor
  2054. * @param result defines the Vector2 object where to store the result
  2055. * @returns the unmodified current Vector2
  2056. */
  2057. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2058. /**
  2059. * Gets a boolean if two vectors are equals
  2060. * @param otherVector defines the other vector
  2061. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2062. */
  2063. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2064. /**
  2065. * Gets a boolean if two vectors are equals (using an epsilon value)
  2066. * @param otherVector defines the other vector
  2067. * @param epsilon defines the minimal distance to consider equality
  2068. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2069. */
  2070. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2071. /**
  2072. * Gets a new Vector2 from current Vector2 floored values
  2073. * @returns a new Vector2
  2074. */
  2075. floor(): Vector2;
  2076. /**
  2077. * Gets a new Vector2 from current Vector2 floored values
  2078. * @returns a new Vector2
  2079. */
  2080. fract(): Vector2;
  2081. /**
  2082. * Gets the length of the vector
  2083. * @returns the vector length (float)
  2084. */
  2085. length(): number;
  2086. /**
  2087. * Gets the vector squared length
  2088. * @returns the vector squared length (float)
  2089. */
  2090. lengthSquared(): number;
  2091. /**
  2092. * Normalize the vector
  2093. * @returns the current updated Vector2
  2094. */
  2095. normalize(): Vector2;
  2096. /**
  2097. * Gets a new Vector2 copied from the Vector2
  2098. * @returns a new Vector2
  2099. */
  2100. clone(): Vector2;
  2101. /**
  2102. * Gets a new Vector2(0, 0)
  2103. * @returns a new Vector2
  2104. */
  2105. static Zero(): Vector2;
  2106. /**
  2107. * Gets a new Vector2(1, 1)
  2108. * @returns a new Vector2
  2109. */
  2110. static One(): Vector2;
  2111. /**
  2112. * Gets a new Vector2 set from the given index element of the given array
  2113. * @param array defines the data source
  2114. * @param offset defines the offset in the data source
  2115. * @returns a new Vector2
  2116. */
  2117. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2118. /**
  2119. * Sets "result" from the given index element of the given array
  2120. * @param array defines the data source
  2121. * @param offset defines the offset in the data source
  2122. * @param result defines the target vector
  2123. */
  2124. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2125. /**
  2126. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2127. * @param value1 defines 1st point of control
  2128. * @param value2 defines 2nd point of control
  2129. * @param value3 defines 3rd point of control
  2130. * @param value4 defines 4th point of control
  2131. * @param amount defines the interpolation factor
  2132. * @returns a new Vector2
  2133. */
  2134. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2135. /**
  2136. * 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".
  2137. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2138. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2139. * @param value defines the value to clamp
  2140. * @param min defines the lower limit
  2141. * @param max defines the upper limit
  2142. * @returns a new Vector2
  2143. */
  2144. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2145. /**
  2146. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2147. * @param value1 defines the 1st control point
  2148. * @param tangent1 defines the outgoing tangent
  2149. * @param value2 defines the 2nd control point
  2150. * @param tangent2 defines the incoming tangent
  2151. * @param amount defines the interpolation factor
  2152. * @returns a new Vector2
  2153. */
  2154. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2155. /**
  2156. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2157. * @param start defines the start vector
  2158. * @param end defines the end vector
  2159. * @param amount defines the interpolation factor
  2160. * @returns a new Vector2
  2161. */
  2162. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2163. /**
  2164. * Gets the dot product of the vector "left" and the vector "right"
  2165. * @param left defines first vector
  2166. * @param right defines second vector
  2167. * @returns the dot product (float)
  2168. */
  2169. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2170. /**
  2171. * Returns a new Vector2 equal to the normalized given vector
  2172. * @param vector defines the vector to normalize
  2173. * @returns a new Vector2
  2174. */
  2175. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2178. * @param left defines 1st vector
  2179. * @param right defines 2nd vector
  2180. * @returns a new Vector2
  2181. */
  2182. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2185. * @param left defines 1st vector
  2186. * @param right defines 2nd vector
  2187. * @returns a new Vector2
  2188. */
  2189. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2192. * @param vector defines the vector to transform
  2193. * @param transformation defines the matrix to apply
  2194. * @returns a new Vector2
  2195. */
  2196. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2197. /**
  2198. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2199. * @param vector defines the vector to transform
  2200. * @param transformation defines the matrix to apply
  2201. * @param result defines the target vector
  2202. */
  2203. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2204. /**
  2205. * Determines if a given vector is included in a triangle
  2206. * @param p defines the vector to test
  2207. * @param p0 defines 1st triangle point
  2208. * @param p1 defines 2nd triangle point
  2209. * @param p2 defines 3rd triangle point
  2210. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2211. */
  2212. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2213. /**
  2214. * Gets the distance between the vectors "value1" and "value2"
  2215. * @param value1 defines first vector
  2216. * @param value2 defines second vector
  2217. * @returns the distance between vectors
  2218. */
  2219. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2220. /**
  2221. * Returns the squared distance between the vectors "value1" and "value2"
  2222. * @param value1 defines first vector
  2223. * @param value2 defines second vector
  2224. * @returns the squared distance between vectors
  2225. */
  2226. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2227. /**
  2228. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2229. * @param value1 defines first vector
  2230. * @param value2 defines second vector
  2231. * @returns a new Vector2
  2232. */
  2233. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2236. * @param p defines the middle point
  2237. * @param segA defines one point of the segment
  2238. * @param segB defines the other point of the segment
  2239. * @returns the shortest distance
  2240. */
  2241. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2242. }
  2243. /**
  2244. * Classed used to store (x,y,z) vector representation
  2245. * A Vector3 is the main object used in 3D geometry
  2246. * It can represent etiher the coordinates of a point the space, either a direction
  2247. * Reminder: js uses a left handed forward facing system
  2248. */
  2249. export class Vector3 {
  2250. /**
  2251. * Defines the first coordinates (on X axis)
  2252. */
  2253. x: number;
  2254. /**
  2255. * Defines the second coordinates (on Y axis)
  2256. */
  2257. y: number;
  2258. /**
  2259. * Defines the third coordinates (on Z axis)
  2260. */
  2261. z: number;
  2262. private static _UpReadOnly;
  2263. private static _ZeroReadOnly;
  2264. /**
  2265. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2266. * @param x defines the first coordinates (on X axis)
  2267. * @param y defines the second coordinates (on Y axis)
  2268. * @param z defines the third coordinates (on Z axis)
  2269. */
  2270. constructor(
  2271. /**
  2272. * Defines the first coordinates (on X axis)
  2273. */
  2274. x?: number,
  2275. /**
  2276. * Defines the second coordinates (on Y axis)
  2277. */
  2278. y?: number,
  2279. /**
  2280. * Defines the third coordinates (on Z axis)
  2281. */
  2282. z?: number);
  2283. /**
  2284. * Creates a string representation of the Vector3
  2285. * @returns a string with the Vector3 coordinates.
  2286. */
  2287. toString(): string;
  2288. /**
  2289. * Gets the class name
  2290. * @returns the string "Vector3"
  2291. */
  2292. getClassName(): string;
  2293. /**
  2294. * Creates the Vector3 hash code
  2295. * @returns a number which tends to be unique between Vector3 instances
  2296. */
  2297. getHashCode(): number;
  2298. /**
  2299. * Creates an array containing three elements : the coordinates of the Vector3
  2300. * @returns a new array of numbers
  2301. */
  2302. asArray(): number[];
  2303. /**
  2304. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2305. * @param array defines the destination array
  2306. * @param index defines the offset in the destination array
  2307. * @returns the current Vector3
  2308. */
  2309. toArray(array: FloatArray, index?: number): Vector3;
  2310. /**
  2311. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2312. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2313. */
  2314. toQuaternion(): Quaternion;
  2315. /**
  2316. * Adds the given vector to the current Vector3
  2317. * @param otherVector defines the second operand
  2318. * @returns the current updated Vector3
  2319. */
  2320. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2321. /**
  2322. * Adds the given coordinates to the current Vector3
  2323. * @param x defines the x coordinate of the operand
  2324. * @param y defines the y coordinate of the operand
  2325. * @param z defines the z coordinate of the operand
  2326. * @returns the current updated Vector3
  2327. */
  2328. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2329. /**
  2330. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2331. * @param otherVector defines the second operand
  2332. * @returns the resulting Vector3
  2333. */
  2334. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2335. /**
  2336. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2337. * @param otherVector defines the second operand
  2338. * @param result defines the Vector3 object where to store the result
  2339. * @returns the current Vector3
  2340. */
  2341. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2342. /**
  2343. * Subtract the given vector from the current Vector3
  2344. * @param otherVector defines the second operand
  2345. * @returns the current updated Vector3
  2346. */
  2347. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2348. /**
  2349. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2350. * @param otherVector defines the second operand
  2351. * @returns the resulting Vector3
  2352. */
  2353. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2356. * @param otherVector defines the second operand
  2357. * @param result defines the Vector3 object where to store the result
  2358. * @returns the current Vector3
  2359. */
  2360. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2361. /**
  2362. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2363. * @param x defines the x coordinate of the operand
  2364. * @param y defines the y coordinate of the operand
  2365. * @param z defines the z coordinate of the operand
  2366. * @returns the resulting Vector3
  2367. */
  2368. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2369. /**
  2370. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2371. * @param x defines the x coordinate of the operand
  2372. * @param y defines the y coordinate of the operand
  2373. * @param z defines the z coordinate of the operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2378. /**
  2379. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2380. * @returns a new Vector3
  2381. */
  2382. negate(): Vector3;
  2383. /**
  2384. * Multiplies the Vector3 coordinates by the float "scale"
  2385. * @param scale defines the multiplier factor
  2386. * @returns the current updated Vector3
  2387. */
  2388. scaleInPlace(scale: number): Vector3;
  2389. /**
  2390. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2391. * @param scale defines the multiplier factor
  2392. * @returns a new Vector3
  2393. */
  2394. scale(scale: number): Vector3;
  2395. /**
  2396. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2397. * @param scale defines the multiplier factor
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. scaleToRef(scale: number, result: Vector3): Vector3;
  2402. /**
  2403. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2404. * @param scale defines the scale factor
  2405. * @param result defines the Vector3 object where to store the result
  2406. * @returns the unmodified current Vector3
  2407. */
  2408. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2409. /**
  2410. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2411. * @param otherVector defines the second operand
  2412. * @returns true if both vectors are equals
  2413. */
  2414. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2415. /**
  2416. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2417. * @param otherVector defines the second operand
  2418. * @param epsilon defines the minimal distance to define values as equals
  2419. * @returns true if both vectors are distant less than epsilon
  2420. */
  2421. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2422. /**
  2423. * Returns true if the current Vector3 coordinates equals the given floats
  2424. * @param x defines the x coordinate of the operand
  2425. * @param y defines the y coordinate of the operand
  2426. * @param z defines the z coordinate of the operand
  2427. * @returns true if both vectors are equals
  2428. */
  2429. equalsToFloats(x: number, y: number, z: number): boolean;
  2430. /**
  2431. * Multiplies the current Vector3 coordinates by the given ones
  2432. * @param otherVector defines the second operand
  2433. * @returns the current updated Vector3
  2434. */
  2435. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2436. /**
  2437. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2438. * @param otherVector defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2444. * @param otherVector defines the second operand
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2449. /**
  2450. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2451. * @param x defines the x coordinate of the operand
  2452. * @param y defines the y coordinate of the operand
  2453. * @param z defines the z coordinate of the operand
  2454. * @returns the new Vector3
  2455. */
  2456. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2457. /**
  2458. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2459. * @param otherVector defines the second operand
  2460. * @returns the new Vector3
  2461. */
  2462. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2463. /**
  2464. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2465. * @param otherVector defines the second operand
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2470. /**
  2471. * Divides the current Vector3 coordinates by the given ones.
  2472. * @param otherVector defines the second operand
  2473. * @returns the current updated Vector3
  2474. */
  2475. divideInPlace(otherVector: Vector3): Vector3;
  2476. /**
  2477. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2478. * @param other defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2484. * @param other defines the second operand
  2485. * @returns the current updated Vector3
  2486. */
  2487. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2490. * @param x defines the x coordinate of the operand
  2491. * @param y defines the y coordinate of the operand
  2492. * @param z defines the z coordinate of the operand
  2493. * @returns the current updated Vector3
  2494. */
  2495. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2496. /**
  2497. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the current updated Vector3
  2502. */
  2503. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2506. * Check if is non uniform within a certain amount of decimal places to account for this
  2507. * @param epsilon the amount the values can differ
  2508. * @returns if the the vector is non uniform to a certain number of decimal places
  2509. */
  2510. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2511. /**
  2512. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2513. */
  2514. readonly isNonUniform: boolean;
  2515. /**
  2516. * Gets a new Vector3 from current Vector3 floored values
  2517. * @returns a new Vector3
  2518. */
  2519. floor(): Vector3;
  2520. /**
  2521. * Gets a new Vector3 from current Vector3 floored values
  2522. * @returns a new Vector3
  2523. */
  2524. fract(): Vector3;
  2525. /**
  2526. * Gets the length of the Vector3
  2527. * @returns the length of the Vector3
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Gets the squared length of the Vector3
  2532. * @returns squared length of the Vector3
  2533. */
  2534. lengthSquared(): number;
  2535. /**
  2536. * Normalize the current Vector3.
  2537. * Please note that this is an in place operation.
  2538. * @returns the current updated Vector3
  2539. */
  2540. normalize(): Vector3;
  2541. /**
  2542. * Reorders the x y z properties of the vector in place
  2543. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2544. * @returns the current updated vector
  2545. */
  2546. reorderInPlace(order: string): this;
  2547. /**
  2548. * Rotates the vector around 0,0,0 by a quaternion
  2549. * @param quaternion the rotation quaternion
  2550. * @param result vector to store the result
  2551. * @returns the resulting vector
  2552. */
  2553. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2554. /**
  2555. * Rotates a vector around a given point
  2556. * @param quaternion the rotation quaternion
  2557. * @param point the point to rotate around
  2558. * @param result vector to store the result
  2559. * @returns the resulting vector
  2560. */
  2561. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2562. /**
  2563. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2564. * The cross product is then orthogonal to both current and "other"
  2565. * @param other defines the right operand
  2566. * @returns the cross product
  2567. */
  2568. cross(other: Vector3): Vector3;
  2569. /**
  2570. * Normalize the current Vector3 with the given input length.
  2571. * Please note that this is an in place operation.
  2572. * @param len the length of the vector
  2573. * @returns the current updated Vector3
  2574. */
  2575. normalizeFromLength(len: number): Vector3;
  2576. /**
  2577. * Normalize the current Vector3 to a new vector
  2578. * @returns the new Vector3
  2579. */
  2580. normalizeToNew(): Vector3;
  2581. /**
  2582. * Normalize the current Vector3 to the reference
  2583. * @param reference define the Vector3 to update
  2584. * @returns the updated Vector3
  2585. */
  2586. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2587. /**
  2588. * Creates a new Vector3 copied from the current Vector3
  2589. * @returns the new Vector3
  2590. */
  2591. clone(): Vector3;
  2592. /**
  2593. * Copies the given vector coordinates to the current Vector3 ones
  2594. * @param source defines the source Vector3
  2595. * @returns the current updated Vector3
  2596. */
  2597. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2598. /**
  2599. * Copies the given floats to the current Vector3 coordinates
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @returns the current updated Vector3
  2604. */
  2605. copyFromFloats(x: number, y: number, z: number): Vector3;
  2606. /**
  2607. * Copies the given floats to the current Vector3 coordinates
  2608. * @param x defines the x coordinate of the operand
  2609. * @param y defines the y coordinate of the operand
  2610. * @param z defines the z coordinate of the operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. set(x: number, y: number, z: number): Vector3;
  2614. /**
  2615. * Copies the given float to the current Vector3 coordinates
  2616. * @param v defines the x, y and z coordinates of the operand
  2617. * @returns the current updated Vector3
  2618. */
  2619. setAll(v: number): Vector3;
  2620. /**
  2621. * Get the clip factor between two vectors
  2622. * @param vector0 defines the first operand
  2623. * @param vector1 defines the second operand
  2624. * @param axis defines the axis to use
  2625. * @param size defines the size along the axis
  2626. * @returns the clip factor
  2627. */
  2628. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2629. /**
  2630. * Get angle between two vectors
  2631. * @param vector0 angle between vector0 and vector1
  2632. * @param vector1 angle between vector0 and vector1
  2633. * @param normal direction of the normal
  2634. * @return the angle between vector0 and vector1
  2635. */
  2636. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2637. /**
  2638. * Returns a new Vector3 set from the index "offset" of the given array
  2639. * @param array defines the source array
  2640. * @param offset defines the offset in the source array
  2641. * @returns the new Vector3
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2644. /**
  2645. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2646. * This function is deprecated. Use FromArray instead
  2647. * @param array defines the source array
  2648. * @param offset defines the offset in the source array
  2649. * @returns the new Vector3
  2650. */
  2651. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2652. /**
  2653. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2654. * @param array defines the source array
  2655. * @param offset defines the offset in the source array
  2656. * @param result defines the Vector3 where to store the result
  2657. */
  2658. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2659. /**
  2660. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2661. * This function is deprecated. Use FromArrayToRef instead.
  2662. * @param array defines the source array
  2663. * @param offset defines the offset in the source array
  2664. * @param result defines the Vector3 where to store the result
  2665. */
  2666. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2667. /**
  2668. * Sets the given vector "result" with the given floats.
  2669. * @param x defines the x coordinate of the source
  2670. * @param y defines the y coordinate of the source
  2671. * @param z defines the z coordinate of the source
  2672. * @param result defines the Vector3 where to store the result
  2673. */
  2674. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2675. /**
  2676. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2677. * @returns a new empty Vector3
  2678. */
  2679. static Zero(): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2682. * @returns a new unit Vector3
  2683. */
  2684. static One(): Vector3;
  2685. /**
  2686. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2687. * @returns a new up Vector3
  2688. */
  2689. static Up(): Vector3;
  2690. /**
  2691. * Gets a up Vector3 that must not be updated
  2692. */
  2693. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2694. /**
  2695. * Gets a zero Vector3 that must not be updated
  2696. */
  2697. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2698. /**
  2699. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2700. * @returns a new down Vector3
  2701. */
  2702. static Down(): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2705. * @returns a new forward Vector3
  2706. */
  2707. static Forward(): Vector3;
  2708. /**
  2709. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2710. * @returns a new forward Vector3
  2711. */
  2712. static Backward(): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2715. * @returns a new right Vector3
  2716. */
  2717. static Right(): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2720. * @returns a new left Vector3
  2721. */
  2722. static Left(): Vector3;
  2723. /**
  2724. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2725. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2726. * @param vector defines the Vector3 to transform
  2727. * @param transformation defines the transformation matrix
  2728. * @returns the transformed Vector3
  2729. */
  2730. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2731. /**
  2732. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2733. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2734. * @param vector defines the Vector3 to transform
  2735. * @param transformation defines the transformation matrix
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2741. * This method computes tranformed coordinates only, not transformed direction vectors
  2742. * @param x define the x coordinate of the source vector
  2743. * @param y define the y coordinate of the source vector
  2744. * @param z define the z coordinate of the source vector
  2745. * @param transformation defines the transformation matrix
  2746. * @param result defines the Vector3 where to store the result
  2747. */
  2748. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2749. /**
  2750. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2751. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2752. * @param vector defines the Vector3 to transform
  2753. * @param transformation defines the transformation matrix
  2754. * @returns the new Vector3
  2755. */
  2756. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2757. /**
  2758. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2759. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2760. * @param vector defines the Vector3 to transform
  2761. * @param transformation defines the transformation matrix
  2762. * @param result defines the Vector3 where to store the result
  2763. */
  2764. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2765. /**
  2766. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2768. * @param x define the x coordinate of the source vector
  2769. * @param y define the y coordinate of the source vector
  2770. * @param z define the z coordinate of the source vector
  2771. * @param transformation defines the transformation matrix
  2772. * @param result defines the Vector3 where to store the result
  2773. */
  2774. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2775. /**
  2776. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2777. * @param value1 defines the first control point
  2778. * @param value2 defines the second control point
  2779. * @param value3 defines the third control point
  2780. * @param value4 defines the fourth control point
  2781. * @param amount defines the amount on the spline to use
  2782. * @returns the new Vector3
  2783. */
  2784. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2785. /**
  2786. * 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"
  2787. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2788. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2789. * @param value defines the current value
  2790. * @param min defines the lower range value
  2791. * @param max defines the upper range value
  2792. * @returns the new Vector3
  2793. */
  2794. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2795. /**
  2796. * 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"
  2797. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2798. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2799. * @param value defines the current value
  2800. * @param min defines the lower range value
  2801. * @param max defines the upper range value
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2805. /**
  2806. * Checks if a given vector is inside a specific range
  2807. * @param v defines the vector to test
  2808. * @param min defines the minimum range
  2809. * @param max defines the maximum range
  2810. */
  2811. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2812. /**
  2813. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2814. * @param value1 defines the first control point
  2815. * @param tangent1 defines the first tangent vector
  2816. * @param value2 defines the second control point
  2817. * @param tangent2 defines the second tangent vector
  2818. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2819. * @returns the new Vector3
  2820. */
  2821. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2824. * @param start defines the start value
  2825. * @param end defines the end value
  2826. * @param amount max defines amount between both (between 0 and 1)
  2827. * @returns the new Vector3
  2828. */
  2829. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2832. * @param start defines the start value
  2833. * @param end defines the end value
  2834. * @param amount max defines amount between both (between 0 and 1)
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2838. /**
  2839. * Returns the dot product (float) between the vectors "left" and "right"
  2840. * @param left defines the left operand
  2841. * @param right defines the right operand
  2842. * @returns the dot product
  2843. */
  2844. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2845. /**
  2846. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2847. * The cross product is then orthogonal to both "left" and "right"
  2848. * @param left defines the left operand
  2849. * @param right defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2853. /**
  2854. * Sets the given vector "result" with the cross product of "left" and "right"
  2855. * The cross product is then orthogonal to both "left" and "right"
  2856. * @param left defines the left operand
  2857. * @param right defines the right operand
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 as the normalization of the given vector
  2863. * @param vector defines the Vector3 to normalize
  2864. * @returns the new Vector3
  2865. */
  2866. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2867. /**
  2868. * Sets the given vector "result" with the normalization of the given first vector
  2869. * @param vector defines the Vector3 to normalize
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2873. /**
  2874. * Project a Vector3 onto screen space
  2875. * @param vector defines the Vector3 to project
  2876. * @param world defines the world matrix to use
  2877. * @param transform defines the transform (view x projection) matrix to use
  2878. * @param viewport defines the screen viewport to use
  2879. * @returns the new Vector3
  2880. */
  2881. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2882. /** @hidden */
  2883. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2884. /**
  2885. * Unproject from screen space to object space
  2886. * @param source defines the screen space Vector3 to use
  2887. * @param viewportWidth defines the current width of the viewport
  2888. * @param viewportHeight defines the current height of the viewport
  2889. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2890. * @param transform defines the transform (view x projection) matrix to use
  2891. * @returns the new Vector3
  2892. */
  2893. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2894. /**
  2895. * Unproject from screen space to object space
  2896. * @param source defines the screen space Vector3 to use
  2897. * @param viewportWidth defines the current width of the viewport
  2898. * @param viewportHeight defines the current height of the viewport
  2899. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2900. * @param view defines the view matrix to use
  2901. * @param projection defines the projection matrix to use
  2902. * @returns the new Vector3
  2903. */
  2904. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2905. /**
  2906. * Unproject from screen space to object space
  2907. * @param source defines the screen space Vector3 to use
  2908. * @param viewportWidth defines the current width of the viewport
  2909. * @param viewportHeight defines the current height of the viewport
  2910. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2911. * @param view defines the view matrix to use
  2912. * @param projection defines the projection matrix to use
  2913. * @param result defines the Vector3 where to store the result
  2914. */
  2915. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2916. /**
  2917. * Unproject from screen space to object space
  2918. * @param sourceX defines the screen space x coordinate to use
  2919. * @param sourceY defines the screen space y coordinate to use
  2920. * @param sourceZ defines the screen space z coordinate to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Gets the minimal coordinate values between two Vector3
  2931. * @param left defines the first operand
  2932. * @param right defines the second operand
  2933. * @returns the new Vector3
  2934. */
  2935. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Gets the maximal coordinate values between two Vector3
  2938. * @param left defines the first operand
  2939. * @param right defines the second operand
  2940. * @returns the new Vector3
  2941. */
  2942. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2943. /**
  2944. * Returns the distance between the vectors "value1" and "value2"
  2945. * @param value1 defines the first operand
  2946. * @param value2 defines the second operand
  2947. * @returns the distance
  2948. */
  2949. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2950. /**
  2951. * Returns the squared distance between the vectors "value1" and "value2"
  2952. * @param value1 defines the first operand
  2953. * @param value2 defines the second operand
  2954. * @returns the squared distance
  2955. */
  2956. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2957. /**
  2958. * Returns a new Vector3 located at the center between "value1" and "value2"
  2959. * @param value1 defines the first operand
  2960. * @param value2 defines the second operand
  2961. * @returns the new Vector3
  2962. */
  2963. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2964. /**
  2965. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2966. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2967. * to something in order to rotate it from its local system to the given target system
  2968. * Note: axis1, axis2 and axis3 are normalized during this operation
  2969. * @param axis1 defines the first axis
  2970. * @param axis2 defines the second axis
  2971. * @param axis3 defines the third axis
  2972. * @returns a new Vector3
  2973. */
  2974. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2977. * @param axis1 defines the first axis
  2978. * @param axis2 defines the second axis
  2979. * @param axis3 defines the third axis
  2980. * @param ref defines the Vector3 where to store the result
  2981. */
  2982. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2983. }
  2984. /**
  2985. * Vector4 class created for EulerAngle class conversion to Quaternion
  2986. */
  2987. export class Vector4 {
  2988. /** x value of the vector */
  2989. x: number;
  2990. /** y value of the vector */
  2991. y: number;
  2992. /** z value of the vector */
  2993. z: number;
  2994. /** w value of the vector */
  2995. w: number;
  2996. /**
  2997. * Creates a Vector4 object from the given floats.
  2998. * @param x x value of the vector
  2999. * @param y y value of the vector
  3000. * @param z z value of the vector
  3001. * @param w w value of the vector
  3002. */
  3003. constructor(
  3004. /** x value of the vector */
  3005. x: number,
  3006. /** y value of the vector */
  3007. y: number,
  3008. /** z value of the vector */
  3009. z: number,
  3010. /** w value of the vector */
  3011. w: number);
  3012. /**
  3013. * Returns the string with the Vector4 coordinates.
  3014. * @returns a string containing all the vector values
  3015. */
  3016. toString(): string;
  3017. /**
  3018. * Returns the string "Vector4".
  3019. * @returns "Vector4"
  3020. */
  3021. getClassName(): string;
  3022. /**
  3023. * Returns the Vector4 hash code.
  3024. * @returns a unique hash code
  3025. */
  3026. getHashCode(): number;
  3027. /**
  3028. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3029. * @returns the resulting array
  3030. */
  3031. asArray(): number[];
  3032. /**
  3033. * Populates the given array from the given index with the Vector4 coordinates.
  3034. * @param array array to populate
  3035. * @param index index of the array to start at (default: 0)
  3036. * @returns the Vector4.
  3037. */
  3038. toArray(array: FloatArray, index?: number): Vector4;
  3039. /**
  3040. * Adds the given vector to the current Vector4.
  3041. * @param otherVector the vector to add
  3042. * @returns the updated Vector4.
  3043. */
  3044. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3045. /**
  3046. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3047. * @param otherVector the vector to add
  3048. * @returns the resulting vector
  3049. */
  3050. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3051. /**
  3052. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3053. * @param otherVector the vector to add
  3054. * @param result the vector to store the result
  3055. * @returns the current Vector4.
  3056. */
  3057. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3058. /**
  3059. * Subtract in place the given vector from the current Vector4.
  3060. * @param otherVector the vector to subtract
  3061. * @returns the updated Vector4.
  3062. */
  3063. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3064. /**
  3065. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3066. * @param otherVector the vector to add
  3067. * @returns the new vector with the result
  3068. */
  3069. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3070. /**
  3071. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3072. * @param otherVector the vector to subtract
  3073. * @param result the vector to store the result
  3074. * @returns the current Vector4.
  3075. */
  3076. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3077. /**
  3078. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3079. */
  3080. /**
  3081. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3082. * @param x value to subtract
  3083. * @param y value to subtract
  3084. * @param z value to subtract
  3085. * @param w value to subtract
  3086. * @returns new vector containing the result
  3087. */
  3088. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3089. /**
  3090. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3091. * @param x value to subtract
  3092. * @param y value to subtract
  3093. * @param z value to subtract
  3094. * @param w value to subtract
  3095. * @param result the vector to store the result in
  3096. * @returns the current Vector4.
  3097. */
  3098. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3099. /**
  3100. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3101. * @returns a new vector with the negated values
  3102. */
  3103. negate(): Vector4;
  3104. /**
  3105. * Multiplies the current Vector4 coordinates by scale (float).
  3106. * @param scale the number to scale with
  3107. * @returns the updated Vector4.
  3108. */
  3109. scaleInPlace(scale: number): Vector4;
  3110. /**
  3111. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3112. * @param scale the number to scale with
  3113. * @returns a new vector with the result
  3114. */
  3115. scale(scale: number): Vector4;
  3116. /**
  3117. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3118. * @param scale the number to scale with
  3119. * @param result a vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. scaleToRef(scale: number, result: Vector4): Vector4;
  3123. /**
  3124. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3125. * @param scale defines the scale factor
  3126. * @param result defines the Vector4 object where to store the result
  3127. * @returns the unmodified current Vector4
  3128. */
  3129. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3130. /**
  3131. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3132. * @param otherVector the vector to compare against
  3133. * @returns true if they are equal
  3134. */
  3135. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3136. /**
  3137. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3138. * @param otherVector vector to compare against
  3139. * @param epsilon (Default: very small number)
  3140. * @returns true if they are equal
  3141. */
  3142. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3143. /**
  3144. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3145. * @param x x value to compare against
  3146. * @param y y value to compare against
  3147. * @param z z value to compare against
  3148. * @param w w value to compare against
  3149. * @returns true if equal
  3150. */
  3151. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3152. /**
  3153. * Multiplies in place the current Vector4 by the given one.
  3154. * @param otherVector vector to multiple with
  3155. * @returns the updated Vector4.
  3156. */
  3157. multiplyInPlace(otherVector: Vector4): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3160. * @param otherVector vector to multiple with
  3161. * @returns resulting new vector
  3162. */
  3163. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3164. /**
  3165. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3166. * @param otherVector vector to multiple with
  3167. * @param result vector to store the result
  3168. * @returns the current Vector4.
  3169. */
  3170. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3171. /**
  3172. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3173. * @param x x value multiply with
  3174. * @param y y value multiply with
  3175. * @param z z value multiply with
  3176. * @param w w value multiply with
  3177. * @returns resulting new vector
  3178. */
  3179. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3180. /**
  3181. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3182. * @param otherVector vector to devide with
  3183. * @returns resulting new vector
  3184. */
  3185. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3186. /**
  3187. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3188. * @param otherVector vector to devide with
  3189. * @param result vector to store the result
  3190. * @returns the current Vector4.
  3191. */
  3192. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3193. /**
  3194. * Divides the current Vector3 coordinates by the given ones.
  3195. * @param otherVector vector to devide with
  3196. * @returns the updated Vector3.
  3197. */
  3198. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3199. /**
  3200. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3201. * @param other defines the second operand
  3202. * @returns the current updated Vector4
  3203. */
  3204. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3205. /**
  3206. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3207. * @param other defines the second operand
  3208. * @returns the current updated Vector4
  3209. */
  3210. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3211. /**
  3212. * Gets a new Vector4 from current Vector4 floored values
  3213. * @returns a new Vector4
  3214. */
  3215. floor(): Vector4;
  3216. /**
  3217. * Gets a new Vector4 from current Vector3 floored values
  3218. * @returns a new Vector4
  3219. */
  3220. fract(): Vector4;
  3221. /**
  3222. * Returns the Vector4 length (float).
  3223. * @returns the length
  3224. */
  3225. length(): number;
  3226. /**
  3227. * Returns the Vector4 squared length (float).
  3228. * @returns the length squared
  3229. */
  3230. lengthSquared(): number;
  3231. /**
  3232. * Normalizes in place the Vector4.
  3233. * @returns the updated Vector4.
  3234. */
  3235. normalize(): Vector4;
  3236. /**
  3237. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3238. * @returns this converted to a new vector3
  3239. */
  3240. toVector3(): Vector3;
  3241. /**
  3242. * Returns a new Vector4 copied from the current one.
  3243. * @returns the new cloned vector
  3244. */
  3245. clone(): Vector4;
  3246. /**
  3247. * Updates the current Vector4 with the given one coordinates.
  3248. * @param source the source vector to copy from
  3249. * @returns the updated Vector4.
  3250. */
  3251. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Updates the current Vector4 coordinates with the given floats.
  3254. * @param x float to copy from
  3255. * @param y float to copy from
  3256. * @param z float to copy from
  3257. * @param w float to copy from
  3258. * @returns the updated Vector4.
  3259. */
  3260. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3261. /**
  3262. * Updates the current Vector4 coordinates with the given floats.
  3263. * @param x float to set from
  3264. * @param y float to set from
  3265. * @param z float to set from
  3266. * @param w float to set from
  3267. * @returns the updated Vector4.
  3268. */
  3269. set(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Copies the given float to the current Vector3 coordinates
  3272. * @param v defines the x, y, z and w coordinates of the operand
  3273. * @returns the current updated Vector3
  3274. */
  3275. setAll(v: number): Vector4;
  3276. /**
  3277. * Returns a new Vector4 set from the starting index of the given array.
  3278. * @param array the array to pull values from
  3279. * @param offset the offset into the array to start at
  3280. * @returns the new vector
  3281. */
  3282. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3283. /**
  3284. * Updates the given vector "result" from the starting index of the given array.
  3285. * @param array the array to pull values from
  3286. * @param offset the offset into the array to start at
  3287. * @param result the vector to store the result in
  3288. */
  3289. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3290. /**
  3291. * Updates the given vector "result" from the starting index of the given Float32Array.
  3292. * @param array the array to pull values from
  3293. * @param offset the offset into the array to start at
  3294. * @param result the vector to store the result in
  3295. */
  3296. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3297. /**
  3298. * Updates the given vector "result" coordinates from the given floats.
  3299. * @param x float to set from
  3300. * @param y float to set from
  3301. * @param z float to set from
  3302. * @param w float to set from
  3303. * @param result the vector to the floats in
  3304. */
  3305. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3306. /**
  3307. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3308. * @returns the new vector
  3309. */
  3310. static Zero(): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3313. * @returns the new vector
  3314. */
  3315. static One(): Vector4;
  3316. /**
  3317. * Returns a new normalized Vector4 from the given one.
  3318. * @param vector the vector to normalize
  3319. * @returns the vector
  3320. */
  3321. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3322. /**
  3323. * Updates the given vector "result" from the normalization of the given one.
  3324. * @param vector the vector to normalize
  3325. * @param result the vector to store the result in
  3326. */
  3327. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3328. /**
  3329. * Returns a vector with the minimum values from the left and right vectors
  3330. * @param left left vector to minimize
  3331. * @param right right vector to minimize
  3332. * @returns a new vector with the minimum of the left and right vector values
  3333. */
  3334. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3335. /**
  3336. * Returns a vector with the maximum values from the left and right vectors
  3337. * @param left left vector to maximize
  3338. * @param right right vector to maximize
  3339. * @returns a new vector with the maximum of the left and right vector values
  3340. */
  3341. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3342. /**
  3343. * Returns the distance (float) between the vectors "value1" and "value2".
  3344. * @param value1 value to calulate the distance between
  3345. * @param value2 value to calulate the distance between
  3346. * @return the distance between the two vectors
  3347. */
  3348. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3349. /**
  3350. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3351. * @param value1 value to calulate the distance between
  3352. * @param value2 value to calulate the distance between
  3353. * @return the distance between the two vectors squared
  3354. */
  3355. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3356. /**
  3357. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3358. * @param value1 value to calulate the center between
  3359. * @param value2 value to calulate the center between
  3360. * @return the center between the two vectors
  3361. */
  3362. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3365. * This methods computes transformed normalized direction vectors only.
  3366. * @param vector the vector to transform
  3367. * @param transformation the transformation matrix to apply
  3368. * @returns the new vector
  3369. */
  3370. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3371. /**
  3372. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3373. * This methods computes transformed normalized direction vectors only.
  3374. * @param vector the vector to transform
  3375. * @param transformation the transformation matrix to apply
  3376. * @param result the vector to store the result in
  3377. */
  3378. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3379. /**
  3380. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3381. * This methods computes transformed normalized direction vectors only.
  3382. * @param x value to transform
  3383. * @param y value to transform
  3384. * @param z value to transform
  3385. * @param w value to transform
  3386. * @param transformation the transformation matrix to apply
  3387. * @param result the vector to store the results in
  3388. */
  3389. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3390. /**
  3391. * Creates a new Vector4 from a Vector3
  3392. * @param source defines the source data
  3393. * @param w defines the 4th component (default is 0)
  3394. * @returns a new Vector4
  3395. */
  3396. static FromVector3(source: Vector3, w?: number): Vector4;
  3397. }
  3398. /**
  3399. * Class used to store quaternion data
  3400. * @see https://en.wikipedia.org/wiki/Quaternion
  3401. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3402. */
  3403. export class Quaternion {
  3404. /** defines the first component (0 by default) */
  3405. x: number;
  3406. /** defines the second component (0 by default) */
  3407. y: number;
  3408. /** defines the third component (0 by default) */
  3409. z: number;
  3410. /** defines the fourth component (1.0 by default) */
  3411. w: number;
  3412. /**
  3413. * Creates a new Quaternion from the given floats
  3414. * @param x defines the first component (0 by default)
  3415. * @param y defines the second component (0 by default)
  3416. * @param z defines the third component (0 by default)
  3417. * @param w defines the fourth component (1.0 by default)
  3418. */
  3419. constructor(
  3420. /** defines the first component (0 by default) */
  3421. x?: number,
  3422. /** defines the second component (0 by default) */
  3423. y?: number,
  3424. /** defines the third component (0 by default) */
  3425. z?: number,
  3426. /** defines the fourth component (1.0 by default) */
  3427. w?: number);
  3428. /**
  3429. * Gets a string representation for the current quaternion
  3430. * @returns a string with the Quaternion coordinates
  3431. */
  3432. toString(): string;
  3433. /**
  3434. * Gets the class name of the quaternion
  3435. * @returns the string "Quaternion"
  3436. */
  3437. getClassName(): string;
  3438. /**
  3439. * Gets a hash code for this quaternion
  3440. * @returns the quaternion hash code
  3441. */
  3442. getHashCode(): number;
  3443. /**
  3444. * Copy the quaternion to an array
  3445. * @returns a new array populated with 4 elements from the quaternion coordinates
  3446. */
  3447. asArray(): number[];
  3448. /**
  3449. * Check if two quaternions are equals
  3450. * @param otherQuaternion defines the second operand
  3451. * @return true if the current quaternion and the given one coordinates are strictly equals
  3452. */
  3453. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3454. /**
  3455. * Clone the current quaternion
  3456. * @returns a new quaternion copied from the current one
  3457. */
  3458. clone(): Quaternion;
  3459. /**
  3460. * Copy a quaternion to the current one
  3461. * @param other defines the other quaternion
  3462. * @returns the updated current quaternion
  3463. */
  3464. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3465. /**
  3466. * Updates the current quaternion with the given float coordinates
  3467. * @param x defines the x coordinate
  3468. * @param y defines the y coordinate
  3469. * @param z defines the z coordinate
  3470. * @param w defines the w coordinate
  3471. * @returns the updated current quaternion
  3472. */
  3473. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3474. /**
  3475. * Updates the current quaternion from the given float coordinates
  3476. * @param x defines the x coordinate
  3477. * @param y defines the y coordinate
  3478. * @param z defines the z coordinate
  3479. * @param w defines the w coordinate
  3480. * @returns the updated current quaternion
  3481. */
  3482. set(x: number, y: number, z: number, w: number): Quaternion;
  3483. /**
  3484. * Adds two quaternions
  3485. * @param other defines the second operand
  3486. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3487. */
  3488. add(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Add a quaternion to the current one
  3491. * @param other defines the quaternion to add
  3492. * @returns the current quaternion
  3493. */
  3494. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3495. /**
  3496. * Subtract two quaternions
  3497. * @param other defines the second operand
  3498. * @returns a new quaternion as the subtraction result of the given one from the current one
  3499. */
  3500. subtract(other: Quaternion): Quaternion;
  3501. /**
  3502. * Multiplies the current quaternion by a scale factor
  3503. * @param value defines the scale factor
  3504. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3505. */
  3506. scale(value: number): Quaternion;
  3507. /**
  3508. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3509. * @param scale defines the scale factor
  3510. * @param result defines the Quaternion object where to store the result
  3511. * @returns the unmodified current quaternion
  3512. */
  3513. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3514. /**
  3515. * Multiplies in place the current quaternion by a scale factor
  3516. * @param value defines the scale factor
  3517. * @returns the current modified quaternion
  3518. */
  3519. scaleInPlace(value: number): Quaternion;
  3520. /**
  3521. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3522. * @param scale defines the scale factor
  3523. * @param result defines the Quaternion object where to store the result
  3524. * @returns the unmodified current quaternion
  3525. */
  3526. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3527. /**
  3528. * Multiplies two quaternions
  3529. * @param q1 defines the second operand
  3530. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3531. */
  3532. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3533. /**
  3534. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3535. * @param q1 defines the second operand
  3536. * @param result defines the target quaternion
  3537. * @returns the current quaternion
  3538. */
  3539. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3540. /**
  3541. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3542. * @param q1 defines the second operand
  3543. * @returns the currentupdated quaternion
  3544. */
  3545. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3546. /**
  3547. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3548. * @param ref defines the target quaternion
  3549. * @returns the current quaternion
  3550. */
  3551. conjugateToRef(ref: Quaternion): Quaternion;
  3552. /**
  3553. * Conjugates in place (1-q) the current quaternion
  3554. * @returns the current updated quaternion
  3555. */
  3556. conjugateInPlace(): Quaternion;
  3557. /**
  3558. * Conjugates in place (1-q) the current quaternion
  3559. * @returns a new quaternion
  3560. */
  3561. conjugate(): Quaternion;
  3562. /**
  3563. * Gets length of current quaternion
  3564. * @returns the quaternion length (float)
  3565. */
  3566. length(): number;
  3567. /**
  3568. * Normalize in place the current quaternion
  3569. * @returns the current updated quaternion
  3570. */
  3571. normalize(): Quaternion;
  3572. /**
  3573. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3574. * @param order is a reserved parameter and is ignore for now
  3575. * @returns a new Vector3 containing the Euler angles
  3576. */
  3577. toEulerAngles(order?: string): Vector3;
  3578. /**
  3579. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3580. * @param result defines the vector which will be filled with the Euler angles
  3581. * @param order is a reserved parameter and is ignore for now
  3582. * @returns the current unchanged quaternion
  3583. */
  3584. toEulerAnglesToRef(result: Vector3): Quaternion;
  3585. /**
  3586. * Updates the given rotation matrix with the current quaternion values
  3587. * @param result defines the target matrix
  3588. * @returns the current unchanged quaternion
  3589. */
  3590. toRotationMatrix(result: Matrix): Quaternion;
  3591. /**
  3592. * Updates the current quaternion from the given rotation matrix values
  3593. * @param matrix defines the source matrix
  3594. * @returns the current updated quaternion
  3595. */
  3596. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3597. /**
  3598. * Creates a new quaternion from a rotation matrix
  3599. * @param matrix defines the source matrix
  3600. * @returns a new quaternion created from the given rotation matrix values
  3601. */
  3602. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3603. /**
  3604. * Updates the given quaternion with the given rotation matrix values
  3605. * @param matrix defines the source matrix
  3606. * @param result defines the target quaternion
  3607. */
  3608. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3609. /**
  3610. * Returns the dot product (float) between the quaternions "left" and "right"
  3611. * @param left defines the left operand
  3612. * @param right defines the right operand
  3613. * @returns the dot product
  3614. */
  3615. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3616. /**
  3617. * Checks if the two quaternions are close to each other
  3618. * @param quat0 defines the first quaternion to check
  3619. * @param quat1 defines the second quaternion to check
  3620. * @returns true if the two quaternions are close to each other
  3621. */
  3622. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3623. /**
  3624. * Creates an empty quaternion
  3625. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3626. */
  3627. static Zero(): Quaternion;
  3628. /**
  3629. * Inverse a given quaternion
  3630. * @param q defines the source quaternion
  3631. * @returns a new quaternion as the inverted current quaternion
  3632. */
  3633. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3634. /**
  3635. * Inverse a given quaternion
  3636. * @param q defines the source quaternion
  3637. * @param result the quaternion the result will be stored in
  3638. * @returns the result quaternion
  3639. */
  3640. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3641. /**
  3642. * Creates an identity quaternion
  3643. * @returns the identity quaternion
  3644. */
  3645. static Identity(): Quaternion;
  3646. /**
  3647. * Gets a boolean indicating if the given quaternion is identity
  3648. * @param quaternion defines the quaternion to check
  3649. * @returns true if the quaternion is identity
  3650. */
  3651. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Creates a quaternion from a rotation around an axis
  3654. * @param axis defines the axis to use
  3655. * @param angle defines the angle to use
  3656. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3657. */
  3658. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3659. /**
  3660. * Creates a rotation around an axis and stores it into the given quaternion
  3661. * @param axis defines the axis to use
  3662. * @param angle defines the angle to use
  3663. * @param result defines the target quaternion
  3664. * @returns the target quaternion
  3665. */
  3666. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3667. /**
  3668. * Creates a new quaternion from data stored into an array
  3669. * @param array defines the data source
  3670. * @param offset defines the offset in the source array where the data starts
  3671. * @returns a new quaternion
  3672. */
  3673. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3674. /**
  3675. * Create a quaternion from Euler rotation angles
  3676. * @param x Pitch
  3677. * @param y Yaw
  3678. * @param z Roll
  3679. * @returns the new Quaternion
  3680. */
  3681. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3682. /**
  3683. * Updates a quaternion from Euler rotation angles
  3684. * @param x Pitch
  3685. * @param y Yaw
  3686. * @param z Roll
  3687. * @param result the quaternion to store the result
  3688. * @returns the updated quaternion
  3689. */
  3690. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Create a quaternion from Euler rotation vector
  3693. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3694. * @returns the new Quaternion
  3695. */
  3696. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3697. /**
  3698. * Updates a quaternion from Euler rotation vector
  3699. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3700. * @param result the quaternion to store the result
  3701. * @returns the updated quaternion
  3702. */
  3703. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3704. /**
  3705. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3706. * @param yaw defines the rotation around Y axis
  3707. * @param pitch defines the rotation around X axis
  3708. * @param roll defines the rotation around Z axis
  3709. * @returns the new quaternion
  3710. */
  3711. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3712. /**
  3713. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3714. * @param yaw defines the rotation around Y axis
  3715. * @param pitch defines the rotation around X axis
  3716. * @param roll defines the rotation around Z axis
  3717. * @param result defines the target quaternion
  3718. */
  3719. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3720. /**
  3721. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3722. * @param alpha defines the rotation around first axis
  3723. * @param beta defines the rotation around second axis
  3724. * @param gamma defines the rotation around third axis
  3725. * @returns the new quaternion
  3726. */
  3727. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3730. * @param alpha defines the rotation around first axis
  3731. * @param beta defines the rotation around second axis
  3732. * @param gamma defines the rotation around third axis
  3733. * @param result defines the target quaternion
  3734. */
  3735. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3736. /**
  3737. * 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)
  3738. * @param axis1 defines the first axis
  3739. * @param axis2 defines the second axis
  3740. * @param axis3 defines the third axis
  3741. * @returns the new quaternion
  3742. */
  3743. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3744. /**
  3745. * 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
  3746. * @param axis1 defines the first axis
  3747. * @param axis2 defines the second axis
  3748. * @param axis3 defines the third axis
  3749. * @param ref defines the target quaternion
  3750. */
  3751. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3752. /**
  3753. * Interpolates between two quaternions
  3754. * @param left defines first quaternion
  3755. * @param right defines second quaternion
  3756. * @param amount defines the gradient to use
  3757. * @returns the new interpolated quaternion
  3758. */
  3759. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3760. /**
  3761. * Interpolates between two quaternions and stores it into a target quaternion
  3762. * @param left defines first quaternion
  3763. * @param right defines second quaternion
  3764. * @param amount defines the gradient to use
  3765. * @param result defines the target quaternion
  3766. */
  3767. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3768. /**
  3769. * Interpolate between two quaternions using Hermite interpolation
  3770. * @param value1 defines first quaternion
  3771. * @param tangent1 defines the incoming tangent
  3772. * @param value2 defines second quaternion
  3773. * @param tangent2 defines the outgoing tangent
  3774. * @param amount defines the target quaternion
  3775. * @returns the new interpolated quaternion
  3776. */
  3777. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3778. }
  3779. /**
  3780. * Class used to store matrix data (4x4)
  3781. */
  3782. export class Matrix {
  3783. private static _updateFlagSeed;
  3784. private static _identityReadOnly;
  3785. private _isIdentity;
  3786. private _isIdentityDirty;
  3787. private _isIdentity3x2;
  3788. private _isIdentity3x2Dirty;
  3789. /**
  3790. * Gets the update flag of the matrix which is an unique number for the matrix.
  3791. * It will be incremented every time the matrix data change.
  3792. * You can use it to speed the comparison between two versions of the same matrix.
  3793. */
  3794. updateFlag: number;
  3795. private readonly _m;
  3796. /**
  3797. * Gets the internal data of the matrix
  3798. */
  3799. readonly m: DeepImmutable<Float32Array>;
  3800. /** @hidden */
  3801. _markAsUpdated(): void;
  3802. /** @hidden */
  3803. private _updateIdentityStatus;
  3804. /**
  3805. * Creates an empty matrix (filled with zeros)
  3806. */
  3807. constructor();
  3808. /**
  3809. * Check if the current matrix is identity
  3810. * @returns true is the matrix is the identity matrix
  3811. */
  3812. isIdentity(): boolean;
  3813. /**
  3814. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3815. * @returns true is the matrix is the identity matrix
  3816. */
  3817. isIdentityAs3x2(): boolean;
  3818. /**
  3819. * Gets the determinant of the matrix
  3820. * @returns the matrix determinant
  3821. */
  3822. determinant(): number;
  3823. /**
  3824. * Returns the matrix as a Float32Array
  3825. * @returns the matrix underlying array
  3826. */
  3827. toArray(): DeepImmutable<Float32Array>;
  3828. /**
  3829. * Returns the matrix as a Float32Array
  3830. * @returns the matrix underlying array.
  3831. */
  3832. asArray(): DeepImmutable<Float32Array>;
  3833. /**
  3834. * Inverts the current matrix in place
  3835. * @returns the current inverted matrix
  3836. */
  3837. invert(): Matrix;
  3838. /**
  3839. * Sets all the matrix elements to zero
  3840. * @returns the current matrix
  3841. */
  3842. reset(): Matrix;
  3843. /**
  3844. * Adds the current matrix with a second one
  3845. * @param other defines the matrix to add
  3846. * @returns a new matrix as the addition of the current matrix and the given one
  3847. */
  3848. add(other: DeepImmutable<Matrix>): Matrix;
  3849. /**
  3850. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3851. * @param other defines the matrix to add
  3852. * @param result defines the target matrix
  3853. * @returns the current matrix
  3854. */
  3855. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3856. /**
  3857. * Adds in place the given matrix to the current matrix
  3858. * @param other defines the second operand
  3859. * @returns the current updated matrix
  3860. */
  3861. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3862. /**
  3863. * Sets the given matrix to the current inverted Matrix
  3864. * @param other defines the target matrix
  3865. * @returns the unmodified current matrix
  3866. */
  3867. invertToRef(other: Matrix): Matrix;
  3868. /**
  3869. * add a value at the specified position in the current Matrix
  3870. * @param index the index of the value within the matrix. between 0 and 15.
  3871. * @param value the value to be added
  3872. * @returns the current updated matrix
  3873. */
  3874. addAtIndex(index: number, value: number): Matrix;
  3875. /**
  3876. * mutiply the specified position in the current Matrix by a value
  3877. * @param index the index of the value within the matrix. between 0 and 15.
  3878. * @param value the value to be added
  3879. * @returns the current updated matrix
  3880. */
  3881. multiplyAtIndex(index: number, value: number): Matrix;
  3882. /**
  3883. * Inserts the translation vector (using 3 floats) in the current matrix
  3884. * @param x defines the 1st component of the translation
  3885. * @param y defines the 2nd component of the translation
  3886. * @param z defines the 3rd component of the translation
  3887. * @returns the current updated matrix
  3888. */
  3889. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3890. /**
  3891. * Adds the translation vector (using 3 floats) in the current matrix
  3892. * @param x defines the 1st component of the translation
  3893. * @param y defines the 2nd component of the translation
  3894. * @param z defines the 3rd component of the translation
  3895. * @returns the current updated matrix
  3896. */
  3897. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3898. /**
  3899. * Inserts the translation vector in the current matrix
  3900. * @param vector3 defines the translation to insert
  3901. * @returns the current updated matrix
  3902. */
  3903. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3904. /**
  3905. * Gets the translation value of the current matrix
  3906. * @returns a new Vector3 as the extracted translation from the matrix
  3907. */
  3908. getTranslation(): Vector3;
  3909. /**
  3910. * Fill a Vector3 with the extracted translation from the matrix
  3911. * @param result defines the Vector3 where to store the translation
  3912. * @returns the current matrix
  3913. */
  3914. getTranslationToRef(result: Vector3): Matrix;
  3915. /**
  3916. * Remove rotation and scaling part from the matrix
  3917. * @returns the updated matrix
  3918. */
  3919. removeRotationAndScaling(): Matrix;
  3920. /**
  3921. * Multiply two matrices
  3922. * @param other defines the second operand
  3923. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3924. */
  3925. multiply(other: DeepImmutable<Matrix>): Matrix;
  3926. /**
  3927. * Copy the current matrix from the given one
  3928. * @param other defines the source matrix
  3929. * @returns the current updated matrix
  3930. */
  3931. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Populates the given array from the starting index with the current matrix values
  3934. * @param array defines the target array
  3935. * @param offset defines the offset in the target array where to start storing values
  3936. * @returns the current matrix
  3937. */
  3938. copyToArray(array: Float32Array, offset?: number): Matrix;
  3939. /**
  3940. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3941. * @param other defines the second operand
  3942. * @param result defines the matrix where to store the multiplication
  3943. * @returns the current matrix
  3944. */
  3945. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3946. /**
  3947. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3948. * @param other defines the second operand
  3949. * @param result defines the array where to store the multiplication
  3950. * @param offset defines the offset in the target array where to start storing values
  3951. * @returns the current matrix
  3952. */
  3953. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3954. /**
  3955. * Check equality between this matrix and a second one
  3956. * @param value defines the second matrix to compare
  3957. * @returns true is the current matrix and the given one values are strictly equal
  3958. */
  3959. equals(value: DeepImmutable<Matrix>): boolean;
  3960. /**
  3961. * Clone the current matrix
  3962. * @returns a new matrix from the current matrix
  3963. */
  3964. clone(): Matrix;
  3965. /**
  3966. * Returns the name of the current matrix class
  3967. * @returns the string "Matrix"
  3968. */
  3969. getClassName(): string;
  3970. /**
  3971. * Gets the hash code of the current matrix
  3972. * @returns the hash code
  3973. */
  3974. getHashCode(): number;
  3975. /**
  3976. * Decomposes the current Matrix into a translation, rotation and scaling components
  3977. * @param scale defines the scale vector3 given as a reference to update
  3978. * @param rotation defines the rotation quaternion given as a reference to update
  3979. * @param translation defines the translation vector3 given as a reference to update
  3980. * @returns true if operation was successful
  3981. */
  3982. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3983. /**
  3984. * Gets specific row of the matrix
  3985. * @param index defines the number of the row to get
  3986. * @returns the index-th row of the current matrix as a new Vector4
  3987. */
  3988. getRow(index: number): Nullable<Vector4>;
  3989. /**
  3990. * Sets the index-th row of the current matrix to the vector4 values
  3991. * @param index defines the number of the row to set
  3992. * @param row defines the target vector4
  3993. * @returns the updated current matrix
  3994. */
  3995. setRow(index: number, row: Vector4): Matrix;
  3996. /**
  3997. * Compute the transpose of the matrix
  3998. * @returns the new transposed matrix
  3999. */
  4000. transpose(): Matrix;
  4001. /**
  4002. * Compute the transpose of the matrix and store it in a given matrix
  4003. * @param result defines the target matrix
  4004. * @returns the current matrix
  4005. */
  4006. transposeToRef(result: Matrix): Matrix;
  4007. /**
  4008. * Sets the index-th row of the current matrix with the given 4 x float values
  4009. * @param index defines the row index
  4010. * @param x defines the x component to set
  4011. * @param y defines the y component to set
  4012. * @param z defines the z component to set
  4013. * @param w defines the w component to set
  4014. * @returns the updated current matrix
  4015. */
  4016. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4017. /**
  4018. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4019. * @param scale defines the scale factor
  4020. * @returns a new matrix
  4021. */
  4022. scale(scale: number): Matrix;
  4023. /**
  4024. * Scale the current matrix values by a factor to a given result matrix
  4025. * @param scale defines the scale factor
  4026. * @param result defines the matrix to store the result
  4027. * @returns the current matrix
  4028. */
  4029. scaleToRef(scale: number, result: Matrix): Matrix;
  4030. /**
  4031. * Scale the current matrix values by a factor and add the result to a given matrix
  4032. * @param scale defines the scale factor
  4033. * @param result defines the Matrix to store the result
  4034. * @returns the current matrix
  4035. */
  4036. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4037. /**
  4038. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4039. * @param ref matrix to store the result
  4040. */
  4041. toNormalMatrix(ref: Matrix): void;
  4042. /**
  4043. * Gets only rotation part of the current matrix
  4044. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4045. */
  4046. getRotationMatrix(): Matrix;
  4047. /**
  4048. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4049. * @param result defines the target matrix to store data to
  4050. * @returns the current matrix
  4051. */
  4052. getRotationMatrixToRef(result: Matrix): Matrix;
  4053. /**
  4054. * Toggles model matrix from being right handed to left handed in place and vice versa
  4055. */
  4056. toggleModelMatrixHandInPlace(): void;
  4057. /**
  4058. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4059. */
  4060. toggleProjectionMatrixHandInPlace(): void;
  4061. /**
  4062. * Creates a matrix from an array
  4063. * @param array defines the source array
  4064. * @param offset defines an offset in the source array
  4065. * @returns a new Matrix set from the starting index of the given array
  4066. */
  4067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4068. /**
  4069. * Copy the content of an array into a given matrix
  4070. * @param array defines the source array
  4071. * @param offset defines an offset in the source array
  4072. * @param result defines the target matrix
  4073. */
  4074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4075. /**
  4076. * Stores an array into a matrix after having multiplied each component by a given factor
  4077. * @param array defines the source array
  4078. * @param offset defines the offset in the source array
  4079. * @param scale defines the scaling factor
  4080. * @param result defines the target matrix
  4081. */
  4082. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4083. /**
  4084. * Gets an identity matrix that must not be updated
  4085. */
  4086. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4087. /**
  4088. * Stores a list of values (16) inside a given matrix
  4089. * @param initialM11 defines 1st value of 1st row
  4090. * @param initialM12 defines 2nd value of 1st row
  4091. * @param initialM13 defines 3rd value of 1st row
  4092. * @param initialM14 defines 4th value of 1st row
  4093. * @param initialM21 defines 1st value of 2nd row
  4094. * @param initialM22 defines 2nd value of 2nd row
  4095. * @param initialM23 defines 3rd value of 2nd row
  4096. * @param initialM24 defines 4th value of 2nd row
  4097. * @param initialM31 defines 1st value of 3rd row
  4098. * @param initialM32 defines 2nd value of 3rd row
  4099. * @param initialM33 defines 3rd value of 3rd row
  4100. * @param initialM34 defines 4th value of 3rd row
  4101. * @param initialM41 defines 1st value of 4th row
  4102. * @param initialM42 defines 2nd value of 4th row
  4103. * @param initialM43 defines 3rd value of 4th row
  4104. * @param initialM44 defines 4th value of 4th row
  4105. * @param result defines the target matrix
  4106. */
  4107. 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;
  4108. /**
  4109. * Creates new matrix from a list of values (16)
  4110. * @param initialM11 defines 1st value of 1st row
  4111. * @param initialM12 defines 2nd value of 1st row
  4112. * @param initialM13 defines 3rd value of 1st row
  4113. * @param initialM14 defines 4th value of 1st row
  4114. * @param initialM21 defines 1st value of 2nd row
  4115. * @param initialM22 defines 2nd value of 2nd row
  4116. * @param initialM23 defines 3rd value of 2nd row
  4117. * @param initialM24 defines 4th value of 2nd row
  4118. * @param initialM31 defines 1st value of 3rd row
  4119. * @param initialM32 defines 2nd value of 3rd row
  4120. * @param initialM33 defines 3rd value of 3rd row
  4121. * @param initialM34 defines 4th value of 3rd row
  4122. * @param initialM41 defines 1st value of 4th row
  4123. * @param initialM42 defines 2nd value of 4th row
  4124. * @param initialM43 defines 3rd value of 4th row
  4125. * @param initialM44 defines 4th value of 4th row
  4126. * @returns the new matrix
  4127. */
  4128. 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;
  4129. /**
  4130. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4131. * @param scale defines the scale vector3
  4132. * @param rotation defines the rotation quaternion
  4133. * @param translation defines the translation vector3
  4134. * @returns a new matrix
  4135. */
  4136. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4137. /**
  4138. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4139. * @param scale defines the scale vector3
  4140. * @param rotation defines the rotation quaternion
  4141. * @param translation defines the translation vector3
  4142. * @param result defines the target matrix
  4143. */
  4144. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4145. /**
  4146. * Creates a new identity matrix
  4147. * @returns a new identity matrix
  4148. */
  4149. static Identity(): Matrix;
  4150. /**
  4151. * Creates a new identity matrix and stores the result in a given matrix
  4152. * @param result defines the target matrix
  4153. */
  4154. static IdentityToRef(result: Matrix): void;
  4155. /**
  4156. * Creates a new zero matrix
  4157. * @returns a new zero matrix
  4158. */
  4159. static Zero(): Matrix;
  4160. /**
  4161. * Creates a new rotation matrix for "angle" radians around the X axis
  4162. * @param angle defines the angle (in radians) to use
  4163. * @return the new matrix
  4164. */
  4165. static RotationX(angle: number): Matrix;
  4166. /**
  4167. * Creates a new matrix as the invert of a given matrix
  4168. * @param source defines the source matrix
  4169. * @returns the new matrix
  4170. */
  4171. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4174. * @param angle defines the angle (in radians) to use
  4175. * @param result defines the target matrix
  4176. */
  4177. static RotationXToRef(angle: number, result: Matrix): void;
  4178. /**
  4179. * Creates a new rotation matrix for "angle" radians around the Y axis
  4180. * @param angle defines the angle (in radians) to use
  4181. * @return the new matrix
  4182. */
  4183. static RotationY(angle: number): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4186. * @param angle defines the angle (in radians) to use
  4187. * @param result defines the target matrix
  4188. */
  4189. static RotationYToRef(angle: number, result: Matrix): void;
  4190. /**
  4191. * Creates a new rotation matrix for "angle" radians around the Z axis
  4192. * @param angle defines the angle (in radians) to use
  4193. * @return the new matrix
  4194. */
  4195. static RotationZ(angle: number): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationZToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the given axis
  4204. * @param axis defines the axis to use
  4205. * @param angle defines the angle (in radians) to use
  4206. * @return the new matrix
  4207. */
  4208. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4211. * @param axis defines the axis to use
  4212. * @param angle defines the angle (in radians) to use
  4213. * @param result defines the target matrix
  4214. */
  4215. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4216. /**
  4217. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4218. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4219. * @param from defines the vector to align
  4220. * @param to defines the vector to align to
  4221. * @param result defines the target matrix
  4222. */
  4223. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4224. /**
  4225. * Creates a rotation matrix
  4226. * @param yaw defines the yaw angle in radians (Y axis)
  4227. * @param pitch defines the pitch angle in radians (X axis)
  4228. * @param roll defines the roll angle in radians (X axis)
  4229. * @returns the new rotation matrix
  4230. */
  4231. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4232. /**
  4233. * Creates a rotation matrix and stores it in a given matrix
  4234. * @param yaw defines the yaw angle in radians (Y axis)
  4235. * @param pitch defines the pitch angle in radians (X axis)
  4236. * @param roll defines the roll angle in radians (X axis)
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4240. /**
  4241. * Creates a scaling matrix
  4242. * @param x defines the scale factor on X axis
  4243. * @param y defines the scale factor on Y axis
  4244. * @param z defines the scale factor on Z axis
  4245. * @returns the new matrix
  4246. */
  4247. static Scaling(x: number, y: number, z: number): Matrix;
  4248. /**
  4249. * Creates a scaling matrix and stores it in a given matrix
  4250. * @param x defines the scale factor on X axis
  4251. * @param y defines the scale factor on Y axis
  4252. * @param z defines the scale factor on Z axis
  4253. * @param result defines the target matrix
  4254. */
  4255. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4256. /**
  4257. * Creates a translation matrix
  4258. * @param x defines the translation on X axis
  4259. * @param y defines the translation on Y axis
  4260. * @param z defines the translationon Z axis
  4261. * @returns the new matrix
  4262. */
  4263. static Translation(x: number, y: number, z: number): Matrix;
  4264. /**
  4265. * Creates a translation matrix and stores it in a given matrix
  4266. * @param x defines the translation on X axis
  4267. * @param y defines the translation on Y axis
  4268. * @param z defines the translationon Z axis
  4269. * @param result defines the target matrix
  4270. */
  4271. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4272. /**
  4273. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4274. * @param startValue defines the start value
  4275. * @param endValue defines the end value
  4276. * @param gradient defines the gradient factor
  4277. * @returns the new matrix
  4278. */
  4279. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4280. /**
  4281. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4282. * @param startValue defines the start value
  4283. * @param endValue defines the end value
  4284. * @param gradient defines the gradient factor
  4285. * @param result defines the Matrix object where to store data
  4286. */
  4287. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4288. /**
  4289. * Builds a new matrix whose values are computed by:
  4290. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4291. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4292. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4293. * @param startValue defines the first matrix
  4294. * @param endValue defines the second matrix
  4295. * @param gradient defines the gradient between the two matrices
  4296. * @returns the new matrix
  4297. */
  4298. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4299. /**
  4300. * Update a matrix to values which are computed by:
  4301. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4302. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4303. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4304. * @param startValue defines the first matrix
  4305. * @param endValue defines the second matrix
  4306. * @param gradient defines the gradient between the two matrices
  4307. * @param result defines the target matrix
  4308. */
  4309. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4310. /**
  4311. * 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"
  4312. * This function works in left handed mode
  4313. * @param eye defines the final position of the entity
  4314. * @param target defines where the entity should look at
  4315. * @param up defines the up vector for the entity
  4316. * @returns the new matrix
  4317. */
  4318. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4319. /**
  4320. * 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".
  4321. * This function works in left handed mode
  4322. * @param eye defines the final position of the entity
  4323. * @param target defines where the entity should look at
  4324. * @param up defines the up vector for the entity
  4325. * @param result defines the target matrix
  4326. */
  4327. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4328. /**
  4329. * 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"
  4330. * This function works in right handed mode
  4331. * @param eye defines the final position of the entity
  4332. * @param target defines where the entity should look at
  4333. * @param up defines the up vector for the entity
  4334. * @returns the new matrix
  4335. */
  4336. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4337. /**
  4338. * 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".
  4339. * This function works in right handed mode
  4340. * @param eye defines the final position of the entity
  4341. * @param target defines where the entity should look at
  4342. * @param up defines the up vector for the entity
  4343. * @param result defines the target matrix
  4344. */
  4345. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4346. /**
  4347. * Create a left-handed orthographic projection matrix
  4348. * @param width defines the viewport width
  4349. * @param height defines the viewport height
  4350. * @param znear defines the near clip plane
  4351. * @param zfar defines the far clip plane
  4352. * @returns a new matrix as a left-handed orthographic projection matrix
  4353. */
  4354. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4355. /**
  4356. * Store a left-handed orthographic projection to a given matrix
  4357. * @param width defines the viewport width
  4358. * @param height defines the viewport height
  4359. * @param znear defines the near clip plane
  4360. * @param zfar defines the far clip plane
  4361. * @param result defines the target matrix
  4362. */
  4363. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4364. /**
  4365. * Create a left-handed orthographic projection matrix
  4366. * @param left defines the viewport left coordinate
  4367. * @param right defines the viewport right coordinate
  4368. * @param bottom defines the viewport bottom coordinate
  4369. * @param top defines the viewport top coordinate
  4370. * @param znear defines the near clip plane
  4371. * @param zfar defines the far clip plane
  4372. * @returns a new matrix as a left-handed orthographic projection matrix
  4373. */
  4374. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4375. /**
  4376. * Stores a left-handed orthographic projection into a given matrix
  4377. * @param left defines the viewport left coordinate
  4378. * @param right defines the viewport right coordinate
  4379. * @param bottom defines the viewport bottom coordinate
  4380. * @param top defines the viewport top coordinate
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @param result defines the target matrix
  4384. */
  4385. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4386. /**
  4387. * Creates a right-handed orthographic projection matrix
  4388. * @param left defines the viewport left coordinate
  4389. * @param right defines the viewport right coordinate
  4390. * @param bottom defines the viewport bottom coordinate
  4391. * @param top defines the viewport top coordinate
  4392. * @param znear defines the near clip plane
  4393. * @param zfar defines the far clip plane
  4394. * @returns a new matrix as a right-handed orthographic projection matrix
  4395. */
  4396. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4397. /**
  4398. * Stores a right-handed orthographic projection into a given matrix
  4399. * @param left defines the viewport left coordinate
  4400. * @param right defines the viewport right coordinate
  4401. * @param bottom defines the viewport bottom coordinate
  4402. * @param top defines the viewport top coordinate
  4403. * @param znear defines the near clip plane
  4404. * @param zfar defines the far clip plane
  4405. * @param result defines the target matrix
  4406. */
  4407. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4408. /**
  4409. * Creates a left-handed perspective projection matrix
  4410. * @param width defines the viewport width
  4411. * @param height defines the viewport height
  4412. * @param znear defines the near clip plane
  4413. * @param zfar defines the far clip plane
  4414. * @returns a new matrix as a left-handed perspective projection matrix
  4415. */
  4416. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4417. /**
  4418. * Creates a left-handed perspective projection matrix
  4419. * @param fov defines the horizontal field of view
  4420. * @param aspect defines the aspect ratio
  4421. * @param znear defines the near clip plane
  4422. * @param zfar defines the far clip plane
  4423. * @returns a new matrix as a left-handed perspective projection matrix
  4424. */
  4425. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4426. /**
  4427. * Stores a left-handed perspective projection into a given matrix
  4428. * @param fov defines the horizontal field of view
  4429. * @param aspect defines the aspect ratio
  4430. * @param znear defines the near clip plane
  4431. * @param zfar defines the far clip plane
  4432. * @param result defines the target matrix
  4433. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4434. */
  4435. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4436. /**
  4437. * Creates a right-handed perspective projection matrix
  4438. * @param fov defines the horizontal field of view
  4439. * @param aspect defines the aspect ratio
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @returns a new matrix as a right-handed perspective projection matrix
  4443. */
  4444. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4445. /**
  4446. * Stores a right-handed perspective projection into a given matrix
  4447. * @param fov defines the horizontal field of view
  4448. * @param aspect defines the aspect ratio
  4449. * @param znear defines the near clip plane
  4450. * @param zfar defines the far clip plane
  4451. * @param result defines the target matrix
  4452. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4453. */
  4454. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4455. /**
  4456. * Stores a perspective projection for WebVR info a given matrix
  4457. * @param fov defines the field of view
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4462. */
  4463. static PerspectiveFovWebVRToRef(fov: {
  4464. upDegrees: number;
  4465. downDegrees: number;
  4466. leftDegrees: number;
  4467. rightDegrees: number;
  4468. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4469. /**
  4470. * Computes a complete transformation matrix
  4471. * @param viewport defines the viewport to use
  4472. * @param world defines the world matrix
  4473. * @param view defines the view matrix
  4474. * @param projection defines the projection matrix
  4475. * @param zmin defines the near clip plane
  4476. * @param zmax defines the far clip plane
  4477. * @returns the transformation matrix
  4478. */
  4479. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4480. /**
  4481. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4482. * @param matrix defines the matrix to use
  4483. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4484. */
  4485. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4486. /**
  4487. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4488. * @param matrix defines the matrix to use
  4489. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4490. */
  4491. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4492. /**
  4493. * Compute the transpose of a given matrix
  4494. * @param matrix defines the matrix to transpose
  4495. * @returns the new matrix
  4496. */
  4497. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4498. /**
  4499. * Compute the transpose of a matrix and store it in a target matrix
  4500. * @param matrix defines the matrix to transpose
  4501. * @param result defines the target matrix
  4502. */
  4503. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4504. /**
  4505. * Computes a reflection matrix from a plane
  4506. * @param plane defines the reflection plane
  4507. * @returns a new matrix
  4508. */
  4509. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4510. /**
  4511. * Computes a reflection matrix from a plane
  4512. * @param plane defines the reflection plane
  4513. * @param result defines the target matrix
  4514. */
  4515. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4516. /**
  4517. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4518. * @param xaxis defines the value of the 1st axis
  4519. * @param yaxis defines the value of the 2nd axis
  4520. * @param zaxis defines the value of the 3rd axis
  4521. * @param result defines the target matrix
  4522. */
  4523. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4524. /**
  4525. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4526. * @param quat defines the quaternion to use
  4527. * @param result defines the target matrix
  4528. */
  4529. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4530. }
  4531. /**
  4532. * @hidden
  4533. */
  4534. export class TmpVectors {
  4535. static Vector2: Vector2[];
  4536. static Vector3: Vector3[];
  4537. static Vector4: Vector4[];
  4538. static Quaternion: Quaternion[];
  4539. static Matrix: Matrix[];
  4540. }
  4541. }
  4542. declare module "babylonjs/Maths/math.path" {
  4543. import { DeepImmutable, Nullable } from "babylonjs/types";
  4544. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4545. /**
  4546. * Defines potential orientation for back face culling
  4547. */
  4548. export enum Orientation {
  4549. /**
  4550. * Clockwise
  4551. */
  4552. CW = 0,
  4553. /** Counter clockwise */
  4554. CCW = 1
  4555. }
  4556. /** Class used to represent a Bezier curve */
  4557. export class BezierCurve {
  4558. /**
  4559. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4560. * @param t defines the time
  4561. * @param x1 defines the left coordinate on X axis
  4562. * @param y1 defines the left coordinate on Y axis
  4563. * @param x2 defines the right coordinate on X axis
  4564. * @param y2 defines the right coordinate on Y axis
  4565. * @returns the interpolated value
  4566. */
  4567. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4568. }
  4569. /**
  4570. * Defines angle representation
  4571. */
  4572. export class Angle {
  4573. private _radians;
  4574. /**
  4575. * Creates an Angle object of "radians" radians (float).
  4576. * @param radians the angle in radians
  4577. */
  4578. constructor(radians: number);
  4579. /**
  4580. * Get value in degrees
  4581. * @returns the Angle value in degrees (float)
  4582. */
  4583. degrees(): number;
  4584. /**
  4585. * Get value in radians
  4586. * @returns the Angle value in radians (float)
  4587. */
  4588. radians(): number;
  4589. /**
  4590. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4591. * @param a defines first vector
  4592. * @param b defines second vector
  4593. * @returns a new Angle
  4594. */
  4595. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4596. /**
  4597. * Gets a new Angle object from the given float in radians
  4598. * @param radians defines the angle value in radians
  4599. * @returns a new Angle
  4600. */
  4601. static FromRadians(radians: number): Angle;
  4602. /**
  4603. * Gets a new Angle object from the given float in degrees
  4604. * @param degrees defines the angle value in degrees
  4605. * @returns a new Angle
  4606. */
  4607. static FromDegrees(degrees: number): Angle;
  4608. }
  4609. /**
  4610. * This represents an arc in a 2d space.
  4611. */
  4612. export class Arc2 {
  4613. /** Defines the start point of the arc */
  4614. startPoint: Vector2;
  4615. /** Defines the mid point of the arc */
  4616. midPoint: Vector2;
  4617. /** Defines the end point of the arc */
  4618. endPoint: Vector2;
  4619. /**
  4620. * Defines the center point of the arc.
  4621. */
  4622. centerPoint: Vector2;
  4623. /**
  4624. * Defines the radius of the arc.
  4625. */
  4626. radius: number;
  4627. /**
  4628. * Defines the angle of the arc (from mid point to end point).
  4629. */
  4630. angle: Angle;
  4631. /**
  4632. * Defines the start angle of the arc (from start point to middle point).
  4633. */
  4634. startAngle: Angle;
  4635. /**
  4636. * Defines the orientation of the arc (clock wise/counter clock wise).
  4637. */
  4638. orientation: Orientation;
  4639. /**
  4640. * Creates an Arc object from the three given points : start, middle and end.
  4641. * @param startPoint Defines the start point of the arc
  4642. * @param midPoint Defines the midlle point of the arc
  4643. * @param endPoint Defines the end point of the arc
  4644. */
  4645. constructor(
  4646. /** Defines the start point of the arc */
  4647. startPoint: Vector2,
  4648. /** Defines the mid point of the arc */
  4649. midPoint: Vector2,
  4650. /** Defines the end point of the arc */
  4651. endPoint: Vector2);
  4652. }
  4653. /**
  4654. * Represents a 2D path made up of multiple 2D points
  4655. */
  4656. export class Path2 {
  4657. private _points;
  4658. private _length;
  4659. /**
  4660. * If the path start and end point are the same
  4661. */
  4662. closed: boolean;
  4663. /**
  4664. * Creates a Path2 object from the starting 2D coordinates x and y.
  4665. * @param x the starting points x value
  4666. * @param y the starting points y value
  4667. */
  4668. constructor(x: number, y: number);
  4669. /**
  4670. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4671. * @param x the added points x value
  4672. * @param y the added points y value
  4673. * @returns the updated Path2.
  4674. */
  4675. addLineTo(x: number, y: number): Path2;
  4676. /**
  4677. * 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.
  4678. * @param midX middle point x value
  4679. * @param midY middle point y value
  4680. * @param endX end point x value
  4681. * @param endY end point y value
  4682. * @param numberOfSegments (default: 36)
  4683. * @returns the updated Path2.
  4684. */
  4685. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4686. /**
  4687. * Closes the Path2.
  4688. * @returns the Path2.
  4689. */
  4690. close(): Path2;
  4691. /**
  4692. * Gets the sum of the distance between each sequential point in the path
  4693. * @returns the Path2 total length (float).
  4694. */
  4695. length(): number;
  4696. /**
  4697. * Gets the points which construct the path
  4698. * @returns the Path2 internal array of points.
  4699. */
  4700. getPoints(): Vector2[];
  4701. /**
  4702. * Retreives the point at the distance aways from the starting point
  4703. * @param normalizedLengthPosition the length along the path to retreive the point from
  4704. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4705. */
  4706. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4707. /**
  4708. * Creates a new path starting from an x and y position
  4709. * @param x starting x value
  4710. * @param y starting y value
  4711. * @returns a new Path2 starting at the coordinates (x, y).
  4712. */
  4713. static StartingAt(x: number, y: number): Path2;
  4714. }
  4715. /**
  4716. * Represents a 3D path made up of multiple 3D points
  4717. */
  4718. export class Path3D {
  4719. /**
  4720. * an array of Vector3, the curve axis of the Path3D
  4721. */
  4722. path: Vector3[];
  4723. private _curve;
  4724. private _distances;
  4725. private _tangents;
  4726. private _normals;
  4727. private _binormals;
  4728. private _raw;
  4729. /**
  4730. * new Path3D(path, normal, raw)
  4731. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4732. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4733. * @param path an array of Vector3, the curve axis of the Path3D
  4734. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4735. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4736. */
  4737. constructor(
  4738. /**
  4739. * an array of Vector3, the curve axis of the Path3D
  4740. */
  4741. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4742. /**
  4743. * Returns the Path3D array of successive Vector3 designing its curve.
  4744. * @returns the Path3D array of successive Vector3 designing its curve.
  4745. */
  4746. getCurve(): Vector3[];
  4747. /**
  4748. * Returns an array populated with tangent vectors on each Path3D curve point.
  4749. * @returns an array populated with tangent vectors on each Path3D curve point.
  4750. */
  4751. getTangents(): Vector3[];
  4752. /**
  4753. * Returns an array populated with normal vectors on each Path3D curve point.
  4754. * @returns an array populated with normal vectors on each Path3D curve point.
  4755. */
  4756. getNormals(): Vector3[];
  4757. /**
  4758. * Returns an array populated with binormal vectors on each Path3D curve point.
  4759. * @returns an array populated with binormal vectors on each Path3D curve point.
  4760. */
  4761. getBinormals(): Vector3[];
  4762. /**
  4763. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4764. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4765. */
  4766. getDistances(): number[];
  4767. /**
  4768. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4769. * @param path path which all values are copied into the curves points
  4770. * @param firstNormal which should be projected onto the curve
  4771. * @returns the same object updated.
  4772. */
  4773. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4774. private _compute;
  4775. private _getFirstNonNullVector;
  4776. private _getLastNonNullVector;
  4777. private _normalVector;
  4778. }
  4779. /**
  4780. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4781. * A Curve3 is designed from a series of successive Vector3.
  4782. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4783. */
  4784. export class Curve3 {
  4785. private _points;
  4786. private _length;
  4787. /**
  4788. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4789. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4790. * @param v1 (Vector3) the control point
  4791. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4792. * @param nbPoints (integer) the wanted number of points in the curve
  4793. * @returns the created Curve3
  4794. */
  4795. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4796. /**
  4797. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4798. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4799. * @param v1 (Vector3) the first control point
  4800. * @param v2 (Vector3) the second control point
  4801. * @param v3 (Vector3) the end point of the Cubic Bezier
  4802. * @param nbPoints (integer) the wanted number of points in the curve
  4803. * @returns the created Curve3
  4804. */
  4805. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4806. /**
  4807. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4808. * @param p1 (Vector3) the origin point of the Hermite Spline
  4809. * @param t1 (Vector3) the tangent vector at the origin point
  4810. * @param p2 (Vector3) the end point of the Hermite Spline
  4811. * @param t2 (Vector3) the tangent vector at the end point
  4812. * @param nbPoints (integer) the wanted number of points in the curve
  4813. * @returns the created Curve3
  4814. */
  4815. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4816. /**
  4817. * Returns a Curve3 object along a CatmullRom Spline curve :
  4818. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4819. * @param nbPoints (integer) the wanted number of points between each curve control points
  4820. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4821. * @returns the created Curve3
  4822. */
  4823. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4824. /**
  4825. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4826. * A Curve3 is designed from a series of successive Vector3.
  4827. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4828. * @param points points which make up the curve
  4829. */
  4830. constructor(points: Vector3[]);
  4831. /**
  4832. * @returns the Curve3 stored array of successive Vector3
  4833. */
  4834. getPoints(): Vector3[];
  4835. /**
  4836. * @returns the computed length (float) of the curve.
  4837. */
  4838. length(): number;
  4839. /**
  4840. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4841. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4842. * curveA and curveB keep unchanged.
  4843. * @param curve the curve to continue from this curve
  4844. * @returns the newly constructed curve
  4845. */
  4846. continue(curve: DeepImmutable<Curve3>): Curve3;
  4847. private _computeLength;
  4848. }
  4849. }
  4850. declare module "babylonjs/Animations/easing" {
  4851. /**
  4852. * This represents the main contract an easing function should follow.
  4853. * Easing functions are used throughout the animation system.
  4854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4855. */
  4856. export interface IEasingFunction {
  4857. /**
  4858. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4859. * of the easing function.
  4860. * The link below provides some of the most common examples of easing functions.
  4861. * @see https://easings.net/
  4862. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4863. * @returns the corresponding value on the curve defined by the easing function
  4864. */
  4865. ease(gradient: number): number;
  4866. }
  4867. /**
  4868. * Base class used for every default easing function.
  4869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4870. */
  4871. export class EasingFunction implements IEasingFunction {
  4872. /**
  4873. * Interpolation follows the mathematical formula associated with the easing function.
  4874. */
  4875. static readonly EASINGMODE_EASEIN: number;
  4876. /**
  4877. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4878. */
  4879. static readonly EASINGMODE_EASEOUT: number;
  4880. /**
  4881. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4882. */
  4883. static readonly EASINGMODE_EASEINOUT: number;
  4884. private _easingMode;
  4885. /**
  4886. * Sets the easing mode of the current function.
  4887. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4888. */
  4889. setEasingMode(easingMode: number): void;
  4890. /**
  4891. * Gets the current easing mode.
  4892. * @returns the easing mode
  4893. */
  4894. getEasingMode(): number;
  4895. /**
  4896. * @hidden
  4897. */
  4898. easeInCore(gradient: number): number;
  4899. /**
  4900. * Given an input gradient between 0 and 1, this returns the corresponding value
  4901. * of the easing function.
  4902. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4903. * @returns the corresponding value on the curve defined by the easing function
  4904. */
  4905. ease(gradient: number): number;
  4906. }
  4907. /**
  4908. * Easing function with a circle shape (see link below).
  4909. * @see https://easings.net/#easeInCirc
  4910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4911. */
  4912. export class CircleEase extends EasingFunction implements IEasingFunction {
  4913. /** @hidden */
  4914. easeInCore(gradient: number): number;
  4915. }
  4916. /**
  4917. * Easing function with a ease back shape (see link below).
  4918. * @see https://easings.net/#easeInBack
  4919. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4920. */
  4921. export class BackEase extends EasingFunction implements IEasingFunction {
  4922. /** Defines the amplitude of the function */
  4923. amplitude: number;
  4924. /**
  4925. * Instantiates a back ease easing
  4926. * @see https://easings.net/#easeInBack
  4927. * @param amplitude Defines the amplitude of the function
  4928. */
  4929. constructor(
  4930. /** Defines the amplitude of the function */
  4931. amplitude?: number);
  4932. /** @hidden */
  4933. easeInCore(gradient: number): number;
  4934. }
  4935. /**
  4936. * Easing function with a bouncing shape (see link below).
  4937. * @see https://easings.net/#easeInBounce
  4938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4939. */
  4940. export class BounceEase extends EasingFunction implements IEasingFunction {
  4941. /** Defines the number of bounces */
  4942. bounces: number;
  4943. /** Defines the amplitude of the bounce */
  4944. bounciness: number;
  4945. /**
  4946. * Instantiates a bounce easing
  4947. * @see https://easings.net/#easeInBounce
  4948. * @param bounces Defines the number of bounces
  4949. * @param bounciness Defines the amplitude of the bounce
  4950. */
  4951. constructor(
  4952. /** Defines the number of bounces */
  4953. bounces?: number,
  4954. /** Defines the amplitude of the bounce */
  4955. bounciness?: number);
  4956. /** @hidden */
  4957. easeInCore(gradient: number): number;
  4958. }
  4959. /**
  4960. * Easing function with a power of 3 shape (see link below).
  4961. * @see https://easings.net/#easeInCubic
  4962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4963. */
  4964. export class CubicEase extends EasingFunction implements IEasingFunction {
  4965. /** @hidden */
  4966. easeInCore(gradient: number): number;
  4967. }
  4968. /**
  4969. * Easing function with an elastic shape (see link below).
  4970. * @see https://easings.net/#easeInElastic
  4971. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4972. */
  4973. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4974. /** Defines the number of oscillations*/
  4975. oscillations: number;
  4976. /** Defines the amplitude of the oscillations*/
  4977. springiness: number;
  4978. /**
  4979. * Instantiates an elastic easing function
  4980. * @see https://easings.net/#easeInElastic
  4981. * @param oscillations Defines the number of oscillations
  4982. * @param springiness Defines the amplitude of the oscillations
  4983. */
  4984. constructor(
  4985. /** Defines the number of oscillations*/
  4986. oscillations?: number,
  4987. /** Defines the amplitude of the oscillations*/
  4988. springiness?: number);
  4989. /** @hidden */
  4990. easeInCore(gradient: number): number;
  4991. }
  4992. /**
  4993. * Easing function with an exponential shape (see link below).
  4994. * @see https://easings.net/#easeInExpo
  4995. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4996. */
  4997. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4998. /** Defines the exponent of the function */
  4999. exponent: number;
  5000. /**
  5001. * Instantiates an exponential easing function
  5002. * @see https://easings.net/#easeInExpo
  5003. * @param exponent Defines the exponent of the function
  5004. */
  5005. constructor(
  5006. /** Defines the exponent of the function */
  5007. exponent?: number);
  5008. /** @hidden */
  5009. easeInCore(gradient: number): number;
  5010. }
  5011. /**
  5012. * Easing function with a power shape (see link below).
  5013. * @see https://easings.net/#easeInQuad
  5014. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5015. */
  5016. export class PowerEase extends EasingFunction implements IEasingFunction {
  5017. /** Defines the power of the function */
  5018. power: number;
  5019. /**
  5020. * Instantiates an power base easing function
  5021. * @see https://easings.net/#easeInQuad
  5022. * @param power Defines the power of the function
  5023. */
  5024. constructor(
  5025. /** Defines the power of the function */
  5026. power?: number);
  5027. /** @hidden */
  5028. easeInCore(gradient: number): number;
  5029. }
  5030. /**
  5031. * Easing function with a power of 2 shape (see link below).
  5032. * @see https://easings.net/#easeInQuad
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5036. /** @hidden */
  5037. easeInCore(gradient: number): number;
  5038. }
  5039. /**
  5040. * Easing function with a power of 4 shape (see link below).
  5041. * @see https://easings.net/#easeInQuart
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5045. /** @hidden */
  5046. easeInCore(gradient: number): number;
  5047. }
  5048. /**
  5049. * Easing function with a power of 5 shape (see link below).
  5050. * @see https://easings.net/#easeInQuint
  5051. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5052. */
  5053. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5054. /** @hidden */
  5055. easeInCore(gradient: number): number;
  5056. }
  5057. /**
  5058. * Easing function with a sin shape (see link below).
  5059. * @see https://easings.net/#easeInSine
  5060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5061. */
  5062. export class SineEase extends EasingFunction implements IEasingFunction {
  5063. /** @hidden */
  5064. easeInCore(gradient: number): number;
  5065. }
  5066. /**
  5067. * Easing function with a bezier shape (see link below).
  5068. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5072. /** Defines the x component of the start tangent in the bezier curve */
  5073. x1: number;
  5074. /** Defines the y component of the start tangent in the bezier curve */
  5075. y1: number;
  5076. /** Defines the x component of the end tangent in the bezier curve */
  5077. x2: number;
  5078. /** Defines the y component of the end tangent in the bezier curve */
  5079. y2: number;
  5080. /**
  5081. * Instantiates a bezier function
  5082. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5083. * @param x1 Defines the x component of the start tangent in the bezier curve
  5084. * @param y1 Defines the y component of the start tangent in the bezier curve
  5085. * @param x2 Defines the x component of the end tangent in the bezier curve
  5086. * @param y2 Defines the y component of the end tangent in the bezier curve
  5087. */
  5088. constructor(
  5089. /** Defines the x component of the start tangent in the bezier curve */
  5090. x1?: number,
  5091. /** Defines the y component of the start tangent in the bezier curve */
  5092. y1?: number,
  5093. /** Defines the x component of the end tangent in the bezier curve */
  5094. x2?: number,
  5095. /** Defines the y component of the end tangent in the bezier curve */
  5096. y2?: number);
  5097. /** @hidden */
  5098. easeInCore(gradient: number): number;
  5099. }
  5100. }
  5101. declare module "babylonjs/Maths/math.color" {
  5102. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5103. /**
  5104. * Class used to hold a RBG color
  5105. */
  5106. export class Color3 {
  5107. /**
  5108. * Defines the red component (between 0 and 1, default is 0)
  5109. */
  5110. r: number;
  5111. /**
  5112. * Defines the green component (between 0 and 1, default is 0)
  5113. */
  5114. g: number;
  5115. /**
  5116. * Defines the blue component (between 0 and 1, default is 0)
  5117. */
  5118. b: number;
  5119. /**
  5120. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5121. * @param r defines the red component (between 0 and 1, default is 0)
  5122. * @param g defines the green component (between 0 and 1, default is 0)
  5123. * @param b defines the blue component (between 0 and 1, default is 0)
  5124. */
  5125. constructor(
  5126. /**
  5127. * Defines the red component (between 0 and 1, default is 0)
  5128. */
  5129. r?: number,
  5130. /**
  5131. * Defines the green component (between 0 and 1, default is 0)
  5132. */
  5133. g?: number,
  5134. /**
  5135. * Defines the blue component (between 0 and 1, default is 0)
  5136. */
  5137. b?: number);
  5138. /**
  5139. * Creates a string with the Color3 current values
  5140. * @returns the string representation of the Color3 object
  5141. */
  5142. toString(): string;
  5143. /**
  5144. * Returns the string "Color3"
  5145. * @returns "Color3"
  5146. */
  5147. getClassName(): string;
  5148. /**
  5149. * Compute the Color3 hash code
  5150. * @returns an unique number that can be used to hash Color3 objects
  5151. */
  5152. getHashCode(): number;
  5153. /**
  5154. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5155. * @param array defines the array where to store the r,g,b components
  5156. * @param index defines an optional index in the target array to define where to start storing values
  5157. * @returns the current Color3 object
  5158. */
  5159. toArray(array: FloatArray, index?: number): Color3;
  5160. /**
  5161. * Returns a new Color4 object from the current Color3 and the given alpha
  5162. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5163. * @returns a new Color4 object
  5164. */
  5165. toColor4(alpha?: number): Color4;
  5166. /**
  5167. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Returns the luminance value
  5173. * @returns a float value
  5174. */
  5175. toLuminance(): number;
  5176. /**
  5177. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5178. * @param otherColor defines the second operand
  5179. * @returns the new Color3 object
  5180. */
  5181. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5182. /**
  5183. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5184. * @param otherColor defines the second operand
  5185. * @param result defines the Color3 object where to store the result
  5186. * @returns the current Color3
  5187. */
  5188. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5189. /**
  5190. * Determines equality between Color3 objects
  5191. * @param otherColor defines the second operand
  5192. * @returns true if the rgb values are equal to the given ones
  5193. */
  5194. equals(otherColor: DeepImmutable<Color3>): boolean;
  5195. /**
  5196. * Determines equality between the current Color3 object and a set of r,b,g values
  5197. * @param r defines the red component to check
  5198. * @param g defines the green component to check
  5199. * @param b defines the blue component to check
  5200. * @returns true if the rgb values are equal to the given ones
  5201. */
  5202. equalsFloats(r: number, g: number, b: number): boolean;
  5203. /**
  5204. * Multiplies in place each rgb value by scale
  5205. * @param scale defines the scaling factor
  5206. * @returns the updated Color3
  5207. */
  5208. scale(scale: number): Color3;
  5209. /**
  5210. * Multiplies the rgb values by scale and stores the result into "result"
  5211. * @param scale defines the scaling factor
  5212. * @param result defines the Color3 object where to store the result
  5213. * @returns the unmodified current Color3
  5214. */
  5215. scaleToRef(scale: number, result: Color3): Color3;
  5216. /**
  5217. * Scale the current Color3 values by a factor and add the result to a given Color3
  5218. * @param scale defines the scale factor
  5219. * @param result defines color to store the result into
  5220. * @returns the unmodified current Color3
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into
  5228. * @returns the original Color3
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5231. /**
  5232. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5233. * @param otherColor defines the second operand
  5234. * @returns the new Color3
  5235. */
  5236. add(otherColor: DeepImmutable<Color3>): Color3;
  5237. /**
  5238. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5239. * @param otherColor defines the second operand
  5240. * @param result defines Color3 object to store the result into
  5241. * @returns the unmodified current Color3
  5242. */
  5243. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5244. /**
  5245. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5246. * @param otherColor defines the second operand
  5247. * @returns the new Color3
  5248. */
  5249. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5250. /**
  5251. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5252. * @param otherColor defines the second operand
  5253. * @param result defines Color3 object to store the result into
  5254. * @returns the unmodified current Color3
  5255. */
  5256. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5257. /**
  5258. * Copy the current object
  5259. * @returns a new Color3 copied the current one
  5260. */
  5261. clone(): Color3;
  5262. /**
  5263. * Copies the rgb values from the source in the current Color3
  5264. * @param source defines the source Color3 object
  5265. * @returns the updated Color3 object
  5266. */
  5267. copyFrom(source: DeepImmutable<Color3>): Color3;
  5268. /**
  5269. * Updates the Color3 rgb values from the given floats
  5270. * @param r defines the red component to read from
  5271. * @param g defines the green component to read from
  5272. * @param b defines the blue component to read from
  5273. * @returns the current Color3 object
  5274. */
  5275. copyFromFloats(r: number, g: number, b: number): Color3;
  5276. /**
  5277. * Updates the Color3 rgb values from the given floats
  5278. * @param r defines the red component to read from
  5279. * @param g defines the green component to read from
  5280. * @param b defines the blue component to read from
  5281. * @returns the current Color3 object
  5282. */
  5283. set(r: number, g: number, b: number): Color3;
  5284. /**
  5285. * Compute the Color3 hexadecimal code as a string
  5286. * @returns a string containing the hexadecimal representation of the Color3 object
  5287. */
  5288. toHexString(): string;
  5289. /**
  5290. * Computes a new Color3 converted from the current one to linear space
  5291. * @returns a new Color3 object
  5292. */
  5293. toLinearSpace(): Color3;
  5294. /**
  5295. * Converts current color in rgb space to HSV values
  5296. * @returns a new color3 representing the HSV values
  5297. */
  5298. toHSV(): Color3;
  5299. /**
  5300. * Converts current color in rgb space to HSV values
  5301. * @param result defines the Color3 where to store the HSV values
  5302. */
  5303. toHSVToRef(result: Color3): void;
  5304. /**
  5305. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color3 object where to store the linear space version
  5307. * @returns the unmodified Color3
  5308. */
  5309. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5310. /**
  5311. * Computes a new Color3 converted from the current one to gamma space
  5312. * @returns a new Color3 object
  5313. */
  5314. toGammaSpace(): Color3;
  5315. /**
  5316. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5317. * @param convertedColor defines the Color3 object where to store the gamma space version
  5318. * @returns the unmodified Color3
  5319. */
  5320. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5321. private static _BlackReadOnly;
  5322. /**
  5323. * Convert Hue, saturation and value to a Color3 (RGB)
  5324. * @param hue defines the hue
  5325. * @param saturation defines the saturation
  5326. * @param value defines the value
  5327. * @param result defines the Color3 where to store the RGB values
  5328. */
  5329. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5330. /**
  5331. * Creates a new Color3 from the string containing valid hexadecimal values
  5332. * @param hex defines a string containing valid hexadecimal values
  5333. * @returns a new Color3 object
  5334. */
  5335. static FromHexString(hex: string): Color3;
  5336. /**
  5337. * Creates a new Color3 from the starting index of the given array
  5338. * @param array defines the source array
  5339. * @param offset defines an offset in the source array
  5340. * @returns a new Color3 object
  5341. */
  5342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5343. /**
  5344. * Creates a new Color3 from integer values (< 256)
  5345. * @param r defines the red component to read from (value between 0 and 255)
  5346. * @param g defines the green component to read from (value between 0 and 255)
  5347. * @param b defines the blue component to read from (value between 0 and 255)
  5348. * @returns a new Color3 object
  5349. */
  5350. static FromInts(r: number, g: number, b: number): Color3;
  5351. /**
  5352. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5353. * @param start defines the start Color3 value
  5354. * @param end defines the end Color3 value
  5355. * @param amount defines the gradient value between start and end
  5356. * @returns a new Color3 object
  5357. */
  5358. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5359. /**
  5360. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5361. * @param left defines the start value
  5362. * @param right defines the end value
  5363. * @param amount defines the gradient factor
  5364. * @param result defines the Color3 object where to store the result
  5365. */
  5366. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5367. /**
  5368. * Returns a Color3 value containing a red color
  5369. * @returns a new Color3 object
  5370. */
  5371. static Red(): Color3;
  5372. /**
  5373. * Returns a Color3 value containing a green color
  5374. * @returns a new Color3 object
  5375. */
  5376. static Green(): Color3;
  5377. /**
  5378. * Returns a Color3 value containing a blue color
  5379. * @returns a new Color3 object
  5380. */
  5381. static Blue(): Color3;
  5382. /**
  5383. * Returns a Color3 value containing a black color
  5384. * @returns a new Color3 object
  5385. */
  5386. static Black(): Color3;
  5387. /**
  5388. * Gets a Color3 value containing a black color that must not be updated
  5389. */
  5390. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5391. /**
  5392. * Returns a Color3 value containing a white color
  5393. * @returns a new Color3 object
  5394. */
  5395. static White(): Color3;
  5396. /**
  5397. * Returns a Color3 value containing a purple color
  5398. * @returns a new Color3 object
  5399. */
  5400. static Purple(): Color3;
  5401. /**
  5402. * Returns a Color3 value containing a magenta color
  5403. * @returns a new Color3 object
  5404. */
  5405. static Magenta(): Color3;
  5406. /**
  5407. * Returns a Color3 value containing a yellow color
  5408. * @returns a new Color3 object
  5409. */
  5410. static Yellow(): Color3;
  5411. /**
  5412. * Returns a Color3 value containing a gray color
  5413. * @returns a new Color3 object
  5414. */
  5415. static Gray(): Color3;
  5416. /**
  5417. * Returns a Color3 value containing a teal color
  5418. * @returns a new Color3 object
  5419. */
  5420. static Teal(): Color3;
  5421. /**
  5422. * Returns a Color3 value containing a random color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Random(): Color3;
  5426. }
  5427. /**
  5428. * Class used to hold a RBGA color
  5429. */
  5430. export class Color4 {
  5431. /**
  5432. * Defines the red component (between 0 and 1, default is 0)
  5433. */
  5434. r: number;
  5435. /**
  5436. * Defines the green component (between 0 and 1, default is 0)
  5437. */
  5438. g: number;
  5439. /**
  5440. * Defines the blue component (between 0 and 1, default is 0)
  5441. */
  5442. b: number;
  5443. /**
  5444. * Defines the alpha component (between 0 and 1, default is 1)
  5445. */
  5446. a: number;
  5447. /**
  5448. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5449. * @param r defines the red component (between 0 and 1, default is 0)
  5450. * @param g defines the green component (between 0 and 1, default is 0)
  5451. * @param b defines the blue component (between 0 and 1, default is 0)
  5452. * @param a defines the alpha component (between 0 and 1, default is 1)
  5453. */
  5454. constructor(
  5455. /**
  5456. * Defines the red component (between 0 and 1, default is 0)
  5457. */
  5458. r?: number,
  5459. /**
  5460. * Defines the green component (between 0 and 1, default is 0)
  5461. */
  5462. g?: number,
  5463. /**
  5464. * Defines the blue component (between 0 and 1, default is 0)
  5465. */
  5466. b?: number,
  5467. /**
  5468. * Defines the alpha component (between 0 and 1, default is 1)
  5469. */
  5470. a?: number);
  5471. /**
  5472. * Adds in place the given Color4 values to the current Color4 object
  5473. * @param right defines the second operand
  5474. * @returns the current updated Color4 object
  5475. */
  5476. addInPlace(right: DeepImmutable<Color4>): Color4;
  5477. /**
  5478. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Stores from the starting index in the given array the Color4 successive values
  5484. * @param array defines the array where to store the r,g,b components
  5485. * @param index defines an optional index in the target array to define where to start storing values
  5486. * @returns the current Color4 object
  5487. */
  5488. toArray(array: number[], index?: number): Color4;
  5489. /**
  5490. * Determines equality between Color4 objects
  5491. * @param otherColor defines the second operand
  5492. * @returns true if the rgba values are equal to the given ones
  5493. */
  5494. equals(otherColor: DeepImmutable<Color4>): boolean;
  5495. /**
  5496. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5497. * @param right defines the second operand
  5498. * @returns a new Color4 object
  5499. */
  5500. add(right: DeepImmutable<Color4>): Color4;
  5501. /**
  5502. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5503. * @param right defines the second operand
  5504. * @returns a new Color4 object
  5505. */
  5506. subtract(right: DeepImmutable<Color4>): Color4;
  5507. /**
  5508. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5509. * @param right defines the second operand
  5510. * @param result defines the Color4 object where to store the result
  5511. * @returns the current Color4 object
  5512. */
  5513. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5514. /**
  5515. * Creates a new Color4 with the current Color4 values multiplied by scale
  5516. * @param scale defines the scaling factor to apply
  5517. * @returns a new Color4 object
  5518. */
  5519. scale(scale: number): Color4;
  5520. /**
  5521. * Multiplies the current Color4 values by scale and stores the result in "result"
  5522. * @param scale defines the scaling factor to apply
  5523. * @param result defines the Color4 object where to store the result
  5524. * @returns the current unmodified Color4
  5525. */
  5526. scaleToRef(scale: number, result: Color4): Color4;
  5527. /**
  5528. * Scale the current Color4 values by a factor and add the result to a given Color4
  5529. * @param scale defines the scale factor
  5530. * @param result defines the Color4 object where to store the result
  5531. * @returns the unmodified current Color4
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into.
  5539. * @returns the cuurent Color4
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5542. /**
  5543. * Multipy an Color4 value by another and return a new Color4 object
  5544. * @param color defines the Color4 value to multiply by
  5545. * @returns a new Color4 object
  5546. */
  5547. multiply(color: Color4): Color4;
  5548. /**
  5549. * Multipy a Color4 value by another and push the result in a reference value
  5550. * @param color defines the Color4 value to multiply by
  5551. * @param result defines the Color4 to fill the result in
  5552. * @returns the result Color4
  5553. */
  5554. multiplyToRef(color: Color4, result: Color4): Color4;
  5555. /**
  5556. * Creates a string with the Color4 current values
  5557. * @returns the string representation of the Color4 object
  5558. */
  5559. toString(): string;
  5560. /**
  5561. * Returns the string "Color4"
  5562. * @returns "Color4"
  5563. */
  5564. getClassName(): string;
  5565. /**
  5566. * Compute the Color4 hash code
  5567. * @returns an unique number that can be used to hash Color4 objects
  5568. */
  5569. getHashCode(): number;
  5570. /**
  5571. * Creates a new Color4 copied from the current one
  5572. * @returns a new Color4 object
  5573. */
  5574. clone(): Color4;
  5575. /**
  5576. * Copies the given Color4 values into the current one
  5577. * @param source defines the source Color4 object
  5578. * @returns the current updated Color4 object
  5579. */
  5580. copyFrom(source: Color4): Color4;
  5581. /**
  5582. * Copies the given float values into the current one
  5583. * @param r defines the red component to read from
  5584. * @param g defines the green component to read from
  5585. * @param b defines the blue component to read from
  5586. * @param a defines the alpha component to read from
  5587. * @returns the current updated Color4 object
  5588. */
  5589. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5590. /**
  5591. * Copies the given float values into the current one
  5592. * @param r defines the red component to read from
  5593. * @param g defines the green component to read from
  5594. * @param b defines the blue component to read from
  5595. * @param a defines the alpha component to read from
  5596. * @returns the current updated Color4 object
  5597. */
  5598. set(r: number, g: number, b: number, a: number): Color4;
  5599. /**
  5600. * Compute the Color4 hexadecimal code as a string
  5601. * @returns a string containing the hexadecimal representation of the Color4 object
  5602. */
  5603. toHexString(): string;
  5604. /**
  5605. * Computes a new Color4 converted from the current one to linear space
  5606. * @returns a new Color4 object
  5607. */
  5608. toLinearSpace(): Color4;
  5609. /**
  5610. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5611. * @param convertedColor defines the Color4 object where to store the linear space version
  5612. * @returns the unmodified Color4
  5613. */
  5614. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5615. /**
  5616. * Computes a new Color4 converted from the current one to gamma space
  5617. * @returns a new Color4 object
  5618. */
  5619. toGammaSpace(): Color4;
  5620. /**
  5621. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5622. * @param convertedColor defines the Color4 object where to store the gamma space version
  5623. * @returns the unmodified Color4
  5624. */
  5625. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5626. /**
  5627. * Creates a new Color4 from the string containing valid hexadecimal values
  5628. * @param hex defines a string containing valid hexadecimal values
  5629. * @returns a new Color4 object
  5630. */
  5631. static FromHexString(hex: string): Color4;
  5632. /**
  5633. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5634. * @param left defines the start value
  5635. * @param right defines the end value
  5636. * @param amount defines the gradient factor
  5637. * @returns a new Color4 object
  5638. */
  5639. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5640. /**
  5641. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5642. * @param left defines the start value
  5643. * @param right defines the end value
  5644. * @param amount defines the gradient factor
  5645. * @param result defines the Color4 object where to store data
  5646. */
  5647. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5648. /**
  5649. * Creates a new Color4 from a Color3 and an alpha value
  5650. * @param color3 defines the source Color3 to read from
  5651. * @param alpha defines the alpha component (1.0 by default)
  5652. * @returns a new Color4 object
  5653. */
  5654. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5655. /**
  5656. * Creates a new Color4 from the starting index element of the given array
  5657. * @param array defines the source array to read from
  5658. * @param offset defines the offset in the source array
  5659. * @returns a new Color4 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @param a defines the alpha component to read from (value between 0 and 255)
  5668. * @returns a new Color3 object
  5669. */
  5670. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5671. /**
  5672. * Check the content of a given array and convert it to an array containing RGBA data
  5673. * If the original array was already containing count * 4 values then it is returned directly
  5674. * @param colors defines the array to check
  5675. * @param count defines the number of RGBA data to expect
  5676. * @returns an array containing count * 4 values (RGBA)
  5677. */
  5678. static CheckColors4(colors: number[], count: number): number[];
  5679. }
  5680. /**
  5681. * @hidden
  5682. */
  5683. export class TmpColors {
  5684. static Color3: Color3[];
  5685. static Color4: Color4[];
  5686. }
  5687. }
  5688. declare module "babylonjs/Animations/animationKey" {
  5689. /**
  5690. * Defines an interface which represents an animation key frame
  5691. */
  5692. export interface IAnimationKey {
  5693. /**
  5694. * Frame of the key frame
  5695. */
  5696. frame: number;
  5697. /**
  5698. * Value at the specifies key frame
  5699. */
  5700. value: any;
  5701. /**
  5702. * The input tangent for the cubic hermite spline
  5703. */
  5704. inTangent?: any;
  5705. /**
  5706. * The output tangent for the cubic hermite spline
  5707. */
  5708. outTangent?: any;
  5709. /**
  5710. * The animation interpolation type
  5711. */
  5712. interpolation?: AnimationKeyInterpolation;
  5713. }
  5714. /**
  5715. * Enum for the animation key frame interpolation type
  5716. */
  5717. export enum AnimationKeyInterpolation {
  5718. /**
  5719. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5720. */
  5721. STEP = 1
  5722. }
  5723. }
  5724. declare module "babylonjs/Animations/animationRange" {
  5725. /**
  5726. * Represents the range of an animation
  5727. */
  5728. export class AnimationRange {
  5729. /**The name of the animation range**/
  5730. name: string;
  5731. /**The starting frame of the animation */
  5732. from: number;
  5733. /**The ending frame of the animation*/
  5734. to: number;
  5735. /**
  5736. * Initializes the range of an animation
  5737. * @param name The name of the animation range
  5738. * @param from The starting frame of the animation
  5739. * @param to The ending frame of the animation
  5740. */
  5741. constructor(
  5742. /**The name of the animation range**/
  5743. name: string,
  5744. /**The starting frame of the animation */
  5745. from: number,
  5746. /**The ending frame of the animation*/
  5747. to: number);
  5748. /**
  5749. * Makes a copy of the animation range
  5750. * @returns A copy of the animation range
  5751. */
  5752. clone(): AnimationRange;
  5753. }
  5754. }
  5755. declare module "babylonjs/Animations/animationEvent" {
  5756. /**
  5757. * Composed of a frame, and an action function
  5758. */
  5759. export class AnimationEvent {
  5760. /** The frame for which the event is triggered **/
  5761. frame: number;
  5762. /** The event to perform when triggered **/
  5763. action: (currentFrame: number) => void;
  5764. /** Specifies if the event should be triggered only once**/
  5765. onlyOnce?: boolean | undefined;
  5766. /**
  5767. * Specifies if the animation event is done
  5768. */
  5769. isDone: boolean;
  5770. /**
  5771. * Initializes the animation event
  5772. * @param frame The frame for which the event is triggered
  5773. * @param action The event to perform when triggered
  5774. * @param onlyOnce Specifies if the event should be triggered only once
  5775. */
  5776. constructor(
  5777. /** The frame for which the event is triggered **/
  5778. frame: number,
  5779. /** The event to perform when triggered **/
  5780. action: (currentFrame: number) => void,
  5781. /** Specifies if the event should be triggered only once**/
  5782. onlyOnce?: boolean | undefined);
  5783. /** @hidden */
  5784. _clone(): AnimationEvent;
  5785. }
  5786. }
  5787. declare module "babylonjs/Behaviors/behavior" {
  5788. import { Nullable } from "babylonjs/types";
  5789. /**
  5790. * Interface used to define a behavior
  5791. */
  5792. export interface Behavior<T> {
  5793. /** gets or sets behavior's name */
  5794. name: string;
  5795. /**
  5796. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5797. */
  5798. init(): void;
  5799. /**
  5800. * Called when the behavior is attached to a target
  5801. * @param target defines the target where the behavior is attached to
  5802. */
  5803. attach(target: T): void;
  5804. /**
  5805. * Called when the behavior is detached from its target
  5806. */
  5807. detach(): void;
  5808. }
  5809. /**
  5810. * Interface implemented by classes supporting behaviors
  5811. */
  5812. export interface IBehaviorAware<T> {
  5813. /**
  5814. * Attach a behavior
  5815. * @param behavior defines the behavior to attach
  5816. * @returns the current host
  5817. */
  5818. addBehavior(behavior: Behavior<T>): T;
  5819. /**
  5820. * Remove a behavior from the current object
  5821. * @param behavior defines the behavior to detach
  5822. * @returns the current host
  5823. */
  5824. removeBehavior(behavior: Behavior<T>): T;
  5825. /**
  5826. * Gets a behavior using its name to search
  5827. * @param name defines the name to search
  5828. * @returns the behavior or null if not found
  5829. */
  5830. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5831. }
  5832. }
  5833. declare module "babylonjs/Misc/smartArray" {
  5834. /**
  5835. * Defines an array and its length.
  5836. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5837. */
  5838. export interface ISmartArrayLike<T> {
  5839. /**
  5840. * The data of the array.
  5841. */
  5842. data: Array<T>;
  5843. /**
  5844. * The active length of the array.
  5845. */
  5846. length: number;
  5847. }
  5848. /**
  5849. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5850. */
  5851. export class SmartArray<T> implements ISmartArrayLike<T> {
  5852. /**
  5853. * The full set of data from the array.
  5854. */
  5855. data: Array<T>;
  5856. /**
  5857. * The active length of the array.
  5858. */
  5859. length: number;
  5860. protected _id: number;
  5861. /**
  5862. * Instantiates a Smart Array.
  5863. * @param capacity defines the default capacity of the array.
  5864. */
  5865. constructor(capacity: number);
  5866. /**
  5867. * Pushes a value at the end of the active data.
  5868. * @param value defines the object to push in the array.
  5869. */
  5870. push(value: T): void;
  5871. /**
  5872. * Iterates over the active data and apply the lambda to them.
  5873. * @param func defines the action to apply on each value.
  5874. */
  5875. forEach(func: (content: T) => void): void;
  5876. /**
  5877. * Sorts the full sets of data.
  5878. * @param compareFn defines the comparison function to apply.
  5879. */
  5880. sort(compareFn: (a: T, b: T) => number): void;
  5881. /**
  5882. * Resets the active data to an empty array.
  5883. */
  5884. reset(): void;
  5885. /**
  5886. * Releases all the data from the array as well as the array.
  5887. */
  5888. dispose(): void;
  5889. /**
  5890. * Concats the active data with a given array.
  5891. * @param array defines the data to concatenate with.
  5892. */
  5893. concat(array: any): void;
  5894. /**
  5895. * Returns the position of a value in the active data.
  5896. * @param value defines the value to find the index for
  5897. * @returns the index if found in the active data otherwise -1
  5898. */
  5899. indexOf(value: T): number;
  5900. /**
  5901. * Returns whether an element is part of the active data.
  5902. * @param value defines the value to look for
  5903. * @returns true if found in the active data otherwise false
  5904. */
  5905. contains(value: T): boolean;
  5906. private static _GlobalId;
  5907. }
  5908. /**
  5909. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5910. * The data in this array can only be present once
  5911. */
  5912. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5913. private _duplicateId;
  5914. /**
  5915. * Pushes a value at the end of the active data.
  5916. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5917. * @param value defines the object to push in the array.
  5918. */
  5919. push(value: T): void;
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * If the data is already present, it won t be added again
  5923. * @param value defines the object to push in the array.
  5924. * @returns true if added false if it was already present
  5925. */
  5926. pushNoDuplicate(value: T): boolean;
  5927. /**
  5928. * Resets the active data to an empty array.
  5929. */
  5930. reset(): void;
  5931. /**
  5932. * Concats the active data with a given array.
  5933. * This ensures no dupplicate will be present in the result.
  5934. * @param array defines the data to concatenate with.
  5935. */
  5936. concatWithNoDuplicate(array: any): void;
  5937. }
  5938. }
  5939. declare module "babylonjs/Cameras/cameraInputsManager" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Camera } from "babylonjs/Cameras/camera";
  5942. /**
  5943. * @ignore
  5944. * This is a list of all the different input types that are available in the application.
  5945. * Fo instance: ArcRotateCameraGamepadInput...
  5946. */
  5947. export var CameraInputTypes: {};
  5948. /**
  5949. * This is the contract to implement in order to create a new input class.
  5950. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5951. */
  5952. export interface ICameraInput<TCamera extends Camera> {
  5953. /**
  5954. * Defines the camera the input is attached to.
  5955. */
  5956. camera: Nullable<TCamera>;
  5957. /**
  5958. * Gets the class name of the current intput.
  5959. * @returns the class name
  5960. */
  5961. getClassName(): string;
  5962. /**
  5963. * Get the friendly name associated with the input class.
  5964. * @returns the input friendly name
  5965. */
  5966. getSimpleName(): string;
  5967. /**
  5968. * Attach the input controls to a specific dom element to get the input from.
  5969. * @param element Defines the element the controls should be listened from
  5970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5971. */
  5972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5973. /**
  5974. * Detach the current controls from the specified dom element.
  5975. * @param element Defines the element to stop listening the inputs from
  5976. */
  5977. detachControl(element: Nullable<HTMLElement>): void;
  5978. /**
  5979. * Update the current camera state depending on the inputs that have been used this frame.
  5980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5981. */
  5982. checkInputs?: () => void;
  5983. }
  5984. /**
  5985. * Represents a map of input types to input instance or input index to input instance.
  5986. */
  5987. export interface CameraInputsMap<TCamera extends Camera> {
  5988. /**
  5989. * Accessor to the input by input type.
  5990. */
  5991. [name: string]: ICameraInput<TCamera>;
  5992. /**
  5993. * Accessor to the input by input index.
  5994. */
  5995. [idx: number]: ICameraInput<TCamera>;
  5996. }
  5997. /**
  5998. * This represents the input manager used within a camera.
  5999. * It helps dealing with all the different kind of input attached to a camera.
  6000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6001. */
  6002. export class CameraInputsManager<TCamera extends Camera> {
  6003. /**
  6004. * Defines the list of inputs attahed to the camera.
  6005. */
  6006. attached: CameraInputsMap<TCamera>;
  6007. /**
  6008. * Defines the dom element the camera is collecting inputs from.
  6009. * This is null if the controls have not been attached.
  6010. */
  6011. attachedElement: Nullable<HTMLElement>;
  6012. /**
  6013. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6014. */
  6015. noPreventDefault: boolean;
  6016. /**
  6017. * Defined the camera the input manager belongs to.
  6018. */
  6019. camera: TCamera;
  6020. /**
  6021. * Update the current camera state depending on the inputs that have been used this frame.
  6022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6023. */
  6024. checkInputs: () => void;
  6025. /**
  6026. * Instantiate a new Camera Input Manager.
  6027. * @param camera Defines the camera the input manager blongs to
  6028. */
  6029. constructor(camera: TCamera);
  6030. /**
  6031. * Add an input method to a camera
  6032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6033. * @param input camera input method
  6034. */
  6035. add(input: ICameraInput<TCamera>): void;
  6036. /**
  6037. * Remove a specific input method from a camera
  6038. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6039. * @param inputToRemove camera input method
  6040. */
  6041. remove(inputToRemove: ICameraInput<TCamera>): void;
  6042. /**
  6043. * Remove a specific input type from a camera
  6044. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6045. * @param inputType the type of the input to remove
  6046. */
  6047. removeByType(inputType: string): void;
  6048. private _addCheckInputs;
  6049. /**
  6050. * Attach the input controls to the currently attached dom element to listen the events from.
  6051. * @param input Defines the input to attach
  6052. */
  6053. attachInput(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6056. * @param element Defines the dom element to collect the events from
  6057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6058. */
  6059. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6060. /**
  6061. * Detach the current manager inputs controls from a specific dom element.
  6062. * @param element Defines the dom element to collect the events from
  6063. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6064. */
  6065. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6066. /**
  6067. * Rebuild the dynamic inputCheck function from the current list of
  6068. * defined inputs in the manager.
  6069. */
  6070. rebuildInputCheck(): void;
  6071. /**
  6072. * Remove all attached input methods from a camera
  6073. */
  6074. clear(): void;
  6075. /**
  6076. * Serialize the current input manager attached to a camera.
  6077. * This ensures than once parsed,
  6078. * the input associated to the camera will be identical to the current ones
  6079. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6080. */
  6081. serialize(serializedCamera: any): void;
  6082. /**
  6083. * Parses an input manager serialized JSON to restore the previous list of inputs
  6084. * and states associated to a camera.
  6085. * @param parsedCamera Defines the JSON to parse
  6086. */
  6087. parse(parsedCamera: any): void;
  6088. }
  6089. }
  6090. declare module "babylonjs/Meshes/buffer" {
  6091. import { Nullable, DataArray } from "babylonjs/types";
  6092. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6093. /**
  6094. * Class used to store data that will be store in GPU memory
  6095. */
  6096. export class Buffer {
  6097. private _engine;
  6098. private _buffer;
  6099. /** @hidden */
  6100. _data: Nullable<DataArray>;
  6101. private _updatable;
  6102. private _instanced;
  6103. /**
  6104. * Gets the byte stride.
  6105. */
  6106. readonly byteStride: number;
  6107. /**
  6108. * Constructor
  6109. * @param engine the engine
  6110. * @param data the data to use for this buffer
  6111. * @param updatable whether the data is updatable
  6112. * @param stride the stride (optional)
  6113. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6114. * @param instanced whether the buffer is instanced (optional)
  6115. * @param useBytes set to true if the stride in in bytes (optional)
  6116. */
  6117. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6118. /**
  6119. * Create a new VertexBuffer based on the current buffer
  6120. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6121. * @param offset defines offset in the buffer (0 by default)
  6122. * @param size defines the size in floats of attributes (position is 3 for instance)
  6123. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6124. * @param instanced defines if the vertex buffer contains indexed data
  6125. * @param useBytes defines if the offset and stride are in bytes
  6126. * @returns the new vertex buffer
  6127. */
  6128. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6129. /**
  6130. * Gets a boolean indicating if the Buffer is updatable?
  6131. * @returns true if the buffer is updatable
  6132. */
  6133. isUpdatable(): boolean;
  6134. /**
  6135. * Gets current buffer's data
  6136. * @returns a DataArray or null
  6137. */
  6138. getData(): Nullable<DataArray>;
  6139. /**
  6140. * Gets underlying native buffer
  6141. * @returns underlying native buffer
  6142. */
  6143. getBuffer(): Nullable<DataBuffer>;
  6144. /**
  6145. * Gets the stride in float32 units (i.e. byte stride / 4).
  6146. * May not be an integer if the byte stride is not divisible by 4.
  6147. * DEPRECATED. Use byteStride instead.
  6148. * @returns the stride in float32 units
  6149. */
  6150. getStrideSize(): number;
  6151. /**
  6152. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6153. * @param data defines the data to store
  6154. */
  6155. create(data?: Nullable<DataArray>): void;
  6156. /** @hidden */
  6157. _rebuild(): void;
  6158. /**
  6159. * Update current buffer data
  6160. * @param data defines the data to store
  6161. */
  6162. update(data: DataArray): void;
  6163. /**
  6164. * Updates the data directly.
  6165. * @param data the new data
  6166. * @param offset the new offset
  6167. * @param vertexCount the vertex count (optional)
  6168. * @param useBytes set to true if the offset is in bytes
  6169. */
  6170. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6171. /**
  6172. * Release all resources
  6173. */
  6174. dispose(): void;
  6175. }
  6176. /**
  6177. * Specialized buffer used to store vertex data
  6178. */
  6179. export class VertexBuffer {
  6180. /** @hidden */
  6181. _buffer: Buffer;
  6182. private _kind;
  6183. private _size;
  6184. private _ownsBuffer;
  6185. private _instanced;
  6186. private _instanceDivisor;
  6187. /**
  6188. * The byte type.
  6189. */
  6190. static readonly BYTE: number;
  6191. /**
  6192. * The unsigned byte type.
  6193. */
  6194. static readonly UNSIGNED_BYTE: number;
  6195. /**
  6196. * The short type.
  6197. */
  6198. static readonly SHORT: number;
  6199. /**
  6200. * The unsigned short type.
  6201. */
  6202. static readonly UNSIGNED_SHORT: number;
  6203. /**
  6204. * The integer type.
  6205. */
  6206. static readonly INT: number;
  6207. /**
  6208. * The unsigned integer type.
  6209. */
  6210. static readonly UNSIGNED_INT: number;
  6211. /**
  6212. * The float type.
  6213. */
  6214. static readonly FLOAT: number;
  6215. /**
  6216. * Gets or sets the instance divisor when in instanced mode
  6217. */
  6218. instanceDivisor: number;
  6219. /**
  6220. * Gets the byte stride.
  6221. */
  6222. readonly byteStride: number;
  6223. /**
  6224. * Gets the byte offset.
  6225. */
  6226. readonly byteOffset: number;
  6227. /**
  6228. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6229. */
  6230. readonly normalized: boolean;
  6231. /**
  6232. * Gets the data type of each component in the array.
  6233. */
  6234. readonly type: number;
  6235. /**
  6236. * Constructor
  6237. * @param engine the engine
  6238. * @param data the data to use for this vertex buffer
  6239. * @param kind the vertex buffer kind
  6240. * @param updatable whether the data is updatable
  6241. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6242. * @param stride the stride (optional)
  6243. * @param instanced whether the buffer is instanced (optional)
  6244. * @param offset the offset of the data (optional)
  6245. * @param size the number of components (optional)
  6246. * @param type the type of the component (optional)
  6247. * @param normalized whether the data contains normalized data (optional)
  6248. * @param useBytes set to true if stride and offset are in bytes (optional)
  6249. */
  6250. 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);
  6251. /** @hidden */
  6252. _rebuild(): void;
  6253. /**
  6254. * Returns the kind of the VertexBuffer (string)
  6255. * @returns a string
  6256. */
  6257. getKind(): string;
  6258. /**
  6259. * Gets a boolean indicating if the VertexBuffer is updatable?
  6260. * @returns true if the buffer is updatable
  6261. */
  6262. isUpdatable(): boolean;
  6263. /**
  6264. * Gets current buffer's data
  6265. * @returns a DataArray or null
  6266. */
  6267. getData(): Nullable<DataArray>;
  6268. /**
  6269. * Gets underlying native buffer
  6270. * @returns underlying native buffer
  6271. */
  6272. getBuffer(): Nullable<DataBuffer>;
  6273. /**
  6274. * Gets the stride in float32 units (i.e. byte stride / 4).
  6275. * May not be an integer if the byte stride is not divisible by 4.
  6276. * DEPRECATED. Use byteStride instead.
  6277. * @returns the stride in float32 units
  6278. */
  6279. getStrideSize(): number;
  6280. /**
  6281. * Returns the offset as a multiple of the type byte length.
  6282. * DEPRECATED. Use byteOffset instead.
  6283. * @returns the offset in bytes
  6284. */
  6285. getOffset(): number;
  6286. /**
  6287. * Returns the number of components per vertex attribute (integer)
  6288. * @returns the size in float
  6289. */
  6290. getSize(): number;
  6291. /**
  6292. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6293. * @returns true if this buffer is instanced
  6294. */
  6295. getIsInstanced(): boolean;
  6296. /**
  6297. * Returns the instancing divisor, zero for non-instanced (integer).
  6298. * @returns a number
  6299. */
  6300. getInstanceDivisor(): number;
  6301. /**
  6302. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6303. * @param data defines the data to store
  6304. */
  6305. create(data?: DataArray): void;
  6306. /**
  6307. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6308. * This function will create a new buffer if the current one is not updatable
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6314. * Returns the directly updated WebGLBuffer.
  6315. * @param data the new data
  6316. * @param offset the new offset
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6320. /**
  6321. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6322. */
  6323. dispose(): void;
  6324. /**
  6325. * Enumerates each value of this vertex buffer as numbers.
  6326. * @param count the number of values to enumerate
  6327. * @param callback the callback function called for each value
  6328. */
  6329. forEach(count: number, callback: (value: number, index: number) => void): void;
  6330. /**
  6331. * Positions
  6332. */
  6333. static readonly PositionKind: string;
  6334. /**
  6335. * Normals
  6336. */
  6337. static readonly NormalKind: string;
  6338. /**
  6339. * Tangents
  6340. */
  6341. static readonly TangentKind: string;
  6342. /**
  6343. * Texture coordinates
  6344. */
  6345. static readonly UVKind: string;
  6346. /**
  6347. * Texture coordinates 2
  6348. */
  6349. static readonly UV2Kind: string;
  6350. /**
  6351. * Texture coordinates 3
  6352. */
  6353. static readonly UV3Kind: string;
  6354. /**
  6355. * Texture coordinates 4
  6356. */
  6357. static readonly UV4Kind: string;
  6358. /**
  6359. * Texture coordinates 5
  6360. */
  6361. static readonly UV5Kind: string;
  6362. /**
  6363. * Texture coordinates 6
  6364. */
  6365. static readonly UV6Kind: string;
  6366. /**
  6367. * Colors
  6368. */
  6369. static readonly ColorKind: string;
  6370. /**
  6371. * Matrix indices (for bones)
  6372. */
  6373. static readonly MatricesIndicesKind: string;
  6374. /**
  6375. * Matrix weights (for bones)
  6376. */
  6377. static readonly MatricesWeightsKind: string;
  6378. /**
  6379. * Additional matrix indices (for bones)
  6380. */
  6381. static readonly MatricesIndicesExtraKind: string;
  6382. /**
  6383. * Additional matrix weights (for bones)
  6384. */
  6385. static readonly MatricesWeightsExtraKind: string;
  6386. /**
  6387. * Deduces the stride given a kind.
  6388. * @param kind The kind string to deduce
  6389. * @returns The deduced stride
  6390. */
  6391. static DeduceStride(kind: string): number;
  6392. /**
  6393. * Gets the byte length of the given type.
  6394. * @param type the type
  6395. * @returns the number of bytes
  6396. */
  6397. static GetTypeByteLength(type: number): number;
  6398. /**
  6399. * Enumerates each value of the given parameters as numbers.
  6400. * @param data the data to enumerate
  6401. * @param byteOffset the byte offset of the data
  6402. * @param byteStride the byte stride of the data
  6403. * @param componentCount the number of components per element
  6404. * @param componentType the type of the component
  6405. * @param count the number of values to enumerate
  6406. * @param normalized whether the data is normalized
  6407. * @param callback the callback function called for each value
  6408. */
  6409. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6410. private static _GetFloatValue;
  6411. }
  6412. }
  6413. declare module "babylonjs/Collisions/intersectionInfo" {
  6414. import { Nullable } from "babylonjs/types";
  6415. /**
  6416. * @hidden
  6417. */
  6418. export class IntersectionInfo {
  6419. bu: Nullable<number>;
  6420. bv: Nullable<number>;
  6421. distance: number;
  6422. faceId: number;
  6423. subMeshId: number;
  6424. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6425. }
  6426. }
  6427. declare module "babylonjs/Maths/math.plane" {
  6428. import { DeepImmutable } from "babylonjs/types";
  6429. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6430. /**
  6431. * Represens a plane by the equation ax + by + cz + d = 0
  6432. */
  6433. export class Plane {
  6434. private static _TmpMatrix;
  6435. /**
  6436. * Normal of the plane (a,b,c)
  6437. */
  6438. normal: Vector3;
  6439. /**
  6440. * d component of the plane
  6441. */
  6442. d: number;
  6443. /**
  6444. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6445. * @param a a component of the plane
  6446. * @param b b component of the plane
  6447. * @param c c component of the plane
  6448. * @param d d component of the plane
  6449. */
  6450. constructor(a: number, b: number, c: number, d: number);
  6451. /**
  6452. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6453. */
  6454. asArray(): number[];
  6455. /**
  6456. * @returns a new plane copied from the current Plane.
  6457. */
  6458. clone(): Plane;
  6459. /**
  6460. * @returns the string "Plane".
  6461. */
  6462. getClassName(): string;
  6463. /**
  6464. * @returns the Plane hash code.
  6465. */
  6466. getHashCode(): number;
  6467. /**
  6468. * Normalize the current Plane in place.
  6469. * @returns the updated Plane.
  6470. */
  6471. normalize(): Plane;
  6472. /**
  6473. * Applies a transformation the plane and returns the result
  6474. * @param transformation the transformation matrix to be applied to the plane
  6475. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6476. */
  6477. transform(transformation: DeepImmutable<Matrix>): Plane;
  6478. /**
  6479. * Calcualtte the dot product between the point and the plane normal
  6480. * @param point point to calculate the dot product with
  6481. * @returns the dot product (float) of the point coordinates and the plane normal.
  6482. */
  6483. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6484. /**
  6485. * Updates the current Plane from the plane defined by the three given points.
  6486. * @param point1 one of the points used to contruct the plane
  6487. * @param point2 one of the points used to contruct the plane
  6488. * @param point3 one of the points used to contruct the plane
  6489. * @returns the updated Plane.
  6490. */
  6491. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6492. /**
  6493. * Checks if the plane is facing a given direction
  6494. * @param direction the direction to check if the plane is facing
  6495. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6496. * @returns True is the vector "direction" is the same side than the plane normal.
  6497. */
  6498. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6499. /**
  6500. * Calculates the distance to a point
  6501. * @param point point to calculate distance to
  6502. * @returns the signed distance (float) from the given point to the Plane.
  6503. */
  6504. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6505. /**
  6506. * Creates a plane from an array
  6507. * @param array the array to create a plane from
  6508. * @returns a new Plane from the given array.
  6509. */
  6510. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6511. /**
  6512. * Creates a plane from three points
  6513. * @param point1 point used to create the plane
  6514. * @param point2 point used to create the plane
  6515. * @param point3 point used to create the plane
  6516. * @returns a new Plane defined by the three given points.
  6517. */
  6518. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6519. /**
  6520. * Creates a plane from an origin point and a normal
  6521. * @param origin origin of the plane to be constructed
  6522. * @param normal normal of the plane to be constructed
  6523. * @returns a new Plane the normal vector to this plane at the given origin point.
  6524. * Note : the vector "normal" is updated because normalized.
  6525. */
  6526. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6527. /**
  6528. * Calculates the distance from a plane and a point
  6529. * @param origin origin of the plane to be constructed
  6530. * @param normal normal of the plane to be constructed
  6531. * @param point point to calculate distance to
  6532. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6533. */
  6534. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6535. }
  6536. }
  6537. declare module "babylonjs/Culling/boundingSphere" {
  6538. import { DeepImmutable } from "babylonjs/types";
  6539. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6540. import { Plane } from "babylonjs/Maths/math.plane";
  6541. /**
  6542. * Class used to store bounding sphere information
  6543. */
  6544. export class BoundingSphere {
  6545. /**
  6546. * Gets the center of the bounding sphere in local space
  6547. */
  6548. readonly center: Vector3;
  6549. /**
  6550. * Radius of the bounding sphere in local space
  6551. */
  6552. radius: number;
  6553. /**
  6554. * Gets the center of the bounding sphere in world space
  6555. */
  6556. readonly centerWorld: Vector3;
  6557. /**
  6558. * Radius of the bounding sphere in world space
  6559. */
  6560. radiusWorld: number;
  6561. /**
  6562. * Gets the minimum vector in local space
  6563. */
  6564. readonly minimum: Vector3;
  6565. /**
  6566. * Gets the maximum vector in local space
  6567. */
  6568. readonly maximum: Vector3;
  6569. private _worldMatrix;
  6570. private static readonly TmpVector3;
  6571. /**
  6572. * Creates a new bounding sphere
  6573. * @param min defines the minimum vector (in local space)
  6574. * @param max defines the maximum vector (in local space)
  6575. * @param worldMatrix defines the new world matrix
  6576. */
  6577. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6578. /**
  6579. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6580. * @param min defines the new minimum vector (in local space)
  6581. * @param max defines the new maximum vector (in local space)
  6582. * @param worldMatrix defines the new world matrix
  6583. */
  6584. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6585. /**
  6586. * Scale the current bounding sphere by applying a scale factor
  6587. * @param factor defines the scale factor to apply
  6588. * @returns the current bounding box
  6589. */
  6590. scale(factor: number): BoundingSphere;
  6591. /**
  6592. * Gets the world matrix of the bounding box
  6593. * @returns a matrix
  6594. */
  6595. getWorldMatrix(): DeepImmutable<Matrix>;
  6596. /** @hidden */
  6597. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6598. /**
  6599. * Tests if the bounding sphere is intersecting the frustum planes
  6600. * @param frustumPlanes defines the frustum planes to test
  6601. * @returns true if there is an intersection
  6602. */
  6603. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6604. /**
  6605. * Tests if the bounding sphere center is in between the frustum planes.
  6606. * Used for optimistic fast inclusion.
  6607. * @param frustumPlanes defines the frustum planes to test
  6608. * @returns true if the sphere center is in between the frustum planes
  6609. */
  6610. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6611. /**
  6612. * Tests if a point is inside the bounding sphere
  6613. * @param point defines the point to test
  6614. * @returns true if the point is inside the bounding sphere
  6615. */
  6616. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6617. /**
  6618. * Checks if two sphere intersct
  6619. * @param sphere0 sphere 0
  6620. * @param sphere1 sphere 1
  6621. * @returns true if the speres intersect
  6622. */
  6623. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6624. }
  6625. }
  6626. declare module "babylonjs/Culling/boundingBox" {
  6627. import { DeepImmutable } from "babylonjs/types";
  6628. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6629. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6630. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6631. import { Plane } from "babylonjs/Maths/math.plane";
  6632. /**
  6633. * Class used to store bounding box information
  6634. */
  6635. export class BoundingBox implements ICullable {
  6636. /**
  6637. * Gets the 8 vectors representing the bounding box in local space
  6638. */
  6639. readonly vectors: Vector3[];
  6640. /**
  6641. * Gets the center of the bounding box in local space
  6642. */
  6643. readonly center: Vector3;
  6644. /**
  6645. * Gets the center of the bounding box in world space
  6646. */
  6647. readonly centerWorld: Vector3;
  6648. /**
  6649. * Gets the extend size in local space
  6650. */
  6651. readonly extendSize: Vector3;
  6652. /**
  6653. * Gets the extend size in world space
  6654. */
  6655. readonly extendSizeWorld: Vector3;
  6656. /**
  6657. * Gets the OBB (object bounding box) directions
  6658. */
  6659. readonly directions: Vector3[];
  6660. /**
  6661. * Gets the 8 vectors representing the bounding box in world space
  6662. */
  6663. readonly vectorsWorld: Vector3[];
  6664. /**
  6665. * Gets the minimum vector in world space
  6666. */
  6667. readonly minimumWorld: Vector3;
  6668. /**
  6669. * Gets the maximum vector in world space
  6670. */
  6671. readonly maximumWorld: Vector3;
  6672. /**
  6673. * Gets the minimum vector in local space
  6674. */
  6675. readonly minimum: Vector3;
  6676. /**
  6677. * Gets the maximum vector in local space
  6678. */
  6679. readonly maximum: Vector3;
  6680. private _worldMatrix;
  6681. private static readonly TmpVector3;
  6682. /**
  6683. * @hidden
  6684. */
  6685. _tag: number;
  6686. /**
  6687. * Creates a new bounding box
  6688. * @param min defines the minimum vector (in local space)
  6689. * @param max defines the maximum vector (in local space)
  6690. * @param worldMatrix defines the new world matrix
  6691. */
  6692. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6693. /**
  6694. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6695. * @param min defines the new minimum vector (in local space)
  6696. * @param max defines the new maximum vector (in local space)
  6697. * @param worldMatrix defines the new world matrix
  6698. */
  6699. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6700. /**
  6701. * Scale the current bounding box by applying a scale factor
  6702. * @param factor defines the scale factor to apply
  6703. * @returns the current bounding box
  6704. */
  6705. scale(factor: number): BoundingBox;
  6706. /**
  6707. * Gets the world matrix of the bounding box
  6708. * @returns a matrix
  6709. */
  6710. getWorldMatrix(): DeepImmutable<Matrix>;
  6711. /** @hidden */
  6712. _update(world: DeepImmutable<Matrix>): void;
  6713. /**
  6714. * Tests if the bounding box is intersecting the frustum planes
  6715. * @param frustumPlanes defines the frustum planes to test
  6716. * @returns true if there is an intersection
  6717. */
  6718. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6719. /**
  6720. * Tests if the bounding box is entirely inside the frustum planes
  6721. * @param frustumPlanes defines the frustum planes to test
  6722. * @returns true if there is an inclusion
  6723. */
  6724. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6725. /**
  6726. * Tests if a point is inside the bounding box
  6727. * @param point defines the point to test
  6728. * @returns true if the point is inside the bounding box
  6729. */
  6730. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6731. /**
  6732. * Tests if the bounding box intersects with a bounding sphere
  6733. * @param sphere defines the sphere to test
  6734. * @returns true if there is an intersection
  6735. */
  6736. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6737. /**
  6738. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6739. * @param min defines the min vector to use
  6740. * @param max defines the max vector to use
  6741. * @returns true if there is an intersection
  6742. */
  6743. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6744. /**
  6745. * Tests if two bounding boxes are intersections
  6746. * @param box0 defines the first box to test
  6747. * @param box1 defines the second box to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6751. /**
  6752. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6753. * @param minPoint defines the minimum vector of the bounding box
  6754. * @param maxPoint defines the maximum vector of the bounding box
  6755. * @param sphereCenter defines the sphere center
  6756. * @param sphereRadius defines the sphere radius
  6757. * @returns true if there is an intersection
  6758. */
  6759. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6760. /**
  6761. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6762. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6763. * @param frustumPlanes defines the frustum planes to test
  6764. * @return true if there is an inclusion
  6765. */
  6766. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6767. /**
  6768. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6769. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6770. * @param frustumPlanes defines the frustum planes to test
  6771. * @return true if there is an intersection
  6772. */
  6773. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/collider" {
  6777. import { Nullable, IndicesArray } from "babylonjs/types";
  6778. import { Vector3 } from "babylonjs/Maths/math.vector";
  6779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /** @hidden */
  6782. export class Collider {
  6783. /** Define if a collision was found */
  6784. collisionFound: boolean;
  6785. /**
  6786. * Define last intersection point in local space
  6787. */
  6788. intersectionPoint: Vector3;
  6789. /**
  6790. * Define last collided mesh
  6791. */
  6792. collidedMesh: Nullable<AbstractMesh>;
  6793. private _collisionPoint;
  6794. private _planeIntersectionPoint;
  6795. private _tempVector;
  6796. private _tempVector2;
  6797. private _tempVector3;
  6798. private _tempVector4;
  6799. private _edge;
  6800. private _baseToVertex;
  6801. private _destinationPoint;
  6802. private _slidePlaneNormal;
  6803. private _displacementVector;
  6804. /** @hidden */
  6805. _radius: Vector3;
  6806. /** @hidden */
  6807. _retry: number;
  6808. private _velocity;
  6809. private _basePoint;
  6810. private _epsilon;
  6811. /** @hidden */
  6812. _velocityWorldLength: number;
  6813. /** @hidden */
  6814. _basePointWorld: Vector3;
  6815. private _velocityWorld;
  6816. private _normalizedVelocity;
  6817. /** @hidden */
  6818. _initialVelocity: Vector3;
  6819. /** @hidden */
  6820. _initialPosition: Vector3;
  6821. private _nearestDistance;
  6822. private _collisionMask;
  6823. collisionMask: number;
  6824. /**
  6825. * Gets the plane normal used to compute the sliding response (in local space)
  6826. */
  6827. readonly slidePlaneNormal: Vector3;
  6828. /** @hidden */
  6829. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6830. /** @hidden */
  6831. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6832. /** @hidden */
  6833. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6834. /** @hidden */
  6835. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6838. /** @hidden */
  6839. _getResponse(pos: Vector3, vel: Vector3): void;
  6840. }
  6841. }
  6842. declare module "babylonjs/Culling/boundingInfo" {
  6843. import { DeepImmutable } from "babylonjs/types";
  6844. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6845. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6846. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6847. import { Plane } from "babylonjs/Maths/math.plane";
  6848. import { Collider } from "babylonjs/Collisions/collider";
  6849. /**
  6850. * Interface for cullable objects
  6851. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6852. */
  6853. export interface ICullable {
  6854. /**
  6855. * Checks if the object or part of the object is in the frustum
  6856. * @param frustumPlanes Camera near/planes
  6857. * @returns true if the object is in frustum otherwise false
  6858. */
  6859. isInFrustum(frustumPlanes: Plane[]): boolean;
  6860. /**
  6861. * Checks if a cullable object (mesh...) is in the camera frustum
  6862. * Unlike isInFrustum this cheks the full bounding box
  6863. * @param frustumPlanes Camera near/planes
  6864. * @returns true if the object is in frustum otherwise false
  6865. */
  6866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6867. }
  6868. /**
  6869. * Info for a bounding data of a mesh
  6870. */
  6871. export class BoundingInfo implements ICullable {
  6872. /**
  6873. * Bounding box for the mesh
  6874. */
  6875. readonly boundingBox: BoundingBox;
  6876. /**
  6877. * Bounding sphere for the mesh
  6878. */
  6879. readonly boundingSphere: BoundingSphere;
  6880. private _isLocked;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Constructs bounding info
  6884. * @param minimum min vector of the bounding box/sphere
  6885. * @param maximum max vector of the bounding box/sphere
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * min vector of the bounding box/sphere
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * max vector of the bounding box/sphere
  6902. */
  6903. readonly maximum: Vector3;
  6904. /**
  6905. * If the info is locked and won't be updated to avoid perf overhead
  6906. */
  6907. isLocked: boolean;
  6908. /**
  6909. * Updates the bounding sphere and box
  6910. * @param world world matrix to be used to update
  6911. */
  6912. update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6915. * @param center New center of the bounding info
  6916. * @param extend New extend of the bounding info
  6917. * @returns the current bounding info
  6918. */
  6919. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6920. /**
  6921. * Scale the current bounding info by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding info
  6924. */
  6925. scale(factor: number): BoundingInfo;
  6926. /**
  6927. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6928. * @param frustumPlanes defines the frustum to test
  6929. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6930. * @returns true if the bounding info is in the frustum planes
  6931. */
  6932. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6933. /**
  6934. * Gets the world distance between the min and max points of the bounding box
  6935. */
  6936. readonly diagonalLength: number;
  6937. /**
  6938. * Checks if a cullable object (mesh...) is in the camera frustum
  6939. * Unlike isInFrustum this cheks the full bounding box
  6940. * @param frustumPlanes Camera near/planes
  6941. * @returns true if the object is in frustum otherwise false
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /** @hidden */
  6945. _checkCollision(collider: Collider): boolean;
  6946. /**
  6947. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6948. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6949. * @param point the point to check intersection with
  6950. * @returns if the point intersects
  6951. */
  6952. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6953. /**
  6954. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6955. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6956. * @param boundingInfo the bounding info to check intersection with
  6957. * @param precise if the intersection should be done using OBB
  6958. * @returns if the bounding info intersects
  6959. */
  6960. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6961. }
  6962. }
  6963. declare module "babylonjs/Maths/math.functions" {
  6964. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6965. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6966. /**
  6967. * Extracts minimum and maximum values from a list of indexed positions
  6968. * @param positions defines the positions to use
  6969. * @param indices defines the indices to the positions
  6970. * @param indexStart defines the start index
  6971. * @param indexCount defines the end index
  6972. * @param bias defines bias value to add to the result
  6973. * @return minimum and maximum values
  6974. */
  6975. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6976. minimum: Vector3;
  6977. maximum: Vector3;
  6978. };
  6979. /**
  6980. * Extracts minimum and maximum values from a list of positions
  6981. * @param positions defines the positions to use
  6982. * @param start defines the start index in the positions array
  6983. * @param count defines the number of positions to handle
  6984. * @param bias defines bias value to add to the result
  6985. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6986. * @return minimum and maximum values
  6987. */
  6988. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6989. minimum: Vector3;
  6990. maximum: Vector3;
  6991. };
  6992. }
  6993. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6994. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6995. /** @hidden */
  6996. export class WebGLDataBuffer extends DataBuffer {
  6997. private _buffer;
  6998. constructor(resource: WebGLBuffer);
  6999. readonly underlyingResource: any;
  7000. }
  7001. }
  7002. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7003. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7004. import { Nullable } from "babylonjs/types";
  7005. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7006. /** @hidden */
  7007. export class WebGLPipelineContext implements IPipelineContext {
  7008. engine: ThinEngine;
  7009. program: Nullable<WebGLProgram>;
  7010. context?: WebGLRenderingContext;
  7011. vertexShader?: WebGLShader;
  7012. fragmentShader?: WebGLShader;
  7013. isParallelCompiled: boolean;
  7014. onCompiled?: () => void;
  7015. transformFeedback?: WebGLTransformFeedback | null;
  7016. readonly isAsync: boolean;
  7017. readonly isReady: boolean;
  7018. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7019. }
  7020. }
  7021. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7022. import { FloatArray, Nullable } from "babylonjs/types";
  7023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7025. module "babylonjs/Engines/thinEngine" {
  7026. interface ThinEngine {
  7027. /**
  7028. * Create an uniform buffer
  7029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7030. * @param elements defines the content of the uniform buffer
  7031. * @returns the webGL uniform buffer
  7032. */
  7033. createUniformBuffer(elements: FloatArray): DataBuffer;
  7034. /**
  7035. * Create a dynamic uniform buffer
  7036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7037. * @param elements defines the content of the uniform buffer
  7038. * @returns the webGL uniform buffer
  7039. */
  7040. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7041. /**
  7042. * Update an existing uniform buffer
  7043. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7044. * @param uniformBuffer defines the target uniform buffer
  7045. * @param elements defines the content to update
  7046. * @param offset defines the offset in the uniform buffer where update should start
  7047. * @param count defines the size of the data to update
  7048. */
  7049. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7050. /**
  7051. * Bind an uniform buffer to the current webGL context
  7052. * @param buffer defines the buffer to bind
  7053. */
  7054. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7055. /**
  7056. * Bind a buffer to the current webGL context at a given location
  7057. * @param buffer defines the buffer to bind
  7058. * @param location defines the index where to bind the buffer
  7059. */
  7060. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7061. /**
  7062. * Bind a specific block at a given index in a specific shader program
  7063. * @param pipelineContext defines the pipeline context to use
  7064. * @param blockName defines the block name
  7065. * @param index defines the index where to bind the block
  7066. */
  7067. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7068. }
  7069. }
  7070. }
  7071. declare module "babylonjs/Materials/uniformBuffer" {
  7072. import { Nullable, FloatArray } from "babylonjs/types";
  7073. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7074. import { Engine } from "babylonjs/Engines/engine";
  7075. import { Effect } from "babylonjs/Materials/effect";
  7076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7078. import { Color3 } from "babylonjs/Maths/math.color";
  7079. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7080. /**
  7081. * Uniform buffer objects.
  7082. *
  7083. * Handles blocks of uniform on the GPU.
  7084. *
  7085. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7086. *
  7087. * For more information, please refer to :
  7088. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7089. */
  7090. export class UniformBuffer {
  7091. private _engine;
  7092. private _buffer;
  7093. private _data;
  7094. private _bufferData;
  7095. private _dynamic?;
  7096. private _uniformLocations;
  7097. private _uniformSizes;
  7098. private _uniformLocationPointer;
  7099. private _needSync;
  7100. private _noUBO;
  7101. private _currentEffect;
  7102. private static _MAX_UNIFORM_SIZE;
  7103. private static _tempBuffer;
  7104. /**
  7105. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7106. * This is dynamic to allow compat with webgl 1 and 2.
  7107. * You will need to pass the name of the uniform as well as the value.
  7108. */
  7109. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7110. /**
  7111. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7112. * This is dynamic to allow compat with webgl 1 and 2.
  7113. * You will need to pass the name of the uniform as well as the value.
  7114. */
  7115. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7116. /**
  7117. * Lambda to Update a single float in a uniform buffer.
  7118. * This is dynamic to allow compat with webgl 1 and 2.
  7119. * You will need to pass the name of the uniform as well as the value.
  7120. */
  7121. updateFloat: (name: string, x: number) => void;
  7122. /**
  7123. * Lambda to Update a vec2 of float in a uniform buffer.
  7124. * This is dynamic to allow compat with webgl 1 and 2.
  7125. * You will need to pass the name of the uniform as well as the value.
  7126. */
  7127. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7128. /**
  7129. * Lambda to Update a vec3 of float in a uniform buffer.
  7130. * This is dynamic to allow compat with webgl 1 and 2.
  7131. * You will need to pass the name of the uniform as well as the value.
  7132. */
  7133. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7134. /**
  7135. * Lambda to Update a vec4 of float in a uniform buffer.
  7136. * This is dynamic to allow compat with webgl 1 and 2.
  7137. * You will need to pass the name of the uniform as well as the value.
  7138. */
  7139. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7140. /**
  7141. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7142. * This is dynamic to allow compat with webgl 1 and 2.
  7143. * You will need to pass the name of the uniform as well as the value.
  7144. */
  7145. updateMatrix: (name: string, mat: Matrix) => void;
  7146. /**
  7147. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7148. * This is dynamic to allow compat with webgl 1 and 2.
  7149. * You will need to pass the name of the uniform as well as the value.
  7150. */
  7151. updateVector3: (name: string, vector: Vector3) => void;
  7152. /**
  7153. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7154. * This is dynamic to allow compat with webgl 1 and 2.
  7155. * You will need to pass the name of the uniform as well as the value.
  7156. */
  7157. updateVector4: (name: string, vector: Vector4) => void;
  7158. /**
  7159. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7160. * This is dynamic to allow compat with webgl 1 and 2.
  7161. * You will need to pass the name of the uniform as well as the value.
  7162. */
  7163. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7164. /**
  7165. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7170. /**
  7171. * Instantiates a new Uniform buffer objects.
  7172. *
  7173. * Handles blocks of uniform on the GPU.
  7174. *
  7175. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7176. *
  7177. * For more information, please refer to :
  7178. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7179. * @param engine Define the engine the buffer is associated with
  7180. * @param data Define the data contained in the buffer
  7181. * @param dynamic Define if the buffer is updatable
  7182. */
  7183. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7184. /**
  7185. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7186. * or just falling back on setUniformXXX calls.
  7187. */
  7188. readonly useUbo: boolean;
  7189. /**
  7190. * Indicates if the WebGL underlying uniform buffer is in sync
  7191. * with the javascript cache data.
  7192. */
  7193. readonly isSync: boolean;
  7194. /**
  7195. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7196. * Also, a dynamic UniformBuffer will disable cache verification and always
  7197. * update the underlying WebGL uniform buffer to the GPU.
  7198. * @returns if Dynamic, otherwise false
  7199. */
  7200. isDynamic(): boolean;
  7201. /**
  7202. * The data cache on JS side.
  7203. * @returns the underlying data as a float array
  7204. */
  7205. getData(): Float32Array;
  7206. /**
  7207. * The underlying WebGL Uniform buffer.
  7208. * @returns the webgl buffer
  7209. */
  7210. getBuffer(): Nullable<DataBuffer>;
  7211. /**
  7212. * std140 layout specifies how to align data within an UBO structure.
  7213. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7214. * for specs.
  7215. */
  7216. private _fillAlignment;
  7217. /**
  7218. * Adds an uniform in the buffer.
  7219. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7220. * for the layout to be correct !
  7221. * @param name Name of the uniform, as used in the uniform block in the shader.
  7222. * @param size Data size, or data directly.
  7223. */
  7224. addUniform(name: string, size: number | number[]): void;
  7225. /**
  7226. * Adds a Matrix 4x4 to the uniform buffer.
  7227. * @param name Name of the uniform, as used in the uniform block in the shader.
  7228. * @param mat A 4x4 matrix.
  7229. */
  7230. addMatrix(name: string, mat: Matrix): void;
  7231. /**
  7232. * Adds a vec2 to the uniform buffer.
  7233. * @param name Name of the uniform, as used in the uniform block in the shader.
  7234. * @param x Define the x component value of the vec2
  7235. * @param y Define the y component value of the vec2
  7236. */
  7237. addFloat2(name: string, x: number, y: number): void;
  7238. /**
  7239. * Adds a vec3 to the uniform buffer.
  7240. * @param name Name of the uniform, as used in the uniform block in the shader.
  7241. * @param x Define the x component value of the vec3
  7242. * @param y Define the y component value of the vec3
  7243. * @param z Define the z component value of the vec3
  7244. */
  7245. addFloat3(name: string, x: number, y: number, z: number): void;
  7246. /**
  7247. * Adds a vec3 to the uniform buffer.
  7248. * @param name Name of the uniform, as used in the uniform block in the shader.
  7249. * @param color Define the vec3 from a Color
  7250. */
  7251. addColor3(name: string, color: Color3): void;
  7252. /**
  7253. * Adds a vec4 to the uniform buffer.
  7254. * @param name Name of the uniform, as used in the uniform block in the shader.
  7255. * @param color Define the rgb components from a Color
  7256. * @param alpha Define the a component of the vec4
  7257. */
  7258. addColor4(name: string, color: Color3, alpha: number): void;
  7259. /**
  7260. * Adds a vec3 to the uniform buffer.
  7261. * @param name Name of the uniform, as used in the uniform block in the shader.
  7262. * @param vector Define the vec3 components from a Vector
  7263. */
  7264. addVector3(name: string, vector: Vector3): void;
  7265. /**
  7266. * Adds a Matrix 3x3 to the uniform buffer.
  7267. * @param name Name of the uniform, as used in the uniform block in the shader.
  7268. */
  7269. addMatrix3x3(name: string): void;
  7270. /**
  7271. * Adds a Matrix 2x2 to the uniform buffer.
  7272. * @param name Name of the uniform, as used in the uniform block in the shader.
  7273. */
  7274. addMatrix2x2(name: string): void;
  7275. /**
  7276. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7277. */
  7278. create(): void;
  7279. /** @hidden */
  7280. _rebuild(): void;
  7281. /**
  7282. * Updates the WebGL Uniform Buffer on the GPU.
  7283. * If the `dynamic` flag is set to true, no cache comparison is done.
  7284. * Otherwise, the buffer will be updated only if the cache differs.
  7285. */
  7286. update(): void;
  7287. /**
  7288. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7289. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7290. * @param data Define the flattened data
  7291. * @param size Define the size of the data.
  7292. */
  7293. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7294. private _valueCache;
  7295. private _cacheMatrix;
  7296. private _updateMatrix3x3ForUniform;
  7297. private _updateMatrix3x3ForEffect;
  7298. private _updateMatrix2x2ForEffect;
  7299. private _updateMatrix2x2ForUniform;
  7300. private _updateFloatForEffect;
  7301. private _updateFloatForUniform;
  7302. private _updateFloat2ForEffect;
  7303. private _updateFloat2ForUniform;
  7304. private _updateFloat3ForEffect;
  7305. private _updateFloat3ForUniform;
  7306. private _updateFloat4ForEffect;
  7307. private _updateFloat4ForUniform;
  7308. private _updateMatrixForEffect;
  7309. private _updateMatrixForUniform;
  7310. private _updateVector3ForEffect;
  7311. private _updateVector3ForUniform;
  7312. private _updateVector4ForEffect;
  7313. private _updateVector4ForUniform;
  7314. private _updateColor3ForEffect;
  7315. private _updateColor3ForUniform;
  7316. private _updateColor4ForEffect;
  7317. private _updateColor4ForUniform;
  7318. /**
  7319. * Sets a sampler uniform on the effect.
  7320. * @param name Define the name of the sampler.
  7321. * @param texture Define the texture to set in the sampler
  7322. */
  7323. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7324. /**
  7325. * Directly updates the value of the uniform in the cache AND on the GPU.
  7326. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7327. * @param data Define the flattened data
  7328. */
  7329. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7330. /**
  7331. * Binds this uniform buffer to an effect.
  7332. * @param effect Define the effect to bind the buffer to
  7333. * @param name Name of the uniform block in the shader.
  7334. */
  7335. bindToEffect(effect: Effect, name: string): void;
  7336. /**
  7337. * Disposes the uniform buffer.
  7338. */
  7339. dispose(): void;
  7340. }
  7341. }
  7342. declare module "babylonjs/Misc/iInspectable" {
  7343. /**
  7344. * Enum that determines the text-wrapping mode to use.
  7345. */
  7346. export enum InspectableType {
  7347. /**
  7348. * Checkbox for booleans
  7349. */
  7350. Checkbox = 0,
  7351. /**
  7352. * Sliders for numbers
  7353. */
  7354. Slider = 1,
  7355. /**
  7356. * Vector3
  7357. */
  7358. Vector3 = 2,
  7359. /**
  7360. * Quaternions
  7361. */
  7362. Quaternion = 3,
  7363. /**
  7364. * Color3
  7365. */
  7366. Color3 = 4,
  7367. /**
  7368. * String
  7369. */
  7370. String = 5
  7371. }
  7372. /**
  7373. * Interface used to define custom inspectable properties.
  7374. * This interface is used by the inspector to display custom property grids
  7375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7376. */
  7377. export interface IInspectable {
  7378. /**
  7379. * Gets the label to display
  7380. */
  7381. label: string;
  7382. /**
  7383. * Gets the name of the property to edit
  7384. */
  7385. propertyName: string;
  7386. /**
  7387. * Gets the type of the editor to use
  7388. */
  7389. type: InspectableType;
  7390. /**
  7391. * Gets the minimum value of the property when using in "slider" mode
  7392. */
  7393. min?: number;
  7394. /**
  7395. * Gets the maximum value of the property when using in "slider" mode
  7396. */
  7397. max?: number;
  7398. /**
  7399. * Gets the setp to use when using in "slider" mode
  7400. */
  7401. step?: number;
  7402. }
  7403. }
  7404. declare module "babylonjs/Misc/timingTools" {
  7405. /**
  7406. * Class used to provide helper for timing
  7407. */
  7408. export class TimingTools {
  7409. /**
  7410. * Polyfill for setImmediate
  7411. * @param action defines the action to execute after the current execution block
  7412. */
  7413. static SetImmediate(action: () => void): void;
  7414. }
  7415. }
  7416. declare module "babylonjs/Misc/instantiationTools" {
  7417. /**
  7418. * Class used to enable instatition of objects by class name
  7419. */
  7420. export class InstantiationTools {
  7421. /**
  7422. * Use this object to register external classes like custom textures or material
  7423. * to allow the laoders to instantiate them
  7424. */
  7425. static RegisteredExternalClasses: {
  7426. [key: string]: Object;
  7427. };
  7428. /**
  7429. * Tries to instantiate a new object from a given class name
  7430. * @param className defines the class name to instantiate
  7431. * @returns the new object or null if the system was not able to do the instantiation
  7432. */
  7433. static Instantiate(className: string): any;
  7434. }
  7435. }
  7436. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7437. /**
  7438. * Define options used to create a depth texture
  7439. */
  7440. export class DepthTextureCreationOptions {
  7441. /** Specifies whether or not a stencil should be allocated in the texture */
  7442. generateStencil?: boolean;
  7443. /** Specifies whether or not bilinear filtering is enable on the texture */
  7444. bilinearFiltering?: boolean;
  7445. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7446. comparisonFunction?: number;
  7447. /** Specifies if the created texture is a cube texture */
  7448. isCube?: boolean;
  7449. }
  7450. }
  7451. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7453. import { Nullable } from "babylonjs/types";
  7454. import { Scene } from "babylonjs/scene";
  7455. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7456. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7457. module "babylonjs/Engines/thinEngine" {
  7458. interface ThinEngine {
  7459. /**
  7460. * Creates a depth stencil cube texture.
  7461. * This is only available in WebGL 2.
  7462. * @param size The size of face edge in the cube texture.
  7463. * @param options The options defining the cube texture.
  7464. * @returns The cube texture
  7465. */
  7466. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7467. /**
  7468. * Creates a cube texture
  7469. * @param rootUrl defines the url where the files to load is located
  7470. * @param scene defines the current scene
  7471. * @param files defines the list of files to load (1 per face)
  7472. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7473. * @param onLoad defines an optional callback raised when the texture is loaded
  7474. * @param onError defines an optional callback raised if there is an issue to load the texture
  7475. * @param format defines the format of the data
  7476. * @param forcedExtension defines the extension to use to pick the right loader
  7477. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7478. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7479. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7480. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7481. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7482. * @returns the cube texture as an InternalTexture
  7483. */
  7484. 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;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @returns the cube texture as an InternalTexture
  7496. */
  7497. 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;
  7498. /**
  7499. * Creates a cube texture
  7500. * @param rootUrl defines the url where the files to load is located
  7501. * @param scene defines the current scene
  7502. * @param files defines the list of files to load (1 per face)
  7503. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7504. * @param onLoad defines an optional callback raised when the texture is loaded
  7505. * @param onError defines an optional callback raised if there is an issue to load the texture
  7506. * @param format defines the format of the data
  7507. * @param forcedExtension defines the extension to use to pick the right loader
  7508. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7509. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7510. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7511. * @returns the cube texture as an InternalTexture
  7512. */
  7513. 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;
  7514. /** @hidden */
  7515. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7516. /** @hidden */
  7517. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7520. /** @hidden */
  7521. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7522. }
  7523. }
  7524. }
  7525. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7526. import { Nullable } from "babylonjs/types";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7530. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7531. /**
  7532. * Class for creating a cube texture
  7533. */
  7534. export class CubeTexture extends BaseTexture {
  7535. private _delayedOnLoad;
  7536. /**
  7537. * The url of the texture
  7538. */
  7539. url: string;
  7540. /**
  7541. * Gets or sets the center of the bounding box associated with the cube texture.
  7542. * It must define where the camera used to render the texture was set
  7543. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7544. */
  7545. boundingBoxPosition: Vector3;
  7546. private _boundingBoxSize;
  7547. /**
  7548. * Gets or sets the size of the bounding box associated with the cube texture
  7549. * When defined, the cubemap will switch to local mode
  7550. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7551. * @example https://www.babylonjs-playground.com/#RNASML
  7552. */
  7553. /**
  7554. * Returns the bounding box size
  7555. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7556. */
  7557. boundingBoxSize: Vector3;
  7558. protected _rotationY: number;
  7559. /**
  7560. * Sets texture matrix rotation angle around Y axis in radians.
  7561. */
  7562. /**
  7563. * Gets texture matrix rotation angle around Y axis radians.
  7564. */
  7565. rotationY: number;
  7566. /**
  7567. * Are mip maps generated for this texture or not.
  7568. */
  7569. readonly noMipmap: boolean;
  7570. private _noMipmap;
  7571. private _files;
  7572. protected _forcedExtension: Nullable<string>;
  7573. private _extensions;
  7574. private _textureMatrix;
  7575. private _format;
  7576. private _createPolynomials;
  7577. /** @hidden */
  7578. _prefiltered: boolean;
  7579. /**
  7580. * Creates a cube texture from an array of image urls
  7581. * @param files defines an array of image urls
  7582. * @param scene defines the hosting scene
  7583. * @param noMipmap specifies if mip maps are not used
  7584. * @returns a cube texture
  7585. */
  7586. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7587. /**
  7588. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7589. * @param url defines the url of the prefiltered texture
  7590. * @param scene defines the scene the texture is attached to
  7591. * @param forcedExtension defines the extension of the file if different from the url
  7592. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7593. * @return the prefiltered texture
  7594. */
  7595. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7596. /**
  7597. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7598. * as prefiltered data.
  7599. * @param rootUrl defines the url of the texture or the root name of the six images
  7600. * @param scene defines the scene the texture is attached to
  7601. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7602. * @param noMipmap defines if mipmaps should be created or not
  7603. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7604. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7605. * @param onError defines a callback triggered in case of error during load
  7606. * @param format defines the internal format to use for the texture once loaded
  7607. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7608. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7611. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7612. * @return the cube texture
  7613. */
  7614. 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);
  7615. /**
  7616. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7617. */
  7618. readonly isPrefiltered: boolean;
  7619. /**
  7620. * Get the current class name of the texture useful for serialization or dynamic coding.
  7621. * @returns "CubeTexture"
  7622. */
  7623. getClassName(): string;
  7624. /**
  7625. * Update the url (and optional buffer) of this texture if url was null during construction.
  7626. * @param url the url of the texture
  7627. * @param forcedExtension defines the extension to use
  7628. * @param onLoad callback called when the texture is loaded (defaults to null)
  7629. */
  7630. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7631. /**
  7632. * Delays loading of the cube texture
  7633. * @param forcedExtension defines the extension to use
  7634. */
  7635. delayLoad(forcedExtension?: string): void;
  7636. /**
  7637. * Returns the reflection texture matrix
  7638. * @returns the reflection texture matrix
  7639. */
  7640. getReflectionTextureMatrix(): Matrix;
  7641. /**
  7642. * Sets the reflection texture matrix
  7643. * @param value Reflection texture matrix
  7644. */
  7645. setReflectionTextureMatrix(value: Matrix): void;
  7646. /**
  7647. * Parses text to create a cube texture
  7648. * @param parsedTexture define the serialized text to read from
  7649. * @param scene defines the hosting scene
  7650. * @param rootUrl defines the root url of the cube texture
  7651. * @returns a cube texture
  7652. */
  7653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7654. /**
  7655. * Makes a clone, or deep copy, of the cube texture
  7656. * @returns a new cube texture
  7657. */
  7658. clone(): CubeTexture;
  7659. }
  7660. }
  7661. declare module "babylonjs/Materials/materialDefines" {
  7662. /**
  7663. * Manages the defines for the Material
  7664. */
  7665. export class MaterialDefines {
  7666. /** @hidden */
  7667. protected _keys: string[];
  7668. private _isDirty;
  7669. /** @hidden */
  7670. _renderId: number;
  7671. /** @hidden */
  7672. _areLightsDirty: boolean;
  7673. /** @hidden */
  7674. _areLightsDisposed: boolean;
  7675. /** @hidden */
  7676. _areAttributesDirty: boolean;
  7677. /** @hidden */
  7678. _areTexturesDirty: boolean;
  7679. /** @hidden */
  7680. _areFresnelDirty: boolean;
  7681. /** @hidden */
  7682. _areMiscDirty: boolean;
  7683. /** @hidden */
  7684. _areImageProcessingDirty: boolean;
  7685. /** @hidden */
  7686. _normals: boolean;
  7687. /** @hidden */
  7688. _uvs: boolean;
  7689. /** @hidden */
  7690. _needNormals: boolean;
  7691. /** @hidden */
  7692. _needUVs: boolean;
  7693. [id: string]: any;
  7694. /**
  7695. * Specifies if the material needs to be re-calculated
  7696. */
  7697. readonly isDirty: boolean;
  7698. /**
  7699. * Marks the material to indicate that it has been re-calculated
  7700. */
  7701. markAsProcessed(): void;
  7702. /**
  7703. * Marks the material to indicate that it needs to be re-calculated
  7704. */
  7705. markAsUnprocessed(): void;
  7706. /**
  7707. * Marks the material to indicate all of its defines need to be re-calculated
  7708. */
  7709. markAllAsDirty(): void;
  7710. /**
  7711. * Marks the material to indicate that image processing needs to be re-calculated
  7712. */
  7713. markAsImageProcessingDirty(): void;
  7714. /**
  7715. * Marks the material to indicate the lights need to be re-calculated
  7716. * @param disposed Defines whether the light is dirty due to dispose or not
  7717. */
  7718. markAsLightDirty(disposed?: boolean): void;
  7719. /**
  7720. * Marks the attribute state as changed
  7721. */
  7722. markAsAttributesDirty(): void;
  7723. /**
  7724. * Marks the texture state as changed
  7725. */
  7726. markAsTexturesDirty(): void;
  7727. /**
  7728. * Marks the fresnel state as changed
  7729. */
  7730. markAsFresnelDirty(): void;
  7731. /**
  7732. * Marks the misc state as changed
  7733. */
  7734. markAsMiscDirty(): void;
  7735. /**
  7736. * Rebuilds the material defines
  7737. */
  7738. rebuild(): void;
  7739. /**
  7740. * Specifies if two material defines are equal
  7741. * @param other - A material define instance to compare to
  7742. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7743. */
  7744. isEqual(other: MaterialDefines): boolean;
  7745. /**
  7746. * Clones this instance's defines to another instance
  7747. * @param other - material defines to clone values to
  7748. */
  7749. cloneTo(other: MaterialDefines): void;
  7750. /**
  7751. * Resets the material define values
  7752. */
  7753. reset(): void;
  7754. /**
  7755. * Converts the material define values to a string
  7756. * @returns - String of material define information
  7757. */
  7758. toString(): string;
  7759. }
  7760. }
  7761. declare module "babylonjs/Materials/colorCurves" {
  7762. import { Effect } from "babylonjs/Materials/effect";
  7763. /**
  7764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7766. * 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;
  7767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7768. */
  7769. export class ColorCurves {
  7770. private _dirty;
  7771. private _tempColor;
  7772. private _globalCurve;
  7773. private _highlightsCurve;
  7774. private _midtonesCurve;
  7775. private _shadowsCurve;
  7776. private _positiveCurve;
  7777. private _negativeCurve;
  7778. private _globalHue;
  7779. private _globalDensity;
  7780. private _globalSaturation;
  7781. private _globalExposure;
  7782. /**
  7783. * Gets the global Hue value.
  7784. * 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).
  7785. */
  7786. /**
  7787. * Sets the global Hue value.
  7788. * 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).
  7789. */
  7790. globalHue: number;
  7791. /**
  7792. * Gets the global Density value.
  7793. * 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.
  7794. * Values less than zero provide a filter of opposite hue.
  7795. */
  7796. /**
  7797. * Sets the global Density value.
  7798. * 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.
  7799. * Values less than zero provide a filter of opposite hue.
  7800. */
  7801. globalDensity: number;
  7802. /**
  7803. * Gets the global Saturation value.
  7804. * 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.
  7805. */
  7806. /**
  7807. * Sets the global Saturation value.
  7808. * 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.
  7809. */
  7810. globalSaturation: number;
  7811. /**
  7812. * Gets the global Exposure value.
  7813. * 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.
  7814. */
  7815. /**
  7816. * Sets the global Exposure value.
  7817. * 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.
  7818. */
  7819. globalExposure: number;
  7820. private _highlightsHue;
  7821. private _highlightsDensity;
  7822. private _highlightsSaturation;
  7823. private _highlightsExposure;
  7824. /**
  7825. * Gets the highlights Hue value.
  7826. * 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).
  7827. */
  7828. /**
  7829. * Sets the highlights Hue value.
  7830. * 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).
  7831. */
  7832. highlightsHue: number;
  7833. /**
  7834. * Gets the highlights Density value.
  7835. * 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.
  7836. * Values less than zero provide a filter of opposite hue.
  7837. */
  7838. /**
  7839. * Sets the highlights Density value.
  7840. * 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.
  7841. * Values less than zero provide a filter of opposite hue.
  7842. */
  7843. highlightsDensity: number;
  7844. /**
  7845. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  7847. */
  7848. /**
  7849. * Sets the highlights Saturation value.
  7850. * 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.
  7851. */
  7852. highlightsSaturation: number;
  7853. /**
  7854. * Gets the highlights Exposure value.
  7855. * 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.
  7856. */
  7857. /**
  7858. * Sets the highlights Exposure value.
  7859. * 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.
  7860. */
  7861. highlightsExposure: number;
  7862. private _midtonesHue;
  7863. private _midtonesDensity;
  7864. private _midtonesSaturation;
  7865. private _midtonesExposure;
  7866. /**
  7867. * Gets the midtones Hue value.
  7868. * 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).
  7869. */
  7870. /**
  7871. * Sets the midtones Hue value.
  7872. * 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).
  7873. */
  7874. midtonesHue: number;
  7875. /**
  7876. * Gets the midtones Density value.
  7877. * 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.
  7878. * Values less than zero provide a filter of opposite hue.
  7879. */
  7880. /**
  7881. * Sets the midtones Density value.
  7882. * 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.
  7883. * Values less than zero provide a filter of opposite hue.
  7884. */
  7885. midtonesDensity: number;
  7886. /**
  7887. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  7889. */
  7890. /**
  7891. * Sets the midtones Saturation value.
  7892. * 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.
  7893. */
  7894. midtonesSaturation: number;
  7895. /**
  7896. * Gets the midtones Exposure value.
  7897. * 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.
  7898. */
  7899. /**
  7900. * Sets the midtones Exposure value.
  7901. * 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.
  7902. */
  7903. midtonesExposure: number;
  7904. private _shadowsHue;
  7905. private _shadowsDensity;
  7906. private _shadowsSaturation;
  7907. private _shadowsExposure;
  7908. /**
  7909. * Gets the shadows Hue value.
  7910. * 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).
  7911. */
  7912. /**
  7913. * Sets the shadows Hue value.
  7914. * 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).
  7915. */
  7916. shadowsHue: number;
  7917. /**
  7918. * Gets the shadows Density value.
  7919. * 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.
  7920. * Values less than zero provide a filter of opposite hue.
  7921. */
  7922. /**
  7923. * Sets the shadows Density value.
  7924. * 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.
  7925. * Values less than zero provide a filter of opposite hue.
  7926. */
  7927. shadowsDensity: number;
  7928. /**
  7929. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  7931. */
  7932. /**
  7933. * Sets the shadows Saturation value.
  7934. * 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.
  7935. */
  7936. shadowsSaturation: number;
  7937. /**
  7938. * Gets the shadows Exposure value.
  7939. * 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.
  7940. */
  7941. /**
  7942. * Sets the shadows Exposure value.
  7943. * 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.
  7944. */
  7945. shadowsExposure: number;
  7946. /**
  7947. * Returns the class name
  7948. * @returns The class name
  7949. */
  7950. getClassName(): string;
  7951. /**
  7952. * Binds the color curves to the shader.
  7953. * @param colorCurves The color curve to bind
  7954. * @param effect The effect to bind to
  7955. * @param positiveUniform The positive uniform shader parameter
  7956. * @param neutralUniform The neutral uniform shader parameter
  7957. * @param negativeUniform The negative uniform shader parameter
  7958. */
  7959. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7960. /**
  7961. * Prepare the list of uniforms associated with the ColorCurves effects.
  7962. * @param uniformsList The list of uniforms used in the effect
  7963. */
  7964. static PrepareUniforms(uniformsList: string[]): void;
  7965. /**
  7966. * Returns color grading data based on a hue, density, saturation and exposure value.
  7967. * @param filterHue The hue of the color filter.
  7968. * @param filterDensity The density of the color filter.
  7969. * @param saturation The saturation.
  7970. * @param exposure The exposure.
  7971. * @param result The result data container.
  7972. */
  7973. private getColorGradingDataToRef;
  7974. /**
  7975. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7976. * @param value The input slider value in range [-100,100].
  7977. * @returns Adjusted value.
  7978. */
  7979. private static applyColorGradingSliderNonlinear;
  7980. /**
  7981. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7982. * @param hue The hue (H) input.
  7983. * @param saturation The saturation (S) input.
  7984. * @param brightness The brightness (B) input.
  7985. * @result An RGBA color represented as Vector4.
  7986. */
  7987. private static fromHSBToRef;
  7988. /**
  7989. * Returns a value clamped between min and max
  7990. * @param value The value to clamp
  7991. * @param min The minimum of value
  7992. * @param max The maximum of value
  7993. * @returns The clamped value.
  7994. */
  7995. private static clamp;
  7996. /**
  7997. * Clones the current color curve instance.
  7998. * @return The cloned curves
  7999. */
  8000. clone(): ColorCurves;
  8001. /**
  8002. * Serializes the current color curve instance to a json representation.
  8003. * @return a JSON representation
  8004. */
  8005. serialize(): any;
  8006. /**
  8007. * Parses the color curve from a json representation.
  8008. * @param source the JSON source to parse
  8009. * @return The parsed curves
  8010. */
  8011. static Parse(source: any): ColorCurves;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8015. import { Observable } from "babylonjs/Misc/observable";
  8016. import { Nullable } from "babylonjs/types";
  8017. import { Color4 } from "babylonjs/Maths/math.color";
  8018. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8019. import { Effect } from "babylonjs/Materials/effect";
  8020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8021. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8022. /**
  8023. * Interface to follow in your material defines to integrate easily the
  8024. * Image proccessing functions.
  8025. * @hidden
  8026. */
  8027. export interface IImageProcessingConfigurationDefines {
  8028. IMAGEPROCESSING: boolean;
  8029. VIGNETTE: boolean;
  8030. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8031. VIGNETTEBLENDMODEOPAQUE: boolean;
  8032. TONEMAPPING: boolean;
  8033. TONEMAPPING_ACES: boolean;
  8034. CONTRAST: boolean;
  8035. EXPOSURE: boolean;
  8036. COLORCURVES: boolean;
  8037. COLORGRADING: boolean;
  8038. COLORGRADING3D: boolean;
  8039. SAMPLER3DGREENDEPTH: boolean;
  8040. SAMPLER3DBGRMAP: boolean;
  8041. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8042. }
  8043. /**
  8044. * @hidden
  8045. */
  8046. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8047. IMAGEPROCESSING: boolean;
  8048. VIGNETTE: boolean;
  8049. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8050. VIGNETTEBLENDMODEOPAQUE: boolean;
  8051. TONEMAPPING: boolean;
  8052. TONEMAPPING_ACES: boolean;
  8053. CONTRAST: boolean;
  8054. COLORCURVES: boolean;
  8055. COLORGRADING: boolean;
  8056. COLORGRADING3D: boolean;
  8057. SAMPLER3DGREENDEPTH: boolean;
  8058. SAMPLER3DBGRMAP: boolean;
  8059. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8060. EXPOSURE: boolean;
  8061. constructor();
  8062. }
  8063. /**
  8064. * This groups together the common properties used for image processing either in direct forward pass
  8065. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8066. * or not.
  8067. */
  8068. export class ImageProcessingConfiguration {
  8069. /**
  8070. * Default tone mapping applied in BabylonJS.
  8071. */
  8072. static readonly TONEMAPPING_STANDARD: number;
  8073. /**
  8074. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8075. * to other engines rendering to increase portability.
  8076. */
  8077. static readonly TONEMAPPING_ACES: number;
  8078. /**
  8079. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8080. */
  8081. colorCurves: Nullable<ColorCurves>;
  8082. private _colorCurvesEnabled;
  8083. /**
  8084. * Gets wether the color curves effect is enabled.
  8085. */
  8086. /**
  8087. * Sets wether the color curves effect is enabled.
  8088. */
  8089. colorCurvesEnabled: boolean;
  8090. private _colorGradingTexture;
  8091. /**
  8092. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8093. */
  8094. /**
  8095. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8096. */
  8097. colorGradingTexture: Nullable<BaseTexture>;
  8098. private _colorGradingEnabled;
  8099. /**
  8100. * Gets wether the color grading effect is enabled.
  8101. */
  8102. /**
  8103. * Sets wether the color grading effect is enabled.
  8104. */
  8105. colorGradingEnabled: boolean;
  8106. private _colorGradingWithGreenDepth;
  8107. /**
  8108. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8109. */
  8110. /**
  8111. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8112. */
  8113. colorGradingWithGreenDepth: boolean;
  8114. private _colorGradingBGR;
  8115. /**
  8116. * Gets wether the color grading texture contains BGR values.
  8117. */
  8118. /**
  8119. * Sets wether the color grading texture contains BGR values.
  8120. */
  8121. colorGradingBGR: boolean;
  8122. /** @hidden */
  8123. _exposure: number;
  8124. /**
  8125. * Gets the Exposure used in the effect.
  8126. */
  8127. /**
  8128. * Sets the Exposure used in the effect.
  8129. */
  8130. exposure: number;
  8131. private _toneMappingEnabled;
  8132. /**
  8133. * Gets wether the tone mapping effect is enabled.
  8134. */
  8135. /**
  8136. * Sets wether the tone mapping effect is enabled.
  8137. */
  8138. toneMappingEnabled: boolean;
  8139. private _toneMappingType;
  8140. /**
  8141. * Gets the type of tone mapping effect.
  8142. */
  8143. /**
  8144. * Sets the type of tone mapping effect used in BabylonJS.
  8145. */
  8146. toneMappingType: number;
  8147. protected _contrast: number;
  8148. /**
  8149. * Gets the contrast used in the effect.
  8150. */
  8151. /**
  8152. * Sets the contrast used in the effect.
  8153. */
  8154. contrast: number;
  8155. /**
  8156. * Vignette stretch size.
  8157. */
  8158. vignetteStretch: number;
  8159. /**
  8160. * Vignette centre X Offset.
  8161. */
  8162. vignetteCentreX: number;
  8163. /**
  8164. * Vignette centre Y Offset.
  8165. */
  8166. vignetteCentreY: number;
  8167. /**
  8168. * Vignette weight or intensity of the vignette effect.
  8169. */
  8170. vignetteWeight: number;
  8171. /**
  8172. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8173. * if vignetteEnabled is set to true.
  8174. */
  8175. vignetteColor: Color4;
  8176. /**
  8177. * Camera field of view used by the Vignette effect.
  8178. */
  8179. vignetteCameraFov: number;
  8180. private _vignetteBlendMode;
  8181. /**
  8182. * Gets the vignette blend mode allowing different kind of effect.
  8183. */
  8184. /**
  8185. * Sets the vignette blend mode allowing different kind of effect.
  8186. */
  8187. vignetteBlendMode: number;
  8188. private _vignetteEnabled;
  8189. /**
  8190. * Gets wether the vignette effect is enabled.
  8191. */
  8192. /**
  8193. * Sets wether the vignette effect is enabled.
  8194. */
  8195. vignetteEnabled: boolean;
  8196. private _applyByPostProcess;
  8197. /**
  8198. * Gets wether the image processing is applied through a post process or not.
  8199. */
  8200. /**
  8201. * Sets wether the image processing is applied through a post process or not.
  8202. */
  8203. applyByPostProcess: boolean;
  8204. private _isEnabled;
  8205. /**
  8206. * Gets wether the image processing is enabled or not.
  8207. */
  8208. /**
  8209. * Sets wether the image processing is enabled or not.
  8210. */
  8211. isEnabled: boolean;
  8212. /**
  8213. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8214. */
  8215. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8216. /**
  8217. * Method called each time the image processing information changes requires to recompile the effect.
  8218. */
  8219. protected _updateParameters(): void;
  8220. /**
  8221. * Gets the current class name.
  8222. * @return "ImageProcessingConfiguration"
  8223. */
  8224. getClassName(): string;
  8225. /**
  8226. * Prepare the list of uniforms associated with the Image Processing effects.
  8227. * @param uniforms The list of uniforms used in the effect
  8228. * @param defines the list of defines currently in use
  8229. */
  8230. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8231. /**
  8232. * Prepare the list of samplers associated with the Image Processing effects.
  8233. * @param samplersList The list of uniforms used in the effect
  8234. * @param defines the list of defines currently in use
  8235. */
  8236. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8237. /**
  8238. * Prepare the list of defines associated to the shader.
  8239. * @param defines the list of defines to complete
  8240. * @param forPostProcess Define if we are currently in post process mode or not
  8241. */
  8242. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8243. /**
  8244. * Returns true if all the image processing information are ready.
  8245. * @returns True if ready, otherwise, false
  8246. */
  8247. isReady(): boolean;
  8248. /**
  8249. * Binds the image processing to the shader.
  8250. * @param effect The effect to bind to
  8251. * @param aspectRatio Define the current aspect ratio of the effect
  8252. */
  8253. bind(effect: Effect, aspectRatio?: number): void;
  8254. /**
  8255. * Clones the current image processing instance.
  8256. * @return The cloned image processing
  8257. */
  8258. clone(): ImageProcessingConfiguration;
  8259. /**
  8260. * Serializes the current image processing instance to a json representation.
  8261. * @return a JSON representation
  8262. */
  8263. serialize(): any;
  8264. /**
  8265. * Parses the image processing from a json representation.
  8266. * @param source the JSON source to parse
  8267. * @return The parsed image processing
  8268. */
  8269. static Parse(source: any): ImageProcessingConfiguration;
  8270. private static _VIGNETTEMODE_MULTIPLY;
  8271. private static _VIGNETTEMODE_OPAQUE;
  8272. /**
  8273. * Used to apply the vignette as a mix with the pixel color.
  8274. */
  8275. static readonly VIGNETTEMODE_MULTIPLY: number;
  8276. /**
  8277. * Used to apply the vignette as a replacement of the pixel color.
  8278. */
  8279. static readonly VIGNETTEMODE_OPAQUE: number;
  8280. }
  8281. }
  8282. declare module "babylonjs/Shaders/postprocess.vertex" {
  8283. /** @hidden */
  8284. export var postprocessVertexShader: {
  8285. name: string;
  8286. shader: string;
  8287. };
  8288. }
  8289. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8290. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8291. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8292. module "babylonjs/Engines/thinEngine" {
  8293. interface ThinEngine {
  8294. /**
  8295. * Creates a new render target texture
  8296. * @param size defines the size of the texture
  8297. * @param options defines the options used to create the texture
  8298. * @returns a new render target texture stored in an InternalTexture
  8299. */
  8300. createRenderTargetTexture(size: number | {
  8301. width: number;
  8302. height: number;
  8303. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8304. }
  8305. }
  8306. }
  8307. declare module "babylonjs/Maths/math.axis" {
  8308. import { Vector3 } from "babylonjs/Maths/math.vector";
  8309. /** Defines supported spaces */
  8310. export enum Space {
  8311. /** Local (object) space */
  8312. LOCAL = 0,
  8313. /** World space */
  8314. WORLD = 1,
  8315. /** Bone space */
  8316. BONE = 2
  8317. }
  8318. /** Defines the 3 main axes */
  8319. export class Axis {
  8320. /** X axis */
  8321. static X: Vector3;
  8322. /** Y axis */
  8323. static Y: Vector3;
  8324. /** Z axis */
  8325. static Z: Vector3;
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/targetCamera" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { Camera } from "babylonjs/Cameras/camera";
  8331. import { Scene } from "babylonjs/scene";
  8332. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8333. /**
  8334. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8335. * This is the base of the follow, arc rotate cameras and Free camera
  8336. * @see http://doc.babylonjs.com/features/cameras
  8337. */
  8338. export class TargetCamera extends Camera {
  8339. private static _RigCamTransformMatrix;
  8340. private static _TargetTransformMatrix;
  8341. private static _TargetFocalPoint;
  8342. /**
  8343. * Define the current direction the camera is moving to
  8344. */
  8345. cameraDirection: Vector3;
  8346. /**
  8347. * Define the current rotation the camera is rotating to
  8348. */
  8349. cameraRotation: Vector2;
  8350. /**
  8351. * When set, the up vector of the camera will be updated by the rotation of the camera
  8352. */
  8353. updateUpVectorFromRotation: boolean;
  8354. private _tmpQuaternion;
  8355. /**
  8356. * Define the current rotation of the camera
  8357. */
  8358. rotation: Vector3;
  8359. /**
  8360. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8361. */
  8362. rotationQuaternion: Quaternion;
  8363. /**
  8364. * Define the current speed of the camera
  8365. */
  8366. speed: number;
  8367. /**
  8368. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8369. * around all axis.
  8370. */
  8371. noRotationConstraint: boolean;
  8372. /**
  8373. * Define the current target of the camera as an object or a position.
  8374. */
  8375. lockedTarget: any;
  8376. /** @hidden */
  8377. _currentTarget: Vector3;
  8378. /** @hidden */
  8379. _initialFocalDistance: number;
  8380. /** @hidden */
  8381. _viewMatrix: Matrix;
  8382. /** @hidden */
  8383. _camMatrix: Matrix;
  8384. /** @hidden */
  8385. _cameraTransformMatrix: Matrix;
  8386. /** @hidden */
  8387. _cameraRotationMatrix: Matrix;
  8388. /** @hidden */
  8389. _referencePoint: Vector3;
  8390. /** @hidden */
  8391. _transformedReferencePoint: Vector3;
  8392. protected _globalCurrentTarget: Vector3;
  8393. protected _globalCurrentUpVector: Vector3;
  8394. /** @hidden */
  8395. _reset: () => void;
  8396. private _defaultUp;
  8397. /**
  8398. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8399. * This is the base of the follow, arc rotate cameras and Free camera
  8400. * @see http://doc.babylonjs.com/features/cameras
  8401. * @param name Defines the name of the camera in the scene
  8402. * @param position Defines the start position of the camera in the scene
  8403. * @param scene Defines the scene the camera belongs to
  8404. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8405. */
  8406. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8407. /**
  8408. * Gets the position in front of the camera at a given distance.
  8409. * @param distance The distance from the camera we want the position to be
  8410. * @returns the position
  8411. */
  8412. getFrontPosition(distance: number): Vector3;
  8413. /** @hidden */
  8414. _getLockedTargetPosition(): Nullable<Vector3>;
  8415. private _storedPosition;
  8416. private _storedRotation;
  8417. private _storedRotationQuaternion;
  8418. /**
  8419. * Store current camera state of the camera (fov, position, rotation, etc..)
  8420. * @returns the camera
  8421. */
  8422. storeState(): Camera;
  8423. /**
  8424. * Restored camera state. You must call storeState() first
  8425. * @returns whether it was successful or not
  8426. * @hidden
  8427. */
  8428. _restoreStateValues(): boolean;
  8429. /** @hidden */
  8430. _initCache(): void;
  8431. /** @hidden */
  8432. _updateCache(ignoreParentClass?: boolean): void;
  8433. /** @hidden */
  8434. _isSynchronizedViewMatrix(): boolean;
  8435. /** @hidden */
  8436. _computeLocalCameraSpeed(): number;
  8437. /**
  8438. * Defines the target the camera should look at.
  8439. * @param target Defines the new target as a Vector or a mesh
  8440. */
  8441. setTarget(target: Vector3): void;
  8442. /**
  8443. * Return the current target position of the camera. This value is expressed in local space.
  8444. * @returns the target position
  8445. */
  8446. getTarget(): Vector3;
  8447. /** @hidden */
  8448. _decideIfNeedsToMove(): boolean;
  8449. /** @hidden */
  8450. _updatePosition(): void;
  8451. /** @hidden */
  8452. _checkInputs(): void;
  8453. protected _updateCameraRotationMatrix(): void;
  8454. /**
  8455. * 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)
  8456. * @returns the current camera
  8457. */
  8458. private _rotateUpVectorWithCameraRotationMatrix;
  8459. private _cachedRotationZ;
  8460. private _cachedQuaternionRotationZ;
  8461. /** @hidden */
  8462. _getViewMatrix(): Matrix;
  8463. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8464. /**
  8465. * @hidden
  8466. */
  8467. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8468. /**
  8469. * @hidden
  8470. */
  8471. _updateRigCameras(): void;
  8472. private _getRigCamPositionAndTarget;
  8473. /**
  8474. * Gets the current object class name.
  8475. * @return the class name
  8476. */
  8477. getClassName(): string;
  8478. }
  8479. }
  8480. declare module "babylonjs/Events/keyboardEvents" {
  8481. /**
  8482. * Gather the list of keyboard event types as constants.
  8483. */
  8484. export class KeyboardEventTypes {
  8485. /**
  8486. * The keydown event is fired when a key becomes active (pressed).
  8487. */
  8488. static readonly KEYDOWN: number;
  8489. /**
  8490. * The keyup event is fired when a key has been released.
  8491. */
  8492. static readonly KEYUP: number;
  8493. }
  8494. /**
  8495. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8496. */
  8497. export class KeyboardInfo {
  8498. /**
  8499. * Defines the type of event (KeyboardEventTypes)
  8500. */
  8501. type: number;
  8502. /**
  8503. * Defines the related dom event
  8504. */
  8505. event: KeyboardEvent;
  8506. /**
  8507. * Instantiates a new keyboard info.
  8508. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8509. * @param type Defines the type of event (KeyboardEventTypes)
  8510. * @param event Defines the related dom event
  8511. */
  8512. constructor(
  8513. /**
  8514. * Defines the type of event (KeyboardEventTypes)
  8515. */
  8516. type: number,
  8517. /**
  8518. * Defines the related dom event
  8519. */
  8520. event: KeyboardEvent);
  8521. }
  8522. /**
  8523. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8524. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8525. */
  8526. export class KeyboardInfoPre extends KeyboardInfo {
  8527. /**
  8528. * Defines the type of event (KeyboardEventTypes)
  8529. */
  8530. type: number;
  8531. /**
  8532. * Defines the related dom event
  8533. */
  8534. event: KeyboardEvent;
  8535. /**
  8536. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8537. */
  8538. skipOnPointerObservable: boolean;
  8539. /**
  8540. * Instantiates a new keyboard pre info.
  8541. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8542. * @param type Defines the type of event (KeyboardEventTypes)
  8543. * @param event Defines the related dom event
  8544. */
  8545. constructor(
  8546. /**
  8547. * Defines the type of event (KeyboardEventTypes)
  8548. */
  8549. type: number,
  8550. /**
  8551. * Defines the related dom event
  8552. */
  8553. event: KeyboardEvent);
  8554. }
  8555. }
  8556. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8557. import { Nullable } from "babylonjs/types";
  8558. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8559. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8560. /**
  8561. * Manage the keyboard inputs to control the movement of a free camera.
  8562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8563. */
  8564. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8565. /**
  8566. * Defines the camera the input is attached to.
  8567. */
  8568. camera: FreeCamera;
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8571. */
  8572. keysUp: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8575. */
  8576. keysDown: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8579. */
  8580. keysLeft: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8583. */
  8584. keysRight: number[];
  8585. private _keys;
  8586. private _onCanvasBlurObserver;
  8587. private _onKeyboardObserver;
  8588. private _engine;
  8589. private _scene;
  8590. /**
  8591. * Attach the input controls to a specific dom element to get the input from.
  8592. * @param element Defines the element the controls should be listened from
  8593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8594. */
  8595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8596. /**
  8597. * Detach the current controls from the specified dom element.
  8598. * @param element Defines the element to stop listening the inputs from
  8599. */
  8600. detachControl(element: Nullable<HTMLElement>): void;
  8601. /**
  8602. * Update the current camera state depending on the inputs that have been used this frame.
  8603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8604. */
  8605. checkInputs(): void;
  8606. /**
  8607. * Gets the class name of the current intput.
  8608. * @returns the class name
  8609. */
  8610. getClassName(): string;
  8611. /** @hidden */
  8612. _onLostFocus(): void;
  8613. /**
  8614. * Get the friendly name associated with the input class.
  8615. * @returns the input friendly name
  8616. */
  8617. getSimpleName(): string;
  8618. }
  8619. }
  8620. declare module "babylonjs/Lights/shadowLight" {
  8621. import { Camera } from "babylonjs/Cameras/camera";
  8622. import { Scene } from "babylonjs/scene";
  8623. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8625. import { Light } from "babylonjs/Lights/light";
  8626. /**
  8627. * Interface describing all the common properties and methods a shadow light needs to implement.
  8628. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8629. * as well as binding the different shadow properties to the effects.
  8630. */
  8631. export interface IShadowLight extends Light {
  8632. /**
  8633. * The light id in the scene (used in scene.findLighById for instance)
  8634. */
  8635. id: string;
  8636. /**
  8637. * The position the shdow will be casted from.
  8638. */
  8639. position: Vector3;
  8640. /**
  8641. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8642. */
  8643. direction: Vector3;
  8644. /**
  8645. * The transformed position. Position of the light in world space taking parenting in account.
  8646. */
  8647. transformedPosition: Vector3;
  8648. /**
  8649. * The transformed direction. Direction of the light in world space taking parenting in account.
  8650. */
  8651. transformedDirection: Vector3;
  8652. /**
  8653. * The friendly name of the light in the scene.
  8654. */
  8655. name: string;
  8656. /**
  8657. * Defines the shadow projection clipping minimum z value.
  8658. */
  8659. shadowMinZ: number;
  8660. /**
  8661. * Defines the shadow projection clipping maximum z value.
  8662. */
  8663. shadowMaxZ: number;
  8664. /**
  8665. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8666. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8667. */
  8668. computeTransformedInformation(): boolean;
  8669. /**
  8670. * Gets the scene the light belongs to.
  8671. * @returns The scene
  8672. */
  8673. getScene(): Scene;
  8674. /**
  8675. * Callback defining a custom Projection Matrix Builder.
  8676. * This can be used to override the default projection matrix computation.
  8677. */
  8678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8679. /**
  8680. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8681. * @param matrix The materix to updated with the projection information
  8682. * @param viewMatrix The transform matrix of the light
  8683. * @param renderList The list of mesh to render in the map
  8684. * @returns The current light
  8685. */
  8686. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8687. /**
  8688. * Gets the current depth scale used in ESM.
  8689. * @returns The scale
  8690. */
  8691. getDepthScale(): number;
  8692. /**
  8693. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8694. * @returns true if a cube texture needs to be use
  8695. */
  8696. needCube(): boolean;
  8697. /**
  8698. * Detects if the projection matrix requires to be recomputed this frame.
  8699. * @returns true if it requires to be recomputed otherwise, false.
  8700. */
  8701. needProjectionMatrixCompute(): boolean;
  8702. /**
  8703. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8704. */
  8705. forceProjectionMatrixCompute(): void;
  8706. /**
  8707. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8708. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8709. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8710. */
  8711. getShadowDirection(faceIndex?: number): Vector3;
  8712. /**
  8713. * Gets the minZ used for shadow according to both the scene and the light.
  8714. * @param activeCamera The camera we are returning the min for
  8715. * @returns the depth min z
  8716. */
  8717. getDepthMinZ(activeCamera: Camera): number;
  8718. /**
  8719. * Gets the maxZ used for shadow according to both the scene and the light.
  8720. * @param activeCamera The camera we are returning the max for
  8721. * @returns the depth max z
  8722. */
  8723. getDepthMaxZ(activeCamera: Camera): number;
  8724. }
  8725. /**
  8726. * Base implementation IShadowLight
  8727. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8728. */
  8729. export abstract class ShadowLight extends Light implements IShadowLight {
  8730. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8731. protected _position: Vector3;
  8732. protected _setPosition(value: Vector3): void;
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. /**
  8738. * Sets the position the shadow will be casted from. Also use as the light position for both
  8739. * point and spot lights.
  8740. */
  8741. position: Vector3;
  8742. protected _direction: Vector3;
  8743. protected _setDirection(value: Vector3): void;
  8744. /**
  8745. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. /**
  8749. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. direction: Vector3;
  8753. private _shadowMinZ;
  8754. /**
  8755. * Gets the shadow projection clipping minimum z value.
  8756. */
  8757. /**
  8758. * Sets the shadow projection clipping minimum z value.
  8759. */
  8760. shadowMinZ: number;
  8761. private _shadowMaxZ;
  8762. /**
  8763. * Sets the shadow projection clipping maximum z value.
  8764. */
  8765. /**
  8766. * Gets the shadow projection clipping maximum z value.
  8767. */
  8768. shadowMaxZ: number;
  8769. /**
  8770. * Callback defining a custom Projection Matrix Builder.
  8771. * This can be used to override the default projection matrix computation.
  8772. */
  8773. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8774. /**
  8775. * The transformed position. Position of the light in world space taking parenting in account.
  8776. */
  8777. transformedPosition: Vector3;
  8778. /**
  8779. * The transformed direction. Direction of the light in world space taking parenting in account.
  8780. */
  8781. transformedDirection: Vector3;
  8782. private _needProjectionMatrixCompute;
  8783. /**
  8784. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8785. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8786. */
  8787. computeTransformedInformation(): boolean;
  8788. /**
  8789. * Return the depth scale used for the shadow map.
  8790. * @returns the depth scale.
  8791. */
  8792. getDepthScale(): number;
  8793. /**
  8794. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8795. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8796. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8797. */
  8798. getShadowDirection(faceIndex?: number): Vector3;
  8799. /**
  8800. * Returns the ShadowLight absolute position in the World.
  8801. * @returns the position vector in world space
  8802. */
  8803. getAbsolutePosition(): Vector3;
  8804. /**
  8805. * Sets the ShadowLight direction toward the passed target.
  8806. * @param target The point to target in local space
  8807. * @returns the updated ShadowLight direction
  8808. */
  8809. setDirectionToTarget(target: Vector3): Vector3;
  8810. /**
  8811. * Returns the light rotation in euler definition.
  8812. * @returns the x y z rotation in local space.
  8813. */
  8814. getRotation(): Vector3;
  8815. /**
  8816. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8817. * @returns true if a cube texture needs to be use
  8818. */
  8819. needCube(): boolean;
  8820. /**
  8821. * Detects if the projection matrix requires to be recomputed this frame.
  8822. * @returns true if it requires to be recomputed otherwise, false.
  8823. */
  8824. needProjectionMatrixCompute(): boolean;
  8825. /**
  8826. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8827. */
  8828. forceProjectionMatrixCompute(): void;
  8829. /** @hidden */
  8830. _initCache(): void;
  8831. /** @hidden */
  8832. _isSynchronized(): boolean;
  8833. /**
  8834. * Computes the world matrix of the node
  8835. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8836. * @returns the world matrix
  8837. */
  8838. computeWorldMatrix(force?: boolean): Matrix;
  8839. /**
  8840. * Gets the minZ used for shadow according to both the scene and the light.
  8841. * @param activeCamera The camera we are returning the min for
  8842. * @returns the depth min z
  8843. */
  8844. getDepthMinZ(activeCamera: Camera): number;
  8845. /**
  8846. * Gets the maxZ used for shadow according to both the scene and the light.
  8847. * @param activeCamera The camera we are returning the max for
  8848. * @returns the depth max z
  8849. */
  8850. getDepthMaxZ(activeCamera: Camera): number;
  8851. /**
  8852. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8853. * @param matrix The materix to updated with the projection information
  8854. * @param viewMatrix The transform matrix of the light
  8855. * @param renderList The list of mesh to render in the map
  8856. * @returns The current light
  8857. */
  8858. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8859. }
  8860. }
  8861. declare module "babylonjs/Materials/effectFallbacks" {
  8862. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8863. import { Effect } from "babylonjs/Materials/effect";
  8864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8865. /**
  8866. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8867. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8868. */
  8869. export class EffectFallbacks implements IEffectFallbacks {
  8870. private _defines;
  8871. private _currentRank;
  8872. private _maxRank;
  8873. private _mesh;
  8874. /**
  8875. * Removes the fallback from the bound mesh.
  8876. */
  8877. unBindMesh(): void;
  8878. /**
  8879. * Adds a fallback on the specified property.
  8880. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8881. * @param define The name of the define in the shader
  8882. */
  8883. addFallback(rank: number, define: string): void;
  8884. /**
  8885. * Sets the mesh to use CPU skinning when needing to fallback.
  8886. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8887. * @param mesh The mesh to use the fallbacks.
  8888. */
  8889. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8890. /**
  8891. * Checks to see if more fallbacks are still availible.
  8892. */
  8893. readonly hasMoreFallbacks: boolean;
  8894. /**
  8895. * Removes the defines that should be removed when falling back.
  8896. * @param currentDefines defines the current define statements for the shader.
  8897. * @param effect defines the current effect we try to compile
  8898. * @returns The resulting defines with defines of the current rank removed.
  8899. */
  8900. reduce(currentDefines: string, effect: Effect): string;
  8901. }
  8902. }
  8903. declare module "babylonjs/Materials/materialHelper" {
  8904. import { Nullable } from "babylonjs/types";
  8905. import { Scene } from "babylonjs/scene";
  8906. import { Engine } from "babylonjs/Engines/engine";
  8907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8908. import { Light } from "babylonjs/Lights/light";
  8909. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8910. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8912. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8913. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8914. /**
  8915. * "Static Class" containing the most commonly used helper while dealing with material for
  8916. * rendering purpose.
  8917. *
  8918. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8919. *
  8920. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8921. */
  8922. export class MaterialHelper {
  8923. /**
  8924. * Bind the current view position to an effect.
  8925. * @param effect The effect to be bound
  8926. * @param scene The scene the eyes position is used from
  8927. */
  8928. static BindEyePosition(effect: Effect, scene: Scene): void;
  8929. /**
  8930. * Helps preparing the defines values about the UVs in used in the effect.
  8931. * UVs are shared as much as we can accross channels in the shaders.
  8932. * @param texture The texture we are preparing the UVs for
  8933. * @param defines The defines to update
  8934. * @param key The channel key "diffuse", "specular"... used in the shader
  8935. */
  8936. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8937. /**
  8938. * Binds a texture matrix value to its corrsponding uniform
  8939. * @param texture The texture to bind the matrix for
  8940. * @param uniformBuffer The uniform buffer receivin the data
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8944. /**
  8945. * Gets the current status of the fog (should it be enabled?)
  8946. * @param mesh defines the mesh to evaluate for fog support
  8947. * @param scene defines the hosting scene
  8948. * @returns true if fog must be enabled
  8949. */
  8950. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8951. /**
  8952. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8953. * @param mesh defines the current mesh
  8954. * @param scene defines the current scene
  8955. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8956. * @param pointsCloud defines if point cloud rendering has to be turned on
  8957. * @param fogEnabled defines if fog has to be turned on
  8958. * @param alphaTest defines if alpha testing has to be turned on
  8959. * @param defines defines the current list of defines
  8960. */
  8961. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8962. /**
  8963. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8964. * @param scene defines the current scene
  8965. * @param engine defines the current engine
  8966. * @param defines specifies the list of active defines
  8967. * @param useInstances defines if instances have to be turned on
  8968. * @param useClipPlane defines if clip plane have to be turned on
  8969. */
  8970. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8971. /**
  8972. * Prepares the defines for bones
  8973. * @param mesh The mesh containing the geometry data we will draw
  8974. * @param defines The defines to update
  8975. */
  8976. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8977. /**
  8978. * Prepares the defines for morph targets
  8979. * @param mesh The mesh containing the geometry data we will draw
  8980. * @param defines The defines to update
  8981. */
  8982. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8983. /**
  8984. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8985. * @param mesh The mesh containing the geometry data we will draw
  8986. * @param defines The defines to update
  8987. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8988. * @param useBones Precise whether bones should be used or not (override mesh info)
  8989. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8990. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8991. * @returns false if defines are considered not dirty and have not been checked
  8992. */
  8993. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8994. /**
  8995. * Prepares the defines related to multiview
  8996. * @param scene The scene we are intending to draw
  8997. * @param defines The defines to update
  8998. */
  8999. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9000. /**
  9001. * Prepares the defines related to the light information passed in parameter
  9002. * @param scene The scene we are intending to draw
  9003. * @param mesh The mesh the effect is compiling for
  9004. * @param light The light the effect is compiling for
  9005. * @param lightIndex The index of the light
  9006. * @param defines The defines to update
  9007. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9008. * @param state Defines the current state regarding what is needed (normals, etc...)
  9009. */
  9010. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9011. needNormals: boolean;
  9012. needRebuild: boolean;
  9013. shadowEnabled: boolean;
  9014. specularEnabled: boolean;
  9015. lightmapMode: boolean;
  9016. }): void;
  9017. /**
  9018. * Prepares the defines related to the light information passed in parameter
  9019. * @param scene The scene we are intending to draw
  9020. * @param mesh The mesh the effect is compiling for
  9021. * @param defines The defines to update
  9022. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9023. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9024. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9025. * @returns true if normals will be required for the rest of the effect
  9026. */
  9027. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9028. /**
  9029. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9030. * @param lightIndex defines the light index
  9031. * @param uniformsList The uniform list
  9032. * @param samplersList The sampler list
  9033. * @param projectedLightTexture defines if projected texture must be used
  9034. * @param uniformBuffersList defines an optional list of uniform buffers
  9035. */
  9036. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9037. /**
  9038. * Prepares the uniforms and samplers list to be used in the effect
  9039. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9040. * @param samplersList The sampler list
  9041. * @param defines The defines helping in the list generation
  9042. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9043. */
  9044. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9045. /**
  9046. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9047. * @param defines The defines to update while falling back
  9048. * @param fallbacks The authorized effect fallbacks
  9049. * @param maxSimultaneousLights The maximum number of lights allowed
  9050. * @param rank the current rank of the Effect
  9051. * @returns The newly affected rank
  9052. */
  9053. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9054. private static _TmpMorphInfluencers;
  9055. /**
  9056. * Prepares the list of attributes required for morph targets according to the effect defines.
  9057. * @param attribs The current list of supported attribs
  9058. * @param mesh The mesh to prepare the morph targets attributes for
  9059. * @param influencers The number of influencers
  9060. */
  9061. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param defines The current Defines of the effect
  9067. */
  9068. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9069. /**
  9070. * Prepares the list of attributes required for bones according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the bones attributes for
  9073. * @param defines The current Defines of the effect
  9074. * @param fallbacks The current efffect fallback strategy
  9075. */
  9076. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9077. /**
  9078. * Check and prepare the list of attributes required for instances according to the effect defines.
  9079. * @param attribs The current list of supported attribs
  9080. * @param defines The current MaterialDefines of the effect
  9081. */
  9082. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9083. /**
  9084. * Add the list of attributes required for instances to the attribs array.
  9085. * @param attribs The current list of supported attribs
  9086. */
  9087. static PushAttributesForInstances(attribs: string[]): void;
  9088. /**
  9089. * Binds the light shadow information to the effect for the given mesh.
  9090. * @param light The light containing the generator
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param lightIndex The light index in the effect used to render the mesh
  9094. * @param effect The effect we are binding the data to
  9095. */
  9096. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9097. /**
  9098. * Binds the light information to the effect.
  9099. * @param light The light containing the generator
  9100. * @param effect The effect we are binding the data to
  9101. * @param lightIndex The light index in the effect used to render
  9102. */
  9103. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9104. /**
  9105. * Binds the lights information from the scene to the effect for the given mesh.
  9106. * @param light Light to bind
  9107. * @param lightIndex Light index
  9108. * @param scene The scene where the light belongs to
  9109. * @param mesh The mesh we are binding the information to render
  9110. * @param effect The effect we are binding the data to
  9111. * @param useSpecular Defines if specular is supported
  9112. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9113. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9114. */
  9115. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9116. /**
  9117. * Binds the lights information from the scene to the effect for the given mesh.
  9118. * @param scene The scene the lights belongs to
  9119. * @param mesh The mesh we are binding the information to render
  9120. * @param effect The effect we are binding the data to
  9121. * @param defines The generated defines for the effect
  9122. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9123. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9124. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9125. */
  9126. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9127. private static _tempFogColor;
  9128. /**
  9129. * Binds the fog information from the scene to the effect for the given mesh.
  9130. * @param scene The scene the lights belongs to
  9131. * @param mesh The mesh we are binding the information to render
  9132. * @param effect The effect we are binding the data to
  9133. * @param linearSpace Defines if the fog effect is applied in linear space
  9134. */
  9135. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9136. /**
  9137. * Binds the bones information from the mesh to the effect.
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. */
  9141. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9142. /**
  9143. * Binds the morph targets information from the mesh to the effect.
  9144. * @param abstractMesh The mesh we are binding the information to render
  9145. * @param effect The effect we are binding the data to
  9146. */
  9147. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9148. /**
  9149. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9150. * @param defines The generated defines used in the effect
  9151. * @param effect The effect we are binding the data to
  9152. * @param scene The scene we are willing to render with logarithmic scale for
  9153. */
  9154. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9155. /**
  9156. * Binds the clip plane information from the scene to the effect.
  9157. * @param scene The scene the clip plane information are extracted from
  9158. * @param effect The effect we are binding the data to
  9159. */
  9160. static BindClipPlane(effect: Effect, scene: Scene): void;
  9161. }
  9162. }
  9163. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9164. /** @hidden */
  9165. export var packingFunctions: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9171. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9172. /** @hidden */
  9173. export var shadowMapPixelShader: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9179. /** @hidden */
  9180. export var bonesDeclaration: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9186. /** @hidden */
  9187. export var morphTargetsVertexGlobalDeclaration: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9193. /** @hidden */
  9194. export var morphTargetsVertexDeclaration: {
  9195. name: string;
  9196. shader: string;
  9197. };
  9198. }
  9199. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9200. /** @hidden */
  9201. export var instancesDeclaration: {
  9202. name: string;
  9203. shader: string;
  9204. };
  9205. }
  9206. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9207. /** @hidden */
  9208. export var helperFunctions: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9214. /** @hidden */
  9215. export var morphTargetsVertex: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9221. /** @hidden */
  9222. export var instancesVertex: {
  9223. name: string;
  9224. shader: string;
  9225. };
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9228. /** @hidden */
  9229. export var bonesVertex: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9235. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9236. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9237. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9238. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9239. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9241. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9242. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9243. /** @hidden */
  9244. export var shadowMapVertexShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9250. /** @hidden */
  9251. export var depthBoxBlurPixelShader: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9257. import { Nullable } from "babylonjs/types";
  9258. import { Scene } from "babylonjs/scene";
  9259. import { Matrix } from "babylonjs/Maths/math.vector";
  9260. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9262. import { Mesh } from "babylonjs/Meshes/mesh";
  9263. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9264. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9265. import { Effect } from "babylonjs/Materials/effect";
  9266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9267. import "babylonjs/Shaders/shadowMap.fragment";
  9268. import "babylonjs/Shaders/shadowMap.vertex";
  9269. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9270. import { Observable } from "babylonjs/Misc/observable";
  9271. /**
  9272. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9273. */
  9274. export interface ICustomShaderOptions {
  9275. /**
  9276. * Gets or sets the custom shader name to use
  9277. */
  9278. shaderName: string;
  9279. /**
  9280. * The list of attribute names used in the shader
  9281. */
  9282. attributes?: string[];
  9283. /**
  9284. * The list of unifrom names used in the shader
  9285. */
  9286. uniforms?: string[];
  9287. /**
  9288. * The list of sampler names used in the shader
  9289. */
  9290. samplers?: string[];
  9291. /**
  9292. * The list of defines used in the shader
  9293. */
  9294. defines?: string[];
  9295. }
  9296. /**
  9297. * Interface to implement to create a shadow generator compatible with BJS.
  9298. */
  9299. export interface IShadowGenerator {
  9300. /**
  9301. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9302. * @returns The render target texture if present otherwise, null
  9303. */
  9304. getShadowMap(): Nullable<RenderTargetTexture>;
  9305. /**
  9306. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9307. * @returns The render target texture if the shadow map is present otherwise, null
  9308. */
  9309. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9310. /**
  9311. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9312. * @param subMesh The submesh we want to render in the shadow map
  9313. * @param useInstances Defines wether will draw in the map using instances
  9314. * @returns true if ready otherwise, false
  9315. */
  9316. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9317. /**
  9318. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9319. * @param defines Defines of the material we want to update
  9320. * @param lightIndex Index of the light in the enabled light list of the material
  9321. */
  9322. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9323. /**
  9324. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9325. * defined in the generator but impacting the effect).
  9326. * It implies the unifroms available on the materials are the standard BJS ones.
  9327. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9328. * @param effect The effect we are binfing the information for
  9329. */
  9330. bindShadowLight(lightIndex: string, effect: Effect): void;
  9331. /**
  9332. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9333. * (eq to shadow prjection matrix * light transform matrix)
  9334. * @returns The transform matrix used to create the shadow map
  9335. */
  9336. getTransformMatrix(): Matrix;
  9337. /**
  9338. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9339. * Cube and 2D textures for instance.
  9340. */
  9341. recreateShadowMap(): void;
  9342. /**
  9343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9344. * @param onCompiled Callback triggered at the and of the effects compilation
  9345. * @param options Sets of optional options forcing the compilation with different modes
  9346. */
  9347. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9348. useInstances: boolean;
  9349. }>): void;
  9350. /**
  9351. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9352. * @param options Sets of optional options forcing the compilation with different modes
  9353. * @returns A promise that resolves when the compilation completes
  9354. */
  9355. forceCompilationAsync(options?: Partial<{
  9356. useInstances: boolean;
  9357. }>): Promise<void>;
  9358. /**
  9359. * Serializes the shadow generator setup to a json object.
  9360. * @returns The serialized JSON object
  9361. */
  9362. serialize(): any;
  9363. /**
  9364. * Disposes the Shadow map and related Textures and effects.
  9365. */
  9366. dispose(): void;
  9367. }
  9368. /**
  9369. * Default implementation IShadowGenerator.
  9370. * This is the main object responsible of generating shadows in the framework.
  9371. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9372. */
  9373. export class ShadowGenerator implements IShadowGenerator {
  9374. /**
  9375. * Shadow generator mode None: no filtering applied.
  9376. */
  9377. static readonly FILTER_NONE: number;
  9378. /**
  9379. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9381. */
  9382. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9383. /**
  9384. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9385. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9386. */
  9387. static readonly FILTER_POISSONSAMPLING: number;
  9388. /**
  9389. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9391. */
  9392. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9393. /**
  9394. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9395. * edge artifacts on steep falloff.
  9396. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9397. */
  9398. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9399. /**
  9400. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9401. * edge artifacts on steep falloff.
  9402. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9403. */
  9404. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9405. /**
  9406. * Shadow generator mode PCF: Percentage Closer Filtering
  9407. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9408. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9409. */
  9410. static readonly FILTER_PCF: number;
  9411. /**
  9412. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9413. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9414. * Contact Hardening
  9415. */
  9416. static readonly FILTER_PCSS: number;
  9417. /**
  9418. * Reserved for PCF and PCSS
  9419. * Highest Quality.
  9420. *
  9421. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9422. *
  9423. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9424. */
  9425. static readonly QUALITY_HIGH: number;
  9426. /**
  9427. * Reserved for PCF and PCSS
  9428. * Good tradeoff for quality/perf cross devices
  9429. *
  9430. * Execute PCF on a 3*3 kernel.
  9431. *
  9432. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9433. */
  9434. static readonly QUALITY_MEDIUM: number;
  9435. /**
  9436. * Reserved for PCF and PCSS
  9437. * The lowest quality but the fastest.
  9438. *
  9439. * Execute PCF on a 1*1 kernel.
  9440. *
  9441. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9442. */
  9443. static readonly QUALITY_LOW: number;
  9444. /** Gets or sets the custom shader name to use */
  9445. customShaderOptions: ICustomShaderOptions;
  9446. /**
  9447. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9448. */
  9449. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9450. /**
  9451. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9452. */
  9453. onAfterShadowMapRenderObservable: Observable<Effect>;
  9454. /**
  9455. * Observable triggered before a mesh is rendered in the shadow map.
  9456. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9457. */
  9458. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9459. /**
  9460. * Observable triggered after a mesh is rendered in the shadow map.
  9461. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9462. */
  9463. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9464. private _bias;
  9465. /**
  9466. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9467. */
  9468. /**
  9469. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9470. */
  9471. bias: number;
  9472. private _normalBias;
  9473. /**
  9474. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9475. */
  9476. /**
  9477. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9478. */
  9479. normalBias: number;
  9480. private _blurBoxOffset;
  9481. /**
  9482. * Gets the blur box offset: offset applied during the blur pass.
  9483. * Only useful if useKernelBlur = false
  9484. */
  9485. /**
  9486. * Sets the blur box offset: offset applied during the blur pass.
  9487. * Only useful if useKernelBlur = false
  9488. */
  9489. blurBoxOffset: number;
  9490. private _blurScale;
  9491. /**
  9492. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9493. * 2 means half of the size.
  9494. */
  9495. /**
  9496. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9497. * 2 means half of the size.
  9498. */
  9499. blurScale: number;
  9500. private _blurKernel;
  9501. /**
  9502. * Gets the blur kernel: kernel size of the blur pass.
  9503. * Only useful if useKernelBlur = true
  9504. */
  9505. /**
  9506. * Sets the blur kernel: kernel size of the blur pass.
  9507. * Only useful if useKernelBlur = true
  9508. */
  9509. blurKernel: number;
  9510. private _useKernelBlur;
  9511. /**
  9512. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9513. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9514. */
  9515. /**
  9516. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9517. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9518. */
  9519. useKernelBlur: boolean;
  9520. private _depthScale;
  9521. /**
  9522. * Gets the depth scale used in ESM mode.
  9523. */
  9524. /**
  9525. * Sets the depth scale used in ESM mode.
  9526. * This can override the scale stored on the light.
  9527. */
  9528. depthScale: number;
  9529. private _filter;
  9530. /**
  9531. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9532. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9533. */
  9534. /**
  9535. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9536. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9537. */
  9538. filter: number;
  9539. /**
  9540. * Gets if the current filter is set to Poisson Sampling.
  9541. */
  9542. /**
  9543. * Sets the current filter to Poisson Sampling.
  9544. */
  9545. usePoissonSampling: boolean;
  9546. /**
  9547. * Gets if the current filter is set to ESM.
  9548. */
  9549. /**
  9550. * Sets the current filter is to ESM.
  9551. */
  9552. useExponentialShadowMap: boolean;
  9553. /**
  9554. * Gets if the current filter is set to filtered ESM.
  9555. */
  9556. /**
  9557. * Gets if the current filter is set to filtered ESM.
  9558. */
  9559. useBlurExponentialShadowMap: boolean;
  9560. /**
  9561. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9562. * exponential to prevent steep falloff artifacts).
  9563. */
  9564. /**
  9565. * Sets the current filter to "close ESM" (using the inverse of the
  9566. * exponential to prevent steep falloff artifacts).
  9567. */
  9568. useCloseExponentialShadowMap: boolean;
  9569. /**
  9570. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9571. * exponential to prevent steep falloff artifacts).
  9572. */
  9573. /**
  9574. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9575. * exponential to prevent steep falloff artifacts).
  9576. */
  9577. useBlurCloseExponentialShadowMap: boolean;
  9578. /**
  9579. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9580. */
  9581. /**
  9582. * Sets the current filter to "PCF" (percentage closer filtering).
  9583. */
  9584. usePercentageCloserFiltering: boolean;
  9585. private _filteringQuality;
  9586. /**
  9587. * Gets the PCF or PCSS Quality.
  9588. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9589. */
  9590. /**
  9591. * Sets the PCF or PCSS Quality.
  9592. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9593. */
  9594. filteringQuality: number;
  9595. /**
  9596. * Gets if the current filter is set to "PCSS" (contact hardening).
  9597. */
  9598. /**
  9599. * Sets the current filter to "PCSS" (contact hardening).
  9600. */
  9601. useContactHardeningShadow: boolean;
  9602. private _contactHardeningLightSizeUVRatio;
  9603. /**
  9604. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9605. * Using a ratio helps keeping shape stability independently of the map size.
  9606. *
  9607. * It does not account for the light projection as it was having too much
  9608. * instability during the light setup or during light position changes.
  9609. *
  9610. * Only valid if useContactHardeningShadow is true.
  9611. */
  9612. /**
  9613. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9614. * Using a ratio helps keeping shape stability independently of the map size.
  9615. *
  9616. * It does not account for the light projection as it was having too much
  9617. * instability during the light setup or during light position changes.
  9618. *
  9619. * Only valid if useContactHardeningShadow is true.
  9620. */
  9621. contactHardeningLightSizeUVRatio: number;
  9622. private _darkness;
  9623. /** Gets or sets the actual darkness of a shadow */
  9624. darkness: number;
  9625. /**
  9626. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9627. * 0 means strongest and 1 would means no shadow.
  9628. * @returns the darkness.
  9629. */
  9630. getDarkness(): number;
  9631. /**
  9632. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9633. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9634. * @returns the shadow generator allowing fluent coding.
  9635. */
  9636. setDarkness(darkness: number): ShadowGenerator;
  9637. private _transparencyShadow;
  9638. /** Gets or sets the ability to have transparent shadow */
  9639. transparencyShadow: boolean;
  9640. /**
  9641. * Sets the ability to have transparent shadow (boolean).
  9642. * @param transparent True if transparent else False
  9643. * @returns the shadow generator allowing fluent coding
  9644. */
  9645. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9646. private _shadowMap;
  9647. private _shadowMap2;
  9648. /**
  9649. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9650. * @returns The render target texture if present otherwise, null
  9651. */
  9652. getShadowMap(): Nullable<RenderTargetTexture>;
  9653. /**
  9654. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9655. * @returns The render target texture if the shadow map is present otherwise, null
  9656. */
  9657. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9658. /**
  9659. * Gets the class name of that object
  9660. * @returns "ShadowGenerator"
  9661. */
  9662. getClassName(): string;
  9663. /**
  9664. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9665. * @param mesh Mesh to add
  9666. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9667. * @returns the Shadow Generator itself
  9668. */
  9669. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9670. /**
  9671. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9672. * @param mesh Mesh to remove
  9673. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9674. * @returns the Shadow Generator itself
  9675. */
  9676. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9677. /**
  9678. * Controls the extent to which the shadows fade out at the edge of the frustum
  9679. * Used only by directionals and spots
  9680. */
  9681. frustumEdgeFalloff: number;
  9682. private _light;
  9683. /**
  9684. * Returns the associated light object.
  9685. * @returns the light generating the shadow
  9686. */
  9687. getLight(): IShadowLight;
  9688. /**
  9689. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9690. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9691. * It might on the other hand introduce peter panning.
  9692. */
  9693. forceBackFacesOnly: boolean;
  9694. private _scene;
  9695. private _lightDirection;
  9696. private _effect;
  9697. private _viewMatrix;
  9698. private _projectionMatrix;
  9699. private _transformMatrix;
  9700. private _cachedPosition;
  9701. private _cachedDirection;
  9702. private _cachedDefines;
  9703. private _currentRenderID;
  9704. private _boxBlurPostprocess;
  9705. private _kernelBlurXPostprocess;
  9706. private _kernelBlurYPostprocess;
  9707. private _blurPostProcesses;
  9708. private _mapSize;
  9709. private _currentFaceIndex;
  9710. private _currentFaceIndexCache;
  9711. private _textureType;
  9712. private _defaultTextureMatrix;
  9713. private _storedUniqueId;
  9714. /** @hidden */
  9715. static _SceneComponentInitialization: (scene: Scene) => void;
  9716. /**
  9717. * Creates a ShadowGenerator object.
  9718. * A ShadowGenerator is the required tool to use the shadows.
  9719. * Each light casting shadows needs to use its own ShadowGenerator.
  9720. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9721. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9722. * @param light The light object generating the shadows.
  9723. * @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.
  9724. */
  9725. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9726. private _initializeGenerator;
  9727. private _initializeShadowMap;
  9728. private _initializeBlurRTTAndPostProcesses;
  9729. private _renderForShadowMap;
  9730. private _renderSubMeshForShadowMap;
  9731. private _applyFilterValues;
  9732. /**
  9733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9734. * @param onCompiled Callback triggered at the and of the effects compilation
  9735. * @param options Sets of optional options forcing the compilation with different modes
  9736. */
  9737. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9738. useInstances: boolean;
  9739. }>): void;
  9740. /**
  9741. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9742. * @param options Sets of optional options forcing the compilation with different modes
  9743. * @returns A promise that resolves when the compilation completes
  9744. */
  9745. forceCompilationAsync(options?: Partial<{
  9746. useInstances: boolean;
  9747. }>): Promise<void>;
  9748. /**
  9749. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9750. * @param subMesh The submesh we want to render in the shadow map
  9751. * @param useInstances Defines wether will draw in the map using instances
  9752. * @returns true if ready otherwise, false
  9753. */
  9754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9755. /**
  9756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9757. * @param defines Defines of the material we want to update
  9758. * @param lightIndex Index of the light in the enabled light list of the material
  9759. */
  9760. prepareDefines(defines: any, lightIndex: number): void;
  9761. /**
  9762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9763. * defined in the generator but impacting the effect).
  9764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9765. * @param effect The effect we are binfing the information for
  9766. */
  9767. bindShadowLight(lightIndex: string, effect: Effect): void;
  9768. /**
  9769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9770. * (eq to shadow prjection matrix * light transform matrix)
  9771. * @returns The transform matrix used to create the shadow map
  9772. */
  9773. getTransformMatrix(): Matrix;
  9774. /**
  9775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9776. * Cube and 2D textures for instance.
  9777. */
  9778. recreateShadowMap(): void;
  9779. private _disposeBlurPostProcesses;
  9780. private _disposeRTTandPostProcesses;
  9781. /**
  9782. * Disposes the ShadowGenerator.
  9783. * Returns nothing.
  9784. */
  9785. dispose(): void;
  9786. /**
  9787. * Serializes the shadow generator setup to a json object.
  9788. * @returns The serialized JSON object
  9789. */
  9790. serialize(): any;
  9791. /**
  9792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9793. * @param parsedShadowGenerator The JSON object to parse
  9794. * @param scene The scene to create the shadow map for
  9795. * @returns The parsed shadow generator
  9796. */
  9797. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9798. }
  9799. }
  9800. declare module "babylonjs/Lights/light" {
  9801. import { Nullable } from "babylonjs/types";
  9802. import { Scene } from "babylonjs/scene";
  9803. import { Vector3 } from "babylonjs/Maths/math.vector";
  9804. import { Color3 } from "babylonjs/Maths/math.color";
  9805. import { Node } from "babylonjs/node";
  9806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9807. import { Effect } from "babylonjs/Materials/effect";
  9808. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9809. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9810. /**
  9811. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9812. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9813. * 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.
  9814. */
  9815. export abstract class Light extends Node {
  9816. /**
  9817. * Falloff Default: light is falling off following the material specification:
  9818. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9819. */
  9820. static readonly FALLOFF_DEFAULT: number;
  9821. /**
  9822. * Falloff Physical: light is falling off following the inverse squared distance law.
  9823. */
  9824. static readonly FALLOFF_PHYSICAL: number;
  9825. /**
  9826. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9827. * to enhance interoperability with other engines.
  9828. */
  9829. static readonly FALLOFF_GLTF: number;
  9830. /**
  9831. * Falloff Standard: light is falling off like in the standard material
  9832. * to enhance interoperability with other materials.
  9833. */
  9834. static readonly FALLOFF_STANDARD: number;
  9835. /**
  9836. * If every light affecting the material is in this lightmapMode,
  9837. * material.lightmapTexture adds or multiplies
  9838. * (depends on material.useLightmapAsShadowmap)
  9839. * after every other light calculations.
  9840. */
  9841. static readonly LIGHTMAP_DEFAULT: number;
  9842. /**
  9843. * material.lightmapTexture as only diffuse lighting from this light
  9844. * adds only specular lighting from this light
  9845. * adds dynamic shadows
  9846. */
  9847. static readonly LIGHTMAP_SPECULAR: number;
  9848. /**
  9849. * material.lightmapTexture as only lighting
  9850. * no light calculation from this light
  9851. * only adds dynamic shadows from this light
  9852. */
  9853. static readonly LIGHTMAP_SHADOWSONLY: number;
  9854. /**
  9855. * Each light type uses the default quantity according to its type:
  9856. * point/spot lights use luminous intensity
  9857. * directional lights use illuminance
  9858. */
  9859. static readonly INTENSITYMODE_AUTOMATIC: number;
  9860. /**
  9861. * lumen (lm)
  9862. */
  9863. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9864. /**
  9865. * candela (lm/sr)
  9866. */
  9867. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9868. /**
  9869. * lux (lm/m^2)
  9870. */
  9871. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9872. /**
  9873. * nit (cd/m^2)
  9874. */
  9875. static readonly INTENSITYMODE_LUMINANCE: number;
  9876. /**
  9877. * Light type const id of the point light.
  9878. */
  9879. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9880. /**
  9881. * Light type const id of the directional light.
  9882. */
  9883. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9884. /**
  9885. * Light type const id of the spot light.
  9886. */
  9887. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9888. /**
  9889. * Light type const id of the hemispheric light.
  9890. */
  9891. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9892. /**
  9893. * Diffuse gives the basic color to an object.
  9894. */
  9895. diffuse: Color3;
  9896. /**
  9897. * Specular produces a highlight color on an object.
  9898. * Note: This is note affecting PBR materials.
  9899. */
  9900. specular: Color3;
  9901. /**
  9902. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9903. * falling off base on range or angle.
  9904. * This can be set to any values in Light.FALLOFF_x.
  9905. *
  9906. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9907. * other types of materials.
  9908. */
  9909. falloffType: number;
  9910. /**
  9911. * Strength of the light.
  9912. * Note: By default it is define in the framework own unit.
  9913. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9914. */
  9915. intensity: number;
  9916. private _range;
  9917. protected _inverseSquaredRange: number;
  9918. /**
  9919. * Defines how far from the source the light is impacting in scene units.
  9920. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9921. */
  9922. /**
  9923. * Defines how far from the source the light is impacting in scene units.
  9924. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9925. */
  9926. range: number;
  9927. /**
  9928. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9929. * of light.
  9930. */
  9931. private _photometricScale;
  9932. private _intensityMode;
  9933. /**
  9934. * Gets the photometric scale used to interpret the intensity.
  9935. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9936. */
  9937. /**
  9938. * Sets the photometric scale used to interpret the intensity.
  9939. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9940. */
  9941. intensityMode: number;
  9942. private _radius;
  9943. /**
  9944. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9945. */
  9946. /**
  9947. * sets the light radius used by PBR Materials to simulate soft area lights.
  9948. */
  9949. radius: number;
  9950. private _renderPriority;
  9951. /**
  9952. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9953. * exceeding the number allowed of the materials.
  9954. */
  9955. renderPriority: number;
  9956. private _shadowEnabled;
  9957. /**
  9958. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9959. * the current shadow generator.
  9960. */
  9961. /**
  9962. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9963. * the current shadow generator.
  9964. */
  9965. shadowEnabled: boolean;
  9966. private _includedOnlyMeshes;
  9967. /**
  9968. * Gets the only meshes impacted by this light.
  9969. */
  9970. /**
  9971. * Sets the only meshes impacted by this light.
  9972. */
  9973. includedOnlyMeshes: AbstractMesh[];
  9974. private _excludedMeshes;
  9975. /**
  9976. * Gets the meshes not impacted by this light.
  9977. */
  9978. /**
  9979. * Sets the meshes not impacted by this light.
  9980. */
  9981. excludedMeshes: AbstractMesh[];
  9982. private _excludeWithLayerMask;
  9983. /**
  9984. * Gets the layer id use to find what meshes are not impacted by the light.
  9985. * Inactive if 0
  9986. */
  9987. /**
  9988. * Sets the layer id use to find what meshes are not impacted by the light.
  9989. * Inactive if 0
  9990. */
  9991. excludeWithLayerMask: number;
  9992. private _includeOnlyWithLayerMask;
  9993. /**
  9994. * Gets the layer id use to find what meshes are impacted by the light.
  9995. * Inactive if 0
  9996. */
  9997. /**
  9998. * Sets the layer id use to find what meshes are impacted by the light.
  9999. * Inactive if 0
  10000. */
  10001. includeOnlyWithLayerMask: number;
  10002. private _lightmapMode;
  10003. /**
  10004. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10005. */
  10006. /**
  10007. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10008. */
  10009. lightmapMode: number;
  10010. /**
  10011. * Shadow generator associted to the light.
  10012. * @hidden Internal use only.
  10013. */
  10014. _shadowGenerator: Nullable<IShadowGenerator>;
  10015. /**
  10016. * @hidden Internal use only.
  10017. */
  10018. _excludedMeshesIds: string[];
  10019. /**
  10020. * @hidden Internal use only.
  10021. */
  10022. _includedOnlyMeshesIds: string[];
  10023. /**
  10024. * The current light unifom buffer.
  10025. * @hidden Internal use only.
  10026. */
  10027. _uniformBuffer: UniformBuffer;
  10028. /**
  10029. * Creates a Light object in the scene.
  10030. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10031. * @param name The firendly name of the light
  10032. * @param scene The scene the light belongs too
  10033. */
  10034. constructor(name: string, scene: Scene);
  10035. protected abstract _buildUniformLayout(): void;
  10036. /**
  10037. * Sets the passed Effect "effect" with the Light information.
  10038. * @param effect The effect to update
  10039. * @param lightIndex The index of the light in the effect to update
  10040. * @returns The light
  10041. */
  10042. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10043. /**
  10044. * Sets the passed Effect "effect" with the Light information.
  10045. * @param effect The effect to update
  10046. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10047. * @returns The light
  10048. */
  10049. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10050. /**
  10051. * Returns the string "Light".
  10052. * @returns the class name
  10053. */
  10054. getClassName(): string;
  10055. /** @hidden */
  10056. readonly _isLight: boolean;
  10057. /**
  10058. * Converts the light information to a readable string for debug purpose.
  10059. * @param fullDetails Supports for multiple levels of logging within scene loading
  10060. * @returns the human readable light info
  10061. */
  10062. toString(fullDetails?: boolean): string;
  10063. /** @hidden */
  10064. protected _syncParentEnabledState(): void;
  10065. /**
  10066. * Set the enabled state of this node.
  10067. * @param value - the new enabled state
  10068. */
  10069. setEnabled(value: boolean): void;
  10070. /**
  10071. * Returns the Light associated shadow generator if any.
  10072. * @return the associated shadow generator.
  10073. */
  10074. getShadowGenerator(): Nullable<IShadowGenerator>;
  10075. /**
  10076. * Returns a Vector3, the absolute light position in the World.
  10077. * @returns the world space position of the light
  10078. */
  10079. getAbsolutePosition(): Vector3;
  10080. /**
  10081. * Specifies if the light will affect the passed mesh.
  10082. * @param mesh The mesh to test against the light
  10083. * @return true the mesh is affected otherwise, false.
  10084. */
  10085. canAffectMesh(mesh: AbstractMesh): boolean;
  10086. /**
  10087. * Sort function to order lights for rendering.
  10088. * @param a First Light object to compare to second.
  10089. * @param b Second Light object to compare first.
  10090. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10091. */
  10092. static CompareLightsPriority(a: Light, b: Light): number;
  10093. /**
  10094. * Releases resources associated with this node.
  10095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10097. */
  10098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10099. /**
  10100. * Returns the light type ID (integer).
  10101. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10102. */
  10103. getTypeID(): number;
  10104. /**
  10105. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10106. * @returns the scaled intensity in intensity mode unit
  10107. */
  10108. getScaledIntensity(): number;
  10109. /**
  10110. * Returns a new Light object, named "name", from the current one.
  10111. * @param name The name of the cloned light
  10112. * @returns the new created light
  10113. */
  10114. clone(name: string): Nullable<Light>;
  10115. /**
  10116. * Serializes the current light into a Serialization object.
  10117. * @returns the serialized object.
  10118. */
  10119. serialize(): any;
  10120. /**
  10121. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10122. * This new light is named "name" and added to the passed scene.
  10123. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10124. * @param name The friendly name of the light
  10125. * @param scene The scene the new light will belong to
  10126. * @returns the constructor function
  10127. */
  10128. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10129. /**
  10130. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10131. * @param parsedLight The JSON representation of the light
  10132. * @param scene The scene to create the parsed light in
  10133. * @returns the created light after parsing
  10134. */
  10135. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10136. private _hookArrayForExcluded;
  10137. private _hookArrayForIncludedOnly;
  10138. private _resyncMeshes;
  10139. /**
  10140. * Forces the meshes to update their light related information in their rendering used effects
  10141. * @hidden Internal Use Only
  10142. */
  10143. _markMeshesAsLightDirty(): void;
  10144. /**
  10145. * Recomputes the cached photometric scale if needed.
  10146. */
  10147. private _computePhotometricScale;
  10148. /**
  10149. * Returns the Photometric Scale according to the light type and intensity mode.
  10150. */
  10151. private _getPhotometricScale;
  10152. /**
  10153. * Reorder the light in the scene according to their defined priority.
  10154. * @hidden Internal Use Only
  10155. */
  10156. _reorderLightsInScene(): void;
  10157. /**
  10158. * Prepares the list of defines specific to the light type.
  10159. * @param defines the list of defines
  10160. * @param lightIndex defines the index of the light for the effect
  10161. */
  10162. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10163. }
  10164. }
  10165. declare module "babylonjs/Actions/action" {
  10166. import { Observable } from "babylonjs/Misc/observable";
  10167. import { Condition } from "babylonjs/Actions/condition";
  10168. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10169. import { ActionManager } from "babylonjs/Actions/actionManager";
  10170. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10171. /**
  10172. * Interface used to define Action
  10173. */
  10174. export interface IAction {
  10175. /**
  10176. * Trigger for the action
  10177. */
  10178. trigger: number;
  10179. /** Options of the trigger */
  10180. triggerOptions: any;
  10181. /**
  10182. * Gets the trigger parameters
  10183. * @returns the trigger parameters
  10184. */
  10185. getTriggerParameter(): any;
  10186. /**
  10187. * Internal only - executes current action event
  10188. * @hidden
  10189. */
  10190. _executeCurrent(evt?: ActionEvent): void;
  10191. /**
  10192. * Serialize placeholder for child classes
  10193. * @param parent of child
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. /**
  10198. * Internal only
  10199. * @hidden
  10200. */
  10201. _prepare(): void;
  10202. /**
  10203. * Internal only - manager for action
  10204. * @hidden
  10205. */
  10206. _actionManager: AbstractActionManager;
  10207. /**
  10208. * Adds action to chain of actions, may be a DoNothingAction
  10209. * @param action defines the next action to execute
  10210. * @returns The action passed in
  10211. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10212. */
  10213. then(action: IAction): IAction;
  10214. }
  10215. /**
  10216. * The action to be carried out following a trigger
  10217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10218. */
  10219. export class Action implements IAction {
  10220. /** the trigger, with or without parameters, for the action */
  10221. triggerOptions: any;
  10222. /**
  10223. * Trigger for the action
  10224. */
  10225. trigger: number;
  10226. /**
  10227. * Internal only - manager for action
  10228. * @hidden
  10229. */
  10230. _actionManager: ActionManager;
  10231. private _nextActiveAction;
  10232. private _child;
  10233. private _condition?;
  10234. private _triggerParameter;
  10235. /**
  10236. * An event triggered prior to action being executed.
  10237. */
  10238. onBeforeExecuteObservable: Observable<Action>;
  10239. /**
  10240. * Creates a new Action
  10241. * @param triggerOptions the trigger, with or without parameters, for the action
  10242. * @param condition an optional determinant of action
  10243. */
  10244. constructor(
  10245. /** the trigger, with or without parameters, for the action */
  10246. triggerOptions: any, condition?: Condition);
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. _prepare(): void;
  10252. /**
  10253. * Gets the trigger parameters
  10254. * @returns the trigger parameters
  10255. */
  10256. getTriggerParameter(): any;
  10257. /**
  10258. * Internal only - executes current action event
  10259. * @hidden
  10260. */
  10261. _executeCurrent(evt?: ActionEvent): void;
  10262. /**
  10263. * Execute placeholder for child classes
  10264. * @param evt optional action event
  10265. */
  10266. execute(evt?: ActionEvent): void;
  10267. /**
  10268. * Skips to next active action
  10269. */
  10270. skipToNextActiveAction(): void;
  10271. /**
  10272. * Adds action to chain of actions, may be a DoNothingAction
  10273. * @param action defines the next action to execute
  10274. * @returns The action passed in
  10275. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10276. */
  10277. then(action: Action): Action;
  10278. /**
  10279. * Internal only
  10280. * @hidden
  10281. */
  10282. _getProperty(propertyPath: string): string;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /**
  10289. * Serialize placeholder for child classes
  10290. * @param parent of child
  10291. * @returns the serialized object
  10292. */
  10293. serialize(parent: any): any;
  10294. /**
  10295. * Internal only called by serialize
  10296. * @hidden
  10297. */
  10298. protected _serialize(serializedAction: any, parent?: any): any;
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. static _SerializeValueAsString: (value: any) => string;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10309. name: string;
  10310. targetType: string;
  10311. value: string;
  10312. };
  10313. }
  10314. }
  10315. declare module "babylonjs/Actions/condition" {
  10316. import { ActionManager } from "babylonjs/Actions/actionManager";
  10317. /**
  10318. * A Condition applied to an Action
  10319. */
  10320. export class Condition {
  10321. /**
  10322. * Internal only - manager for action
  10323. * @hidden
  10324. */
  10325. _actionManager: ActionManager;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _evaluationId: number;
  10331. /**
  10332. * Internal only
  10333. * @hidden
  10334. */
  10335. _currentResult: boolean;
  10336. /**
  10337. * Creates a new Condition
  10338. * @param actionManager the manager of the action the condition is applied to
  10339. */
  10340. constructor(actionManager: ActionManager);
  10341. /**
  10342. * Check if the current condition is valid
  10343. * @returns a boolean
  10344. */
  10345. isValid(): boolean;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. _getProperty(propertyPath: string): string;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getEffectiveTarget(target: any, propertyPath: string): any;
  10356. /**
  10357. * Serialize placeholder for child classes
  10358. * @returns the serialized object
  10359. */
  10360. serialize(): any;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. protected _serialize(serializedCondition: any): any;
  10366. }
  10367. /**
  10368. * Defines specific conditional operators as extensions of Condition
  10369. */
  10370. export class ValueCondition extends Condition {
  10371. /** path to specify the property of the target the conditional operator uses */
  10372. propertyPath: string;
  10373. /** the value compared by the conditional operator against the current value of the property */
  10374. value: any;
  10375. /** the conditional operator, default ValueCondition.IsEqual */
  10376. operator: number;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. private static _IsEqual;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. private static _IsDifferent;
  10387. /**
  10388. * Internal only
  10389. * @hidden
  10390. */
  10391. private static _IsGreater;
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. private static _IsLesser;
  10397. /**
  10398. * returns the number for IsEqual
  10399. */
  10400. static readonly IsEqual: number;
  10401. /**
  10402. * Returns the number for IsDifferent
  10403. */
  10404. static readonly IsDifferent: number;
  10405. /**
  10406. * Returns the number for IsGreater
  10407. */
  10408. static readonly IsGreater: number;
  10409. /**
  10410. * Returns the number for IsLesser
  10411. */
  10412. static readonly IsLesser: number;
  10413. /**
  10414. * Internal only The action manager for the condition
  10415. * @hidden
  10416. */
  10417. _actionManager: ActionManager;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. private _target;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. private _effectiveTarget;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. private _property;
  10433. /**
  10434. * Creates a new ValueCondition
  10435. * @param actionManager manager for the action the condition applies to
  10436. * @param target for the action
  10437. * @param propertyPath path to specify the property of the target the conditional operator uses
  10438. * @param value the value compared by the conditional operator against the current value of the property
  10439. * @param operator the conditional operator, default ValueCondition.IsEqual
  10440. */
  10441. constructor(actionManager: ActionManager, target: any,
  10442. /** path to specify the property of the target the conditional operator uses */
  10443. propertyPath: string,
  10444. /** the value compared by the conditional operator against the current value of the property */
  10445. value: any,
  10446. /** the conditional operator, default ValueCondition.IsEqual */
  10447. operator?: number);
  10448. /**
  10449. * Compares the given value with the property value for the specified conditional operator
  10450. * @returns the result of the comparison
  10451. */
  10452. isValid(): boolean;
  10453. /**
  10454. * Serialize the ValueCondition into a JSON compatible object
  10455. * @returns serialization object
  10456. */
  10457. serialize(): any;
  10458. /**
  10459. * Gets the name of the conditional operator for the ValueCondition
  10460. * @param operator the conditional operator
  10461. * @returns the name
  10462. */
  10463. static GetOperatorName(operator: number): string;
  10464. }
  10465. /**
  10466. * Defines a predicate condition as an extension of Condition
  10467. */
  10468. export class PredicateCondition extends Condition {
  10469. /** defines the predicate function used to validate the condition */
  10470. predicate: () => boolean;
  10471. /**
  10472. * Internal only - manager for action
  10473. * @hidden
  10474. */
  10475. _actionManager: ActionManager;
  10476. /**
  10477. * Creates a new PredicateCondition
  10478. * @param actionManager manager for the action the condition applies to
  10479. * @param predicate defines the predicate function used to validate the condition
  10480. */
  10481. constructor(actionManager: ActionManager,
  10482. /** defines the predicate function used to validate the condition */
  10483. predicate: () => boolean);
  10484. /**
  10485. * @returns the validity of the predicate condition
  10486. */
  10487. isValid(): boolean;
  10488. }
  10489. /**
  10490. * Defines a state condition as an extension of Condition
  10491. */
  10492. export class StateCondition extends Condition {
  10493. /** Value to compare with target state */
  10494. value: string;
  10495. /**
  10496. * Internal only - manager for action
  10497. * @hidden
  10498. */
  10499. _actionManager: ActionManager;
  10500. /**
  10501. * Internal only
  10502. * @hidden
  10503. */
  10504. private _target;
  10505. /**
  10506. * Creates a new StateCondition
  10507. * @param actionManager manager for the action the condition applies to
  10508. * @param target of the condition
  10509. * @param value to compare with target state
  10510. */
  10511. constructor(actionManager: ActionManager, target: any,
  10512. /** Value to compare with target state */
  10513. value: string);
  10514. /**
  10515. * Gets a boolean indicating if the current condition is met
  10516. * @returns the validity of the state
  10517. */
  10518. isValid(): boolean;
  10519. /**
  10520. * Serialize the StateCondition into a JSON compatible object
  10521. * @returns serialization object
  10522. */
  10523. serialize(): any;
  10524. }
  10525. }
  10526. declare module "babylonjs/Actions/directActions" {
  10527. import { Action } from "babylonjs/Actions/action";
  10528. import { Condition } from "babylonjs/Actions/condition";
  10529. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10530. /**
  10531. * This defines an action responsible to toggle a boolean once triggered.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class SwitchBooleanAction extends Action {
  10535. /**
  10536. * The path to the boolean property in the target object
  10537. */
  10538. propertyPath: string;
  10539. private _target;
  10540. private _effectiveTarget;
  10541. private _property;
  10542. /**
  10543. * Instantiate the action
  10544. * @param triggerOptions defines the trigger options
  10545. * @param target defines the object containing the boolean
  10546. * @param propertyPath defines the path to the boolean property in the target object
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10550. /** @hidden */
  10551. _prepare(): void;
  10552. /**
  10553. * Execute the action toggle the boolean value.
  10554. */
  10555. execute(): void;
  10556. /**
  10557. * Serializes the actions and its related information.
  10558. * @param parent defines the object to serialize in
  10559. * @returns the serialized object
  10560. */
  10561. serialize(parent: any): any;
  10562. }
  10563. /**
  10564. * This defines an action responsible to set a the state field of the target
  10565. * to a desired value once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class SetStateAction extends Action {
  10569. /**
  10570. * The value to store in the state field.
  10571. */
  10572. value: string;
  10573. private _target;
  10574. /**
  10575. * Instantiate the action
  10576. * @param triggerOptions defines the trigger options
  10577. * @param target defines the object containing the state property
  10578. * @param value defines the value to store in the state field
  10579. * @param condition defines the trigger related conditions
  10580. */
  10581. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10582. /**
  10583. * Execute the action and store the value on the target state property.
  10584. */
  10585. execute(): void;
  10586. /**
  10587. * Serializes the actions and its related information.
  10588. * @param parent defines the object to serialize in
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. }
  10593. /**
  10594. * This defines an action responsible to set a property of the target
  10595. * to a desired value once triggered.
  10596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10597. */
  10598. export class SetValueAction extends Action {
  10599. /**
  10600. * The path of the property to set in the target.
  10601. */
  10602. propertyPath: string;
  10603. /**
  10604. * The value to set in the property
  10605. */
  10606. value: any;
  10607. private _target;
  10608. private _effectiveTarget;
  10609. private _property;
  10610. /**
  10611. * Instantiate the action
  10612. * @param triggerOptions defines the trigger options
  10613. * @param target defines the object containing the property
  10614. * @param propertyPath defines the path of the property to set in the target
  10615. * @param value defines the value to set in the property
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the targetted property to the desired value.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. /**
  10633. * This defines an action responsible to increment the target value
  10634. * to a desired value once triggered.
  10635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10636. */
  10637. export class IncrementValueAction extends Action {
  10638. /**
  10639. * The path of the property to increment in the target.
  10640. */
  10641. propertyPath: string;
  10642. /**
  10643. * The value we should increment the property by.
  10644. */
  10645. value: any;
  10646. private _target;
  10647. private _effectiveTarget;
  10648. private _property;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the object containing the property
  10653. * @param propertyPath defines the path of the property to increment in the target
  10654. * @param value defines the value value we should increment the property by
  10655. * @param condition defines the trigger related conditions
  10656. */
  10657. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10658. /** @hidden */
  10659. _prepare(): void;
  10660. /**
  10661. * Execute the action and increment the target of the value amount.
  10662. */
  10663. execute(): void;
  10664. /**
  10665. * Serializes the actions and its related information.
  10666. * @param parent defines the object to serialize in
  10667. * @returns the serialized object
  10668. */
  10669. serialize(parent: any): any;
  10670. }
  10671. /**
  10672. * This defines an action responsible to start an animation once triggered.
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class PlayAnimationAction extends Action {
  10676. /**
  10677. * Where the animation should start (animation frame)
  10678. */
  10679. from: number;
  10680. /**
  10681. * Where the animation should stop (animation frame)
  10682. */
  10683. to: number;
  10684. /**
  10685. * Define if the animation should loop or stop after the first play.
  10686. */
  10687. loop?: boolean;
  10688. private _target;
  10689. /**
  10690. * Instantiate the action
  10691. * @param triggerOptions defines the trigger options
  10692. * @param target defines the target animation or animation name
  10693. * @param from defines from where the animation should start (animation frame)
  10694. * @param end defines where the animation should stop (animation frame)
  10695. * @param loop defines if the animation should loop or stop after the first play
  10696. * @param condition defines the trigger related conditions
  10697. */
  10698. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10699. /** @hidden */
  10700. _prepare(): void;
  10701. /**
  10702. * Execute the action and play the animation.
  10703. */
  10704. execute(): void;
  10705. /**
  10706. * Serializes the actions and its related information.
  10707. * @param parent defines the object to serialize in
  10708. * @returns the serialized object
  10709. */
  10710. serialize(parent: any): any;
  10711. }
  10712. /**
  10713. * This defines an action responsible to stop an animation once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class StopAnimationAction extends Action {
  10717. private _target;
  10718. /**
  10719. * Instantiate the action
  10720. * @param triggerOptions defines the trigger options
  10721. * @param target defines the target animation or animation name
  10722. * @param condition defines the trigger related conditions
  10723. */
  10724. constructor(triggerOptions: any, target: any, condition?: Condition);
  10725. /** @hidden */
  10726. _prepare(): void;
  10727. /**
  10728. * Execute the action and stop the animation.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible that does nothing once triggered.
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10741. */
  10742. export class DoNothingAction extends Action {
  10743. /**
  10744. * Instantiate the action
  10745. * @param triggerOptions defines the trigger options
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions?: any, condition?: Condition);
  10749. /**
  10750. * Execute the action and do nothing.
  10751. */
  10752. execute(): void;
  10753. /**
  10754. * Serializes the actions and its related information.
  10755. * @param parent defines the object to serialize in
  10756. * @returns the serialized object
  10757. */
  10758. serialize(parent: any): any;
  10759. }
  10760. /**
  10761. * This defines an action responsible to trigger several actions once triggered.
  10762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10763. */
  10764. export class CombineAction extends Action {
  10765. /**
  10766. * The list of aggregated animations to run.
  10767. */
  10768. children: Action[];
  10769. /**
  10770. * Instantiate the action
  10771. * @param triggerOptions defines the trigger options
  10772. * @param children defines the list of aggregated animations to run
  10773. * @param condition defines the trigger related conditions
  10774. */
  10775. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10776. /** @hidden */
  10777. _prepare(): void;
  10778. /**
  10779. * Execute the action and executes all the aggregated actions.
  10780. */
  10781. execute(evt: ActionEvent): void;
  10782. /**
  10783. * Serializes the actions and its related information.
  10784. * @param parent defines the object to serialize in
  10785. * @returns the serialized object
  10786. */
  10787. serialize(parent: any): any;
  10788. }
  10789. /**
  10790. * This defines an action responsible to run code (external event) once triggered.
  10791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10792. */
  10793. export class ExecuteCodeAction extends Action {
  10794. /**
  10795. * The callback function to run.
  10796. */
  10797. func: (evt: ActionEvent) => void;
  10798. /**
  10799. * Instantiate the action
  10800. * @param triggerOptions defines the trigger options
  10801. * @param func defines the callback function to run
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10805. /**
  10806. * Execute the action and run the attached code.
  10807. */
  10808. execute(evt: ActionEvent): void;
  10809. }
  10810. /**
  10811. * This defines an action responsible to set the parent property of the target once triggered.
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10813. */
  10814. export class SetParentAction extends Action {
  10815. private _parent;
  10816. private _target;
  10817. /**
  10818. * Instantiate the action
  10819. * @param triggerOptions defines the trigger options
  10820. * @param target defines the target containing the parent property
  10821. * @param parent defines from where the animation should start (animation frame)
  10822. * @param condition defines the trigger related conditions
  10823. */
  10824. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10825. /** @hidden */
  10826. _prepare(): void;
  10827. /**
  10828. * Execute the action and set the parent property.
  10829. */
  10830. execute(): void;
  10831. /**
  10832. * Serializes the actions and its related information.
  10833. * @param parent defines the object to serialize in
  10834. * @returns the serialized object
  10835. */
  10836. serialize(parent: any): any;
  10837. }
  10838. }
  10839. declare module "babylonjs/Actions/actionManager" {
  10840. import { Nullable } from "babylonjs/types";
  10841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10842. import { Scene } from "babylonjs/scene";
  10843. import { IAction } from "babylonjs/Actions/action";
  10844. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10845. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10846. /**
  10847. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10848. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class ActionManager extends AbstractActionManager {
  10852. /**
  10853. * Nothing
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly NothingTrigger: number;
  10857. /**
  10858. * On pick
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnPickTrigger: number;
  10862. /**
  10863. * On left pick
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnLeftPickTrigger: number;
  10867. /**
  10868. * On right pick
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnRightPickTrigger: number;
  10872. /**
  10873. * On center pick
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnCenterPickTrigger: number;
  10877. /**
  10878. * On pick down
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnPickDownTrigger: number;
  10882. /**
  10883. * On double pick
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnDoublePickTrigger: number;
  10887. /**
  10888. * On pick up
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPickUpTrigger: number;
  10892. /**
  10893. * On pick out.
  10894. * This trigger will only be raised if you also declared a OnPickDown
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickOutTrigger: number;
  10898. /**
  10899. * On long press
  10900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10901. */
  10902. static readonly OnLongPressTrigger: number;
  10903. /**
  10904. * On pointer over
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10906. */
  10907. static readonly OnPointerOverTrigger: number;
  10908. /**
  10909. * On pointer out
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10911. */
  10912. static readonly OnPointerOutTrigger: number;
  10913. /**
  10914. * On every frame
  10915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10916. */
  10917. static readonly OnEveryFrameTrigger: number;
  10918. /**
  10919. * On intersection enter
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10921. */
  10922. static readonly OnIntersectionEnterTrigger: number;
  10923. /**
  10924. * On intersection exit
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10926. */
  10927. static readonly OnIntersectionExitTrigger: number;
  10928. /**
  10929. * On key down
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnKeyDownTrigger: number;
  10933. /**
  10934. * On key up
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnKeyUpTrigger: number;
  10938. private _scene;
  10939. /**
  10940. * Creates a new action manager
  10941. * @param scene defines the hosting scene
  10942. */
  10943. constructor(scene: Scene);
  10944. /**
  10945. * Releases all associated resources
  10946. */
  10947. dispose(): void;
  10948. /**
  10949. * Gets hosting scene
  10950. * @returns the hosting scene
  10951. */
  10952. getScene(): Scene;
  10953. /**
  10954. * Does this action manager handles actions of any of the given triggers
  10955. * @param triggers defines the triggers to be tested
  10956. * @return a boolean indicating whether one (or more) of the triggers is handled
  10957. */
  10958. hasSpecificTriggers(triggers: number[]): boolean;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10961. * speed.
  10962. * @param triggerA defines the trigger to be tested
  10963. * @param triggerB defines the trigger to be tested
  10964. * @return a boolean indicating whether one (or more) of the triggers is handled
  10965. */
  10966. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10967. /**
  10968. * Does this action manager handles actions of a given trigger
  10969. * @param trigger defines the trigger to be tested
  10970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10971. * @return whether the trigger is handled
  10972. */
  10973. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10974. /**
  10975. * Does this action manager has pointer triggers
  10976. */
  10977. readonly hasPointerTriggers: boolean;
  10978. /**
  10979. * Does this action manager has pick triggers
  10980. */
  10981. readonly hasPickTriggers: boolean;
  10982. /**
  10983. * Registers an action to this action manager
  10984. * @param action defines the action to be registered
  10985. * @return the action amended (prepared) after registration
  10986. */
  10987. registerAction(action: IAction): Nullable<IAction>;
  10988. /**
  10989. * Unregisters an action to this action manager
  10990. * @param action defines the action to be unregistered
  10991. * @return a boolean indicating whether the action has been unregistered
  10992. */
  10993. unregisterAction(action: IAction): Boolean;
  10994. /**
  10995. * Process a specific trigger
  10996. * @param trigger defines the trigger to process
  10997. * @param evt defines the event details to be processed
  10998. */
  10999. processTrigger(trigger: number, evt?: IActionEvent): void;
  11000. /** @hidden */
  11001. _getEffectiveTarget(target: any, propertyPath: string): any;
  11002. /** @hidden */
  11003. _getProperty(propertyPath: string): string;
  11004. /**
  11005. * Serialize this manager to a JSON object
  11006. * @param name defines the property name to store this manager
  11007. * @returns a JSON representation of this manager
  11008. */
  11009. serialize(name: string): any;
  11010. /**
  11011. * Creates a new ActionManager from a JSON data
  11012. * @param parsedActions defines the JSON data to read from
  11013. * @param object defines the hosting mesh
  11014. * @param scene defines the hosting scene
  11015. */
  11016. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11017. /**
  11018. * Get a trigger name by index
  11019. * @param trigger defines the trigger index
  11020. * @returns a trigger name
  11021. */
  11022. static GetTriggerName(trigger: number): string;
  11023. }
  11024. }
  11025. declare module "babylonjs/Culling/ray" {
  11026. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11027. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11029. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11030. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11031. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11032. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11033. import { Plane } from "babylonjs/Maths/math.plane";
  11034. /**
  11035. * Class representing a ray with position and direction
  11036. */
  11037. export class Ray {
  11038. /** origin point */
  11039. origin: Vector3;
  11040. /** direction */
  11041. direction: Vector3;
  11042. /** length of the ray */
  11043. length: number;
  11044. private static readonly TmpVector3;
  11045. private _tmpRay;
  11046. /**
  11047. * Creates a new ray
  11048. * @param origin origin point
  11049. * @param direction direction
  11050. * @param length length of the ray
  11051. */
  11052. constructor(
  11053. /** origin point */
  11054. origin: Vector3,
  11055. /** direction */
  11056. direction: Vector3,
  11057. /** length of the ray */
  11058. length?: number);
  11059. /**
  11060. * Checks if the ray intersects a box
  11061. * @param minimum bound of the box
  11062. * @param maximum bound of the box
  11063. * @param intersectionTreshold extra extend to be added to the box in all direction
  11064. * @returns if the box was hit
  11065. */
  11066. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11067. /**
  11068. * Checks if the ray intersects a box
  11069. * @param box the bounding box to check
  11070. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11071. * @returns if the box was hit
  11072. */
  11073. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11074. /**
  11075. * If the ray hits a sphere
  11076. * @param sphere the bounding sphere to check
  11077. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11078. * @returns true if it hits the sphere
  11079. */
  11080. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11081. /**
  11082. * If the ray hits a triange
  11083. * @param vertex0 triangle vertex
  11084. * @param vertex1 triangle vertex
  11085. * @param vertex2 triangle vertex
  11086. * @returns intersection information if hit
  11087. */
  11088. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11089. /**
  11090. * Checks if ray intersects a plane
  11091. * @param plane the plane to check
  11092. * @returns the distance away it was hit
  11093. */
  11094. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11095. /**
  11096. * Calculate the intercept of a ray on a given axis
  11097. * @param axis to check 'x' | 'y' | 'z'
  11098. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11099. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11100. */
  11101. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11102. /**
  11103. * Checks if ray intersects a mesh
  11104. * @param mesh the mesh to check
  11105. * @param fastCheck if only the bounding box should checked
  11106. * @returns picking info of the intersecton
  11107. */
  11108. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11109. /**
  11110. * Checks if ray intersects a mesh
  11111. * @param meshes the meshes to check
  11112. * @param fastCheck if only the bounding box should checked
  11113. * @param results array to store result in
  11114. * @returns Array of picking infos
  11115. */
  11116. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11117. private _comparePickingInfo;
  11118. private static smallnum;
  11119. private static rayl;
  11120. /**
  11121. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11122. * @param sega the first point of the segment to test the intersection against
  11123. * @param segb the second point of the segment to test the intersection against
  11124. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11125. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11126. */
  11127. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11128. /**
  11129. * Update the ray from viewport position
  11130. * @param x position
  11131. * @param y y position
  11132. * @param viewportWidth viewport width
  11133. * @param viewportHeight viewport height
  11134. * @param world world matrix
  11135. * @param view view matrix
  11136. * @param projection projection matrix
  11137. * @returns this ray updated
  11138. */
  11139. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Creates a ray with origin and direction of 0,0,0
  11142. * @returns the new ray
  11143. */
  11144. static Zero(): Ray;
  11145. /**
  11146. * Creates a new ray from screen space and viewport
  11147. * @param x position
  11148. * @param y y position
  11149. * @param viewportWidth viewport width
  11150. * @param viewportHeight viewport height
  11151. * @param world world matrix
  11152. * @param view view matrix
  11153. * @param projection projection matrix
  11154. * @returns new ray
  11155. */
  11156. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11157. /**
  11158. * 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
  11159. * transformed to the given world matrix.
  11160. * @param origin The origin point
  11161. * @param end The end point
  11162. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11163. * @returns the new ray
  11164. */
  11165. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11166. /**
  11167. * Transforms a ray by a matrix
  11168. * @param ray ray to transform
  11169. * @param matrix matrix to apply
  11170. * @returns the resulting new ray
  11171. */
  11172. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11173. /**
  11174. * Transforms a ray by a matrix
  11175. * @param ray ray to transform
  11176. * @param matrix matrix to apply
  11177. * @param result ray to store result in
  11178. */
  11179. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11180. /**
  11181. * Unproject a ray from screen space to object space
  11182. * @param sourceX defines the screen space x coordinate to use
  11183. * @param sourceY defines the screen space y coordinate to use
  11184. * @param viewportWidth defines the current width of the viewport
  11185. * @param viewportHeight defines the current height of the viewport
  11186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11187. * @param view defines the view matrix to use
  11188. * @param projection defines the projection matrix to use
  11189. */
  11190. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11191. }
  11192. /**
  11193. * Type used to define predicate used to select faces when a mesh intersection is detected
  11194. */
  11195. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11196. module "babylonjs/scene" {
  11197. interface Scene {
  11198. /** @hidden */
  11199. _tempPickingRay: Nullable<Ray>;
  11200. /** @hidden */
  11201. _cachedRayForTransform: Ray;
  11202. /** @hidden */
  11203. _pickWithRayInverseMatrix: Matrix;
  11204. /** @hidden */
  11205. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11206. /** @hidden */
  11207. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11208. }
  11209. }
  11210. }
  11211. declare module "babylonjs/sceneComponent" {
  11212. import { Scene } from "babylonjs/scene";
  11213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11215. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11216. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11217. import { Nullable } from "babylonjs/types";
  11218. import { Camera } from "babylonjs/Cameras/camera";
  11219. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11220. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11221. import { AbstractScene } from "babylonjs/abstractScene";
  11222. /**
  11223. * Groups all the scene component constants in one place to ease maintenance.
  11224. * @hidden
  11225. */
  11226. export class SceneComponentConstants {
  11227. static readonly NAME_EFFECTLAYER: string;
  11228. static readonly NAME_LAYER: string;
  11229. static readonly NAME_LENSFLARESYSTEM: string;
  11230. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11231. static readonly NAME_PARTICLESYSTEM: string;
  11232. static readonly NAME_GAMEPAD: string;
  11233. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11234. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11235. static readonly NAME_DEPTHRENDERER: string;
  11236. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11237. static readonly NAME_SPRITE: string;
  11238. static readonly NAME_OUTLINERENDERER: string;
  11239. static readonly NAME_PROCEDURALTEXTURE: string;
  11240. static readonly NAME_SHADOWGENERATOR: string;
  11241. static readonly NAME_OCTREE: string;
  11242. static readonly NAME_PHYSICSENGINE: string;
  11243. static readonly NAME_AUDIO: string;
  11244. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11245. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11247. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11248. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11249. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11250. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11251. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11252. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11253. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11254. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11255. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11256. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11257. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11258. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11259. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11262. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11263. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11264. static readonly STEP_AFTERRENDER_AUDIO: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11267. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11269. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11270. static readonly STEP_POINTERMOVE_SPRITE: number;
  11271. static readonly STEP_POINTERDOWN_SPRITE: number;
  11272. static readonly STEP_POINTERUP_SPRITE: number;
  11273. }
  11274. /**
  11275. * This represents a scene component.
  11276. *
  11277. * This is used to decouple the dependency the scene is having on the different workloads like
  11278. * layers, post processes...
  11279. */
  11280. export interface ISceneComponent {
  11281. /**
  11282. * The name of the component. Each component must have a unique name.
  11283. */
  11284. name: string;
  11285. /**
  11286. * The scene the component belongs to.
  11287. */
  11288. scene: Scene;
  11289. /**
  11290. * Register the component to one instance of a scene.
  11291. */
  11292. register(): void;
  11293. /**
  11294. * Rebuilds the elements related to this component in case of
  11295. * context lost for instance.
  11296. */
  11297. rebuild(): void;
  11298. /**
  11299. * Disposes the component and the associated ressources.
  11300. */
  11301. dispose(): void;
  11302. }
  11303. /**
  11304. * This represents a SERIALIZABLE scene component.
  11305. *
  11306. * This extends Scene Component to add Serialization methods on top.
  11307. */
  11308. export interface ISceneSerializableComponent extends ISceneComponent {
  11309. /**
  11310. * Adds all the elements from the container to the scene
  11311. * @param container the container holding the elements
  11312. */
  11313. addFromContainer(container: AbstractScene): void;
  11314. /**
  11315. * Removes all the elements in the container from the scene
  11316. * @param container contains the elements to remove
  11317. * @param dispose if the removed element should be disposed (default: false)
  11318. */
  11319. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11320. /**
  11321. * Serializes the component data to the specified json object
  11322. * @param serializationObject The object to serialize to
  11323. */
  11324. serialize(serializationObject: any): void;
  11325. }
  11326. /**
  11327. * Strong typing of a Mesh related stage step action
  11328. */
  11329. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11330. /**
  11331. * Strong typing of a Evaluate Sub Mesh related stage step action
  11332. */
  11333. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11334. /**
  11335. * Strong typing of a Active Mesh related stage step action
  11336. */
  11337. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11338. /**
  11339. * Strong typing of a Camera related stage step action
  11340. */
  11341. export type CameraStageAction = (camera: Camera) => void;
  11342. /**
  11343. * Strong typing of a Camera Frame buffer related stage step action
  11344. */
  11345. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11346. /**
  11347. * Strong typing of a Render Target related stage step action
  11348. */
  11349. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11350. /**
  11351. * Strong typing of a RenderingGroup related stage step action
  11352. */
  11353. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11354. /**
  11355. * Strong typing of a Mesh Render related stage step action
  11356. */
  11357. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11358. /**
  11359. * Strong typing of a simple stage step action
  11360. */
  11361. export type SimpleStageAction = () => void;
  11362. /**
  11363. * Strong typing of a render target action.
  11364. */
  11365. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11366. /**
  11367. * Strong typing of a pointer move action.
  11368. */
  11369. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11370. /**
  11371. * Strong typing of a pointer up/down action.
  11372. */
  11373. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11374. /**
  11375. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11376. * @hidden
  11377. */
  11378. export class Stage<T extends Function> extends Array<{
  11379. index: number;
  11380. component: ISceneComponent;
  11381. action: T;
  11382. }> {
  11383. /**
  11384. * Hide ctor from the rest of the world.
  11385. * @param items The items to add.
  11386. */
  11387. private constructor();
  11388. /**
  11389. * Creates a new Stage.
  11390. * @returns A new instance of a Stage
  11391. */
  11392. static Create<T extends Function>(): Stage<T>;
  11393. /**
  11394. * Registers a step in an ordered way in the targeted stage.
  11395. * @param index Defines the position to register the step in
  11396. * @param component Defines the component attached to the step
  11397. * @param action Defines the action to launch during the step
  11398. */
  11399. registerStep(index: number, component: ISceneComponent, action: T): void;
  11400. /**
  11401. * Clears all the steps from the stage.
  11402. */
  11403. clear(): void;
  11404. }
  11405. }
  11406. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11407. import { Nullable } from "babylonjs/types";
  11408. import { Observable } from "babylonjs/Misc/observable";
  11409. import { Scene } from "babylonjs/scene";
  11410. import { Sprite } from "babylonjs/Sprites/sprite";
  11411. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11412. import { Ray } from "babylonjs/Culling/ray";
  11413. import { Camera } from "babylonjs/Cameras/camera";
  11414. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11415. import { ISceneComponent } from "babylonjs/sceneComponent";
  11416. module "babylonjs/scene" {
  11417. interface Scene {
  11418. /** @hidden */
  11419. _pointerOverSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _pickedDownSprite: Nullable<Sprite>;
  11422. /** @hidden */
  11423. _tempSpritePickingRay: Nullable<Ray>;
  11424. /**
  11425. * All of the sprite managers added to this scene
  11426. * @see http://doc.babylonjs.com/babylon101/sprites
  11427. */
  11428. spriteManagers: Array<ISpriteManager>;
  11429. /**
  11430. * An event triggered when sprites rendering is about to start
  11431. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11432. */
  11433. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11434. /**
  11435. * An event triggered when sprites rendering is done
  11436. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11437. */
  11438. onAfterSpritesRenderingObservable: Observable<Scene>;
  11439. /** @hidden */
  11440. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11441. /** Launch a ray to try to pick a sprite in the scene
  11442. * @param x position on screen
  11443. * @param y position on screen
  11444. * @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
  11445. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11446. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11447. * @returns a PickingInfo
  11448. */
  11449. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11450. /** Use the given ray to pick a sprite in the scene
  11451. * @param ray The ray (in world space) to use to pick meshes
  11452. * @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
  11453. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11454. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11455. * @returns a PickingInfo
  11456. */
  11457. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11458. /** @hidden */
  11459. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11460. /** Launch a ray to try to pick sprites in the scene
  11461. * @param x position on screen
  11462. * @param y position on screen
  11463. * @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
  11464. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11465. * @returns a PickingInfo array
  11466. */
  11467. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11468. /** Use the given ray to pick sprites in the scene
  11469. * @param ray The ray (in world space) to use to pick meshes
  11470. * @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
  11471. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11472. * @returns a PickingInfo array
  11473. */
  11474. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11475. /**
  11476. * Force the sprite under the pointer
  11477. * @param sprite defines the sprite to use
  11478. */
  11479. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11480. /**
  11481. * Gets the sprite under the pointer
  11482. * @returns a Sprite or null if no sprite is under the pointer
  11483. */
  11484. getPointerOverSprite(): Nullable<Sprite>;
  11485. }
  11486. }
  11487. /**
  11488. * Defines the sprite scene component responsible to manage sprites
  11489. * in a given scene.
  11490. */
  11491. export class SpriteSceneComponent implements ISceneComponent {
  11492. /**
  11493. * The component name helpfull to identify the component in the list of scene components.
  11494. */
  11495. readonly name: string;
  11496. /**
  11497. * The scene the component belongs to.
  11498. */
  11499. scene: Scene;
  11500. /** @hidden */
  11501. private _spritePredicate;
  11502. /**
  11503. * Creates a new instance of the component for the given scene
  11504. * @param scene Defines the scene to register the component in
  11505. */
  11506. constructor(scene: Scene);
  11507. /**
  11508. * Registers the component in a given scene
  11509. */
  11510. register(): void;
  11511. /**
  11512. * Rebuilds the elements related to this component in case of
  11513. * context lost for instance.
  11514. */
  11515. rebuild(): void;
  11516. /**
  11517. * Disposes the component and the associated ressources.
  11518. */
  11519. dispose(): void;
  11520. private _pickSpriteButKeepRay;
  11521. private _pointerMove;
  11522. private _pointerDown;
  11523. private _pointerUp;
  11524. }
  11525. }
  11526. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11527. /** @hidden */
  11528. export var fogFragmentDeclaration: {
  11529. name: string;
  11530. shader: string;
  11531. };
  11532. }
  11533. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11534. /** @hidden */
  11535. export var fogFragment: {
  11536. name: string;
  11537. shader: string;
  11538. };
  11539. }
  11540. declare module "babylonjs/Shaders/sprites.fragment" {
  11541. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11542. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11543. /** @hidden */
  11544. export var spritesPixelShader: {
  11545. name: string;
  11546. shader: string;
  11547. };
  11548. }
  11549. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11550. /** @hidden */
  11551. export var fogVertexDeclaration: {
  11552. name: string;
  11553. shader: string;
  11554. };
  11555. }
  11556. declare module "babylonjs/Shaders/sprites.vertex" {
  11557. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11558. /** @hidden */
  11559. export var spritesVertexShader: {
  11560. name: string;
  11561. shader: string;
  11562. };
  11563. }
  11564. declare module "babylonjs/Sprites/spriteManager" {
  11565. import { IDisposable, Scene } from "babylonjs/scene";
  11566. import { Nullable } from "babylonjs/types";
  11567. import { Observable } from "babylonjs/Misc/observable";
  11568. import { Sprite } from "babylonjs/Sprites/sprite";
  11569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11570. import { Camera } from "babylonjs/Cameras/camera";
  11571. import { Texture } from "babylonjs/Materials/Textures/texture";
  11572. import "babylonjs/Shaders/sprites.fragment";
  11573. import "babylonjs/Shaders/sprites.vertex";
  11574. import { Ray } from "babylonjs/Culling/ray";
  11575. /**
  11576. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11577. */
  11578. export interface ISpriteManager extends IDisposable {
  11579. /**
  11580. * Restricts the camera to viewing objects with the same layerMask.
  11581. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11582. */
  11583. layerMask: number;
  11584. /**
  11585. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11586. */
  11587. isPickable: boolean;
  11588. /**
  11589. * Specifies the rendering group id for this mesh (0 by default)
  11590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11591. */
  11592. renderingGroupId: number;
  11593. /**
  11594. * Defines the list of sprites managed by the manager.
  11595. */
  11596. sprites: Array<Sprite>;
  11597. /**
  11598. * Tests the intersection of a sprite with a specific ray.
  11599. * @param ray The ray we are sending to test the collision
  11600. * @param camera The camera space we are sending rays in
  11601. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11602. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11603. * @returns picking info or null.
  11604. */
  11605. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11606. /**
  11607. * Intersects the sprites with a ray
  11608. * @param ray defines the ray to intersect with
  11609. * @param camera defines the current active camera
  11610. * @param predicate defines a predicate used to select candidate sprites
  11611. * @returns null if no hit or a PickingInfo array
  11612. */
  11613. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11614. /**
  11615. * Renders the list of sprites on screen.
  11616. */
  11617. render(): void;
  11618. }
  11619. /**
  11620. * Class used to manage multiple sprites on the same spritesheet
  11621. * @see http://doc.babylonjs.com/babylon101/sprites
  11622. */
  11623. export class SpriteManager implements ISpriteManager {
  11624. /** defines the manager's name */
  11625. name: string;
  11626. /** Gets the list of sprites */
  11627. sprites: Sprite[];
  11628. /** Gets or sets the rendering group id (0 by default) */
  11629. renderingGroupId: number;
  11630. /** Gets or sets camera layer mask */
  11631. layerMask: number;
  11632. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11633. fogEnabled: boolean;
  11634. /** Gets or sets a boolean indicating if the sprites are pickable */
  11635. isPickable: boolean;
  11636. /** Defines the default width of a cell in the spritesheet */
  11637. cellWidth: number;
  11638. /** Defines the default height of a cell in the spritesheet */
  11639. cellHeight: number;
  11640. /** Associative array from JSON sprite data file */
  11641. private _cellData;
  11642. /** Array of sprite names from JSON sprite data file */
  11643. private _spriteMap;
  11644. /** True when packed cell data from JSON file is ready*/
  11645. private _packedAndReady;
  11646. /**
  11647. * An event triggered when the manager is disposed.
  11648. */
  11649. onDisposeObservable: Observable<SpriteManager>;
  11650. private _onDisposeObserver;
  11651. /**
  11652. * Callback called when the manager is disposed
  11653. */
  11654. onDispose: () => void;
  11655. private _capacity;
  11656. private _fromPacked;
  11657. private _spriteTexture;
  11658. private _epsilon;
  11659. private _scene;
  11660. private _vertexData;
  11661. private _buffer;
  11662. private _vertexBuffers;
  11663. private _indexBuffer;
  11664. private _effectBase;
  11665. private _effectFog;
  11666. /**
  11667. * Gets or sets the spritesheet texture
  11668. */
  11669. texture: Texture;
  11670. /**
  11671. * Creates a new sprite manager
  11672. * @param name defines the manager's name
  11673. * @param imgUrl defines the sprite sheet url
  11674. * @param capacity defines the maximum allowed number of sprites
  11675. * @param cellSize defines the size of a sprite cell
  11676. * @param scene defines the hosting scene
  11677. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11678. * @param samplingMode defines the smapling mode to use with spritesheet
  11679. * @param fromPacked set to false; do not alter
  11680. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11681. */
  11682. constructor(
  11683. /** defines the manager's name */
  11684. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11685. private _makePacked;
  11686. private _appendSpriteVertex;
  11687. /**
  11688. * Intersects the sprites with a ray
  11689. * @param ray defines the ray to intersect with
  11690. * @param camera defines the current active camera
  11691. * @param predicate defines a predicate used to select candidate sprites
  11692. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11693. * @returns null if no hit or a PickingInfo
  11694. */
  11695. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11696. /**
  11697. * Intersects the sprites with a ray
  11698. * @param ray defines the ray to intersect with
  11699. * @param camera defines the current active camera
  11700. * @param predicate defines a predicate used to select candidate sprites
  11701. * @returns null if no hit or a PickingInfo array
  11702. */
  11703. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11704. /**
  11705. * Render all child sprites
  11706. */
  11707. render(): void;
  11708. /**
  11709. * Release associated resources
  11710. */
  11711. dispose(): void;
  11712. }
  11713. }
  11714. declare module "babylonjs/Sprites/sprite" {
  11715. import { Vector3 } from "babylonjs/Maths/math.vector";
  11716. import { Nullable } from "babylonjs/types";
  11717. import { ActionManager } from "babylonjs/Actions/actionManager";
  11718. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11719. import { Color4 } from "babylonjs/Maths/math.color";
  11720. /**
  11721. * Class used to represent a sprite
  11722. * @see http://doc.babylonjs.com/babylon101/sprites
  11723. */
  11724. export class Sprite {
  11725. /** defines the name */
  11726. name: string;
  11727. /** Gets or sets the current world position */
  11728. position: Vector3;
  11729. /** Gets or sets the main color */
  11730. color: Color4;
  11731. /** Gets or sets the width */
  11732. width: number;
  11733. /** Gets or sets the height */
  11734. height: number;
  11735. /** Gets or sets rotation angle */
  11736. angle: number;
  11737. /** Gets or sets the cell index in the sprite sheet */
  11738. cellIndex: number;
  11739. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11740. cellRef: string;
  11741. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11742. invertU: number;
  11743. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11744. invertV: number;
  11745. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11746. disposeWhenFinishedAnimating: boolean;
  11747. /** Gets the list of attached animations */
  11748. animations: Animation[];
  11749. /** Gets or sets a boolean indicating if the sprite can be picked */
  11750. isPickable: boolean;
  11751. /**
  11752. * Gets or sets the associated action manager
  11753. */
  11754. actionManager: Nullable<ActionManager>;
  11755. private _animationStarted;
  11756. private _loopAnimation;
  11757. private _fromIndex;
  11758. private _toIndex;
  11759. private _delay;
  11760. private _direction;
  11761. private _manager;
  11762. private _time;
  11763. private _onAnimationEnd;
  11764. /**
  11765. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11766. */
  11767. isVisible: boolean;
  11768. /**
  11769. * Gets or sets the sprite size
  11770. */
  11771. size: number;
  11772. /**
  11773. * Creates a new Sprite
  11774. * @param name defines the name
  11775. * @param manager defines the manager
  11776. */
  11777. constructor(
  11778. /** defines the name */
  11779. name: string, manager: ISpriteManager);
  11780. /**
  11781. * Starts an animation
  11782. * @param from defines the initial key
  11783. * @param to defines the end key
  11784. * @param loop defines if the animation must loop
  11785. * @param delay defines the start delay (in ms)
  11786. * @param onAnimationEnd defines a callback to call when animation ends
  11787. */
  11788. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11789. /** Stops current animation (if any) */
  11790. stopAnimation(): void;
  11791. /** @hidden */
  11792. _animate(deltaTime: number): void;
  11793. /** Release associated resources */
  11794. dispose(): void;
  11795. }
  11796. }
  11797. declare module "babylonjs/Collisions/pickingInfo" {
  11798. import { Nullable } from "babylonjs/types";
  11799. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11801. import { Sprite } from "babylonjs/Sprites/sprite";
  11802. import { Ray } from "babylonjs/Culling/ray";
  11803. /**
  11804. * Information about the result of picking within a scene
  11805. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11806. */
  11807. export class PickingInfo {
  11808. /** @hidden */
  11809. _pickingUnavailable: boolean;
  11810. /**
  11811. * If the pick collided with an object
  11812. */
  11813. hit: boolean;
  11814. /**
  11815. * Distance away where the pick collided
  11816. */
  11817. distance: number;
  11818. /**
  11819. * The location of pick collision
  11820. */
  11821. pickedPoint: Nullable<Vector3>;
  11822. /**
  11823. * The mesh corresponding the the pick collision
  11824. */
  11825. pickedMesh: Nullable<AbstractMesh>;
  11826. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11827. bu: number;
  11828. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11829. bv: number;
  11830. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11831. faceId: number;
  11832. /** Id of the the submesh that was picked */
  11833. subMeshId: number;
  11834. /** If a sprite was picked, this will be the sprite the pick collided with */
  11835. pickedSprite: Nullable<Sprite>;
  11836. /**
  11837. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11838. */
  11839. originMesh: Nullable<AbstractMesh>;
  11840. /**
  11841. * The ray that was used to perform the picking.
  11842. */
  11843. ray: Nullable<Ray>;
  11844. /**
  11845. * Gets the normal correspodning to the face the pick collided with
  11846. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11847. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11848. * @returns The normal correspodning to the face the pick collided with
  11849. */
  11850. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11851. /**
  11852. * Gets the texture coordinates of where the pick occured
  11853. * @returns the vector containing the coordnates of the texture
  11854. */
  11855. getTextureCoordinates(): Nullable<Vector2>;
  11856. }
  11857. }
  11858. declare module "babylonjs/Events/pointerEvents" {
  11859. import { Nullable } from "babylonjs/types";
  11860. import { Vector2 } from "babylonjs/Maths/math.vector";
  11861. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11862. import { Ray } from "babylonjs/Culling/ray";
  11863. /**
  11864. * Gather the list of pointer event types as constants.
  11865. */
  11866. export class PointerEventTypes {
  11867. /**
  11868. * 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.
  11869. */
  11870. static readonly POINTERDOWN: number;
  11871. /**
  11872. * The pointerup event is fired when a pointer is no longer active.
  11873. */
  11874. static readonly POINTERUP: number;
  11875. /**
  11876. * The pointermove event is fired when a pointer changes coordinates.
  11877. */
  11878. static readonly POINTERMOVE: number;
  11879. /**
  11880. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11881. */
  11882. static readonly POINTERWHEEL: number;
  11883. /**
  11884. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11885. */
  11886. static readonly POINTERPICK: number;
  11887. /**
  11888. * The pointertap event is fired when a the object has been touched and released without drag.
  11889. */
  11890. static readonly POINTERTAP: number;
  11891. /**
  11892. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11893. */
  11894. static readonly POINTERDOUBLETAP: number;
  11895. }
  11896. /**
  11897. * Base class of pointer info types.
  11898. */
  11899. export class PointerInfoBase {
  11900. /**
  11901. * Defines the type of event (PointerEventTypes)
  11902. */
  11903. type: number;
  11904. /**
  11905. * Defines the related dom event
  11906. */
  11907. event: PointerEvent | MouseWheelEvent;
  11908. /**
  11909. * Instantiates the base class of pointers info.
  11910. * @param type Defines the type of event (PointerEventTypes)
  11911. * @param event Defines the related dom event
  11912. */
  11913. constructor(
  11914. /**
  11915. * Defines the type of event (PointerEventTypes)
  11916. */
  11917. type: number,
  11918. /**
  11919. * Defines the related dom event
  11920. */
  11921. event: PointerEvent | MouseWheelEvent);
  11922. }
  11923. /**
  11924. * This class is used to store pointer related info for the onPrePointerObservable event.
  11925. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11926. */
  11927. export class PointerInfoPre extends PointerInfoBase {
  11928. /**
  11929. * Ray from a pointer if availible (eg. 6dof controller)
  11930. */
  11931. ray: Nullable<Ray>;
  11932. /**
  11933. * Defines the local position of the pointer on the canvas.
  11934. */
  11935. localPosition: Vector2;
  11936. /**
  11937. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11938. */
  11939. skipOnPointerObservable: boolean;
  11940. /**
  11941. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11942. * @param type Defines the type of event (PointerEventTypes)
  11943. * @param event Defines the related dom event
  11944. * @param localX Defines the local x coordinates of the pointer when the event occured
  11945. * @param localY Defines the local y coordinates of the pointer when the event occured
  11946. */
  11947. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11948. }
  11949. /**
  11950. * This type contains all the data related to a pointer event in Babylon.js.
  11951. * 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.
  11952. */
  11953. export class PointerInfo extends PointerInfoBase {
  11954. /**
  11955. * Defines the picking info associated to the info (if any)\
  11956. */
  11957. pickInfo: Nullable<PickingInfo>;
  11958. /**
  11959. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11960. * @param type Defines the type of event (PointerEventTypes)
  11961. * @param event Defines the related dom event
  11962. * @param pickInfo Defines the picking info associated to the info (if any)\
  11963. */
  11964. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11965. /**
  11966. * Defines the picking info associated to the info (if any)\
  11967. */
  11968. pickInfo: Nullable<PickingInfo>);
  11969. }
  11970. /**
  11971. * Data relating to a touch event on the screen.
  11972. */
  11973. export interface PointerTouch {
  11974. /**
  11975. * X coordinate of touch.
  11976. */
  11977. x: number;
  11978. /**
  11979. * Y coordinate of touch.
  11980. */
  11981. y: number;
  11982. /**
  11983. * Id of touch. Unique for each finger.
  11984. */
  11985. pointerId: number;
  11986. /**
  11987. * Event type passed from DOM.
  11988. */
  11989. type: any;
  11990. }
  11991. }
  11992. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11993. import { Observable } from "babylonjs/Misc/observable";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11997. /**
  11998. * Manage the mouse inputs to control the movement of a free camera.
  11999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12000. */
  12001. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12002. /**
  12003. * Define if touch is enabled in the mouse input
  12004. */
  12005. touchEnabled: boolean;
  12006. /**
  12007. * Defines the camera the input is attached to.
  12008. */
  12009. camera: FreeCamera;
  12010. /**
  12011. * Defines the buttons associated with the input to handle camera move.
  12012. */
  12013. buttons: number[];
  12014. /**
  12015. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12016. */
  12017. angularSensibility: number;
  12018. private _pointerInput;
  12019. private _onMouseMove;
  12020. private _observer;
  12021. private previousPosition;
  12022. /**
  12023. * Observable for when a pointer move event occurs containing the move offset
  12024. */
  12025. onPointerMovedObservable: Observable<{
  12026. offsetX: number;
  12027. offsetY: number;
  12028. }>;
  12029. /**
  12030. * @hidden
  12031. * If the camera should be rotated automatically based on pointer movement
  12032. */
  12033. _allowCameraRotation: boolean;
  12034. /**
  12035. * Manage the mouse inputs to control the movement of a free camera.
  12036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12037. * @param touchEnabled Defines if touch is enabled or not
  12038. */
  12039. constructor(
  12040. /**
  12041. * Define if touch is enabled in the mouse input
  12042. */
  12043. touchEnabled?: boolean);
  12044. /**
  12045. * Attach the input controls to a specific dom element to get the input from.
  12046. * @param element Defines the element the controls should be listened from
  12047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12048. */
  12049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12050. /**
  12051. * Called on JS contextmenu event.
  12052. * Override this method to provide functionality.
  12053. */
  12054. protected onContextMenu(evt: PointerEvent): void;
  12055. /**
  12056. * Detach the current controls from the specified dom element.
  12057. * @param element Defines the element to stop listening the inputs from
  12058. */
  12059. detachControl(element: Nullable<HTMLElement>): void;
  12060. /**
  12061. * Gets the class name of the current intput.
  12062. * @returns the class name
  12063. */
  12064. getClassName(): string;
  12065. /**
  12066. * Get the friendly name associated with the input class.
  12067. * @returns the input friendly name
  12068. */
  12069. getSimpleName(): string;
  12070. }
  12071. }
  12072. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12073. import { Nullable } from "babylonjs/types";
  12074. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12075. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12076. /**
  12077. * Manage the touch inputs to control the movement of a free camera.
  12078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12079. */
  12080. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12081. /**
  12082. * Defines the camera the input is attached to.
  12083. */
  12084. camera: FreeCamera;
  12085. /**
  12086. * Defines the touch sensibility for rotation.
  12087. * The higher the faster.
  12088. */
  12089. touchAngularSensibility: number;
  12090. /**
  12091. * Defines the touch sensibility for move.
  12092. * The higher the faster.
  12093. */
  12094. touchMoveSensibility: number;
  12095. private _offsetX;
  12096. private _offsetY;
  12097. private _pointerPressed;
  12098. private _pointerInput;
  12099. private _observer;
  12100. private _onLostFocus;
  12101. /**
  12102. * Attach the input controls to a specific dom element to get the input from.
  12103. * @param element Defines the element the controls should be listened from
  12104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12105. */
  12106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12107. /**
  12108. * Detach the current controls from the specified dom element.
  12109. * @param element Defines the element to stop listening the inputs from
  12110. */
  12111. detachControl(element: Nullable<HTMLElement>): void;
  12112. /**
  12113. * Update the current camera state depending on the inputs that have been used this frame.
  12114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12115. */
  12116. checkInputs(): void;
  12117. /**
  12118. * Gets the class name of the current intput.
  12119. * @returns the class name
  12120. */
  12121. getClassName(): string;
  12122. /**
  12123. * Get the friendly name associated with the input class.
  12124. * @returns the input friendly name
  12125. */
  12126. getSimpleName(): string;
  12127. }
  12128. }
  12129. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12130. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12131. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12132. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12133. import { Nullable } from "babylonjs/types";
  12134. /**
  12135. * Default Inputs manager for the FreeCamera.
  12136. * It groups all the default supported inputs for ease of use.
  12137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12138. */
  12139. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12140. /**
  12141. * @hidden
  12142. */
  12143. _mouseInput: Nullable<FreeCameraMouseInput>;
  12144. /**
  12145. * Instantiates a new FreeCameraInputsManager.
  12146. * @param camera Defines the camera the inputs belong to
  12147. */
  12148. constructor(camera: FreeCamera);
  12149. /**
  12150. * Add keyboard input support to the input manager.
  12151. * @returns the current input manager
  12152. */
  12153. addKeyboard(): FreeCameraInputsManager;
  12154. /**
  12155. * Add mouse input support to the input manager.
  12156. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12157. * @returns the current input manager
  12158. */
  12159. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12160. /**
  12161. * Removes the mouse input support from the manager
  12162. * @returns the current input manager
  12163. */
  12164. removeMouse(): FreeCameraInputsManager;
  12165. /**
  12166. * Add touch input support to the input manager.
  12167. * @returns the current input manager
  12168. */
  12169. addTouch(): FreeCameraInputsManager;
  12170. /**
  12171. * Remove all attached input methods from a camera
  12172. */
  12173. clear(): void;
  12174. }
  12175. }
  12176. declare module "babylonjs/Cameras/freeCamera" {
  12177. import { Vector3 } from "babylonjs/Maths/math.vector";
  12178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12179. import { Scene } from "babylonjs/scene";
  12180. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12181. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12182. /**
  12183. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12184. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12185. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12186. */
  12187. export class FreeCamera extends TargetCamera {
  12188. /**
  12189. * Define the collision ellipsoid of the camera.
  12190. * This is helpful to simulate a camera body like the player body around the camera
  12191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12192. */
  12193. ellipsoid: Vector3;
  12194. /**
  12195. * Define an offset for the position of the ellipsoid around the camera.
  12196. * This can be helpful to determine the center of the body near the gravity center of the body
  12197. * instead of its head.
  12198. */
  12199. ellipsoidOffset: Vector3;
  12200. /**
  12201. * Enable or disable collisions of the camera with the rest of the scene objects.
  12202. */
  12203. checkCollisions: boolean;
  12204. /**
  12205. * Enable or disable gravity on the camera.
  12206. */
  12207. applyGravity: boolean;
  12208. /**
  12209. * Define the input manager associated to the camera.
  12210. */
  12211. inputs: FreeCameraInputsManager;
  12212. /**
  12213. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12214. * Higher values reduce sensitivity.
  12215. */
  12216. /**
  12217. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12218. * Higher values reduce sensitivity.
  12219. */
  12220. angularSensibility: number;
  12221. /**
  12222. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12223. */
  12224. keysUp: number[];
  12225. /**
  12226. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12227. */
  12228. keysDown: number[];
  12229. /**
  12230. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12231. */
  12232. keysLeft: number[];
  12233. /**
  12234. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12235. */
  12236. keysRight: number[];
  12237. /**
  12238. * Event raised when the camera collide with a mesh in the scene.
  12239. */
  12240. onCollide: (collidedMesh: AbstractMesh) => void;
  12241. private _collider;
  12242. private _needMoveForGravity;
  12243. private _oldPosition;
  12244. private _diffPosition;
  12245. private _newPosition;
  12246. /** @hidden */
  12247. _localDirection: Vector3;
  12248. /** @hidden */
  12249. _transformedDirection: Vector3;
  12250. /**
  12251. * Instantiates a Free Camera.
  12252. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12253. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12255. * @param name Define the name of the camera in the scene
  12256. * @param position Define the start position of the camera in the scene
  12257. * @param scene Define the scene the camera belongs to
  12258. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12259. */
  12260. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12261. /**
  12262. * Attached controls to the current camera.
  12263. * @param element Defines the element the controls should be listened from
  12264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12265. */
  12266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12267. /**
  12268. * Detach the current controls from the camera.
  12269. * The camera will stop reacting to inputs.
  12270. * @param element Defines the element to stop listening the inputs from
  12271. */
  12272. detachControl(element: HTMLElement): void;
  12273. private _collisionMask;
  12274. /**
  12275. * Define a collision mask to limit the list of object the camera can collide with
  12276. */
  12277. collisionMask: number;
  12278. /** @hidden */
  12279. _collideWithWorld(displacement: Vector3): void;
  12280. private _onCollisionPositionChange;
  12281. /** @hidden */
  12282. _checkInputs(): void;
  12283. /** @hidden */
  12284. _decideIfNeedsToMove(): boolean;
  12285. /** @hidden */
  12286. _updatePosition(): void;
  12287. /**
  12288. * Destroy the camera and release the current resources hold by it.
  12289. */
  12290. dispose(): void;
  12291. /**
  12292. * Gets the current object class name.
  12293. * @return the class name
  12294. */
  12295. getClassName(): string;
  12296. }
  12297. }
  12298. declare module "babylonjs/Gamepads/gamepad" {
  12299. import { Observable } from "babylonjs/Misc/observable";
  12300. /**
  12301. * Represents a gamepad control stick position
  12302. */
  12303. export class StickValues {
  12304. /**
  12305. * The x component of the control stick
  12306. */
  12307. x: number;
  12308. /**
  12309. * The y component of the control stick
  12310. */
  12311. y: number;
  12312. /**
  12313. * Initializes the gamepad x and y control stick values
  12314. * @param x The x component of the gamepad control stick value
  12315. * @param y The y component of the gamepad control stick value
  12316. */
  12317. constructor(
  12318. /**
  12319. * The x component of the control stick
  12320. */
  12321. x: number,
  12322. /**
  12323. * The y component of the control stick
  12324. */
  12325. y: number);
  12326. }
  12327. /**
  12328. * An interface which manages callbacks for gamepad button changes
  12329. */
  12330. export interface GamepadButtonChanges {
  12331. /**
  12332. * Called when a gamepad has been changed
  12333. */
  12334. changed: boolean;
  12335. /**
  12336. * Called when a gamepad press event has been triggered
  12337. */
  12338. pressChanged: boolean;
  12339. /**
  12340. * Called when a touch event has been triggered
  12341. */
  12342. touchChanged: boolean;
  12343. /**
  12344. * Called when a value has changed
  12345. */
  12346. valueChanged: boolean;
  12347. }
  12348. /**
  12349. * Represents a gamepad
  12350. */
  12351. export class Gamepad {
  12352. /**
  12353. * The id of the gamepad
  12354. */
  12355. id: string;
  12356. /**
  12357. * The index of the gamepad
  12358. */
  12359. index: number;
  12360. /**
  12361. * The browser gamepad
  12362. */
  12363. browserGamepad: any;
  12364. /**
  12365. * Specifies what type of gamepad this represents
  12366. */
  12367. type: number;
  12368. private _leftStick;
  12369. private _rightStick;
  12370. /** @hidden */
  12371. _isConnected: boolean;
  12372. private _leftStickAxisX;
  12373. private _leftStickAxisY;
  12374. private _rightStickAxisX;
  12375. private _rightStickAxisY;
  12376. /**
  12377. * Triggered when the left control stick has been changed
  12378. */
  12379. private _onleftstickchanged;
  12380. /**
  12381. * Triggered when the right control stick has been changed
  12382. */
  12383. private _onrightstickchanged;
  12384. /**
  12385. * Represents a gamepad controller
  12386. */
  12387. static GAMEPAD: number;
  12388. /**
  12389. * Represents a generic controller
  12390. */
  12391. static GENERIC: number;
  12392. /**
  12393. * Represents an XBox controller
  12394. */
  12395. static XBOX: number;
  12396. /**
  12397. * Represents a pose-enabled controller
  12398. */
  12399. static POSE_ENABLED: number;
  12400. /**
  12401. * Represents an Dual Shock controller
  12402. */
  12403. static DUALSHOCK: number;
  12404. /**
  12405. * Specifies whether the left control stick should be Y-inverted
  12406. */
  12407. protected _invertLeftStickY: boolean;
  12408. /**
  12409. * Specifies if the gamepad has been connected
  12410. */
  12411. readonly isConnected: boolean;
  12412. /**
  12413. * Initializes the gamepad
  12414. * @param id The id of the gamepad
  12415. * @param index The index of the gamepad
  12416. * @param browserGamepad The browser gamepad
  12417. * @param leftStickX The x component of the left joystick
  12418. * @param leftStickY The y component of the left joystick
  12419. * @param rightStickX The x component of the right joystick
  12420. * @param rightStickY The y component of the right joystick
  12421. */
  12422. constructor(
  12423. /**
  12424. * The id of the gamepad
  12425. */
  12426. id: string,
  12427. /**
  12428. * The index of the gamepad
  12429. */
  12430. index: number,
  12431. /**
  12432. * The browser gamepad
  12433. */
  12434. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12435. /**
  12436. * Callback triggered when the left joystick has changed
  12437. * @param callback
  12438. */
  12439. onleftstickchanged(callback: (values: StickValues) => void): void;
  12440. /**
  12441. * Callback triggered when the right joystick has changed
  12442. * @param callback
  12443. */
  12444. onrightstickchanged(callback: (values: StickValues) => void): void;
  12445. /**
  12446. * Gets the left joystick
  12447. */
  12448. /**
  12449. * Sets the left joystick values
  12450. */
  12451. leftStick: StickValues;
  12452. /**
  12453. * Gets the right joystick
  12454. */
  12455. /**
  12456. * Sets the right joystick value
  12457. */
  12458. rightStick: StickValues;
  12459. /**
  12460. * Updates the gamepad joystick positions
  12461. */
  12462. update(): void;
  12463. /**
  12464. * Disposes the gamepad
  12465. */
  12466. dispose(): void;
  12467. }
  12468. /**
  12469. * Represents a generic gamepad
  12470. */
  12471. export class GenericPad extends Gamepad {
  12472. private _buttons;
  12473. private _onbuttondown;
  12474. private _onbuttonup;
  12475. /**
  12476. * Observable triggered when a button has been pressed
  12477. */
  12478. onButtonDownObservable: Observable<number>;
  12479. /**
  12480. * Observable triggered when a button has been released
  12481. */
  12482. onButtonUpObservable: Observable<number>;
  12483. /**
  12484. * Callback triggered when a button has been pressed
  12485. * @param callback Called when a button has been pressed
  12486. */
  12487. onbuttondown(callback: (buttonPressed: number) => void): void;
  12488. /**
  12489. * Callback triggered when a button has been released
  12490. * @param callback Called when a button has been released
  12491. */
  12492. onbuttonup(callback: (buttonReleased: number) => void): void;
  12493. /**
  12494. * Initializes the generic gamepad
  12495. * @param id The id of the generic gamepad
  12496. * @param index The index of the generic gamepad
  12497. * @param browserGamepad The browser gamepad
  12498. */
  12499. constructor(id: string, index: number, browserGamepad: any);
  12500. private _setButtonValue;
  12501. /**
  12502. * Updates the generic gamepad
  12503. */
  12504. update(): void;
  12505. /**
  12506. * Disposes the generic gamepad
  12507. */
  12508. dispose(): void;
  12509. }
  12510. }
  12511. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12512. import { Nullable } from "babylonjs/types";
  12513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12514. import { Scene } from "babylonjs/scene";
  12515. module "babylonjs/Engines/engine" {
  12516. interface Engine {
  12517. /**
  12518. * Creates a raw texture
  12519. * @param data defines the data to store in the texture
  12520. * @param width defines the width of the texture
  12521. * @param height defines the height of the texture
  12522. * @param format defines the format of the data
  12523. * @param generateMipMaps defines if the engine should generate the mip levels
  12524. * @param invertY defines if data must be stored with Y axis inverted
  12525. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12526. * @param compression defines the compression used (null by default)
  12527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12528. * @returns the raw texture inside an InternalTexture
  12529. */
  12530. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12531. /**
  12532. * Update a raw texture
  12533. * @param texture defines the texture to update
  12534. * @param data defines the data to store in the texture
  12535. * @param format defines the format of the data
  12536. * @param invertY defines if data must be stored with Y axis inverted
  12537. */
  12538. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12539. /**
  12540. * Update a raw texture
  12541. * @param texture defines the texture to update
  12542. * @param data defines the data to store in the texture
  12543. * @param format defines the format of the data
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12547. */
  12548. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12549. /**
  12550. * Creates a new raw cube texture
  12551. * @param data defines the array of data to use to create each face
  12552. * @param size defines the size of the textures
  12553. * @param format defines the format of the data
  12554. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12555. * @param generateMipMaps defines if the engine should generate the mip levels
  12556. * @param invertY defines if data must be stored with Y axis inverted
  12557. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12558. * @param compression defines the compression used (null by default)
  12559. * @returns the cube texture as an InternalTexture
  12560. */
  12561. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12562. /**
  12563. * Update a raw cube texture
  12564. * @param texture defines the texture to udpdate
  12565. * @param data defines the data to store
  12566. * @param format defines the data format
  12567. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12568. * @param invertY defines if data must be stored with Y axis inverted
  12569. */
  12570. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12571. /**
  12572. * Update a raw cube texture
  12573. * @param texture defines the texture to udpdate
  12574. * @param data defines the data to store
  12575. * @param format defines the data format
  12576. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12577. * @param invertY defines if data must be stored with Y axis inverted
  12578. * @param compression defines the compression used (null by default)
  12579. */
  12580. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12581. /**
  12582. * Update a raw cube texture
  12583. * @param texture defines the texture to udpdate
  12584. * @param data defines the data to store
  12585. * @param format defines the data format
  12586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param compression defines the compression used (null by default)
  12589. * @param level defines which level of the texture to update
  12590. */
  12591. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12592. /**
  12593. * Creates a new raw cube texture from a specified url
  12594. * @param url defines the url where the data is located
  12595. * @param scene defines the current scene
  12596. * @param size defines the size of the textures
  12597. * @param format defines the format of the data
  12598. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12599. * @param noMipmap defines if the engine should avoid generating the mip levels
  12600. * @param callback defines a callback used to extract texture data from loaded data
  12601. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12602. * @param onLoad defines a callback called when texture is loaded
  12603. * @param onError defines a callback called if there is an error
  12604. * @returns the cube texture as an InternalTexture
  12605. */
  12606. 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;
  12607. /**
  12608. * Creates a new raw cube texture from a specified url
  12609. * @param url defines the url where the data is located
  12610. * @param scene defines the current scene
  12611. * @param size defines the size of the textures
  12612. * @param format defines the format of the data
  12613. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12614. * @param noMipmap defines if the engine should avoid generating the mip levels
  12615. * @param callback defines a callback used to extract texture data from loaded data
  12616. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12617. * @param onLoad defines a callback called when texture is loaded
  12618. * @param onError defines a callback called if there is an error
  12619. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12620. * @param invertY defines if data must be stored with Y axis inverted
  12621. * @returns the cube texture as an InternalTexture
  12622. */
  12623. 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;
  12624. /**
  12625. * Creates a new raw 3D texture
  12626. * @param data defines the data used to create the texture
  12627. * @param width defines the width of the texture
  12628. * @param height defines the height of the texture
  12629. * @param depth defines the depth of the texture
  12630. * @param format defines the format of the texture
  12631. * @param generateMipMaps defines if the engine must generate mip levels
  12632. * @param invertY defines if data must be stored with Y axis inverted
  12633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12634. * @param compression defines the compressed used (can be null)
  12635. * @param textureType defines the compressed used (can be null)
  12636. * @returns a new raw 3D texture (stored in an InternalTexture)
  12637. */
  12638. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12639. /**
  12640. * Update a raw 3D texture
  12641. * @param texture defines the texture to update
  12642. * @param data defines the data to store
  12643. * @param format defines the data format
  12644. * @param invertY defines if data must be stored with Y axis inverted
  12645. */
  12646. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12647. /**
  12648. * Update a raw 3D texture
  12649. * @param texture defines the texture to update
  12650. * @param data defines the data to store
  12651. * @param format defines the data format
  12652. * @param invertY defines if data must be stored with Y axis inverted
  12653. * @param compression defines the used compression (can be null)
  12654. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12655. */
  12656. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12657. }
  12658. }
  12659. }
  12660. declare module "babylonjs/Materials/Textures/rawTexture" {
  12661. import { Scene } from "babylonjs/scene";
  12662. import { Texture } from "babylonjs/Materials/Textures/texture";
  12663. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12664. /**
  12665. * Raw texture can help creating a texture directly from an array of data.
  12666. * This can be super useful if you either get the data from an uncompressed source or
  12667. * if you wish to create your texture pixel by pixel.
  12668. */
  12669. export class RawTexture extends Texture {
  12670. /**
  12671. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12672. */
  12673. format: number;
  12674. private _engine;
  12675. /**
  12676. * Instantiates a new RawTexture.
  12677. * Raw texture can help creating a texture directly from an array of data.
  12678. * This can be super useful if you either get the data from an uncompressed source or
  12679. * if you wish to create your texture pixel by pixel.
  12680. * @param data define the array of data to use to create the texture
  12681. * @param width define the width of the texture
  12682. * @param height define the height of the texture
  12683. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12684. * @param scene define the scene the texture belongs to
  12685. * @param generateMipMaps define whether mip maps should be generated or not
  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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12689. */
  12690. constructor(data: ArrayBufferView, width: number, height: number,
  12691. /**
  12692. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12693. */
  12694. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12695. /**
  12696. * Updates the texture underlying data.
  12697. * @param data Define the new data of the texture
  12698. */
  12699. update(data: ArrayBufferView): void;
  12700. /**
  12701. * Creates a luminance texture from some data.
  12702. * @param data Define the texture data
  12703. * @param width Define the width of the texture
  12704. * @param height Define the height of the texture
  12705. * @param scene Define the scene the texture belongs to
  12706. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12707. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12708. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12709. * @returns the luminance texture
  12710. */
  12711. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12712. /**
  12713. * Creates a luminance alpha texture from some data.
  12714. * @param data Define the texture data
  12715. * @param width Define the width of the texture
  12716. * @param height Define the height of the texture
  12717. * @param scene Define the scene the texture belongs to
  12718. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12719. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12720. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12721. * @returns the luminance alpha texture
  12722. */
  12723. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12724. /**
  12725. * Creates an alpha texture from some data.
  12726. * @param data Define the texture data
  12727. * @param width Define the width of the texture
  12728. * @param height Define the height of the texture
  12729. * @param scene Define the scene the texture belongs to
  12730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12733. * @returns the alpha texture
  12734. */
  12735. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12736. /**
  12737. * Creates a RGB texture from some data.
  12738. * @param data Define the texture data
  12739. * @param width Define the width of the texture
  12740. * @param height Define the height of the texture
  12741. * @param scene Define the scene the texture belongs to
  12742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12745. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12746. * @returns the RGB alpha texture
  12747. */
  12748. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12749. /**
  12750. * Creates a RGBA texture from some data.
  12751. * @param data Define the texture data
  12752. * @param width Define the width of the texture
  12753. * @param height Define the height of the texture
  12754. * @param scene Define the scene the texture belongs to
  12755. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12756. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12757. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12758. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12759. * @returns the RGBA texture
  12760. */
  12761. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12762. /**
  12763. * Creates a R texture from some data.
  12764. * @param data Define the texture data
  12765. * @param width Define the width of the texture
  12766. * @param height Define the height of the texture
  12767. * @param scene Define the scene the texture belongs to
  12768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12771. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12772. * @returns the R texture
  12773. */
  12774. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12775. }
  12776. }
  12777. declare module "babylonjs/Maths/math.size" {
  12778. /**
  12779. * Interface for the size containing width and height
  12780. */
  12781. export interface ISize {
  12782. /**
  12783. * Width
  12784. */
  12785. width: number;
  12786. /**
  12787. * Heighht
  12788. */
  12789. height: number;
  12790. }
  12791. /**
  12792. * Size containing widht and height
  12793. */
  12794. export class Size implements ISize {
  12795. /**
  12796. * Width
  12797. */
  12798. width: number;
  12799. /**
  12800. * Height
  12801. */
  12802. height: number;
  12803. /**
  12804. * Creates a Size object from the given width and height (floats).
  12805. * @param width width of the new size
  12806. * @param height height of the new size
  12807. */
  12808. constructor(width: number, height: number);
  12809. /**
  12810. * Returns a string with the Size width and height
  12811. * @returns a string with the Size width and height
  12812. */
  12813. toString(): string;
  12814. /**
  12815. * "Size"
  12816. * @returns the string "Size"
  12817. */
  12818. getClassName(): string;
  12819. /**
  12820. * Returns the Size hash code.
  12821. * @returns a hash code for a unique width and height
  12822. */
  12823. getHashCode(): number;
  12824. /**
  12825. * Updates the current size from the given one.
  12826. * @param src the given size
  12827. */
  12828. copyFrom(src: Size): void;
  12829. /**
  12830. * Updates in place the current Size from the given floats.
  12831. * @param width width of the new size
  12832. * @param height height of the new size
  12833. * @returns the updated Size.
  12834. */
  12835. copyFromFloats(width: number, height: number): Size;
  12836. /**
  12837. * Updates in place the current Size from the given floats.
  12838. * @param width width to set
  12839. * @param height height to set
  12840. * @returns the updated Size.
  12841. */
  12842. set(width: number, height: number): Size;
  12843. /**
  12844. * Multiplies the width and height by numbers
  12845. * @param w factor to multiple the width by
  12846. * @param h factor to multiple the height by
  12847. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12848. */
  12849. multiplyByFloats(w: number, h: number): Size;
  12850. /**
  12851. * Clones the size
  12852. * @returns a new Size copied from the given one.
  12853. */
  12854. clone(): Size;
  12855. /**
  12856. * True if the current Size and the given one width and height are strictly equal.
  12857. * @param other the other size to compare against
  12858. * @returns True if the current Size and the given one width and height are strictly equal.
  12859. */
  12860. equals(other: Size): boolean;
  12861. /**
  12862. * The surface of the Size : width * height (float).
  12863. */
  12864. readonly surface: number;
  12865. /**
  12866. * Create a new size of zero
  12867. * @returns a new Size set to (0.0, 0.0)
  12868. */
  12869. static Zero(): Size;
  12870. /**
  12871. * Sums the width and height of two sizes
  12872. * @param otherSize size to add to this size
  12873. * @returns a new Size set as the addition result of the current Size and the given one.
  12874. */
  12875. add(otherSize: Size): Size;
  12876. /**
  12877. * Subtracts the width and height of two
  12878. * @param otherSize size to subtract to this size
  12879. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12880. */
  12881. subtract(otherSize: Size): Size;
  12882. /**
  12883. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12884. * @param start starting size to lerp between
  12885. * @param end end size to lerp between
  12886. * @param amount amount to lerp between the start and end values
  12887. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12888. */
  12889. static Lerp(start: Size, end: Size, amount: number): Size;
  12890. }
  12891. }
  12892. declare module "babylonjs/Animations/runtimeAnimation" {
  12893. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12894. import { Animatable } from "babylonjs/Animations/animatable";
  12895. import { Scene } from "babylonjs/scene";
  12896. /**
  12897. * Defines a runtime animation
  12898. */
  12899. export class RuntimeAnimation {
  12900. private _events;
  12901. /**
  12902. * The current frame of the runtime animation
  12903. */
  12904. private _currentFrame;
  12905. /**
  12906. * The animation used by the runtime animation
  12907. */
  12908. private _animation;
  12909. /**
  12910. * The target of the runtime animation
  12911. */
  12912. private _target;
  12913. /**
  12914. * The initiating animatable
  12915. */
  12916. private _host;
  12917. /**
  12918. * The original value of the runtime animation
  12919. */
  12920. private _originalValue;
  12921. /**
  12922. * The original blend value of the runtime animation
  12923. */
  12924. private _originalBlendValue;
  12925. /**
  12926. * The offsets cache of the runtime animation
  12927. */
  12928. private _offsetsCache;
  12929. /**
  12930. * The high limits cache of the runtime animation
  12931. */
  12932. private _highLimitsCache;
  12933. /**
  12934. * Specifies if the runtime animation has been stopped
  12935. */
  12936. private _stopped;
  12937. /**
  12938. * The blending factor of the runtime animation
  12939. */
  12940. private _blendingFactor;
  12941. /**
  12942. * The BabylonJS scene
  12943. */
  12944. private _scene;
  12945. /**
  12946. * The current value of the runtime animation
  12947. */
  12948. private _currentValue;
  12949. /** @hidden */
  12950. _animationState: _IAnimationState;
  12951. /**
  12952. * The active target of the runtime animation
  12953. */
  12954. private _activeTargets;
  12955. private _currentActiveTarget;
  12956. private _directTarget;
  12957. /**
  12958. * The target path of the runtime animation
  12959. */
  12960. private _targetPath;
  12961. /**
  12962. * The weight of the runtime animation
  12963. */
  12964. private _weight;
  12965. /**
  12966. * The ratio offset of the runtime animation
  12967. */
  12968. private _ratioOffset;
  12969. /**
  12970. * The previous delay of the runtime animation
  12971. */
  12972. private _previousDelay;
  12973. /**
  12974. * The previous ratio of the runtime animation
  12975. */
  12976. private _previousRatio;
  12977. private _enableBlending;
  12978. private _keys;
  12979. private _minFrame;
  12980. private _maxFrame;
  12981. private _minValue;
  12982. private _maxValue;
  12983. private _targetIsArray;
  12984. /**
  12985. * Gets the current frame of the runtime animation
  12986. */
  12987. readonly currentFrame: number;
  12988. /**
  12989. * Gets the weight of the runtime animation
  12990. */
  12991. readonly weight: number;
  12992. /**
  12993. * Gets the current value of the runtime animation
  12994. */
  12995. readonly currentValue: any;
  12996. /**
  12997. * Gets the target path of the runtime animation
  12998. */
  12999. readonly targetPath: string;
  13000. /**
  13001. * Gets the actual target of the runtime animation
  13002. */
  13003. readonly target: any;
  13004. /** @hidden */
  13005. _onLoop: () => void;
  13006. /**
  13007. * Create a new RuntimeAnimation object
  13008. * @param target defines the target of the animation
  13009. * @param animation defines the source animation object
  13010. * @param scene defines the hosting scene
  13011. * @param host defines the initiating Animatable
  13012. */
  13013. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13014. private _preparePath;
  13015. /**
  13016. * Gets the animation from the runtime animation
  13017. */
  13018. readonly animation: Animation;
  13019. /**
  13020. * Resets the runtime animation to the beginning
  13021. * @param restoreOriginal defines whether to restore the target property to the original value
  13022. */
  13023. reset(restoreOriginal?: boolean): void;
  13024. /**
  13025. * Specifies if the runtime animation is stopped
  13026. * @returns Boolean specifying if the runtime animation is stopped
  13027. */
  13028. isStopped(): boolean;
  13029. /**
  13030. * Disposes of the runtime animation
  13031. */
  13032. dispose(): void;
  13033. /**
  13034. * Apply the interpolated value to the target
  13035. * @param currentValue defines the value computed by the animation
  13036. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13037. */
  13038. setValue(currentValue: any, weight: number): void;
  13039. private _getOriginalValues;
  13040. private _setValue;
  13041. /**
  13042. * Gets the loop pmode of the runtime animation
  13043. * @returns Loop Mode
  13044. */
  13045. private _getCorrectLoopMode;
  13046. /**
  13047. * Move the current animation to a given frame
  13048. * @param frame defines the frame to move to
  13049. */
  13050. goToFrame(frame: number): void;
  13051. /**
  13052. * @hidden Internal use only
  13053. */
  13054. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13055. /**
  13056. * Execute the current animation
  13057. * @param delay defines the delay to add to the current frame
  13058. * @param from defines the lower bound of the animation range
  13059. * @param to defines the upper bound of the animation range
  13060. * @param loop defines if the current animation must loop
  13061. * @param speedRatio defines the current speed ratio
  13062. * @param weight defines the weight of the animation (default is -1 so no weight)
  13063. * @param onLoop optional callback called when animation loops
  13064. * @returns a boolean indicating if the animation is running
  13065. */
  13066. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13067. }
  13068. }
  13069. declare module "babylonjs/Animations/animatable" {
  13070. import { Animation } from "babylonjs/Animations/animation";
  13071. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13072. import { Nullable } from "babylonjs/types";
  13073. import { Observable } from "babylonjs/Misc/observable";
  13074. import { Scene } from "babylonjs/scene";
  13075. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13076. import { Node } from "babylonjs/node";
  13077. /**
  13078. * Class used to store an actual running animation
  13079. */
  13080. export class Animatable {
  13081. /** defines the target object */
  13082. target: any;
  13083. /** defines the starting frame number (default is 0) */
  13084. fromFrame: number;
  13085. /** defines the ending frame number (default is 100) */
  13086. toFrame: number;
  13087. /** defines if the animation must loop (default is false) */
  13088. loopAnimation: boolean;
  13089. /** defines a callback to call when animation ends if it is not looping */
  13090. onAnimationEnd?: (() => void) | null | undefined;
  13091. /** defines a callback to call when animation loops */
  13092. onAnimationLoop?: (() => void) | null | undefined;
  13093. private _localDelayOffset;
  13094. private _pausedDelay;
  13095. private _runtimeAnimations;
  13096. private _paused;
  13097. private _scene;
  13098. private _speedRatio;
  13099. private _weight;
  13100. private _syncRoot;
  13101. /**
  13102. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13103. * This will only apply for non looping animation (default is true)
  13104. */
  13105. disposeOnEnd: boolean;
  13106. /**
  13107. * Gets a boolean indicating if the animation has started
  13108. */
  13109. animationStarted: boolean;
  13110. /**
  13111. * Observer raised when the animation ends
  13112. */
  13113. onAnimationEndObservable: Observable<Animatable>;
  13114. /**
  13115. * Observer raised when the animation loops
  13116. */
  13117. onAnimationLoopObservable: Observable<Animatable>;
  13118. /**
  13119. * Gets the root Animatable used to synchronize and normalize animations
  13120. */
  13121. readonly syncRoot: Nullable<Animatable>;
  13122. /**
  13123. * Gets the current frame of the first RuntimeAnimation
  13124. * Used to synchronize Animatables
  13125. */
  13126. readonly masterFrame: number;
  13127. /**
  13128. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13129. */
  13130. weight: number;
  13131. /**
  13132. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13133. */
  13134. speedRatio: number;
  13135. /**
  13136. * Creates a new Animatable
  13137. * @param scene defines the hosting scene
  13138. * @param target defines the target object
  13139. * @param fromFrame defines the starting frame number (default is 0)
  13140. * @param toFrame defines the ending frame number (default is 100)
  13141. * @param loopAnimation defines if the animation must loop (default is false)
  13142. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13143. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13144. * @param animations defines a group of animation to add to the new Animatable
  13145. * @param onAnimationLoop defines a callback to call when animation loops
  13146. */
  13147. constructor(scene: Scene,
  13148. /** defines the target object */
  13149. target: any,
  13150. /** defines the starting frame number (default is 0) */
  13151. fromFrame?: number,
  13152. /** defines the ending frame number (default is 100) */
  13153. toFrame?: number,
  13154. /** defines if the animation must loop (default is false) */
  13155. loopAnimation?: boolean, speedRatio?: number,
  13156. /** defines a callback to call when animation ends if it is not looping */
  13157. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13158. /** defines a callback to call when animation loops */
  13159. onAnimationLoop?: (() => void) | null | undefined);
  13160. /**
  13161. * Synchronize and normalize current Animatable with a source Animatable
  13162. * This is useful when using animation weights and when animations are not of the same length
  13163. * @param root defines the root Animatable to synchronize with
  13164. * @returns the current Animatable
  13165. */
  13166. syncWith(root: Animatable): Animatable;
  13167. /**
  13168. * Gets the list of runtime animations
  13169. * @returns an array of RuntimeAnimation
  13170. */
  13171. getAnimations(): RuntimeAnimation[];
  13172. /**
  13173. * Adds more animations to the current animatable
  13174. * @param target defines the target of the animations
  13175. * @param animations defines the new animations to add
  13176. */
  13177. appendAnimations(target: any, animations: Animation[]): void;
  13178. /**
  13179. * Gets the source animation for a specific property
  13180. * @param property defines the propertyu to look for
  13181. * @returns null or the source animation for the given property
  13182. */
  13183. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13184. /**
  13185. * Gets the runtime animation for a specific property
  13186. * @param property defines the propertyu to look for
  13187. * @returns null or the runtime animation for the given property
  13188. */
  13189. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13190. /**
  13191. * Resets the animatable to its original state
  13192. */
  13193. reset(): void;
  13194. /**
  13195. * Allows the animatable to blend with current running animations
  13196. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13197. * @param blendingSpeed defines the blending speed to use
  13198. */
  13199. enableBlending(blendingSpeed: number): void;
  13200. /**
  13201. * Disable animation blending
  13202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13203. */
  13204. disableBlending(): void;
  13205. /**
  13206. * Jump directly to a given frame
  13207. * @param frame defines the frame to jump to
  13208. */
  13209. goToFrame(frame: number): void;
  13210. /**
  13211. * Pause the animation
  13212. */
  13213. pause(): void;
  13214. /**
  13215. * Restart the animation
  13216. */
  13217. restart(): void;
  13218. private _raiseOnAnimationEnd;
  13219. /**
  13220. * Stop and delete the current animation
  13221. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13222. * @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)
  13223. */
  13224. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13225. /**
  13226. * Wait asynchronously for the animation to end
  13227. * @returns a promise which will be fullfilled when the animation ends
  13228. */
  13229. waitAsync(): Promise<Animatable>;
  13230. /** @hidden */
  13231. _animate(delay: number): boolean;
  13232. }
  13233. module "babylonjs/scene" {
  13234. interface Scene {
  13235. /** @hidden */
  13236. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13237. /** @hidden */
  13238. _processLateAnimationBindingsForMatrices(holder: {
  13239. totalWeight: number;
  13240. animations: RuntimeAnimation[];
  13241. originalValue: Matrix;
  13242. }): any;
  13243. /** @hidden */
  13244. _processLateAnimationBindingsForQuaternions(holder: {
  13245. totalWeight: number;
  13246. animations: RuntimeAnimation[];
  13247. originalValue: Quaternion;
  13248. }, refQuaternion: Quaternion): Quaternion;
  13249. /** @hidden */
  13250. _processLateAnimationBindings(): void;
  13251. /**
  13252. * Will start the animation sequence of a given target
  13253. * @param target defines the target
  13254. * @param from defines from which frame should animation start
  13255. * @param to defines until which frame should animation run.
  13256. * @param weight defines the weight to apply to the animation (1.0 by default)
  13257. * @param loop defines if the animation loops
  13258. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13259. * @param onAnimationEnd defines the function to be executed when the animation ends
  13260. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13261. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13262. * @param onAnimationLoop defines the callback to call when an animation loops
  13263. * @returns the animatable object created for this animation
  13264. */
  13265. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13266. /**
  13267. * Will start the animation sequence of a given target
  13268. * @param target defines the target
  13269. * @param from defines from which frame should animation start
  13270. * @param to defines until which frame should animation run.
  13271. * @param loop defines if the animation loops
  13272. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13273. * @param onAnimationEnd defines the function to be executed when the animation ends
  13274. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13275. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13276. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13277. * @param onAnimationLoop defines the callback to call when an animation loops
  13278. * @returns the animatable object created for this animation
  13279. */
  13280. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13281. /**
  13282. * Will start the animation sequence of a given target and its hierarchy
  13283. * @param target defines the target
  13284. * @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.
  13285. * @param from defines from which frame should animation start
  13286. * @param to defines until which frame should animation run.
  13287. * @param loop defines if the animation loops
  13288. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13289. * @param onAnimationEnd defines the function to be executed when the animation ends
  13290. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13291. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13292. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13293. * @param onAnimationLoop defines the callback to call when an animation loops
  13294. * @returns the list of created animatables
  13295. */
  13296. 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[];
  13297. /**
  13298. * Begin a new animation on a given node
  13299. * @param target defines the target where the animation will take place
  13300. * @param animations defines the list of animations to start
  13301. * @param from defines the initial value
  13302. * @param to defines the final value
  13303. * @param loop defines if you want animation to loop (off by default)
  13304. * @param speedRatio defines the speed ratio to apply to all animations
  13305. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13306. * @param onAnimationLoop defines the callback to call when an animation loops
  13307. * @returns the list of created animatables
  13308. */
  13309. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13310. /**
  13311. * Begin a new animation on a given node and its hierarchy
  13312. * @param target defines the root node where the animation will take place
  13313. * @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.
  13314. * @param animations defines the list of animations to start
  13315. * @param from defines the initial value
  13316. * @param to defines the final value
  13317. * @param loop defines if you want animation to loop (off by default)
  13318. * @param speedRatio defines the speed ratio to apply to all animations
  13319. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13320. * @param onAnimationLoop defines the callback to call when an animation loops
  13321. * @returns the list of animatables created for all nodes
  13322. */
  13323. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13324. /**
  13325. * Gets the animatable associated with a specific target
  13326. * @param target defines the target of the animatable
  13327. * @returns the required animatable if found
  13328. */
  13329. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13330. /**
  13331. * Gets all animatables associated with a given target
  13332. * @param target defines the target to look animatables for
  13333. * @returns an array of Animatables
  13334. */
  13335. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13336. /**
  13337. * Stops and removes all animations that have been applied to the scene
  13338. */
  13339. stopAllAnimations(): void;
  13340. /**
  13341. * Gets the current delta time used by animation engine
  13342. */
  13343. deltaTime: number;
  13344. }
  13345. }
  13346. module "babylonjs/Bones/bone" {
  13347. interface Bone {
  13348. /**
  13349. * Copy an animation range from another bone
  13350. * @param source defines the source bone
  13351. * @param rangeName defines the range name to copy
  13352. * @param frameOffset defines the frame offset
  13353. * @param rescaleAsRequired defines if rescaling must be applied if required
  13354. * @param skelDimensionsRatio defines the scaling ratio
  13355. * @returns true if operation was successful
  13356. */
  13357. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13358. }
  13359. }
  13360. }
  13361. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13362. /**
  13363. * Class used to override all child animations of a given target
  13364. */
  13365. export class AnimationPropertiesOverride {
  13366. /**
  13367. * Gets or sets a value indicating if animation blending must be used
  13368. */
  13369. enableBlending: boolean;
  13370. /**
  13371. * Gets or sets the blending speed to use when enableBlending is true
  13372. */
  13373. blendingSpeed: number;
  13374. /**
  13375. * Gets or sets the default loop mode to use
  13376. */
  13377. loopMode: number;
  13378. }
  13379. }
  13380. declare module "babylonjs/Bones/skeleton" {
  13381. import { Bone } from "babylonjs/Bones/bone";
  13382. import { Observable } from "babylonjs/Misc/observable";
  13383. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13384. import { Scene } from "babylonjs/scene";
  13385. import { Nullable } from "babylonjs/types";
  13386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13387. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13388. import { Animatable } from "babylonjs/Animations/animatable";
  13389. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13390. import { Animation } from "babylonjs/Animations/animation";
  13391. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13392. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13394. /**
  13395. * Class used to handle skinning animations
  13396. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13397. */
  13398. export class Skeleton implements IAnimatable {
  13399. /** defines the skeleton name */
  13400. name: string;
  13401. /** defines the skeleton Id */
  13402. id: string;
  13403. /**
  13404. * Defines the list of child bones
  13405. */
  13406. bones: Bone[];
  13407. /**
  13408. * Defines an estimate of the dimension of the skeleton at rest
  13409. */
  13410. dimensionsAtRest: Vector3;
  13411. /**
  13412. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13413. */
  13414. needInitialSkinMatrix: boolean;
  13415. /**
  13416. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13417. */
  13418. overrideMesh: Nullable<AbstractMesh>;
  13419. /**
  13420. * Gets the list of animations attached to this skeleton
  13421. */
  13422. animations: Array<Animation>;
  13423. private _scene;
  13424. private _isDirty;
  13425. private _transformMatrices;
  13426. private _transformMatrixTexture;
  13427. private _meshesWithPoseMatrix;
  13428. private _animatables;
  13429. private _identity;
  13430. private _synchronizedWithMesh;
  13431. private _ranges;
  13432. private _lastAbsoluteTransformsUpdateId;
  13433. private _canUseTextureForBones;
  13434. private _uniqueId;
  13435. /** @hidden */
  13436. _numBonesWithLinkedTransformNode: number;
  13437. /** @hidden */
  13438. _hasWaitingData: Nullable<boolean>;
  13439. /**
  13440. * Specifies if the skeleton should be serialized
  13441. */
  13442. doNotSerialize: boolean;
  13443. private _useTextureToStoreBoneMatrices;
  13444. /**
  13445. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13446. * Please note that this option is not available if the hardware does not support it
  13447. */
  13448. useTextureToStoreBoneMatrices: boolean;
  13449. private _animationPropertiesOverride;
  13450. /**
  13451. * Gets or sets the animation properties override
  13452. */
  13453. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13454. /**
  13455. * List of inspectable custom properties (used by the Inspector)
  13456. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13457. */
  13458. inspectableCustomProperties: IInspectable[];
  13459. /**
  13460. * An observable triggered before computing the skeleton's matrices
  13461. */
  13462. onBeforeComputeObservable: Observable<Skeleton>;
  13463. /**
  13464. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13465. */
  13466. readonly isUsingTextureForMatrices: boolean;
  13467. /**
  13468. * Gets the unique ID of this skeleton
  13469. */
  13470. readonly uniqueId: number;
  13471. /**
  13472. * Creates a new skeleton
  13473. * @param name defines the skeleton name
  13474. * @param id defines the skeleton Id
  13475. * @param scene defines the hosting scene
  13476. */
  13477. constructor(
  13478. /** defines the skeleton name */
  13479. name: string,
  13480. /** defines the skeleton Id */
  13481. id: string, scene: Scene);
  13482. /**
  13483. * Gets the current object class name.
  13484. * @return the class name
  13485. */
  13486. getClassName(): string;
  13487. /**
  13488. * Returns an array containing the root bones
  13489. * @returns an array containing the root bones
  13490. */
  13491. getChildren(): Array<Bone>;
  13492. /**
  13493. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13494. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13495. * @returns a Float32Array containing matrices data
  13496. */
  13497. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13498. /**
  13499. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13500. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13501. * @returns a raw texture containing the data
  13502. */
  13503. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13504. /**
  13505. * Gets the current hosting scene
  13506. * @returns a scene object
  13507. */
  13508. getScene(): Scene;
  13509. /**
  13510. * Gets a string representing the current skeleton data
  13511. * @param fullDetails defines a boolean indicating if we want a verbose version
  13512. * @returns a string representing the current skeleton data
  13513. */
  13514. toString(fullDetails?: boolean): string;
  13515. /**
  13516. * Get bone's index searching by name
  13517. * @param name defines bone's name to search for
  13518. * @return the indice of the bone. Returns -1 if not found
  13519. */
  13520. getBoneIndexByName(name: string): number;
  13521. /**
  13522. * Creater a new animation range
  13523. * @param name defines the name of the range
  13524. * @param from defines the start key
  13525. * @param to defines the end key
  13526. */
  13527. createAnimationRange(name: string, from: number, to: number): void;
  13528. /**
  13529. * Delete a specific animation range
  13530. * @param name defines the name of the range
  13531. * @param deleteFrames defines if frames must be removed as well
  13532. */
  13533. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13534. /**
  13535. * Gets a specific animation range
  13536. * @param name defines the name of the range to look for
  13537. * @returns the requested animation range or null if not found
  13538. */
  13539. getAnimationRange(name: string): Nullable<AnimationRange>;
  13540. /**
  13541. * Gets the list of all animation ranges defined on this skeleton
  13542. * @returns an array
  13543. */
  13544. getAnimationRanges(): Nullable<AnimationRange>[];
  13545. /**
  13546. * Copy animation range from a source skeleton.
  13547. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13548. * @param source defines the source skeleton
  13549. * @param name defines the name of the range to copy
  13550. * @param rescaleAsRequired defines if rescaling must be applied if required
  13551. * @returns true if operation was successful
  13552. */
  13553. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13554. /**
  13555. * Forces the skeleton to go to rest pose
  13556. */
  13557. returnToRest(): void;
  13558. private _getHighestAnimationFrame;
  13559. /**
  13560. * Begin a specific animation range
  13561. * @param name defines the name of the range to start
  13562. * @param loop defines if looping must be turned on (false by default)
  13563. * @param speedRatio defines the speed ratio to apply (1 by default)
  13564. * @param onAnimationEnd defines a callback which will be called when animation will end
  13565. * @returns a new animatable
  13566. */
  13567. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13568. /** @hidden */
  13569. _markAsDirty(): void;
  13570. /** @hidden */
  13571. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13572. /** @hidden */
  13573. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13574. private _computeTransformMatrices;
  13575. /**
  13576. * Build all resources required to render a skeleton
  13577. */
  13578. prepare(): void;
  13579. /**
  13580. * Gets the list of animatables currently running for this skeleton
  13581. * @returns an array of animatables
  13582. */
  13583. getAnimatables(): IAnimatable[];
  13584. /**
  13585. * Clone the current skeleton
  13586. * @param name defines the name of the new skeleton
  13587. * @param id defines the id of the new skeleton
  13588. * @returns the new skeleton
  13589. */
  13590. clone(name: string, id: string): Skeleton;
  13591. /**
  13592. * Enable animation blending for this skeleton
  13593. * @param blendingSpeed defines the blending speed to apply
  13594. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13595. */
  13596. enableBlending(blendingSpeed?: number): void;
  13597. /**
  13598. * Releases all resources associated with the current skeleton
  13599. */
  13600. dispose(): void;
  13601. /**
  13602. * Serialize the skeleton in a JSON object
  13603. * @returns a JSON object
  13604. */
  13605. serialize(): any;
  13606. /**
  13607. * Creates a new skeleton from serialized data
  13608. * @param parsedSkeleton defines the serialized data
  13609. * @param scene defines the hosting scene
  13610. * @returns a new skeleton
  13611. */
  13612. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13613. /**
  13614. * Compute all node absolute transforms
  13615. * @param forceUpdate defines if computation must be done even if cache is up to date
  13616. */
  13617. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13618. /**
  13619. * Gets the root pose matrix
  13620. * @returns a matrix
  13621. */
  13622. getPoseMatrix(): Nullable<Matrix>;
  13623. /**
  13624. * Sorts bones per internal index
  13625. */
  13626. sortBones(): void;
  13627. private _sortBones;
  13628. }
  13629. }
  13630. declare module "babylonjs/Bones/bone" {
  13631. import { Skeleton } from "babylonjs/Bones/skeleton";
  13632. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13633. import { Nullable } from "babylonjs/types";
  13634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13636. import { Node } from "babylonjs/node";
  13637. import { Space } from "babylonjs/Maths/math.axis";
  13638. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13639. /**
  13640. * Class used to store bone information
  13641. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13642. */
  13643. export class Bone extends Node {
  13644. /**
  13645. * defines the bone name
  13646. */
  13647. name: string;
  13648. private static _tmpVecs;
  13649. private static _tmpQuat;
  13650. private static _tmpMats;
  13651. /**
  13652. * Gets the list of child bones
  13653. */
  13654. children: Bone[];
  13655. /** Gets the animations associated with this bone */
  13656. animations: import("babylonjs/Animations/animation").Animation[];
  13657. /**
  13658. * Gets or sets bone length
  13659. */
  13660. length: number;
  13661. /**
  13662. * @hidden Internal only
  13663. * Set this value to map this bone to a different index in the transform matrices
  13664. * Set this value to -1 to exclude the bone from the transform matrices
  13665. */
  13666. _index: Nullable<number>;
  13667. private _skeleton;
  13668. private _localMatrix;
  13669. private _restPose;
  13670. private _baseMatrix;
  13671. private _absoluteTransform;
  13672. private _invertedAbsoluteTransform;
  13673. private _parent;
  13674. private _scalingDeterminant;
  13675. private _worldTransform;
  13676. private _localScaling;
  13677. private _localRotation;
  13678. private _localPosition;
  13679. private _needToDecompose;
  13680. private _needToCompose;
  13681. /** @hidden */
  13682. _linkedTransformNode: Nullable<TransformNode>;
  13683. /** @hidden */
  13684. _waitingTransformNodeId: Nullable<string>;
  13685. /** @hidden */
  13686. /** @hidden */
  13687. _matrix: Matrix;
  13688. /**
  13689. * Create a new bone
  13690. * @param name defines the bone name
  13691. * @param skeleton defines the parent skeleton
  13692. * @param parentBone defines the parent (can be null if the bone is the root)
  13693. * @param localMatrix defines the local matrix
  13694. * @param restPose defines the rest pose matrix
  13695. * @param baseMatrix defines the base matrix
  13696. * @param index defines index of the bone in the hiearchy
  13697. */
  13698. constructor(
  13699. /**
  13700. * defines the bone name
  13701. */
  13702. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13703. /**
  13704. * Gets the current object class name.
  13705. * @return the class name
  13706. */
  13707. getClassName(): string;
  13708. /**
  13709. * Gets the parent skeleton
  13710. * @returns a skeleton
  13711. */
  13712. getSkeleton(): Skeleton;
  13713. /**
  13714. * Gets parent bone
  13715. * @returns a bone or null if the bone is the root of the bone hierarchy
  13716. */
  13717. getParent(): Nullable<Bone>;
  13718. /**
  13719. * Returns an array containing the root bones
  13720. * @returns an array containing the root bones
  13721. */
  13722. getChildren(): Array<Bone>;
  13723. /**
  13724. * Sets the parent bone
  13725. * @param parent defines the parent (can be null if the bone is the root)
  13726. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13727. */
  13728. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13729. /**
  13730. * Gets the local matrix
  13731. * @returns a matrix
  13732. */
  13733. getLocalMatrix(): Matrix;
  13734. /**
  13735. * Gets the base matrix (initial matrix which remains unchanged)
  13736. * @returns a matrix
  13737. */
  13738. getBaseMatrix(): Matrix;
  13739. /**
  13740. * Gets the rest pose matrix
  13741. * @returns a matrix
  13742. */
  13743. getRestPose(): Matrix;
  13744. /**
  13745. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13746. */
  13747. getWorldMatrix(): Matrix;
  13748. /**
  13749. * Sets the local matrix to rest pose matrix
  13750. */
  13751. returnToRest(): void;
  13752. /**
  13753. * Gets the inverse of the absolute transform matrix.
  13754. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13755. * @returns a matrix
  13756. */
  13757. getInvertedAbsoluteTransform(): Matrix;
  13758. /**
  13759. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13760. * @returns a matrix
  13761. */
  13762. getAbsoluteTransform(): Matrix;
  13763. /**
  13764. * Links with the given transform node.
  13765. * The local matrix of this bone is copied from the transform node every frame.
  13766. * @param transformNode defines the transform node to link to
  13767. */
  13768. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13769. /**
  13770. * Gets the node used to drive the bone's transformation
  13771. * @returns a transform node or null
  13772. */
  13773. getTransformNode(): Nullable<TransformNode>;
  13774. /** Gets or sets current position (in local space) */
  13775. position: Vector3;
  13776. /** Gets or sets current rotation (in local space) */
  13777. rotation: Vector3;
  13778. /** Gets or sets current rotation quaternion (in local space) */
  13779. rotationQuaternion: Quaternion;
  13780. /** Gets or sets current scaling (in local space) */
  13781. scaling: Vector3;
  13782. /**
  13783. * Gets the animation properties override
  13784. */
  13785. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13786. private _decompose;
  13787. private _compose;
  13788. /**
  13789. * Update the base and local matrices
  13790. * @param matrix defines the new base or local matrix
  13791. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13792. * @param updateLocalMatrix defines if the local matrix should be updated
  13793. */
  13794. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13795. /** @hidden */
  13796. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13797. /**
  13798. * Flag the bone as dirty (Forcing it to update everything)
  13799. */
  13800. markAsDirty(): void;
  13801. /** @hidden */
  13802. _markAsDirtyAndCompose(): void;
  13803. private _markAsDirtyAndDecompose;
  13804. /**
  13805. * Translate the bone in local or world space
  13806. * @param vec The amount to translate the bone
  13807. * @param space The space that the translation is in
  13808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13809. */
  13810. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13811. /**
  13812. * Set the postion of the bone in local or world space
  13813. * @param position The position to set the bone
  13814. * @param space The space that the position is in
  13815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13816. */
  13817. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13818. /**
  13819. * Set the absolute position of the bone (world space)
  13820. * @param position The position to set the bone
  13821. * @param mesh The mesh that this bone is attached to
  13822. */
  13823. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13824. /**
  13825. * Scale the bone on the x, y and z axes (in local space)
  13826. * @param x The amount to scale the bone on the x axis
  13827. * @param y The amount to scale the bone on the y axis
  13828. * @param z The amount to scale the bone on the z axis
  13829. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13830. */
  13831. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13832. /**
  13833. * Set the bone scaling in local space
  13834. * @param scale defines the scaling vector
  13835. */
  13836. setScale(scale: Vector3): void;
  13837. /**
  13838. * Gets the current scaling in local space
  13839. * @returns the current scaling vector
  13840. */
  13841. getScale(): Vector3;
  13842. /**
  13843. * Gets the current scaling in local space and stores it in a target vector
  13844. * @param result defines the target vector
  13845. */
  13846. getScaleToRef(result: Vector3): void;
  13847. /**
  13848. * Set the yaw, pitch, and roll of the bone in local or world space
  13849. * @param yaw The rotation of the bone on the y axis
  13850. * @param pitch The rotation of the bone on the x axis
  13851. * @param roll The rotation of the bone on the z axis
  13852. * @param space The space that the axes of rotation are in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13856. /**
  13857. * Add a rotation to the bone on an axis in local or world space
  13858. * @param axis The axis to rotate the bone on
  13859. * @param amount The amount to rotate the bone
  13860. * @param space The space that the axis is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. */
  13863. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13864. /**
  13865. * Set the rotation of the bone to a particular axis angle in local or world space
  13866. * @param axis The axis to rotate the bone on
  13867. * @param angle The angle that the bone should be rotated to
  13868. * @param space The space that the axis is in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. */
  13871. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13872. /**
  13873. * Set the euler rotation of the bone in local of world space
  13874. * @param rotation The euler rotation that the bone should be set to
  13875. * @param space The space that the rotation is in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. */
  13878. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13879. /**
  13880. * Set the quaternion rotation of the bone in local of world space
  13881. * @param quat The quaternion rotation that the bone should be set to
  13882. * @param space The space that the rotation is in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. */
  13885. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13886. /**
  13887. * Set the rotation matrix of the bone in local of world space
  13888. * @param rotMat The rotation matrix that the bone should be set to
  13889. * @param space The space that the rotation is in
  13890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13891. */
  13892. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13893. private _rotateWithMatrix;
  13894. private _getNegativeRotationToRef;
  13895. /**
  13896. * Get the position of the bone in local or world space
  13897. * @param space The space that the returned position is in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. * @returns The position of the bone
  13900. */
  13901. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13902. /**
  13903. * Copy the position of the bone to a vector3 in local or world space
  13904. * @param space The space that the returned position is in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @param result The vector3 to copy the position to
  13907. */
  13908. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13909. /**
  13910. * Get the absolute position of the bone (world space)
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @returns The absolute position of the bone
  13913. */
  13914. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13915. /**
  13916. * Copy the absolute position of the bone (world space) to the result param
  13917. * @param mesh The mesh that this bone is attached to
  13918. * @param result The vector3 to copy the absolute position to
  13919. */
  13920. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13921. /**
  13922. * Compute the absolute transforms of this bone and its children
  13923. */
  13924. computeAbsoluteTransforms(): void;
  13925. /**
  13926. * Get the world direction from an axis that is in the local space of the bone
  13927. * @param localAxis The local direction that is used to compute the world direction
  13928. * @param mesh The mesh that this bone is attached to
  13929. * @returns The world direction
  13930. */
  13931. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13932. /**
  13933. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13934. * @param localAxis The local direction that is used to compute the world direction
  13935. * @param mesh The mesh that this bone is attached to
  13936. * @param result The vector3 that the world direction will be copied to
  13937. */
  13938. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13939. /**
  13940. * Get the euler rotation of the bone in local or world space
  13941. * @param space The space that the rotation should be in
  13942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13943. * @returns The euler rotation
  13944. */
  13945. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13946. /**
  13947. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13948. * @param space The space that the rotation should be in
  13949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13950. * @param result The vector3 that the rotation should be copied to
  13951. */
  13952. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13953. /**
  13954. * Get the quaternion rotation of the bone in either local or world space
  13955. * @param space The space that the rotation should be in
  13956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13957. * @returns The quaternion rotation
  13958. */
  13959. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13960. /**
  13961. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13962. * @param space The space that the rotation should be in
  13963. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13964. * @param result The quaternion that the rotation should be copied to
  13965. */
  13966. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13967. /**
  13968. * Get the rotation matrix of the bone in local or world space
  13969. * @param space The space that the rotation should be in
  13970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13971. * @returns The rotation matrix
  13972. */
  13973. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13974. /**
  13975. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13976. * @param space The space that the rotation should be in
  13977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13978. * @param result The quaternion that the rotation should be copied to
  13979. */
  13980. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13981. /**
  13982. * Get the world position of a point that is in the local space of the bone
  13983. * @param position The local position
  13984. * @param mesh The mesh that this bone is attached to
  13985. * @returns The world position
  13986. */
  13987. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13988. /**
  13989. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13990. * @param position The local position
  13991. * @param mesh The mesh that this bone is attached to
  13992. * @param result The vector3 that the world position should be copied to
  13993. */
  13994. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13995. /**
  13996. * Get the local position of a point that is in world space
  13997. * @param position The world position
  13998. * @param mesh The mesh that this bone is attached to
  13999. * @returns The local position
  14000. */
  14001. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14002. /**
  14003. * Get the local position of a point that is in world space and copy it to the result param
  14004. * @param position The world position
  14005. * @param mesh The mesh that this bone is attached to
  14006. * @param result The vector3 that the local position should be copied to
  14007. */
  14008. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14009. }
  14010. }
  14011. declare module "babylonjs/Meshes/transformNode" {
  14012. import { DeepImmutable } from "babylonjs/types";
  14013. import { Observable } from "babylonjs/Misc/observable";
  14014. import { Nullable } from "babylonjs/types";
  14015. import { Camera } from "babylonjs/Cameras/camera";
  14016. import { Scene } from "babylonjs/scene";
  14017. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14018. import { Node } from "babylonjs/node";
  14019. import { Bone } from "babylonjs/Bones/bone";
  14020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14021. import { Space } from "babylonjs/Maths/math.axis";
  14022. /**
  14023. * 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.
  14024. * @see https://doc.babylonjs.com/how_to/transformnode
  14025. */
  14026. export class TransformNode extends Node {
  14027. /**
  14028. * Object will not rotate to face the camera
  14029. */
  14030. static BILLBOARDMODE_NONE: number;
  14031. /**
  14032. * Object will rotate to face the camera but only on the x axis
  14033. */
  14034. static BILLBOARDMODE_X: number;
  14035. /**
  14036. * Object will rotate to face the camera but only on the y axis
  14037. */
  14038. static BILLBOARDMODE_Y: number;
  14039. /**
  14040. * Object will rotate to face the camera but only on the z axis
  14041. */
  14042. static BILLBOARDMODE_Z: number;
  14043. /**
  14044. * Object will rotate to face the camera
  14045. */
  14046. static BILLBOARDMODE_ALL: number;
  14047. /**
  14048. * Object will rotate to face the camera's position instead of orientation
  14049. */
  14050. static BILLBOARDMODE_USE_POSITION: number;
  14051. private _forward;
  14052. private _forwardInverted;
  14053. private _up;
  14054. private _right;
  14055. private _rightInverted;
  14056. private _position;
  14057. private _rotation;
  14058. private _rotationQuaternion;
  14059. protected _scaling: Vector3;
  14060. protected _isDirty: boolean;
  14061. private _transformToBoneReferal;
  14062. private _isAbsoluteSynced;
  14063. private _billboardMode;
  14064. /**
  14065. * Gets or sets the billboard mode. Default is 0.
  14066. *
  14067. * | Value | Type | Description |
  14068. * | --- | --- | --- |
  14069. * | 0 | BILLBOARDMODE_NONE | |
  14070. * | 1 | BILLBOARDMODE_X | |
  14071. * | 2 | BILLBOARDMODE_Y | |
  14072. * | 4 | BILLBOARDMODE_Z | |
  14073. * | 7 | BILLBOARDMODE_ALL | |
  14074. *
  14075. */
  14076. billboardMode: number;
  14077. private _preserveParentRotationForBillboard;
  14078. /**
  14079. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14080. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14081. */
  14082. preserveParentRotationForBillboard: boolean;
  14083. /**
  14084. * 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
  14085. */
  14086. scalingDeterminant: number;
  14087. private _infiniteDistance;
  14088. /**
  14089. * Gets or sets the distance of the object to max, often used by skybox
  14090. */
  14091. infiniteDistance: boolean;
  14092. /**
  14093. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14094. * By default the system will update normals to compensate
  14095. */
  14096. ignoreNonUniformScaling: boolean;
  14097. /**
  14098. * 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
  14099. */
  14100. reIntegrateRotationIntoRotationQuaternion: boolean;
  14101. /** @hidden */
  14102. _poseMatrix: Nullable<Matrix>;
  14103. /** @hidden */
  14104. _localMatrix: Matrix;
  14105. private _usePivotMatrix;
  14106. private _absolutePosition;
  14107. private _absoluteScaling;
  14108. private _absoluteRotationQuaternion;
  14109. private _pivotMatrix;
  14110. private _pivotMatrixInverse;
  14111. protected _postMultiplyPivotMatrix: boolean;
  14112. protected _isWorldMatrixFrozen: boolean;
  14113. /** @hidden */
  14114. _indexInSceneTransformNodesArray: number;
  14115. /**
  14116. * An event triggered after the world matrix is updated
  14117. */
  14118. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14119. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14120. /**
  14121. * Gets a string identifying the name of the class
  14122. * @returns "TransformNode" string
  14123. */
  14124. getClassName(): string;
  14125. /**
  14126. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14127. */
  14128. position: Vector3;
  14129. /**
  14130. * 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)).
  14131. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14132. */
  14133. rotation: Vector3;
  14134. /**
  14135. * 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)).
  14136. */
  14137. scaling: Vector3;
  14138. /**
  14139. * 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).
  14140. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14141. */
  14142. rotationQuaternion: Nullable<Quaternion>;
  14143. /**
  14144. * The forward direction of that transform in world space.
  14145. */
  14146. readonly forward: Vector3;
  14147. /**
  14148. * The up direction of that transform in world space.
  14149. */
  14150. readonly up: Vector3;
  14151. /**
  14152. * The right direction of that transform in world space.
  14153. */
  14154. readonly right: Vector3;
  14155. /**
  14156. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14157. * @param matrix the matrix to copy the pose from
  14158. * @returns this TransformNode.
  14159. */
  14160. updatePoseMatrix(matrix: Matrix): TransformNode;
  14161. /**
  14162. * Returns the mesh Pose matrix.
  14163. * @returns the pose matrix
  14164. */
  14165. getPoseMatrix(): Matrix;
  14166. /** @hidden */
  14167. _isSynchronized(): boolean;
  14168. /** @hidden */
  14169. _initCache(): void;
  14170. /**
  14171. * Flag the transform node as dirty (Forcing it to update everything)
  14172. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14173. * @returns this transform node
  14174. */
  14175. markAsDirty(property: string): TransformNode;
  14176. /**
  14177. * Returns the current mesh absolute position.
  14178. * Returns a Vector3.
  14179. */
  14180. readonly absolutePosition: Vector3;
  14181. /**
  14182. * Returns the current mesh absolute scaling.
  14183. * Returns a Vector3.
  14184. */
  14185. readonly absoluteScaling: Vector3;
  14186. /**
  14187. * Returns the current mesh absolute rotation.
  14188. * Returns a Quaternion.
  14189. */
  14190. readonly absoluteRotationQuaternion: Quaternion;
  14191. /**
  14192. * Sets a new matrix to apply before all other transformation
  14193. * @param matrix defines the transform matrix
  14194. * @returns the current TransformNode
  14195. */
  14196. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14197. /**
  14198. * Sets a new pivot matrix to the current node
  14199. * @param matrix defines the new pivot matrix to use
  14200. * @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
  14201. * @returns the current TransformNode
  14202. */
  14203. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14204. /**
  14205. * Returns the mesh pivot matrix.
  14206. * Default : Identity.
  14207. * @returns the matrix
  14208. */
  14209. getPivotMatrix(): Matrix;
  14210. /**
  14211. * Instantiate (when possible) or clone that node with its hierarchy
  14212. * @param newParent defines the new parent to use for the instance (or clone)
  14213. * @returns an instance (or a clone) of the current node with its hiearchy
  14214. */
  14215. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14216. /**
  14217. * Prevents the World matrix to be computed any longer
  14218. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14219. * @returns the TransformNode.
  14220. */
  14221. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14222. /**
  14223. * Allows back the World matrix computation.
  14224. * @returns the TransformNode.
  14225. */
  14226. unfreezeWorldMatrix(): this;
  14227. /**
  14228. * True if the World matrix has been frozen.
  14229. */
  14230. readonly isWorldMatrixFrozen: boolean;
  14231. /**
  14232. * Retuns the mesh absolute position in the World.
  14233. * @returns a Vector3.
  14234. */
  14235. getAbsolutePosition(): Vector3;
  14236. /**
  14237. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14238. * @param absolutePosition the absolute position to set
  14239. * @returns the TransformNode.
  14240. */
  14241. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14242. /**
  14243. * Sets the mesh position in its local space.
  14244. * @param vector3 the position to set in localspace
  14245. * @returns the TransformNode.
  14246. */
  14247. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14248. /**
  14249. * Returns the mesh position in the local space from the current World matrix values.
  14250. * @returns a new Vector3.
  14251. */
  14252. getPositionExpressedInLocalSpace(): Vector3;
  14253. /**
  14254. * Translates the mesh along the passed Vector3 in its local space.
  14255. * @param vector3 the distance to translate in localspace
  14256. * @returns the TransformNode.
  14257. */
  14258. locallyTranslate(vector3: Vector3): TransformNode;
  14259. private static _lookAtVectorCache;
  14260. /**
  14261. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14262. * @param targetPoint the position (must be in same space as current mesh) to look at
  14263. * @param yawCor optional yaw (y-axis) correction in radians
  14264. * @param pitchCor optional pitch (x-axis) correction in radians
  14265. * @param rollCor optional roll (z-axis) correction in radians
  14266. * @param space the choosen space of the target
  14267. * @returns the TransformNode.
  14268. */
  14269. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14270. /**
  14271. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14272. * This Vector3 is expressed in the World space.
  14273. * @param localAxis axis to rotate
  14274. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14275. */
  14276. getDirection(localAxis: Vector3): Vector3;
  14277. /**
  14278. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14279. * localAxis is expressed in the mesh local space.
  14280. * result is computed in the Wordl space from the mesh World matrix.
  14281. * @param localAxis axis to rotate
  14282. * @param result the resulting transformnode
  14283. * @returns this TransformNode.
  14284. */
  14285. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14286. /**
  14287. * Sets this transform node rotation to the given local axis.
  14288. * @param localAxis the axis in local space
  14289. * @param yawCor optional yaw (y-axis) correction in radians
  14290. * @param pitchCor optional pitch (x-axis) correction in radians
  14291. * @param rollCor optional roll (z-axis) correction in radians
  14292. * @returns this TransformNode
  14293. */
  14294. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14295. /**
  14296. * Sets a new pivot point to the current node
  14297. * @param point defines the new pivot point to use
  14298. * @param space defines if the point is in world or local space (local by default)
  14299. * @returns the current TransformNode
  14300. */
  14301. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14302. /**
  14303. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14304. * @returns the pivot point
  14305. */
  14306. getPivotPoint(): Vector3;
  14307. /**
  14308. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14309. * @param result the vector3 to store the result
  14310. * @returns this TransformNode.
  14311. */
  14312. getPivotPointToRef(result: Vector3): TransformNode;
  14313. /**
  14314. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14315. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14316. */
  14317. getAbsolutePivotPoint(): Vector3;
  14318. /**
  14319. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14320. * @param result vector3 to store the result
  14321. * @returns this TransformNode.
  14322. */
  14323. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14324. /**
  14325. * Defines the passed node as the parent of the current node.
  14326. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14327. * @see https://doc.babylonjs.com/how_to/parenting
  14328. * @param node the node ot set as the parent
  14329. * @returns this TransformNode.
  14330. */
  14331. setParent(node: Nullable<Node>): TransformNode;
  14332. private _nonUniformScaling;
  14333. /**
  14334. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14335. */
  14336. readonly nonUniformScaling: boolean;
  14337. /** @hidden */
  14338. _updateNonUniformScalingState(value: boolean): boolean;
  14339. /**
  14340. * Attach the current TransformNode to another TransformNode associated with a bone
  14341. * @param bone Bone affecting the TransformNode
  14342. * @param affectedTransformNode TransformNode associated with the bone
  14343. * @returns this object
  14344. */
  14345. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14346. /**
  14347. * Detach the transform node if its associated with a bone
  14348. * @returns this object
  14349. */
  14350. detachFromBone(): TransformNode;
  14351. private static _rotationAxisCache;
  14352. /**
  14353. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14354. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14355. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14356. * The passed axis is also normalized.
  14357. * @param axis the axis to rotate around
  14358. * @param amount the amount to rotate in radians
  14359. * @param space Space to rotate in (Default: local)
  14360. * @returns the TransformNode.
  14361. */
  14362. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14363. /**
  14364. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14365. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14366. * The passed axis is also normalized. .
  14367. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14368. * @param point the point to rotate around
  14369. * @param axis the axis to rotate around
  14370. * @param amount the amount to rotate in radians
  14371. * @returns the TransformNode
  14372. */
  14373. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14374. /**
  14375. * Translates the mesh along the axis vector for the passed distance in the given space.
  14376. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14377. * @param axis the axis to translate in
  14378. * @param distance the distance to translate
  14379. * @param space Space to rotate in (Default: local)
  14380. * @returns the TransformNode.
  14381. */
  14382. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14383. /**
  14384. * Adds a rotation step to the mesh current rotation.
  14385. * x, y, z are Euler angles expressed in radians.
  14386. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14387. * This means this rotation is made in the mesh local space only.
  14388. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14389. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14390. * ```javascript
  14391. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14392. * ```
  14393. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14394. * 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.
  14395. * @param x Rotation to add
  14396. * @param y Rotation to add
  14397. * @param z Rotation to add
  14398. * @returns the TransformNode.
  14399. */
  14400. addRotation(x: number, y: number, z: number): TransformNode;
  14401. /**
  14402. * @hidden
  14403. */
  14404. protected _getEffectiveParent(): Nullable<Node>;
  14405. /**
  14406. * Computes the world matrix of the node
  14407. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14408. * @returns the world matrix
  14409. */
  14410. computeWorldMatrix(force?: boolean): Matrix;
  14411. protected _afterComputeWorldMatrix(): void;
  14412. /**
  14413. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14414. * @param func callback function to add
  14415. *
  14416. * @returns the TransformNode.
  14417. */
  14418. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14419. /**
  14420. * Removes a registered callback function.
  14421. * @param func callback function to remove
  14422. * @returns the TransformNode.
  14423. */
  14424. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14425. /**
  14426. * Gets the position of the current mesh in camera space
  14427. * @param camera defines the camera to use
  14428. * @returns a position
  14429. */
  14430. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14431. /**
  14432. * Returns the distance from the mesh to the active camera
  14433. * @param camera defines the camera to use
  14434. * @returns the distance
  14435. */
  14436. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14437. /**
  14438. * Clone the current transform node
  14439. * @param name Name of the new clone
  14440. * @param newParent New parent for the clone
  14441. * @param doNotCloneChildren Do not clone children hierarchy
  14442. * @returns the new transform node
  14443. */
  14444. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14445. /**
  14446. * Serializes the objects information.
  14447. * @param currentSerializationObject defines the object to serialize in
  14448. * @returns the serialized object
  14449. */
  14450. serialize(currentSerializationObject?: any): any;
  14451. /**
  14452. * Returns a new TransformNode object parsed from the source provided.
  14453. * @param parsedTransformNode is the source.
  14454. * @param scene the scne the object belongs to
  14455. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14456. * @returns a new TransformNode object parsed from the source provided.
  14457. */
  14458. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14459. /**
  14460. * Get all child-transformNodes of this node
  14461. * @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
  14462. * @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
  14463. * @returns an array of TransformNode
  14464. */
  14465. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14466. /**
  14467. * Releases resources associated with this transform node.
  14468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14470. */
  14471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14472. /**
  14473. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14474. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14475. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14476. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14477. * @returns the current mesh
  14478. */
  14479. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14480. private _syncAbsoluteScalingAndRotation;
  14481. }
  14482. }
  14483. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14484. import { Observable } from "babylonjs/Misc/observable";
  14485. import { Nullable } from "babylonjs/types";
  14486. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14487. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14489. import { Ray } from "babylonjs/Culling/ray";
  14490. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14491. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14492. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14493. /**
  14494. * Defines the types of pose enabled controllers that are supported
  14495. */
  14496. export enum PoseEnabledControllerType {
  14497. /**
  14498. * HTC Vive
  14499. */
  14500. VIVE = 0,
  14501. /**
  14502. * Oculus Rift
  14503. */
  14504. OCULUS = 1,
  14505. /**
  14506. * Windows mixed reality
  14507. */
  14508. WINDOWS = 2,
  14509. /**
  14510. * Samsung gear VR
  14511. */
  14512. GEAR_VR = 3,
  14513. /**
  14514. * Google Daydream
  14515. */
  14516. DAYDREAM = 4,
  14517. /**
  14518. * Generic
  14519. */
  14520. GENERIC = 5
  14521. }
  14522. /**
  14523. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14524. */
  14525. export interface MutableGamepadButton {
  14526. /**
  14527. * Value of the button/trigger
  14528. */
  14529. value: number;
  14530. /**
  14531. * If the button/trigger is currently touched
  14532. */
  14533. touched: boolean;
  14534. /**
  14535. * If the button/trigger is currently pressed
  14536. */
  14537. pressed: boolean;
  14538. }
  14539. /**
  14540. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14541. * @hidden
  14542. */
  14543. export interface ExtendedGamepadButton extends GamepadButton {
  14544. /**
  14545. * If the button/trigger is currently pressed
  14546. */
  14547. readonly pressed: boolean;
  14548. /**
  14549. * If the button/trigger is currently touched
  14550. */
  14551. readonly touched: boolean;
  14552. /**
  14553. * Value of the button/trigger
  14554. */
  14555. readonly value: number;
  14556. }
  14557. /** @hidden */
  14558. export interface _GamePadFactory {
  14559. /**
  14560. * Returns wether or not the current gamepad can be created for this type of controller.
  14561. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14562. * @returns true if it can be created, otherwise false
  14563. */
  14564. canCreate(gamepadInfo: any): boolean;
  14565. /**
  14566. * Creates a new instance of the Gamepad.
  14567. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14568. * @returns the new gamepad instance
  14569. */
  14570. create(gamepadInfo: any): Gamepad;
  14571. }
  14572. /**
  14573. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14574. */
  14575. export class PoseEnabledControllerHelper {
  14576. /** @hidden */
  14577. static _ControllerFactories: _GamePadFactory[];
  14578. /** @hidden */
  14579. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14580. /**
  14581. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14582. * @param vrGamepad the gamepad to initialized
  14583. * @returns a vr controller of the type the gamepad identified as
  14584. */
  14585. static InitiateController(vrGamepad: any): Gamepad;
  14586. }
  14587. /**
  14588. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14589. */
  14590. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14591. /**
  14592. * If the controller is used in a webXR session
  14593. */
  14594. isXR: boolean;
  14595. private _deviceRoomPosition;
  14596. private _deviceRoomRotationQuaternion;
  14597. /**
  14598. * The device position in babylon space
  14599. */
  14600. devicePosition: Vector3;
  14601. /**
  14602. * The device rotation in babylon space
  14603. */
  14604. deviceRotationQuaternion: Quaternion;
  14605. /**
  14606. * The scale factor of the device in babylon space
  14607. */
  14608. deviceScaleFactor: number;
  14609. /**
  14610. * (Likely devicePosition should be used instead) The device position in its room space
  14611. */
  14612. position: Vector3;
  14613. /**
  14614. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14615. */
  14616. rotationQuaternion: Quaternion;
  14617. /**
  14618. * The type of controller (Eg. Windows mixed reality)
  14619. */
  14620. controllerType: PoseEnabledControllerType;
  14621. protected _calculatedPosition: Vector3;
  14622. private _calculatedRotation;
  14623. /**
  14624. * The raw pose from the device
  14625. */
  14626. rawPose: DevicePose;
  14627. private _trackPosition;
  14628. private _maxRotationDistFromHeadset;
  14629. private _draggedRoomRotation;
  14630. /**
  14631. * @hidden
  14632. */
  14633. _disableTrackPosition(fixedPosition: Vector3): void;
  14634. /**
  14635. * Internal, the mesh attached to the controller
  14636. * @hidden
  14637. */
  14638. _mesh: Nullable<AbstractMesh>;
  14639. private _poseControlledCamera;
  14640. private _leftHandSystemQuaternion;
  14641. /**
  14642. * Internal, matrix used to convert room space to babylon space
  14643. * @hidden
  14644. */
  14645. _deviceToWorld: Matrix;
  14646. /**
  14647. * Node to be used when casting a ray from the controller
  14648. * @hidden
  14649. */
  14650. _pointingPoseNode: Nullable<TransformNode>;
  14651. /**
  14652. * Name of the child mesh that can be used to cast a ray from the controller
  14653. */
  14654. static readonly POINTING_POSE: string;
  14655. /**
  14656. * Creates a new PoseEnabledController from a gamepad
  14657. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14658. */
  14659. constructor(browserGamepad: any);
  14660. private _workingMatrix;
  14661. /**
  14662. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14663. */
  14664. update(): void;
  14665. /**
  14666. * Updates only the pose device and mesh without doing any button event checking
  14667. */
  14668. protected _updatePoseAndMesh(): void;
  14669. /**
  14670. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14671. * @param poseData raw pose fromthe device
  14672. */
  14673. updateFromDevice(poseData: DevicePose): void;
  14674. /**
  14675. * @hidden
  14676. */
  14677. _meshAttachedObservable: Observable<AbstractMesh>;
  14678. /**
  14679. * Attaches a mesh to the controller
  14680. * @param mesh the mesh to be attached
  14681. */
  14682. attachToMesh(mesh: AbstractMesh): void;
  14683. /**
  14684. * Attaches the controllers mesh to a camera
  14685. * @param camera the camera the mesh should be attached to
  14686. */
  14687. attachToPoseControlledCamera(camera: TargetCamera): void;
  14688. /**
  14689. * Disposes of the controller
  14690. */
  14691. dispose(): void;
  14692. /**
  14693. * The mesh that is attached to the controller
  14694. */
  14695. readonly mesh: Nullable<AbstractMesh>;
  14696. /**
  14697. * Gets the ray of the controller in the direction the controller is pointing
  14698. * @param length the length the resulting ray should be
  14699. * @returns a ray in the direction the controller is pointing
  14700. */
  14701. getForwardRay(length?: number): Ray;
  14702. }
  14703. }
  14704. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14705. import { Observable } from "babylonjs/Misc/observable";
  14706. import { Scene } from "babylonjs/scene";
  14707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14708. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14709. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14710. import { Nullable } from "babylonjs/types";
  14711. /**
  14712. * Defines the WebVRController object that represents controllers tracked in 3D space
  14713. */
  14714. export abstract class WebVRController extends PoseEnabledController {
  14715. /**
  14716. * Internal, the default controller model for the controller
  14717. */
  14718. protected _defaultModel: Nullable<AbstractMesh>;
  14719. /**
  14720. * Fired when the trigger state has changed
  14721. */
  14722. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14723. /**
  14724. * Fired when the main button state has changed
  14725. */
  14726. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14727. /**
  14728. * Fired when the secondary button state has changed
  14729. */
  14730. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14731. /**
  14732. * Fired when the pad state has changed
  14733. */
  14734. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14735. /**
  14736. * Fired when controllers stick values have changed
  14737. */
  14738. onPadValuesChangedObservable: Observable<StickValues>;
  14739. /**
  14740. * Array of button availible on the controller
  14741. */
  14742. protected _buttons: Array<MutableGamepadButton>;
  14743. private _onButtonStateChange;
  14744. /**
  14745. * Fired when a controller button's state has changed
  14746. * @param callback the callback containing the button that was modified
  14747. */
  14748. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14749. /**
  14750. * X and Y axis corresponding to the controllers joystick
  14751. */
  14752. pad: StickValues;
  14753. /**
  14754. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14755. */
  14756. hand: string;
  14757. /**
  14758. * The default controller model for the controller
  14759. */
  14760. readonly defaultModel: Nullable<AbstractMesh>;
  14761. /**
  14762. * Creates a new WebVRController from a gamepad
  14763. * @param vrGamepad the gamepad that the WebVRController should be created from
  14764. */
  14765. constructor(vrGamepad: any);
  14766. /**
  14767. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14768. */
  14769. update(): void;
  14770. /**
  14771. * Function to be called when a button is modified
  14772. */
  14773. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14774. /**
  14775. * Loads a mesh and attaches it to the controller
  14776. * @param scene the scene the mesh should be added to
  14777. * @param meshLoaded callback for when the mesh has been loaded
  14778. */
  14779. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14780. private _setButtonValue;
  14781. private _changes;
  14782. private _checkChanges;
  14783. /**
  14784. * Disposes of th webVRCOntroller
  14785. */
  14786. dispose(): void;
  14787. }
  14788. }
  14789. declare module "babylonjs/Lights/hemisphericLight" {
  14790. import { Nullable } from "babylonjs/types";
  14791. import { Scene } from "babylonjs/scene";
  14792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14793. import { Color3 } from "babylonjs/Maths/math.color";
  14794. import { Effect } from "babylonjs/Materials/effect";
  14795. import { Light } from "babylonjs/Lights/light";
  14796. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14797. /**
  14798. * The HemisphericLight simulates the ambient environment light,
  14799. * so the passed direction is the light reflection direction, not the incoming direction.
  14800. */
  14801. export class HemisphericLight extends Light {
  14802. /**
  14803. * The groundColor is the light in the opposite direction to the one specified during creation.
  14804. * 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.
  14805. */
  14806. groundColor: Color3;
  14807. /**
  14808. * The light reflection direction, not the incoming direction.
  14809. */
  14810. direction: Vector3;
  14811. /**
  14812. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14813. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14814. * The HemisphericLight can't cast shadows.
  14815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14816. * @param name The friendly name of the light
  14817. * @param direction The direction of the light reflection
  14818. * @param scene The scene the light belongs to
  14819. */
  14820. constructor(name: string, direction: Vector3, scene: Scene);
  14821. protected _buildUniformLayout(): void;
  14822. /**
  14823. * Returns the string "HemisphericLight".
  14824. * @return The class name
  14825. */
  14826. getClassName(): string;
  14827. /**
  14828. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14829. * Returns the updated direction.
  14830. * @param target The target the direction should point to
  14831. * @return The computed direction
  14832. */
  14833. setDirectionToTarget(target: Vector3): Vector3;
  14834. /**
  14835. * Returns the shadow generator associated to the light.
  14836. * @returns Always null for hemispheric lights because it does not support shadows.
  14837. */
  14838. getShadowGenerator(): Nullable<IShadowGenerator>;
  14839. /**
  14840. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14841. * @param effect The effect to update
  14842. * @param lightIndex The index of the light in the effect to update
  14843. * @returns The hemispheric light
  14844. */
  14845. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14846. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14847. /**
  14848. * Computes the world matrix of the node
  14849. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14850. * @param useWasUpdatedFlag defines a reserved property
  14851. * @returns the world matrix
  14852. */
  14853. computeWorldMatrix(): Matrix;
  14854. /**
  14855. * Returns the integer 3.
  14856. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14857. */
  14858. getTypeID(): number;
  14859. /**
  14860. * Prepares the list of defines specific to the light type.
  14861. * @param defines the list of defines
  14862. * @param lightIndex defines the index of the light for the effect
  14863. */
  14864. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14865. }
  14866. }
  14867. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14868. /** @hidden */
  14869. export var vrMultiviewToSingleviewPixelShader: {
  14870. name: string;
  14871. shader: string;
  14872. };
  14873. }
  14874. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14876. import { Scene } from "babylonjs/scene";
  14877. /**
  14878. * Renders to multiple views with a single draw call
  14879. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14880. */
  14881. export class MultiviewRenderTarget extends RenderTargetTexture {
  14882. /**
  14883. * Creates a multiview render target
  14884. * @param scene scene used with the render target
  14885. * @param size the size of the render target (used for each view)
  14886. */
  14887. constructor(scene: Scene, size?: number | {
  14888. width: number;
  14889. height: number;
  14890. } | {
  14891. ratio: number;
  14892. });
  14893. /**
  14894. * @hidden
  14895. * @param faceIndex the face index, if its a cube texture
  14896. */
  14897. _bindFrameBuffer(faceIndex?: number): void;
  14898. /**
  14899. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14900. * @returns the view count
  14901. */
  14902. getViewCount(): number;
  14903. }
  14904. }
  14905. declare module "babylonjs/Maths/math.frustum" {
  14906. import { Matrix } from "babylonjs/Maths/math.vector";
  14907. import { DeepImmutable } from "babylonjs/types";
  14908. import { Plane } from "babylonjs/Maths/math.plane";
  14909. /**
  14910. * Represents a camera frustum
  14911. */
  14912. export class Frustum {
  14913. /**
  14914. * Gets the planes representing the frustum
  14915. * @param transform matrix to be applied to the returned planes
  14916. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14917. */
  14918. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14919. /**
  14920. * Gets the near frustum plane transformed by the transform matrix
  14921. * @param transform transformation matrix to be applied to the resulting frustum plane
  14922. * @param frustumPlane the resuling frustum plane
  14923. */
  14924. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14925. /**
  14926. * Gets the far frustum plane transformed by the transform matrix
  14927. * @param transform transformation matrix to be applied to the resulting frustum plane
  14928. * @param frustumPlane the resuling frustum plane
  14929. */
  14930. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14931. /**
  14932. * Gets the left frustum plane transformed by the transform matrix
  14933. * @param transform transformation matrix to be applied to the resulting frustum plane
  14934. * @param frustumPlane the resuling frustum plane
  14935. */
  14936. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14937. /**
  14938. * Gets the right frustum plane transformed by the transform matrix
  14939. * @param transform transformation matrix to be applied to the resulting frustum plane
  14940. * @param frustumPlane the resuling frustum plane
  14941. */
  14942. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14943. /**
  14944. * Gets the top frustum plane transformed by the transform matrix
  14945. * @param transform transformation matrix to be applied to the resulting frustum plane
  14946. * @param frustumPlane the resuling frustum plane
  14947. */
  14948. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14949. /**
  14950. * Gets the bottom frustum plane transformed by the transform matrix
  14951. * @param transform transformation matrix to be applied to the resulting frustum plane
  14952. * @param frustumPlane the resuling frustum plane
  14953. */
  14954. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14955. /**
  14956. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14957. * @param transform transformation matrix to be applied to the resulting frustum planes
  14958. * @param frustumPlanes the resuling frustum planes
  14959. */
  14960. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14961. }
  14962. }
  14963. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14964. import { Camera } from "babylonjs/Cameras/camera";
  14965. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14966. import { Nullable } from "babylonjs/types";
  14967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14968. import { Matrix } from "babylonjs/Maths/math.vector";
  14969. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14970. module "babylonjs/Engines/engine" {
  14971. interface Engine {
  14972. /**
  14973. * Creates a new multiview render target
  14974. * @param width defines the width of the texture
  14975. * @param height defines the height of the texture
  14976. * @returns the created multiview texture
  14977. */
  14978. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14979. /**
  14980. * Binds a multiview framebuffer to be drawn to
  14981. * @param multiviewTexture texture to bind
  14982. */
  14983. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14984. }
  14985. }
  14986. module "babylonjs/Cameras/camera" {
  14987. interface Camera {
  14988. /**
  14989. * @hidden
  14990. * 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)
  14991. */
  14992. _useMultiviewToSingleView: boolean;
  14993. /**
  14994. * @hidden
  14995. * 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)
  14996. */
  14997. _multiviewTexture: Nullable<RenderTargetTexture>;
  14998. /**
  14999. * @hidden
  15000. * ensures the multiview texture of the camera exists and has the specified width/height
  15001. * @param width height to set on the multiview texture
  15002. * @param height width to set on the multiview texture
  15003. */
  15004. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15005. }
  15006. }
  15007. module "babylonjs/scene" {
  15008. interface Scene {
  15009. /** @hidden */
  15010. _transformMatrixR: Matrix;
  15011. /** @hidden */
  15012. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15013. /** @hidden */
  15014. _createMultiviewUbo(): void;
  15015. /** @hidden */
  15016. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15017. /** @hidden */
  15018. _renderMultiviewToSingleView(camera: Camera): void;
  15019. }
  15020. }
  15021. }
  15022. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15023. import { Camera } from "babylonjs/Cameras/camera";
  15024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15025. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15026. import "babylonjs/Engines/Extensions/engine.multiview";
  15027. /**
  15028. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15029. * This will not be used for webXR as it supports displaying texture arrays directly
  15030. */
  15031. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15032. /**
  15033. * Initializes a VRMultiviewToSingleview
  15034. * @param name name of the post process
  15035. * @param camera camera to be applied to
  15036. * @param scaleFactor scaling factor to the size of the output texture
  15037. */
  15038. constructor(name: string, camera: Camera, scaleFactor: number);
  15039. }
  15040. }
  15041. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15042. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15043. import { Nullable } from "babylonjs/types";
  15044. import { Size } from "babylonjs/Maths/math.size";
  15045. import { Observable } from "babylonjs/Misc/observable";
  15046. module "babylonjs/Engines/engine" {
  15047. interface Engine {
  15048. /** @hidden */
  15049. _vrDisplay: any;
  15050. /** @hidden */
  15051. _vrSupported: boolean;
  15052. /** @hidden */
  15053. _oldSize: Size;
  15054. /** @hidden */
  15055. _oldHardwareScaleFactor: number;
  15056. /** @hidden */
  15057. _vrExclusivePointerMode: boolean;
  15058. /** @hidden */
  15059. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15060. /** @hidden */
  15061. _onVRDisplayPointerRestricted: () => void;
  15062. /** @hidden */
  15063. _onVRDisplayPointerUnrestricted: () => void;
  15064. /** @hidden */
  15065. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15066. /** @hidden */
  15067. _onVrDisplayDisconnect: Nullable<() => void>;
  15068. /** @hidden */
  15069. _onVrDisplayPresentChange: Nullable<() => void>;
  15070. /**
  15071. * Observable signaled when VR display mode changes
  15072. */
  15073. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15074. /**
  15075. * Observable signaled when VR request present is complete
  15076. */
  15077. onVRRequestPresentComplete: Observable<boolean>;
  15078. /**
  15079. * Observable signaled when VR request present starts
  15080. */
  15081. onVRRequestPresentStart: Observable<Engine>;
  15082. /**
  15083. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15084. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15085. */
  15086. isInVRExclusivePointerMode: boolean;
  15087. /**
  15088. * Gets a boolean indicating if a webVR device was detected
  15089. * @returns true if a webVR device was detected
  15090. */
  15091. isVRDevicePresent(): boolean;
  15092. /**
  15093. * Gets the current webVR device
  15094. * @returns the current webVR device (or null)
  15095. */
  15096. getVRDevice(): any;
  15097. /**
  15098. * Initializes a webVR display and starts listening to display change events
  15099. * The onVRDisplayChangedObservable will be notified upon these changes
  15100. * @returns A promise containing a VRDisplay and if vr is supported
  15101. */
  15102. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15103. /** @hidden */
  15104. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15105. /**
  15106. * Call this function to switch to webVR mode
  15107. * Will do nothing if webVR is not supported or if there is no webVR device
  15108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15109. */
  15110. enableVR(): void;
  15111. /** @hidden */
  15112. _onVRFullScreenTriggered(): void;
  15113. }
  15114. }
  15115. }
  15116. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15117. import { Nullable } from "babylonjs/types";
  15118. import { Observable } from "babylonjs/Misc/observable";
  15119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15120. import { Scene } from "babylonjs/scene";
  15121. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15122. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15123. import { Node } from "babylonjs/node";
  15124. import { Ray } from "babylonjs/Culling/ray";
  15125. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15126. import "babylonjs/Engines/Extensions/engine.webVR";
  15127. /**
  15128. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15129. * IMPORTANT!! The data is right-hand data.
  15130. * @export
  15131. * @interface DevicePose
  15132. */
  15133. export interface DevicePose {
  15134. /**
  15135. * The position of the device, values in array are [x,y,z].
  15136. */
  15137. readonly position: Nullable<Float32Array>;
  15138. /**
  15139. * The linearVelocity of the device, values in array are [x,y,z].
  15140. */
  15141. readonly linearVelocity: Nullable<Float32Array>;
  15142. /**
  15143. * The linearAcceleration of the device, values in array are [x,y,z].
  15144. */
  15145. readonly linearAcceleration: Nullable<Float32Array>;
  15146. /**
  15147. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15148. */
  15149. readonly orientation: Nullable<Float32Array>;
  15150. /**
  15151. * The angularVelocity of the device, values in array are [x,y,z].
  15152. */
  15153. readonly angularVelocity: Nullable<Float32Array>;
  15154. /**
  15155. * The angularAcceleration of the device, values in array are [x,y,z].
  15156. */
  15157. readonly angularAcceleration: Nullable<Float32Array>;
  15158. }
  15159. /**
  15160. * Interface representing a pose controlled object in Babylon.
  15161. * A pose controlled object has both regular pose values as well as pose values
  15162. * from an external device such as a VR head mounted display
  15163. */
  15164. export interface PoseControlled {
  15165. /**
  15166. * The position of the object in babylon space.
  15167. */
  15168. position: Vector3;
  15169. /**
  15170. * The rotation quaternion of the object in babylon space.
  15171. */
  15172. rotationQuaternion: Quaternion;
  15173. /**
  15174. * The position of the device in babylon space.
  15175. */
  15176. devicePosition?: Vector3;
  15177. /**
  15178. * The rotation quaternion of the device in babylon space.
  15179. */
  15180. deviceRotationQuaternion: Quaternion;
  15181. /**
  15182. * The raw pose coming from the device.
  15183. */
  15184. rawPose: Nullable<DevicePose>;
  15185. /**
  15186. * The scale of the device to be used when translating from device space to babylon space.
  15187. */
  15188. deviceScaleFactor: number;
  15189. /**
  15190. * Updates the poseControlled values based on the input device pose.
  15191. * @param poseData the pose data to update the object with
  15192. */
  15193. updateFromDevice(poseData: DevicePose): void;
  15194. }
  15195. /**
  15196. * Set of options to customize the webVRCamera
  15197. */
  15198. export interface WebVROptions {
  15199. /**
  15200. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15201. */
  15202. trackPosition?: boolean;
  15203. /**
  15204. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15205. */
  15206. positionScale?: number;
  15207. /**
  15208. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15209. */
  15210. displayName?: string;
  15211. /**
  15212. * Should the native controller meshes be initialized. (default: true)
  15213. */
  15214. controllerMeshes?: boolean;
  15215. /**
  15216. * Creating a default HemiLight only on controllers. (default: true)
  15217. */
  15218. defaultLightingOnControllers?: boolean;
  15219. /**
  15220. * If you don't want to use the default VR button of the helper. (default: false)
  15221. */
  15222. useCustomVRButton?: boolean;
  15223. /**
  15224. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15225. */
  15226. customVRButton?: HTMLButtonElement;
  15227. /**
  15228. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15229. */
  15230. rayLength?: number;
  15231. /**
  15232. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15233. */
  15234. defaultHeight?: number;
  15235. /**
  15236. * If multiview should be used if availible (default: false)
  15237. */
  15238. useMultiview?: boolean;
  15239. }
  15240. /**
  15241. * This represents a WebVR camera.
  15242. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15243. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15244. */
  15245. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15246. private webVROptions;
  15247. /**
  15248. * @hidden
  15249. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15250. */
  15251. _vrDevice: any;
  15252. /**
  15253. * The rawPose of the vrDevice.
  15254. */
  15255. rawPose: Nullable<DevicePose>;
  15256. private _onVREnabled;
  15257. private _specsVersion;
  15258. private _attached;
  15259. private _frameData;
  15260. protected _descendants: Array<Node>;
  15261. private _deviceRoomPosition;
  15262. /** @hidden */
  15263. _deviceRoomRotationQuaternion: Quaternion;
  15264. private _standingMatrix;
  15265. /**
  15266. * Represents device position in babylon space.
  15267. */
  15268. devicePosition: Vector3;
  15269. /**
  15270. * Represents device rotation in babylon space.
  15271. */
  15272. deviceRotationQuaternion: Quaternion;
  15273. /**
  15274. * The scale of the device to be used when translating from device space to babylon space.
  15275. */
  15276. deviceScaleFactor: number;
  15277. private _deviceToWorld;
  15278. private _worldToDevice;
  15279. /**
  15280. * References to the webVR controllers for the vrDevice.
  15281. */
  15282. controllers: Array<WebVRController>;
  15283. /**
  15284. * Emits an event when a controller is attached.
  15285. */
  15286. onControllersAttachedObservable: Observable<WebVRController[]>;
  15287. /**
  15288. * Emits an event when a controller's mesh has been loaded;
  15289. */
  15290. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15291. /**
  15292. * Emits an event when the HMD's pose has been updated.
  15293. */
  15294. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15295. private _poseSet;
  15296. /**
  15297. * If the rig cameras be used as parent instead of this camera.
  15298. */
  15299. rigParenting: boolean;
  15300. private _lightOnControllers;
  15301. private _defaultHeight?;
  15302. /**
  15303. * Instantiates a WebVRFreeCamera.
  15304. * @param name The name of the WebVRFreeCamera
  15305. * @param position The starting anchor position for the camera
  15306. * @param scene The scene the camera belongs to
  15307. * @param webVROptions a set of customizable options for the webVRCamera
  15308. */
  15309. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15310. /**
  15311. * Gets the device distance from the ground in meters.
  15312. * @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.
  15313. */
  15314. deviceDistanceToRoomGround(): number;
  15315. /**
  15316. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15317. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15318. */
  15319. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15320. /**
  15321. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15322. * @returns A promise with a boolean set to if the standing matrix is supported.
  15323. */
  15324. useStandingMatrixAsync(): Promise<boolean>;
  15325. /**
  15326. * Disposes the camera
  15327. */
  15328. dispose(): void;
  15329. /**
  15330. * Gets a vrController by name.
  15331. * @param name The name of the controller to retreive
  15332. * @returns the controller matching the name specified or null if not found
  15333. */
  15334. getControllerByName(name: string): Nullable<WebVRController>;
  15335. private _leftController;
  15336. /**
  15337. * The controller corresponding to the users left hand.
  15338. */
  15339. readonly leftController: Nullable<WebVRController>;
  15340. private _rightController;
  15341. /**
  15342. * The controller corresponding to the users right hand.
  15343. */
  15344. readonly rightController: Nullable<WebVRController>;
  15345. /**
  15346. * Casts a ray forward from the vrCamera's gaze.
  15347. * @param length Length of the ray (default: 100)
  15348. * @returns the ray corresponding to the gaze
  15349. */
  15350. getForwardRay(length?: number): Ray;
  15351. /**
  15352. * @hidden
  15353. * Updates the camera based on device's frame data
  15354. */
  15355. _checkInputs(): void;
  15356. /**
  15357. * Updates the poseControlled values based on the input device pose.
  15358. * @param poseData Pose coming from the device
  15359. */
  15360. updateFromDevice(poseData: DevicePose): void;
  15361. private _htmlElementAttached;
  15362. private _detachIfAttached;
  15363. /**
  15364. * WebVR's attach control will start broadcasting frames to the device.
  15365. * Note that in certain browsers (chrome for example) this function must be called
  15366. * within a user-interaction callback. Example:
  15367. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15368. *
  15369. * @param element html element to attach the vrDevice to
  15370. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15371. */
  15372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15373. /**
  15374. * Detaches the camera from the html element and disables VR
  15375. *
  15376. * @param element html element to detach from
  15377. */
  15378. detachControl(element: HTMLElement): void;
  15379. /**
  15380. * @returns the name of this class
  15381. */
  15382. getClassName(): string;
  15383. /**
  15384. * Calls resetPose on the vrDisplay
  15385. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15386. */
  15387. resetToCurrentRotation(): void;
  15388. /**
  15389. * @hidden
  15390. * Updates the rig cameras (left and right eye)
  15391. */
  15392. _updateRigCameras(): void;
  15393. private _workingVector;
  15394. private _oneVector;
  15395. private _workingMatrix;
  15396. private updateCacheCalled;
  15397. private _correctPositionIfNotTrackPosition;
  15398. /**
  15399. * @hidden
  15400. * Updates the cached values of the camera
  15401. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15402. */
  15403. _updateCache(ignoreParentClass?: boolean): void;
  15404. /**
  15405. * @hidden
  15406. * Get current device position in babylon world
  15407. */
  15408. _computeDevicePosition(): void;
  15409. /**
  15410. * Updates the current device position and rotation in the babylon world
  15411. */
  15412. update(): void;
  15413. /**
  15414. * @hidden
  15415. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15416. * @returns an identity matrix
  15417. */
  15418. _getViewMatrix(): Matrix;
  15419. private _tmpMatrix;
  15420. /**
  15421. * This function is called by the two RIG cameras.
  15422. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15423. * @hidden
  15424. */
  15425. _getWebVRViewMatrix(): Matrix;
  15426. /** @hidden */
  15427. _getWebVRProjectionMatrix(): Matrix;
  15428. private _onGamepadConnectedObserver;
  15429. private _onGamepadDisconnectedObserver;
  15430. private _updateCacheWhenTrackingDisabledObserver;
  15431. /**
  15432. * Initializes the controllers and their meshes
  15433. */
  15434. initControllers(): void;
  15435. }
  15436. }
  15437. declare module "babylonjs/PostProcesses/postProcess" {
  15438. import { Nullable } from "babylonjs/types";
  15439. import { SmartArray } from "babylonjs/Misc/smartArray";
  15440. import { Observable } from "babylonjs/Misc/observable";
  15441. import { Vector2 } from "babylonjs/Maths/math.vector";
  15442. import { Camera } from "babylonjs/Cameras/camera";
  15443. import { Effect } from "babylonjs/Materials/effect";
  15444. import "babylonjs/Shaders/postprocess.vertex";
  15445. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15446. import { Engine } from "babylonjs/Engines/engine";
  15447. import { Color4 } from "babylonjs/Maths/math.color";
  15448. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15450. /**
  15451. * Size options for a post process
  15452. */
  15453. export type PostProcessOptions = {
  15454. width: number;
  15455. height: number;
  15456. };
  15457. /**
  15458. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15459. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15460. */
  15461. export class PostProcess {
  15462. /** Name of the PostProcess. */
  15463. name: string;
  15464. /**
  15465. * Gets or sets the unique id of the post process
  15466. */
  15467. uniqueId: number;
  15468. /**
  15469. * Width of the texture to apply the post process on
  15470. */
  15471. width: number;
  15472. /**
  15473. * Height of the texture to apply the post process on
  15474. */
  15475. height: number;
  15476. /**
  15477. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15478. * @hidden
  15479. */
  15480. _outputTexture: Nullable<InternalTexture>;
  15481. /**
  15482. * Sampling mode used by the shader
  15483. * See https://doc.babylonjs.com/classes/3.1/texture
  15484. */
  15485. renderTargetSamplingMode: number;
  15486. /**
  15487. * Clear color to use when screen clearing
  15488. */
  15489. clearColor: Color4;
  15490. /**
  15491. * If the buffer needs to be cleared before applying the post process. (default: true)
  15492. * Should be set to false if shader will overwrite all previous pixels.
  15493. */
  15494. autoClear: boolean;
  15495. /**
  15496. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15497. */
  15498. alphaMode: number;
  15499. /**
  15500. * Sets the setAlphaBlendConstants of the babylon engine
  15501. */
  15502. alphaConstants: Color4;
  15503. /**
  15504. * Animations to be used for the post processing
  15505. */
  15506. animations: import("babylonjs/Animations/animation").Animation[];
  15507. /**
  15508. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15509. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15510. */
  15511. enablePixelPerfectMode: boolean;
  15512. /**
  15513. * Force the postprocess to be applied without taking in account viewport
  15514. */
  15515. forceFullscreenViewport: boolean;
  15516. /**
  15517. * List of inspectable custom properties (used by the Inspector)
  15518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15519. */
  15520. inspectableCustomProperties: IInspectable[];
  15521. /**
  15522. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15523. *
  15524. * | Value | Type | Description |
  15525. * | ----- | ----------------------------------- | ----------- |
  15526. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15527. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15528. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15529. *
  15530. */
  15531. scaleMode: number;
  15532. /**
  15533. * Force textures to be a power of two (default: false)
  15534. */
  15535. alwaysForcePOT: boolean;
  15536. private _samples;
  15537. /**
  15538. * Number of sample textures (default: 1)
  15539. */
  15540. samples: number;
  15541. /**
  15542. * Modify the scale of the post process to be the same as the viewport (default: false)
  15543. */
  15544. adaptScaleToCurrentViewport: boolean;
  15545. private _camera;
  15546. private _scene;
  15547. private _engine;
  15548. private _options;
  15549. private _reusable;
  15550. private _textureType;
  15551. /**
  15552. * Smart array of input and output textures for the post process.
  15553. * @hidden
  15554. */
  15555. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15556. /**
  15557. * The index in _textures that corresponds to the output texture.
  15558. * @hidden
  15559. */
  15560. _currentRenderTextureInd: number;
  15561. private _effect;
  15562. private _samplers;
  15563. private _fragmentUrl;
  15564. private _vertexUrl;
  15565. private _parameters;
  15566. private _scaleRatio;
  15567. protected _indexParameters: any;
  15568. private _shareOutputWithPostProcess;
  15569. private _texelSize;
  15570. private _forcedOutputTexture;
  15571. /**
  15572. * Returns the fragment url or shader name used in the post process.
  15573. * @returns the fragment url or name in the shader store.
  15574. */
  15575. getEffectName(): string;
  15576. /**
  15577. * An event triggered when the postprocess is activated.
  15578. */
  15579. onActivateObservable: Observable<Camera>;
  15580. private _onActivateObserver;
  15581. /**
  15582. * A function that is added to the onActivateObservable
  15583. */
  15584. onActivate: Nullable<(camera: Camera) => void>;
  15585. /**
  15586. * An event triggered when the postprocess changes its size.
  15587. */
  15588. onSizeChangedObservable: Observable<PostProcess>;
  15589. private _onSizeChangedObserver;
  15590. /**
  15591. * A function that is added to the onSizeChangedObservable
  15592. */
  15593. onSizeChanged: (postProcess: PostProcess) => void;
  15594. /**
  15595. * An event triggered when the postprocess applies its effect.
  15596. */
  15597. onApplyObservable: Observable<Effect>;
  15598. private _onApplyObserver;
  15599. /**
  15600. * A function that is added to the onApplyObservable
  15601. */
  15602. onApply: (effect: Effect) => void;
  15603. /**
  15604. * An event triggered before rendering the postprocess
  15605. */
  15606. onBeforeRenderObservable: Observable<Effect>;
  15607. private _onBeforeRenderObserver;
  15608. /**
  15609. * A function that is added to the onBeforeRenderObservable
  15610. */
  15611. onBeforeRender: (effect: Effect) => void;
  15612. /**
  15613. * An event triggered after rendering the postprocess
  15614. */
  15615. onAfterRenderObservable: Observable<Effect>;
  15616. private _onAfterRenderObserver;
  15617. /**
  15618. * A function that is added to the onAfterRenderObservable
  15619. */
  15620. onAfterRender: (efect: Effect) => void;
  15621. /**
  15622. * 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
  15623. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15624. */
  15625. inputTexture: InternalTexture;
  15626. /**
  15627. * Gets the camera which post process is applied to.
  15628. * @returns The camera the post process is applied to.
  15629. */
  15630. getCamera(): Camera;
  15631. /**
  15632. * Gets the texel size of the postprocess.
  15633. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15634. */
  15635. readonly texelSize: Vector2;
  15636. /**
  15637. * Creates a new instance PostProcess
  15638. * @param name The name of the PostProcess.
  15639. * @param fragmentUrl The url of the fragment shader to be used.
  15640. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15641. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15642. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15643. * @param camera The camera to apply the render pass to.
  15644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15645. * @param engine The engine which the post process will be applied. (default: current engine)
  15646. * @param reusable If the post process can be reused on the same frame. (default: false)
  15647. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15648. * @param textureType Type of textures used when performing the post process. (default: 0)
  15649. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15650. * @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
  15651. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15652. */
  15653. constructor(
  15654. /** Name of the PostProcess. */
  15655. 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);
  15656. /**
  15657. * Gets a string idenfifying the name of the class
  15658. * @returns "PostProcess" string
  15659. */
  15660. getClassName(): string;
  15661. /**
  15662. * Gets the engine which this post process belongs to.
  15663. * @returns The engine the post process was enabled with.
  15664. */
  15665. getEngine(): Engine;
  15666. /**
  15667. * The effect that is created when initializing the post process.
  15668. * @returns The created effect corresponding the the postprocess.
  15669. */
  15670. getEffect(): Effect;
  15671. /**
  15672. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15673. * @param postProcess The post process to share the output with.
  15674. * @returns This post process.
  15675. */
  15676. shareOutputWith(postProcess: PostProcess): PostProcess;
  15677. /**
  15678. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15679. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15680. */
  15681. useOwnOutput(): void;
  15682. /**
  15683. * Updates the effect with the current post process compile time values and recompiles the shader.
  15684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15687. * @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
  15688. * @param onCompiled Called when the shader has been compiled.
  15689. * @param onError Called if there is an error when compiling a shader.
  15690. */
  15691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15692. /**
  15693. * The post process is reusable if it can be used multiple times within one frame.
  15694. * @returns If the post process is reusable
  15695. */
  15696. isReusable(): boolean;
  15697. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15698. markTextureDirty(): void;
  15699. /**
  15700. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15701. * 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.
  15702. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15703. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15704. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15705. * @returns The target texture that was bound to be written to.
  15706. */
  15707. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15708. /**
  15709. * If the post process is supported.
  15710. */
  15711. readonly isSupported: boolean;
  15712. /**
  15713. * The aspect ratio of the output texture.
  15714. */
  15715. readonly aspectRatio: number;
  15716. /**
  15717. * Get a value indicating if the post-process is ready to be used
  15718. * @returns true if the post-process is ready (shader is compiled)
  15719. */
  15720. isReady(): boolean;
  15721. /**
  15722. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15723. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15724. */
  15725. apply(): Nullable<Effect>;
  15726. private _disposeTextures;
  15727. /**
  15728. * Disposes the post process.
  15729. * @param camera The camera to dispose the post process on.
  15730. */
  15731. dispose(camera?: Camera): void;
  15732. }
  15733. }
  15734. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15735. /** @hidden */
  15736. export var kernelBlurVaryingDeclaration: {
  15737. name: string;
  15738. shader: string;
  15739. };
  15740. }
  15741. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15742. /** @hidden */
  15743. export var kernelBlurFragment: {
  15744. name: string;
  15745. shader: string;
  15746. };
  15747. }
  15748. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15749. /** @hidden */
  15750. export var kernelBlurFragment2: {
  15751. name: string;
  15752. shader: string;
  15753. };
  15754. }
  15755. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15757. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15758. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15759. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15760. /** @hidden */
  15761. export var kernelBlurPixelShader: {
  15762. name: string;
  15763. shader: string;
  15764. };
  15765. }
  15766. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15767. /** @hidden */
  15768. export var kernelBlurVertex: {
  15769. name: string;
  15770. shader: string;
  15771. };
  15772. }
  15773. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15774. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15775. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15776. /** @hidden */
  15777. export var kernelBlurVertexShader: {
  15778. name: string;
  15779. shader: string;
  15780. };
  15781. }
  15782. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15783. import { Vector2 } from "babylonjs/Maths/math.vector";
  15784. import { Nullable } from "babylonjs/types";
  15785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15786. import { Camera } from "babylonjs/Cameras/camera";
  15787. import { Effect } from "babylonjs/Materials/effect";
  15788. import { Engine } from "babylonjs/Engines/engine";
  15789. import "babylonjs/Shaders/kernelBlur.fragment";
  15790. import "babylonjs/Shaders/kernelBlur.vertex";
  15791. /**
  15792. * The Blur Post Process which blurs an image based on a kernel and direction.
  15793. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15794. */
  15795. export class BlurPostProcess extends PostProcess {
  15796. /** The direction in which to blur the image. */
  15797. direction: Vector2;
  15798. private blockCompilation;
  15799. protected _kernel: number;
  15800. protected _idealKernel: number;
  15801. protected _packedFloat: boolean;
  15802. private _staticDefines;
  15803. /**
  15804. * Sets the length in pixels of the blur sample region
  15805. */
  15806. /**
  15807. * Gets the length in pixels of the blur sample region
  15808. */
  15809. kernel: number;
  15810. /**
  15811. * Sets wether or not the blur needs to unpack/repack floats
  15812. */
  15813. /**
  15814. * Gets wether or not the blur is unpacking/repacking floats
  15815. */
  15816. packedFloat: boolean;
  15817. /**
  15818. * Creates a new instance BlurPostProcess
  15819. * @param name The name of the effect.
  15820. * @param direction The direction in which to blur the image.
  15821. * @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.
  15822. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15823. * @param camera The camera to apply the render pass to.
  15824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15825. * @param engine The engine which the post process will be applied. (default: current engine)
  15826. * @param reusable If the post process can be reused on the same frame. (default: false)
  15827. * @param textureType Type of textures used when performing the post process. (default: 0)
  15828. * @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)
  15829. */
  15830. constructor(name: string,
  15831. /** The direction in which to blur the image. */
  15832. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15833. /**
  15834. * Updates the effect with the current post process compile time values and recompiles the shader.
  15835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15838. * @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
  15839. * @param onCompiled Called when the shader has been compiled.
  15840. * @param onError Called if there is an error when compiling a shader.
  15841. */
  15842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15843. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15844. /**
  15845. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15846. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15847. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15848. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15849. * The gaps between physical kernels are compensated for in the weighting of the samples
  15850. * @param idealKernel Ideal blur kernel.
  15851. * @return Nearest best kernel.
  15852. */
  15853. protected _nearestBestKernel(idealKernel: number): number;
  15854. /**
  15855. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15856. * @param x The point on the Gaussian distribution to sample.
  15857. * @return the value of the Gaussian function at x.
  15858. */
  15859. protected _gaussianWeight(x: number): number;
  15860. /**
  15861. * Generates a string that can be used as a floating point number in GLSL.
  15862. * @param x Value to print.
  15863. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15864. * @return GLSL float string.
  15865. */
  15866. protected _glslFloat(x: number, decimalFigures?: number): string;
  15867. }
  15868. }
  15869. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15870. import { Scene } from "babylonjs/scene";
  15871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15872. import { Plane } from "babylonjs/Maths/math.plane";
  15873. /**
  15874. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15875. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15876. * You can then easily use it as a reflectionTexture on a flat surface.
  15877. * In case the surface is not a plane, please consider relying on reflection probes.
  15878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15879. */
  15880. export class MirrorTexture extends RenderTargetTexture {
  15881. private scene;
  15882. /**
  15883. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15884. * 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.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. */
  15887. mirrorPlane: Plane;
  15888. /**
  15889. * Define the blur ratio used to blur the reflection if needed.
  15890. */
  15891. blurRatio: number;
  15892. /**
  15893. * Define the adaptive blur kernel used to blur the reflection if needed.
  15894. * This will autocompute the closest best match for the `blurKernel`
  15895. */
  15896. adaptiveBlurKernel: number;
  15897. /**
  15898. * Define the blur kernel used to blur the reflection if needed.
  15899. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15900. */
  15901. blurKernel: number;
  15902. /**
  15903. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15904. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15905. */
  15906. blurKernelX: number;
  15907. /**
  15908. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15909. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15910. */
  15911. blurKernelY: number;
  15912. private _autoComputeBlurKernel;
  15913. protected _onRatioRescale(): void;
  15914. private _updateGammaSpace;
  15915. private _imageProcessingConfigChangeObserver;
  15916. private _transformMatrix;
  15917. private _mirrorMatrix;
  15918. private _savedViewMatrix;
  15919. private _blurX;
  15920. private _blurY;
  15921. private _adaptiveBlurKernel;
  15922. private _blurKernelX;
  15923. private _blurKernelY;
  15924. private _blurRatio;
  15925. /**
  15926. * Instantiates a Mirror Texture.
  15927. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15928. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15929. * You can then easily use it as a reflectionTexture on a flat surface.
  15930. * In case the surface is not a plane, please consider relying on reflection probes.
  15931. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15932. * @param name
  15933. * @param size
  15934. * @param scene
  15935. * @param generateMipMaps
  15936. * @param type
  15937. * @param samplingMode
  15938. * @param generateDepthBuffer
  15939. */
  15940. constructor(name: string, size: number | {
  15941. width: number;
  15942. height: number;
  15943. } | {
  15944. ratio: number;
  15945. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15946. private _preparePostProcesses;
  15947. /**
  15948. * Clone the mirror texture.
  15949. * @returns the cloned texture
  15950. */
  15951. clone(): MirrorTexture;
  15952. /**
  15953. * Serialize the texture to a JSON representation you could use in Parse later on
  15954. * @returns the serialized JSON representation
  15955. */
  15956. serialize(): any;
  15957. /**
  15958. * Dispose the texture and release its associated resources.
  15959. */
  15960. dispose(): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Materials/Textures/texture" {
  15964. import { Observable } from "babylonjs/Misc/observable";
  15965. import { Nullable } from "babylonjs/types";
  15966. import { Matrix } from "babylonjs/Maths/math.vector";
  15967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15968. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15969. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15970. import { Scene } from "babylonjs/scene";
  15971. /**
  15972. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15973. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15974. */
  15975. export class Texture extends BaseTexture {
  15976. /**
  15977. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15978. */
  15979. static SerializeBuffers: boolean;
  15980. /** @hidden */
  15981. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15982. /** @hidden */
  15983. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15984. /** @hidden */
  15985. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_SAMPLINGMODE: number;
  15988. /** nearest is mag = nearest and min = nearest and mip = linear */
  15989. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly BILINEAR_SAMPLINGMODE: number;
  15992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15993. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly TRILINEAR_SAMPLINGMODE: number;
  15996. /** Trilinear is mag = linear and min = linear and mip = linear */
  15997. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15998. /** mag = nearest and min = nearest and mip = nearest */
  15999. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = nearest */
  16001. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16002. /** mag = nearest and min = linear and mip = linear */
  16003. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16004. /** mag = nearest and min = linear and mip = none */
  16005. static readonly NEAREST_LINEAR: number;
  16006. /** mag = nearest and min = nearest and mip = none */
  16007. static readonly NEAREST_NEAREST: number;
  16008. /** mag = linear and min = nearest and mip = nearest */
  16009. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16010. /** mag = linear and min = nearest and mip = linear */
  16011. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16012. /** mag = linear and min = linear and mip = none */
  16013. static readonly LINEAR_LINEAR: number;
  16014. /** mag = linear and min = nearest and mip = none */
  16015. static readonly LINEAR_NEAREST: number;
  16016. /** Explicit coordinates mode */
  16017. static readonly EXPLICIT_MODE: number;
  16018. /** Spherical coordinates mode */
  16019. static readonly SPHERICAL_MODE: number;
  16020. /** Planar coordinates mode */
  16021. static readonly PLANAR_MODE: number;
  16022. /** Cubic coordinates mode */
  16023. static readonly CUBIC_MODE: number;
  16024. /** Projection coordinates mode */
  16025. static readonly PROJECTION_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly SKYBOX_MODE: number;
  16028. /** Inverse Cubic coordinates mode */
  16029. static readonly INVCUBIC_MODE: number;
  16030. /** Equirectangular coordinates mode */
  16031. static readonly EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16034. /** Equirectangular Fixed Mirrored coordinates mode */
  16035. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16036. /** Texture is not repeating outside of 0..1 UVs */
  16037. static readonly CLAMP_ADDRESSMODE: number;
  16038. /** Texture is repeating outside of 0..1 UVs */
  16039. static readonly WRAP_ADDRESSMODE: number;
  16040. /** Texture is repeating and mirrored */
  16041. static readonly MIRROR_ADDRESSMODE: number;
  16042. /**
  16043. * 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
  16044. */
  16045. static UseSerializedUrlIfAny: boolean;
  16046. /**
  16047. * Define the url of the texture.
  16048. */
  16049. url: Nullable<string>;
  16050. /**
  16051. * Define an offset on the texture to offset the u coordinates of the UVs
  16052. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16053. */
  16054. uOffset: number;
  16055. /**
  16056. * Define an offset on the texture to offset the v coordinates of the UVs
  16057. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16058. */
  16059. vOffset: number;
  16060. /**
  16061. * Define an offset on the texture to scale the u coordinates of the UVs
  16062. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16063. */
  16064. uScale: number;
  16065. /**
  16066. * Define an offset on the texture to scale the v coordinates of the UVs
  16067. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16068. */
  16069. vScale: number;
  16070. /**
  16071. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16072. * @see http://doc.babylonjs.com/how_to/more_materials
  16073. */
  16074. uAng: number;
  16075. /**
  16076. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16077. * @see http://doc.babylonjs.com/how_to/more_materials
  16078. */
  16079. vAng: number;
  16080. /**
  16081. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16082. * @see http://doc.babylonjs.com/how_to/more_materials
  16083. */
  16084. wAng: number;
  16085. /**
  16086. * Defines the center of rotation (U)
  16087. */
  16088. uRotationCenter: number;
  16089. /**
  16090. * Defines the center of rotation (V)
  16091. */
  16092. vRotationCenter: number;
  16093. /**
  16094. * Defines the center of rotation (W)
  16095. */
  16096. wRotationCenter: number;
  16097. /**
  16098. * Are mip maps generated for this texture or not.
  16099. */
  16100. readonly noMipmap: boolean;
  16101. /**
  16102. * List of inspectable custom properties (used by the Inspector)
  16103. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16104. */
  16105. inspectableCustomProperties: Nullable<IInspectable[]>;
  16106. private _noMipmap;
  16107. /** @hidden */
  16108. _invertY: boolean;
  16109. private _rowGenerationMatrix;
  16110. private _cachedTextureMatrix;
  16111. private _projectionModeMatrix;
  16112. private _t0;
  16113. private _t1;
  16114. private _t2;
  16115. private _cachedUOffset;
  16116. private _cachedVOffset;
  16117. private _cachedUScale;
  16118. private _cachedVScale;
  16119. private _cachedUAng;
  16120. private _cachedVAng;
  16121. private _cachedWAng;
  16122. private _cachedProjectionMatrixId;
  16123. private _cachedCoordinatesMode;
  16124. /** @hidden */
  16125. protected _initialSamplingMode: number;
  16126. /** @hidden */
  16127. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16128. private _deleteBuffer;
  16129. protected _format: Nullable<number>;
  16130. private _delayedOnLoad;
  16131. private _delayedOnError;
  16132. private _mimeType?;
  16133. /**
  16134. * Observable triggered once the texture has been loaded.
  16135. */
  16136. onLoadObservable: Observable<Texture>;
  16137. protected _isBlocking: boolean;
  16138. /**
  16139. * Is the texture preventing material to render while loading.
  16140. * If false, a default texture will be used instead of the loading one during the preparation step.
  16141. */
  16142. isBlocking: boolean;
  16143. /**
  16144. * Get the current sampling mode associated with the texture.
  16145. */
  16146. readonly samplingMode: number;
  16147. /**
  16148. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16149. */
  16150. readonly invertY: boolean;
  16151. /**
  16152. * Instantiates a new texture.
  16153. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16154. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16155. * @param url defines the url of the picture to load as a texture
  16156. * @param scene defines the scene or engine the texture will belong to
  16157. * @param noMipmap defines if the texture will require mip maps or not
  16158. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16159. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16160. * @param onLoad defines a callback triggered when the texture has been loaded
  16161. * @param onError defines a callback triggered when an error occurred during the loading session
  16162. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16163. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16164. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16165. * @param mimeType defines an optional mime type information
  16166. */
  16167. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16168. /**
  16169. * Update the url (and optional buffer) of this texture if url was null during construction.
  16170. * @param url the url of the texture
  16171. * @param buffer the buffer of the texture (defaults to null)
  16172. * @param onLoad callback called when the texture is loaded (defaults to null)
  16173. */
  16174. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16175. /**
  16176. * Finish the loading sequence of a texture flagged as delayed load.
  16177. * @hidden
  16178. */
  16179. delayLoad(): void;
  16180. private _prepareRowForTextureGeneration;
  16181. /**
  16182. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16183. * @returns the transform matrix of the texture.
  16184. */
  16185. getTextureMatrix(): Matrix;
  16186. /**
  16187. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16188. * @returns The reflection texture transform
  16189. */
  16190. getReflectionTextureMatrix(): Matrix;
  16191. /**
  16192. * Clones the texture.
  16193. * @returns the cloned texture
  16194. */
  16195. clone(): Texture;
  16196. /**
  16197. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16198. * @returns The JSON representation of the texture
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Get the current class name of the texture useful for serialization or dynamic coding.
  16203. * @returns "Texture"
  16204. */
  16205. getClassName(): string;
  16206. /**
  16207. * Dispose the texture and release its associated resources.
  16208. */
  16209. dispose(): void;
  16210. /**
  16211. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16212. * @param parsedTexture Define the JSON representation of the texture
  16213. * @param scene Define the scene the parsed texture should be instantiated in
  16214. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16215. * @returns The parsed texture if successful
  16216. */
  16217. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16218. /**
  16219. * Creates a texture from its base 64 representation.
  16220. * @param data Define the base64 payload without the data: prefix
  16221. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16222. * @param scene Define the scene the texture should belong to
  16223. * @param noMipmap Forces the texture to not create mip map information if true
  16224. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16225. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16226. * @param onLoad define a callback triggered when the texture has been loaded
  16227. * @param onError define a callback triggered when an error occurred during the loading session
  16228. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16229. * @returns the created texture
  16230. */
  16231. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16232. /**
  16233. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16234. * @param data Define the base64 payload without the data: prefix
  16235. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16236. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16237. * @param scene Define the scene the texture should belong to
  16238. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16239. * @param noMipmap Forces the texture to not create mip map information if true
  16240. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16241. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16242. * @param onLoad define a callback triggered when the texture has been loaded
  16243. * @param onError define a callback triggered when an error occurred during the loading session
  16244. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16245. * @returns the created texture
  16246. */
  16247. 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;
  16248. }
  16249. }
  16250. declare module "babylonjs/PostProcesses/postProcessManager" {
  16251. import { Nullable } from "babylonjs/types";
  16252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16253. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16254. import { Scene } from "babylonjs/scene";
  16255. /**
  16256. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16257. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16258. */
  16259. export class PostProcessManager {
  16260. private _scene;
  16261. private _indexBuffer;
  16262. private _vertexBuffers;
  16263. /**
  16264. * Creates a new instance PostProcess
  16265. * @param scene The scene that the post process is associated with.
  16266. */
  16267. constructor(scene: Scene);
  16268. private _prepareBuffers;
  16269. private _buildIndexBuffer;
  16270. /**
  16271. * Rebuilds the vertex buffers of the manager.
  16272. * @hidden
  16273. */
  16274. _rebuild(): void;
  16275. /**
  16276. * Prepares a frame to be run through a post process.
  16277. * @param sourceTexture The input texture to the post procesess. (default: null)
  16278. * @param postProcesses An array of post processes to be run. (default: null)
  16279. * @returns True if the post processes were able to be run.
  16280. * @hidden
  16281. */
  16282. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16283. /**
  16284. * Manually render a set of post processes to a texture.
  16285. * @param postProcesses An array of post processes to be run.
  16286. * @param targetTexture The target texture to render to.
  16287. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16288. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16289. * @param lodLevel defines which lod of the texture to render to
  16290. */
  16291. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16292. /**
  16293. * Finalize the result of the output of the postprocesses.
  16294. * @param doNotPresent If true the result will not be displayed to the screen.
  16295. * @param targetTexture The target texture to render to.
  16296. * @param faceIndex The index of the face to bind the target texture to.
  16297. * @param postProcesses The array of post processes to render.
  16298. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16299. * @hidden
  16300. */
  16301. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16302. /**
  16303. * Disposes of the post process manager.
  16304. */
  16305. dispose(): void;
  16306. }
  16307. }
  16308. declare module "babylonjs/Misc/gradients" {
  16309. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16310. /** Interface used by value gradients (color, factor, ...) */
  16311. export interface IValueGradient {
  16312. /**
  16313. * Gets or sets the gradient value (between 0 and 1)
  16314. */
  16315. gradient: number;
  16316. }
  16317. /** Class used to store color4 gradient */
  16318. export class ColorGradient implements IValueGradient {
  16319. /**
  16320. * Gets or sets the gradient value (between 0 and 1)
  16321. */
  16322. gradient: number;
  16323. /**
  16324. * Gets or sets first associated color
  16325. */
  16326. color1: Color4;
  16327. /**
  16328. * Gets or sets second associated color
  16329. */
  16330. color2?: Color4;
  16331. /**
  16332. * Will get a color picked randomly between color1 and color2.
  16333. * If color2 is undefined then color1 will be used
  16334. * @param result defines the target Color4 to store the result in
  16335. */
  16336. getColorToRef(result: Color4): void;
  16337. }
  16338. /** Class used to store color 3 gradient */
  16339. export class Color3Gradient implements IValueGradient {
  16340. /**
  16341. * Gets or sets the gradient value (between 0 and 1)
  16342. */
  16343. gradient: number;
  16344. /**
  16345. * Gets or sets the associated color
  16346. */
  16347. color: Color3;
  16348. }
  16349. /** Class used to store factor gradient */
  16350. export class FactorGradient implements IValueGradient {
  16351. /**
  16352. * Gets or sets the gradient value (between 0 and 1)
  16353. */
  16354. gradient: number;
  16355. /**
  16356. * Gets or sets first associated factor
  16357. */
  16358. factor1: number;
  16359. /**
  16360. * Gets or sets second associated factor
  16361. */
  16362. factor2?: number;
  16363. /**
  16364. * Will get a number picked randomly between factor1 and factor2.
  16365. * If factor2 is undefined then factor1 will be used
  16366. * @returns the picked number
  16367. */
  16368. getFactor(): number;
  16369. }
  16370. /**
  16371. * Helper used to simplify some generic gradient tasks
  16372. */
  16373. export class GradientHelper {
  16374. /**
  16375. * Gets the current gradient from an array of IValueGradient
  16376. * @param ratio defines the current ratio to get
  16377. * @param gradients defines the array of IValueGradient
  16378. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16379. */
  16380. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16381. }
  16382. }
  16383. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16385. import { Nullable } from "babylonjs/types";
  16386. module "babylonjs/Engines/thinEngine" {
  16387. interface ThinEngine {
  16388. /**
  16389. * Creates a dynamic texture
  16390. * @param width defines the width of the texture
  16391. * @param height defines the height of the texture
  16392. * @param generateMipMaps defines if the engine should generate the mip levels
  16393. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16394. * @returns the dynamic texture inside an InternalTexture
  16395. */
  16396. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16397. /**
  16398. * Update the content of a dynamic texture
  16399. * @param texture defines the texture to update
  16400. * @param canvas defines the canvas containing the source
  16401. * @param invertY defines if data must be stored with Y axis inverted
  16402. * @param premulAlpha defines if alpha is stored as premultiplied
  16403. * @param format defines the format of the data
  16404. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16405. */
  16406. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16407. }
  16408. }
  16409. }
  16410. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16411. import { Scene } from "babylonjs/scene";
  16412. import { Texture } from "babylonjs/Materials/Textures/texture";
  16413. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16414. /**
  16415. * A class extending Texture allowing drawing on a texture
  16416. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16417. */
  16418. export class DynamicTexture extends Texture {
  16419. private _generateMipMaps;
  16420. private _canvas;
  16421. private _context;
  16422. private _engine;
  16423. /**
  16424. * Creates a DynamicTexture
  16425. * @param name defines the name of the texture
  16426. * @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
  16427. * @param scene defines the scene where you want the texture
  16428. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16429. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16430. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16431. */
  16432. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16433. /**
  16434. * Get the current class name of the texture useful for serialization or dynamic coding.
  16435. * @returns "DynamicTexture"
  16436. */
  16437. getClassName(): string;
  16438. /**
  16439. * Gets the current state of canRescale
  16440. */
  16441. readonly canRescale: boolean;
  16442. private _recreate;
  16443. /**
  16444. * Scales the texture
  16445. * @param ratio the scale factor to apply to both width and height
  16446. */
  16447. scale(ratio: number): void;
  16448. /**
  16449. * Resizes the texture
  16450. * @param width the new width
  16451. * @param height the new height
  16452. */
  16453. scaleTo(width: number, height: number): void;
  16454. /**
  16455. * Gets the context of the canvas used by the texture
  16456. * @returns the canvas context of the dynamic texture
  16457. */
  16458. getContext(): CanvasRenderingContext2D;
  16459. /**
  16460. * Clears the texture
  16461. */
  16462. clear(): void;
  16463. /**
  16464. * Updates the texture
  16465. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16466. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16467. */
  16468. update(invertY?: boolean, premulAlpha?: boolean): void;
  16469. /**
  16470. * Draws text onto the texture
  16471. * @param text defines the text to be drawn
  16472. * @param x defines the placement of the text from the left
  16473. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16474. * @param font defines the font to be used with font-style, font-size, font-name
  16475. * @param color defines the color used for the text
  16476. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16477. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16478. * @param update defines whether texture is immediately update (default is true)
  16479. */
  16480. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16481. /**
  16482. * Clones the texture
  16483. * @returns the clone of the texture.
  16484. */
  16485. clone(): DynamicTexture;
  16486. /**
  16487. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16488. * @returns a serialized dynamic texture object
  16489. */
  16490. serialize(): any;
  16491. /** @hidden */
  16492. _rebuild(): void;
  16493. }
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16496. import { Scene } from "babylonjs/scene";
  16497. import { ISceneComponent } from "babylonjs/sceneComponent";
  16498. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16499. module "babylonjs/abstractScene" {
  16500. interface AbstractScene {
  16501. /**
  16502. * The list of procedural textures added to the scene
  16503. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16504. */
  16505. proceduralTextures: Array<ProceduralTexture>;
  16506. }
  16507. }
  16508. /**
  16509. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16510. * in a given scene.
  16511. */
  16512. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16513. /**
  16514. * The component name helpfull to identify the component in the list of scene components.
  16515. */
  16516. readonly name: string;
  16517. /**
  16518. * The scene the component belongs to.
  16519. */
  16520. scene: Scene;
  16521. /**
  16522. * Creates a new instance of the component for the given scene
  16523. * @param scene Defines the scene to register the component in
  16524. */
  16525. constructor(scene: Scene);
  16526. /**
  16527. * Registers the component in a given scene
  16528. */
  16529. register(): void;
  16530. /**
  16531. * Rebuilds the elements related to this component in case of
  16532. * context lost for instance.
  16533. */
  16534. rebuild(): void;
  16535. /**
  16536. * Disposes the component and the associated ressources.
  16537. */
  16538. dispose(): void;
  16539. private _beforeClear;
  16540. }
  16541. }
  16542. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16544. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16545. module "babylonjs/Engines/thinEngine" {
  16546. interface ThinEngine {
  16547. /**
  16548. * Creates a new render target cube texture
  16549. * @param size defines the size of the texture
  16550. * @param options defines the options used to create the texture
  16551. * @returns a new render target cube texture stored in an InternalTexture
  16552. */
  16553. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16554. }
  16555. }
  16556. }
  16557. declare module "babylonjs/Shaders/procedural.vertex" {
  16558. /** @hidden */
  16559. export var proceduralVertexShader: {
  16560. name: string;
  16561. shader: string;
  16562. };
  16563. }
  16564. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16565. import { Observable } from "babylonjs/Misc/observable";
  16566. import { Nullable } from "babylonjs/types";
  16567. import { Scene } from "babylonjs/scene";
  16568. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16569. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16570. import { Effect } from "babylonjs/Materials/effect";
  16571. import { Texture } from "babylonjs/Materials/Textures/texture";
  16572. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16573. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16574. import "babylonjs/Shaders/procedural.vertex";
  16575. /**
  16576. * 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.
  16577. * This is the base class of any Procedural texture and contains most of the shareable code.
  16578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16579. */
  16580. export class ProceduralTexture extends Texture {
  16581. isCube: boolean;
  16582. /**
  16583. * Define if the texture is enabled or not (disabled texture will not render)
  16584. */
  16585. isEnabled: boolean;
  16586. /**
  16587. * Define if the texture must be cleared before rendering (default is true)
  16588. */
  16589. autoClear: boolean;
  16590. /**
  16591. * Callback called when the texture is generated
  16592. */
  16593. onGenerated: () => void;
  16594. /**
  16595. * Event raised when the texture is generated
  16596. */
  16597. onGeneratedObservable: Observable<ProceduralTexture>;
  16598. /** @hidden */
  16599. _generateMipMaps: boolean;
  16600. /** @hidden **/
  16601. _effect: Effect;
  16602. /** @hidden */
  16603. _textures: {
  16604. [key: string]: Texture;
  16605. };
  16606. private _size;
  16607. private _currentRefreshId;
  16608. private _refreshRate;
  16609. private _vertexBuffers;
  16610. private _indexBuffer;
  16611. private _uniforms;
  16612. private _samplers;
  16613. private _fragment;
  16614. private _floats;
  16615. private _ints;
  16616. private _floatsArrays;
  16617. private _colors3;
  16618. private _colors4;
  16619. private _vectors2;
  16620. private _vectors3;
  16621. private _matrices;
  16622. private _fallbackTexture;
  16623. private _fallbackTextureUsed;
  16624. private _engine;
  16625. private _cachedDefines;
  16626. private _contentUpdateId;
  16627. private _contentData;
  16628. /**
  16629. * Instantiates a new procedural texture.
  16630. * 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.
  16631. * This is the base class of any Procedural texture and contains most of the shareable code.
  16632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16633. * @param name Define the name of the texture
  16634. * @param size Define the size of the texture to create
  16635. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16636. * @param scene Define the scene the texture belongs to
  16637. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16638. * @param generateMipMaps Define if the texture should creates mip maps or not
  16639. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16640. */
  16641. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16642. /**
  16643. * The effect that is created when initializing the post process.
  16644. * @returns The created effect corresponding the the postprocess.
  16645. */
  16646. getEffect(): Effect;
  16647. /**
  16648. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16649. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16650. */
  16651. getContent(): Nullable<ArrayBufferView>;
  16652. private _createIndexBuffer;
  16653. /** @hidden */
  16654. _rebuild(): void;
  16655. /**
  16656. * Resets the texture in order to recreate its associated resources.
  16657. * This can be called in case of context loss
  16658. */
  16659. reset(): void;
  16660. protected _getDefines(): string;
  16661. /**
  16662. * Is the texture ready to be used ? (rendered at least once)
  16663. * @returns true if ready, otherwise, false.
  16664. */
  16665. isReady(): boolean;
  16666. /**
  16667. * Resets the refresh counter of the texture and start bak from scratch.
  16668. * Could be useful to regenerate the texture if it is setup to render only once.
  16669. */
  16670. resetRefreshCounter(): void;
  16671. /**
  16672. * Set the fragment shader to use in order to render the texture.
  16673. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16674. */
  16675. setFragment(fragment: any): void;
  16676. /**
  16677. * Define the refresh rate of the texture or the rendering frequency.
  16678. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16679. */
  16680. refreshRate: number;
  16681. /** @hidden */
  16682. _shouldRender(): boolean;
  16683. /**
  16684. * Get the size the texture is rendering at.
  16685. * @returns the size (texture is always squared)
  16686. */
  16687. getRenderSize(): number;
  16688. /**
  16689. * Resize the texture to new value.
  16690. * @param size Define the new size the texture should have
  16691. * @param generateMipMaps Define whether the new texture should create mip maps
  16692. */
  16693. resize(size: number, generateMipMaps: boolean): void;
  16694. private _checkUniform;
  16695. /**
  16696. * Set a texture in the shader program used to render.
  16697. * @param name Define the name of the uniform samplers as defined in the shader
  16698. * @param texture Define the texture to bind to this sampler
  16699. * @return the texture itself allowing "fluent" like uniform updates
  16700. */
  16701. setTexture(name: string, texture: Texture): ProceduralTexture;
  16702. /**
  16703. * Set a float in the shader.
  16704. * @param name Define the name of the uniform as defined in the shader
  16705. * @param value Define the value to give to the uniform
  16706. * @return the texture itself allowing "fluent" like uniform updates
  16707. */
  16708. setFloat(name: string, value: number): ProceduralTexture;
  16709. /**
  16710. * Set a int in the shader.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the texture itself allowing "fluent" like uniform updates
  16714. */
  16715. setInt(name: string, value: number): ProceduralTexture;
  16716. /**
  16717. * Set an array of floats in the shader.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the texture itself allowing "fluent" like uniform updates
  16721. */
  16722. setFloats(name: string, value: number[]): ProceduralTexture;
  16723. /**
  16724. * Set a vec3 in the shader from a Color3.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the texture itself allowing "fluent" like uniform updates
  16728. */
  16729. setColor3(name: string, value: Color3): ProceduralTexture;
  16730. /**
  16731. * Set a vec4 in the shader from a Color4.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the texture itself allowing "fluent" like uniform updates
  16735. */
  16736. setColor4(name: string, value: Color4): ProceduralTexture;
  16737. /**
  16738. * Set a vec2 in the shader from a Vector2.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the texture itself allowing "fluent" like uniform updates
  16742. */
  16743. setVector2(name: string, value: Vector2): ProceduralTexture;
  16744. /**
  16745. * Set a vec3 in the shader from a Vector3.
  16746. * @param name Define the name of the uniform as defined in the shader
  16747. * @param value Define the value to give to the uniform
  16748. * @return the texture itself allowing "fluent" like uniform updates
  16749. */
  16750. setVector3(name: string, value: Vector3): ProceduralTexture;
  16751. /**
  16752. * Set a mat4 in the shader from a MAtrix.
  16753. * @param name Define the name of the uniform as defined in the shader
  16754. * @param value Define the value to give to the uniform
  16755. * @return the texture itself allowing "fluent" like uniform updates
  16756. */
  16757. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16758. /**
  16759. * Render the texture to its associated render target.
  16760. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16761. */
  16762. render(useCameraPostProcess?: boolean): void;
  16763. /**
  16764. * Clone the texture.
  16765. * @returns the cloned texture
  16766. */
  16767. clone(): ProceduralTexture;
  16768. /**
  16769. * Dispose the texture and release its asoociated resources.
  16770. */
  16771. dispose(): void;
  16772. }
  16773. }
  16774. declare module "babylonjs/Particles/baseParticleSystem" {
  16775. import { Nullable } from "babylonjs/types";
  16776. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16778. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16779. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16780. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16781. import { Scene } from "babylonjs/scene";
  16782. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16783. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16784. import { Texture } from "babylonjs/Materials/Textures/texture";
  16785. import { Color4 } from "babylonjs/Maths/math.color";
  16786. import { Animation } from "babylonjs/Animations/animation";
  16787. /**
  16788. * This represents the base class for particle system in Babylon.
  16789. * 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.
  16790. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16791. * @example https://doc.babylonjs.com/babylon101/particles
  16792. */
  16793. export class BaseParticleSystem {
  16794. /**
  16795. * Source color is added to the destination color without alpha affecting the result
  16796. */
  16797. static BLENDMODE_ONEONE: number;
  16798. /**
  16799. * Blend current color and particle color using particle’s alpha
  16800. */
  16801. static BLENDMODE_STANDARD: number;
  16802. /**
  16803. * Add current color and particle color multiplied by particle’s alpha
  16804. */
  16805. static BLENDMODE_ADD: number;
  16806. /**
  16807. * Multiply current color with particle color
  16808. */
  16809. static BLENDMODE_MULTIPLY: number;
  16810. /**
  16811. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16812. */
  16813. static BLENDMODE_MULTIPLYADD: number;
  16814. /**
  16815. * List of animations used by the particle system.
  16816. */
  16817. animations: Animation[];
  16818. /**
  16819. * The id of the Particle system.
  16820. */
  16821. id: string;
  16822. /**
  16823. * The friendly name of the Particle system.
  16824. */
  16825. name: string;
  16826. /**
  16827. * The rendering group used by the Particle system to chose when to render.
  16828. */
  16829. renderingGroupId: number;
  16830. /**
  16831. * The emitter represents the Mesh or position we are attaching the particle system to.
  16832. */
  16833. emitter: Nullable<AbstractMesh | Vector3>;
  16834. /**
  16835. * The maximum number of particles to emit per frame
  16836. */
  16837. emitRate: number;
  16838. /**
  16839. * If you want to launch only a few particles at once, that can be done, as well.
  16840. */
  16841. manualEmitCount: number;
  16842. /**
  16843. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16844. */
  16845. updateSpeed: number;
  16846. /**
  16847. * The amount of time the particle system is running (depends of the overall update speed).
  16848. */
  16849. targetStopDuration: number;
  16850. /**
  16851. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16852. */
  16853. disposeOnStop: boolean;
  16854. /**
  16855. * Minimum power of emitting particles.
  16856. */
  16857. minEmitPower: number;
  16858. /**
  16859. * Maximum power of emitting particles.
  16860. */
  16861. maxEmitPower: number;
  16862. /**
  16863. * Minimum life time of emitting particles.
  16864. */
  16865. minLifeTime: number;
  16866. /**
  16867. * Maximum life time of emitting particles.
  16868. */
  16869. maxLifeTime: number;
  16870. /**
  16871. * Minimum Size of emitting particles.
  16872. */
  16873. minSize: number;
  16874. /**
  16875. * Maximum Size of emitting particles.
  16876. */
  16877. maxSize: number;
  16878. /**
  16879. * Minimum scale of emitting particles on X axis.
  16880. */
  16881. minScaleX: number;
  16882. /**
  16883. * Maximum scale of emitting particles on X axis.
  16884. */
  16885. maxScaleX: number;
  16886. /**
  16887. * Minimum scale of emitting particles on Y axis.
  16888. */
  16889. minScaleY: number;
  16890. /**
  16891. * Maximum scale of emitting particles on Y axis.
  16892. */
  16893. maxScaleY: number;
  16894. /**
  16895. * Gets or sets the minimal initial rotation in radians.
  16896. */
  16897. minInitialRotation: number;
  16898. /**
  16899. * Gets or sets the maximal initial rotation in radians.
  16900. */
  16901. maxInitialRotation: number;
  16902. /**
  16903. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16904. */
  16905. minAngularSpeed: number;
  16906. /**
  16907. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16908. */
  16909. maxAngularSpeed: number;
  16910. /**
  16911. * The texture used to render each particle. (this can be a spritesheet)
  16912. */
  16913. particleTexture: Nullable<Texture>;
  16914. /**
  16915. * The layer mask we are rendering the particles through.
  16916. */
  16917. layerMask: number;
  16918. /**
  16919. * This can help using your own shader to render the particle system.
  16920. * The according effect will be created
  16921. */
  16922. customShader: any;
  16923. /**
  16924. * By default particle system starts as soon as they are created. This prevents the
  16925. * automatic start to happen and let you decide when to start emitting particles.
  16926. */
  16927. preventAutoStart: boolean;
  16928. private _noiseTexture;
  16929. /**
  16930. * Gets or sets a texture used to add random noise to particle positions
  16931. */
  16932. noiseTexture: Nullable<ProceduralTexture>;
  16933. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16934. noiseStrength: Vector3;
  16935. /**
  16936. * Callback triggered when the particle animation is ending.
  16937. */
  16938. onAnimationEnd: Nullable<() => void>;
  16939. /**
  16940. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16941. */
  16942. blendMode: number;
  16943. /**
  16944. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16945. * to override the particles.
  16946. */
  16947. forceDepthWrite: boolean;
  16948. /** 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 */
  16949. preWarmCycles: number;
  16950. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16951. preWarmStepOffset: number;
  16952. /**
  16953. * 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)
  16954. */
  16955. spriteCellChangeSpeed: number;
  16956. /**
  16957. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16958. */
  16959. startSpriteCellID: number;
  16960. /**
  16961. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16962. */
  16963. endSpriteCellID: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16966. */
  16967. spriteCellWidth: number;
  16968. /**
  16969. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16970. */
  16971. spriteCellHeight: number;
  16972. /**
  16973. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16974. */
  16975. spriteRandomStartCell: boolean;
  16976. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16977. translationPivot: Vector2;
  16978. /** @hidden */
  16979. protected _isAnimationSheetEnabled: boolean;
  16980. /**
  16981. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16982. */
  16983. beginAnimationOnStart: boolean;
  16984. /**
  16985. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16986. */
  16987. beginAnimationFrom: number;
  16988. /**
  16989. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16990. */
  16991. beginAnimationTo: number;
  16992. /**
  16993. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16994. */
  16995. beginAnimationLoop: boolean;
  16996. /**
  16997. * Gets or sets a world offset applied to all particles
  16998. */
  16999. worldOffset: Vector3;
  17000. /**
  17001. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17002. */
  17003. isAnimationSheetEnabled: boolean;
  17004. /**
  17005. * Get hosting scene
  17006. * @returns the scene
  17007. */
  17008. getScene(): Scene;
  17009. /**
  17010. * You can use gravity if you want to give an orientation to your particles.
  17011. */
  17012. gravity: Vector3;
  17013. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17014. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17015. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17016. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17017. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17018. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17019. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17020. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17021. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17022. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17023. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17024. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17025. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17026. /**
  17027. * Defines the delay in milliseconds before starting the system (0 by default)
  17028. */
  17029. startDelay: number;
  17030. /**
  17031. * Gets the current list of drag gradients.
  17032. * You must use addDragGradient and removeDragGradient to udpate this list
  17033. * @returns the list of drag gradients
  17034. */
  17035. getDragGradients(): Nullable<Array<FactorGradient>>;
  17036. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17037. limitVelocityDamping: number;
  17038. /**
  17039. * Gets the current list of limit velocity gradients.
  17040. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17041. * @returns the list of limit velocity gradients
  17042. */
  17043. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Gets the current list of color gradients.
  17046. * You must use addColorGradient and removeColorGradient to udpate this list
  17047. * @returns the list of color gradients
  17048. */
  17049. getColorGradients(): Nullable<Array<ColorGradient>>;
  17050. /**
  17051. * Gets the current list of size gradients.
  17052. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17053. * @returns the list of size gradients
  17054. */
  17055. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17056. /**
  17057. * Gets the current list of color remap gradients.
  17058. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17059. * @returns the list of color remap gradients
  17060. */
  17061. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17062. /**
  17063. * Gets the current list of alpha remap gradients.
  17064. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17065. * @returns the list of alpha remap gradients
  17066. */
  17067. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17068. /**
  17069. * Gets the current list of life time gradients.
  17070. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17071. * @returns the list of life time gradients
  17072. */
  17073. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17074. /**
  17075. * Gets the current list of angular speed gradients.
  17076. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17077. * @returns the list of angular speed gradients
  17078. */
  17079. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17080. /**
  17081. * Gets the current list of velocity gradients.
  17082. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17083. * @returns the list of velocity gradients
  17084. */
  17085. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17086. /**
  17087. * Gets the current list of start size gradients.
  17088. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17089. * @returns the list of start size gradients
  17090. */
  17091. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17092. /**
  17093. * Gets the current list of emit rate gradients.
  17094. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17095. * @returns the list of emit rate gradients
  17096. */
  17097. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17098. /**
  17099. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17100. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17101. */
  17102. direction1: Vector3;
  17103. /**
  17104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17105. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17106. */
  17107. direction2: Vector3;
  17108. /**
  17109. * 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.
  17110. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17111. */
  17112. minEmitBox: Vector3;
  17113. /**
  17114. * 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.
  17115. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17116. */
  17117. maxEmitBox: Vector3;
  17118. /**
  17119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17120. */
  17121. color1: Color4;
  17122. /**
  17123. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17124. */
  17125. color2: Color4;
  17126. /**
  17127. * Color the particle will have at the end of its lifetime
  17128. */
  17129. colorDead: Color4;
  17130. /**
  17131. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17132. */
  17133. textureMask: Color4;
  17134. /**
  17135. * The particle emitter type defines the emitter used by the particle system.
  17136. * It can be for example box, sphere, or cone...
  17137. */
  17138. particleEmitterType: IParticleEmitterType;
  17139. /** @hidden */
  17140. _isSubEmitter: boolean;
  17141. /**
  17142. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17143. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17144. */
  17145. billboardMode: number;
  17146. protected _isBillboardBased: boolean;
  17147. /**
  17148. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17149. */
  17150. isBillboardBased: boolean;
  17151. /**
  17152. * The scene the particle system belongs to.
  17153. */
  17154. protected _scene: Scene;
  17155. /**
  17156. * Local cache of defines for image processing.
  17157. */
  17158. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17159. /**
  17160. * Default configuration related to image processing available in the standard Material.
  17161. */
  17162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17163. /**
  17164. * Gets the image processing configuration used either in this material.
  17165. */
  17166. /**
  17167. * Sets the Default image processing configuration used either in the this material.
  17168. *
  17169. * If sets to null, the scene one is in use.
  17170. */
  17171. imageProcessingConfiguration: ImageProcessingConfiguration;
  17172. /**
  17173. * Attaches a new image processing configuration to the Standard Material.
  17174. * @param configuration
  17175. */
  17176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17177. /** @hidden */
  17178. protected _reset(): void;
  17179. /** @hidden */
  17180. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17181. /**
  17182. * Instantiates a particle system.
  17183. * 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.
  17184. * @param name The name of the particle system
  17185. */
  17186. constructor(name: string);
  17187. /**
  17188. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17191. * @returns the emitter
  17192. */
  17193. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17194. /**
  17195. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17196. * @param radius The radius of the hemisphere to emit from
  17197. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17198. * @returns the emitter
  17199. */
  17200. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17201. /**
  17202. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17203. * @param radius The radius of the sphere to emit from
  17204. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17205. * @returns the emitter
  17206. */
  17207. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17208. /**
  17209. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17210. * @param radius The radius of the sphere to emit from
  17211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17213. * @returns the emitter
  17214. */
  17215. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17216. /**
  17217. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17218. * @param radius The radius of the emission cylinder
  17219. * @param height The height of the emission cylinder
  17220. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17221. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17222. * @returns the emitter
  17223. */
  17224. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17225. /**
  17226. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17227. * @param radius The radius of the cylinder to emit from
  17228. * @param height The height of the emission cylinder
  17229. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17230. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17231. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17232. * @returns the emitter
  17233. */
  17234. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17235. /**
  17236. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17237. * @param radius The radius of the cone to emit from
  17238. * @param angle The base angle of the cone
  17239. * @returns the emitter
  17240. */
  17241. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17242. /**
  17243. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17244. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17245. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17246. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17247. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17248. * @returns the emitter
  17249. */
  17250. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17251. }
  17252. }
  17253. declare module "babylonjs/Particles/subEmitter" {
  17254. import { Scene } from "babylonjs/scene";
  17255. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17256. /**
  17257. * Type of sub emitter
  17258. */
  17259. export enum SubEmitterType {
  17260. /**
  17261. * Attached to the particle over it's lifetime
  17262. */
  17263. ATTACHED = 0,
  17264. /**
  17265. * Created when the particle dies
  17266. */
  17267. END = 1
  17268. }
  17269. /**
  17270. * Sub emitter class used to emit particles from an existing particle
  17271. */
  17272. export class SubEmitter {
  17273. /**
  17274. * the particle system to be used by the sub emitter
  17275. */
  17276. particleSystem: ParticleSystem;
  17277. /**
  17278. * Type of the submitter (Default: END)
  17279. */
  17280. type: SubEmitterType;
  17281. /**
  17282. * 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)
  17283. * Note: This only is supported when using an emitter of type Mesh
  17284. */
  17285. inheritDirection: boolean;
  17286. /**
  17287. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17288. */
  17289. inheritedVelocityAmount: number;
  17290. /**
  17291. * Creates a sub emitter
  17292. * @param particleSystem the particle system to be used by the sub emitter
  17293. */
  17294. constructor(
  17295. /**
  17296. * the particle system to be used by the sub emitter
  17297. */
  17298. particleSystem: ParticleSystem);
  17299. /**
  17300. * Clones the sub emitter
  17301. * @returns the cloned sub emitter
  17302. */
  17303. clone(): SubEmitter;
  17304. /**
  17305. * Serialize current object to a JSON object
  17306. * @returns the serialized object
  17307. */
  17308. serialize(): any;
  17309. /** @hidden */
  17310. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17311. /**
  17312. * Creates a new SubEmitter from a serialized JSON version
  17313. * @param serializationObject defines the JSON object to read from
  17314. * @param scene defines the hosting scene
  17315. * @param rootUrl defines the rootUrl for data loading
  17316. * @returns a new SubEmitter
  17317. */
  17318. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17319. /** Release associated resources */
  17320. dispose(): void;
  17321. }
  17322. }
  17323. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17324. /** @hidden */
  17325. export var clipPlaneFragmentDeclaration: {
  17326. name: string;
  17327. shader: string;
  17328. };
  17329. }
  17330. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17331. /** @hidden */
  17332. export var imageProcessingDeclaration: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17338. /** @hidden */
  17339. export var imageProcessingFunctions: {
  17340. name: string;
  17341. shader: string;
  17342. };
  17343. }
  17344. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17345. /** @hidden */
  17346. export var clipPlaneFragment: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module "babylonjs/Shaders/particles.fragment" {
  17352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17353. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17354. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17355. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17356. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17357. /** @hidden */
  17358. export var particlesPixelShader: {
  17359. name: string;
  17360. shader: string;
  17361. };
  17362. }
  17363. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17364. /** @hidden */
  17365. export var clipPlaneVertexDeclaration: {
  17366. name: string;
  17367. shader: string;
  17368. };
  17369. }
  17370. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17371. /** @hidden */
  17372. export var clipPlaneVertex: {
  17373. name: string;
  17374. shader: string;
  17375. };
  17376. }
  17377. declare module "babylonjs/Shaders/particles.vertex" {
  17378. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17380. /** @hidden */
  17381. export var particlesVertexShader: {
  17382. name: string;
  17383. shader: string;
  17384. };
  17385. }
  17386. declare module "babylonjs/Particles/particleSystem" {
  17387. import { Nullable } from "babylonjs/types";
  17388. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17389. import { Observable } from "babylonjs/Misc/observable";
  17390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17391. import { Effect } from "babylonjs/Materials/effect";
  17392. import { Scene, IDisposable } from "babylonjs/scene";
  17393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17394. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17395. import { Particle } from "babylonjs/Particles/particle";
  17396. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17397. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17398. import "babylonjs/Shaders/particles.fragment";
  17399. import "babylonjs/Shaders/particles.vertex";
  17400. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17401. /**
  17402. * This represents a particle system in Babylon.
  17403. * 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.
  17404. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17405. * @example https://doc.babylonjs.com/babylon101/particles
  17406. */
  17407. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17408. /**
  17409. * Billboard mode will only apply to Y axis
  17410. */
  17411. static readonly BILLBOARDMODE_Y: number;
  17412. /**
  17413. * Billboard mode will apply to all axes
  17414. */
  17415. static readonly BILLBOARDMODE_ALL: number;
  17416. /**
  17417. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17418. */
  17419. static readonly BILLBOARDMODE_STRETCHED: number;
  17420. /**
  17421. * This function can be defined to provide custom update for active particles.
  17422. * This function will be called instead of regular update (age, position, color, etc.).
  17423. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17424. */
  17425. updateFunction: (particles: Particle[]) => void;
  17426. private _emitterWorldMatrix;
  17427. /**
  17428. * This function can be defined to specify initial direction for every new particle.
  17429. * It by default use the emitterType defined function
  17430. */
  17431. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17432. /**
  17433. * This function can be defined to specify initial position for every new particle.
  17434. * It by default use the emitterType defined function
  17435. */
  17436. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17437. /**
  17438. * @hidden
  17439. */
  17440. _inheritedVelocityOffset: Vector3;
  17441. /**
  17442. * An event triggered when the system is disposed
  17443. */
  17444. onDisposeObservable: Observable<ParticleSystem>;
  17445. private _onDisposeObserver;
  17446. /**
  17447. * Sets a callback that will be triggered when the system is disposed
  17448. */
  17449. onDispose: () => void;
  17450. private _particles;
  17451. private _epsilon;
  17452. private _capacity;
  17453. private _stockParticles;
  17454. private _newPartsExcess;
  17455. private _vertexData;
  17456. private _vertexBuffer;
  17457. private _vertexBuffers;
  17458. private _spriteBuffer;
  17459. private _indexBuffer;
  17460. private _effect;
  17461. private _customEffect;
  17462. private _cachedDefines;
  17463. private _scaledColorStep;
  17464. private _colorDiff;
  17465. private _scaledDirection;
  17466. private _scaledGravity;
  17467. private _currentRenderId;
  17468. private _alive;
  17469. private _useInstancing;
  17470. private _started;
  17471. private _stopped;
  17472. private _actualFrame;
  17473. private _scaledUpdateSpeed;
  17474. private _vertexBufferSize;
  17475. /** @hidden */
  17476. _currentEmitRateGradient: Nullable<FactorGradient>;
  17477. /** @hidden */
  17478. _currentEmitRate1: number;
  17479. /** @hidden */
  17480. _currentEmitRate2: number;
  17481. /** @hidden */
  17482. _currentStartSizeGradient: Nullable<FactorGradient>;
  17483. /** @hidden */
  17484. _currentStartSize1: number;
  17485. /** @hidden */
  17486. _currentStartSize2: number;
  17487. private readonly _rawTextureWidth;
  17488. private _rampGradientsTexture;
  17489. private _useRampGradients;
  17490. /** Gets or sets a boolean indicating that ramp gradients must be used
  17491. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17492. */
  17493. useRampGradients: boolean;
  17494. /**
  17495. * 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.
  17496. * 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: [])
  17497. */
  17498. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17499. private _subEmitters;
  17500. /**
  17501. * @hidden
  17502. * If the particle systems emitter should be disposed when the particle system is disposed
  17503. */
  17504. _disposeEmitterOnDispose: boolean;
  17505. /**
  17506. * The current active Sub-systems, this property is used by the root particle system only.
  17507. */
  17508. activeSubSystems: Array<ParticleSystem>;
  17509. private _rootParticleSystem;
  17510. /**
  17511. * Gets the current list of active particles
  17512. */
  17513. readonly particles: Particle[];
  17514. /**
  17515. * Returns the string "ParticleSystem"
  17516. * @returns a string containing the class name
  17517. */
  17518. getClassName(): string;
  17519. /**
  17520. * Instantiates a particle system.
  17521. * 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.
  17522. * @param name The name of the particle system
  17523. * @param capacity The max number of particles alive at the same time
  17524. * @param scene The scene the particle system belongs to
  17525. * @param customEffect a custom effect used to change the way particles are rendered by default
  17526. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17527. * @param epsilon Offset used to render the particles
  17528. */
  17529. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17530. private _addFactorGradient;
  17531. private _removeFactorGradient;
  17532. /**
  17533. * Adds a new life time gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific life time gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new size gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the size factor 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific size gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeSizeGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new color remap gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param min defines the color remap minimal range
  17564. * @param max defines the color remap maximal range
  17565. * @returns the current particle system
  17566. */
  17567. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific color remap gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeColorRemapGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new alpha remap gradient
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param min defines the alpha remap minimal range
  17578. * @param max defines the alpha remap maximal range
  17579. * @returns the current particle system
  17580. */
  17581. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific alpha remap gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new angular speed gradient
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific angular speed gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17602. /**
  17603. * Adds a new velocity gradient
  17604. * @param gradient defines the gradient to use (between 0 and 1)
  17605. * @param factor defines the velocity to affect to the specified gradient
  17606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17607. * @returns the current particle system
  17608. */
  17609. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17610. /**
  17611. * Remove a specific velocity gradient
  17612. * @param gradient defines the gradient to remove
  17613. * @returns the current particle system
  17614. */
  17615. removeVelocityGradient(gradient: number): IParticleSystem;
  17616. /**
  17617. * Adds a new limit velocity gradient
  17618. * @param gradient defines the gradient to use (between 0 and 1)
  17619. * @param factor defines the limit velocity value to affect to the specified gradient
  17620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17621. * @returns the current particle system
  17622. */
  17623. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17624. /**
  17625. * Remove a specific limit velocity gradient
  17626. * @param gradient defines the gradient to remove
  17627. * @returns the current particle system
  17628. */
  17629. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17630. /**
  17631. * Adds a new drag gradient
  17632. * @param gradient defines the gradient to use (between 0 and 1)
  17633. * @param factor defines the drag value to affect to the specified gradient
  17634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17635. * @returns the current particle system
  17636. */
  17637. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17638. /**
  17639. * Remove a specific drag gradient
  17640. * @param gradient defines the gradient to remove
  17641. * @returns the current particle system
  17642. */
  17643. removeDragGradient(gradient: number): IParticleSystem;
  17644. /**
  17645. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17646. * @param gradient defines the gradient to use (between 0 and 1)
  17647. * @param factor defines the emit rate value to affect to the specified gradient
  17648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17649. * @returns the current particle system
  17650. */
  17651. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17652. /**
  17653. * Remove a specific emit rate gradient
  17654. * @param gradient defines the gradient to remove
  17655. * @returns the current particle system
  17656. */
  17657. removeEmitRateGradient(gradient: number): IParticleSystem;
  17658. /**
  17659. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17660. * @param gradient defines the gradient to use (between 0 and 1)
  17661. * @param factor defines the start size value to affect to the specified gradient
  17662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17663. * @returns the current particle system
  17664. */
  17665. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17666. /**
  17667. * Remove a specific start size gradient
  17668. * @param gradient defines the gradient to remove
  17669. * @returns the current particle system
  17670. */
  17671. removeStartSizeGradient(gradient: number): IParticleSystem;
  17672. private _createRampGradientTexture;
  17673. /**
  17674. * Gets the current list of ramp gradients.
  17675. * You must use addRampGradient and removeRampGradient to udpate this list
  17676. * @returns the list of ramp gradients
  17677. */
  17678. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17679. /**
  17680. * Adds a new ramp gradient used to remap particle colors
  17681. * @param gradient defines the gradient to use (between 0 and 1)
  17682. * @param color defines the color to affect to the specified gradient
  17683. * @returns the current particle system
  17684. */
  17685. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17686. /**
  17687. * Remove a specific ramp gradient
  17688. * @param gradient defines the gradient to remove
  17689. * @returns the current particle system
  17690. */
  17691. removeRampGradient(gradient: number): ParticleSystem;
  17692. /**
  17693. * Adds a new color gradient
  17694. * @param gradient defines the gradient to use (between 0 and 1)
  17695. * @param color1 defines the color to affect to the specified gradient
  17696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17697. * @returns this particle system
  17698. */
  17699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17700. /**
  17701. * Remove a specific color gradient
  17702. * @param gradient defines the gradient to remove
  17703. * @returns this particle system
  17704. */
  17705. removeColorGradient(gradient: number): IParticleSystem;
  17706. private _fetchR;
  17707. protected _reset(): void;
  17708. private _resetEffect;
  17709. private _createVertexBuffers;
  17710. private _createIndexBuffer;
  17711. /**
  17712. * Gets the maximum number of particles active at the same time.
  17713. * @returns The max number of active particles.
  17714. */
  17715. getCapacity(): number;
  17716. /**
  17717. * Gets whether there are still active particles in the system.
  17718. * @returns True if it is alive, otherwise false.
  17719. */
  17720. isAlive(): boolean;
  17721. /**
  17722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17723. * @returns True if it has been started, otherwise false.
  17724. */
  17725. isStarted(): boolean;
  17726. private _prepareSubEmitterInternalArray;
  17727. /**
  17728. * Starts the particle system and begins to emit
  17729. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17730. */
  17731. start(delay?: number): void;
  17732. /**
  17733. * Stops the particle system.
  17734. * @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.
  17735. */
  17736. stop(stopSubEmitters?: boolean): void;
  17737. /**
  17738. * Remove all active particles
  17739. */
  17740. reset(): void;
  17741. /**
  17742. * @hidden (for internal use only)
  17743. */
  17744. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17745. /**
  17746. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17747. * Its lifetime will start back at 0.
  17748. */
  17749. recycleParticle: (particle: Particle) => void;
  17750. private _stopSubEmitters;
  17751. private _createParticle;
  17752. private _removeFromRoot;
  17753. private _emitFromParticle;
  17754. private _update;
  17755. /** @hidden */
  17756. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17757. /** @hidden */
  17758. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17759. /** @hidden */
  17760. private _getEffect;
  17761. /**
  17762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17763. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17764. */
  17765. animate(preWarmOnly?: boolean): void;
  17766. private _appendParticleVertices;
  17767. /**
  17768. * Rebuilds the particle system.
  17769. */
  17770. rebuild(): void;
  17771. /**
  17772. * Is this system ready to be used/rendered
  17773. * @return true if the system is ready
  17774. */
  17775. isReady(): boolean;
  17776. private _render;
  17777. /**
  17778. * Renders the particle system in its current state.
  17779. * @returns the current number of particles
  17780. */
  17781. render(): number;
  17782. /**
  17783. * Disposes the particle system and free the associated resources
  17784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17785. */
  17786. dispose(disposeTexture?: boolean): void;
  17787. /**
  17788. * Clones the particle system.
  17789. * @param name The name of the cloned object
  17790. * @param newEmitter The new emitter to use
  17791. * @returns the cloned particle system
  17792. */
  17793. clone(name: string, newEmitter: any): ParticleSystem;
  17794. /**
  17795. * Serializes the particle system to a JSON object.
  17796. * @returns the JSON object
  17797. */
  17798. serialize(): any;
  17799. /** @hidden */
  17800. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17801. /** @hidden */
  17802. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17803. /**
  17804. * Parses a JSON object to create a particle system.
  17805. * @param parsedParticleSystem The JSON object to parse
  17806. * @param scene The scene to create the particle system in
  17807. * @param rootUrl The root url to use to load external dependencies like texture
  17808. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17809. * @returns the Parsed particle system
  17810. */
  17811. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17812. }
  17813. }
  17814. declare module "babylonjs/Particles/particle" {
  17815. import { Nullable } from "babylonjs/types";
  17816. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17817. import { Color4 } from "babylonjs/Maths/math.color";
  17818. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17819. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17820. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17821. /**
  17822. * A particle represents one of the element emitted by a particle system.
  17823. * This is mainly define by its coordinates, direction, velocity and age.
  17824. */
  17825. export class Particle {
  17826. /**
  17827. * The particle system the particle belongs to.
  17828. */
  17829. particleSystem: ParticleSystem;
  17830. private static _Count;
  17831. /**
  17832. * Unique ID of the particle
  17833. */
  17834. id: number;
  17835. /**
  17836. * The world position of the particle in the scene.
  17837. */
  17838. position: Vector3;
  17839. /**
  17840. * The world direction of the particle in the scene.
  17841. */
  17842. direction: Vector3;
  17843. /**
  17844. * The color of the particle.
  17845. */
  17846. color: Color4;
  17847. /**
  17848. * The color change of the particle per step.
  17849. */
  17850. colorStep: Color4;
  17851. /**
  17852. * Defines how long will the life of the particle be.
  17853. */
  17854. lifeTime: number;
  17855. /**
  17856. * The current age of the particle.
  17857. */
  17858. age: number;
  17859. /**
  17860. * The current size of the particle.
  17861. */
  17862. size: number;
  17863. /**
  17864. * The current scale of the particle.
  17865. */
  17866. scale: Vector2;
  17867. /**
  17868. * The current angle of the particle.
  17869. */
  17870. angle: number;
  17871. /**
  17872. * Defines how fast is the angle changing.
  17873. */
  17874. angularSpeed: number;
  17875. /**
  17876. * Defines the cell index used by the particle to be rendered from a sprite.
  17877. */
  17878. cellIndex: number;
  17879. /**
  17880. * The information required to support color remapping
  17881. */
  17882. remapData: Vector4;
  17883. /** @hidden */
  17884. _randomCellOffset?: number;
  17885. /** @hidden */
  17886. _initialDirection: Nullable<Vector3>;
  17887. /** @hidden */
  17888. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17889. /** @hidden */
  17890. _initialStartSpriteCellID: number;
  17891. /** @hidden */
  17892. _initialEndSpriteCellID: number;
  17893. /** @hidden */
  17894. _currentColorGradient: Nullable<ColorGradient>;
  17895. /** @hidden */
  17896. _currentColor1: Color4;
  17897. /** @hidden */
  17898. _currentColor2: Color4;
  17899. /** @hidden */
  17900. _currentSizeGradient: Nullable<FactorGradient>;
  17901. /** @hidden */
  17902. _currentSize1: number;
  17903. /** @hidden */
  17904. _currentSize2: number;
  17905. /** @hidden */
  17906. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17907. /** @hidden */
  17908. _currentAngularSpeed1: number;
  17909. /** @hidden */
  17910. _currentAngularSpeed2: number;
  17911. /** @hidden */
  17912. _currentVelocityGradient: Nullable<FactorGradient>;
  17913. /** @hidden */
  17914. _currentVelocity1: number;
  17915. /** @hidden */
  17916. _currentVelocity2: number;
  17917. /** @hidden */
  17918. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17919. /** @hidden */
  17920. _currentLimitVelocity1: number;
  17921. /** @hidden */
  17922. _currentLimitVelocity2: number;
  17923. /** @hidden */
  17924. _currentDragGradient: Nullable<FactorGradient>;
  17925. /** @hidden */
  17926. _currentDrag1: number;
  17927. /** @hidden */
  17928. _currentDrag2: number;
  17929. /** @hidden */
  17930. _randomNoiseCoordinates1: Vector3;
  17931. /** @hidden */
  17932. _randomNoiseCoordinates2: Vector3;
  17933. /**
  17934. * Creates a new instance Particle
  17935. * @param particleSystem the particle system the particle belongs to
  17936. */
  17937. constructor(
  17938. /**
  17939. * The particle system the particle belongs to.
  17940. */
  17941. particleSystem: ParticleSystem);
  17942. private updateCellInfoFromSystem;
  17943. /**
  17944. * Defines how the sprite cell index is updated for the particle
  17945. */
  17946. updateCellIndex(): void;
  17947. /** @hidden */
  17948. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17949. /** @hidden */
  17950. _inheritParticleInfoToSubEmitters(): void;
  17951. /** @hidden */
  17952. _reset(): void;
  17953. /**
  17954. * Copy the properties of particle to another one.
  17955. * @param other the particle to copy the information to.
  17956. */
  17957. copyTo(other: Particle): void;
  17958. }
  17959. }
  17960. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17961. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17962. import { Effect } from "babylonjs/Materials/effect";
  17963. import { Particle } from "babylonjs/Particles/particle";
  17964. /**
  17965. * Particle emitter represents a volume emitting particles.
  17966. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17967. */
  17968. export interface IParticleEmitterType {
  17969. /**
  17970. * Called by the particle System when the direction is computed for the created particle.
  17971. * @param worldMatrix is the world matrix of the particle system
  17972. * @param directionToUpdate is the direction vector to update with the result
  17973. * @param particle is the particle we are computed the direction for
  17974. */
  17975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17976. /**
  17977. * Called by the particle System when the position is computed for the created particle.
  17978. * @param worldMatrix is the world matrix of the particle system
  17979. * @param positionToUpdate is the position vector to update with the result
  17980. * @param particle is the particle we are computed the position for
  17981. */
  17982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17983. /**
  17984. * Clones the current emitter and returns a copy of it
  17985. * @returns the new emitter
  17986. */
  17987. clone(): IParticleEmitterType;
  17988. /**
  17989. * Called by the GPUParticleSystem to setup the update shader
  17990. * @param effect defines the update shader
  17991. */
  17992. applyToShader(effect: Effect): void;
  17993. /**
  17994. * Returns a string to use to update the GPU particles update shader
  17995. * @returns the effect defines string
  17996. */
  17997. getEffectDefines(): string;
  17998. /**
  17999. * Returns a string representing the class name
  18000. * @returns a string containing the class name
  18001. */
  18002. getClassName(): string;
  18003. /**
  18004. * Serializes the particle system to a JSON object.
  18005. * @returns the JSON object
  18006. */
  18007. serialize(): any;
  18008. /**
  18009. * Parse properties from a JSON object
  18010. * @param serializationObject defines the JSON object
  18011. */
  18012. parse(serializationObject: any): void;
  18013. }
  18014. }
  18015. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18017. import { Effect } from "babylonjs/Materials/effect";
  18018. import { Particle } from "babylonjs/Particles/particle";
  18019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18020. /**
  18021. * Particle emitter emitting particles from the inside of a box.
  18022. * It emits the particles randomly between 2 given directions.
  18023. */
  18024. export class BoxParticleEmitter implements IParticleEmitterType {
  18025. /**
  18026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18027. */
  18028. direction1: Vector3;
  18029. /**
  18030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18031. */
  18032. direction2: Vector3;
  18033. /**
  18034. * 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.
  18035. */
  18036. minEmitBox: Vector3;
  18037. /**
  18038. * 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.
  18039. */
  18040. maxEmitBox: Vector3;
  18041. /**
  18042. * Creates a new instance BoxParticleEmitter
  18043. */
  18044. constructor();
  18045. /**
  18046. * Called by the particle System when the direction is computed for the created particle.
  18047. * @param worldMatrix is the world matrix of the particle system
  18048. * @param directionToUpdate is the direction vector to update with the result
  18049. * @param particle is the particle we are computed the direction for
  18050. */
  18051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18052. /**
  18053. * Called by the particle System when the position is computed for the created particle.
  18054. * @param worldMatrix is the world matrix of the particle system
  18055. * @param positionToUpdate is the position vector to update with the result
  18056. * @param particle is the particle we are computed the position for
  18057. */
  18058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18059. /**
  18060. * Clones the current emitter and returns a copy of it
  18061. * @returns the new emitter
  18062. */
  18063. clone(): BoxParticleEmitter;
  18064. /**
  18065. * Called by the GPUParticleSystem to setup the update shader
  18066. * @param effect defines the update shader
  18067. */
  18068. applyToShader(effect: Effect): void;
  18069. /**
  18070. * Returns a string to use to update the GPU particles update shader
  18071. * @returns a string containng the defines string
  18072. */
  18073. getEffectDefines(): string;
  18074. /**
  18075. * Returns the string "BoxParticleEmitter"
  18076. * @returns a string containing the class name
  18077. */
  18078. getClassName(): string;
  18079. /**
  18080. * Serializes the particle system to a JSON object.
  18081. * @returns the JSON object
  18082. */
  18083. serialize(): any;
  18084. /**
  18085. * Parse properties from a JSON object
  18086. * @param serializationObject defines the JSON object
  18087. */
  18088. parse(serializationObject: any): void;
  18089. }
  18090. }
  18091. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18092. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18093. import { Effect } from "babylonjs/Materials/effect";
  18094. import { Particle } from "babylonjs/Particles/particle";
  18095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18096. /**
  18097. * Particle emitter emitting particles from the inside of a cone.
  18098. * It emits the particles alongside the cone volume from the base to the particle.
  18099. * The emission direction might be randomized.
  18100. */
  18101. export class ConeParticleEmitter implements IParticleEmitterType {
  18102. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18103. directionRandomizer: number;
  18104. private _radius;
  18105. private _angle;
  18106. private _height;
  18107. /**
  18108. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18109. */
  18110. radiusRange: number;
  18111. /**
  18112. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18113. */
  18114. heightRange: number;
  18115. /**
  18116. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18117. */
  18118. emitFromSpawnPointOnly: boolean;
  18119. /**
  18120. * Gets or sets the radius of the emission cone
  18121. */
  18122. radius: number;
  18123. /**
  18124. * Gets or sets the angle of the emission cone
  18125. */
  18126. angle: number;
  18127. private _buildHeight;
  18128. /**
  18129. * Creates a new instance ConeParticleEmitter
  18130. * @param radius the radius of the emission cone (1 by default)
  18131. * @param angle the cone base angle (PI by default)
  18132. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18133. */
  18134. constructor(radius?: number, angle?: number,
  18135. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18136. directionRandomizer?: number);
  18137. /**
  18138. * Called by the particle System when the direction is computed for the created particle.
  18139. * @param worldMatrix is the world matrix of the particle system
  18140. * @param directionToUpdate is the direction vector to update with the result
  18141. * @param particle is the particle we are computed the direction for
  18142. */
  18143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18144. /**
  18145. * Called by the particle System when the position is computed for the created particle.
  18146. * @param worldMatrix is the world matrix of the particle system
  18147. * @param positionToUpdate is the position vector to update with the result
  18148. * @param particle is the particle we are computed the position for
  18149. */
  18150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18151. /**
  18152. * Clones the current emitter and returns a copy of it
  18153. * @returns the new emitter
  18154. */
  18155. clone(): ConeParticleEmitter;
  18156. /**
  18157. * Called by the GPUParticleSystem to setup the update shader
  18158. * @param effect defines the update shader
  18159. */
  18160. applyToShader(effect: Effect): void;
  18161. /**
  18162. * Returns a string to use to update the GPU particles update shader
  18163. * @returns a string containng the defines string
  18164. */
  18165. getEffectDefines(): string;
  18166. /**
  18167. * Returns the string "ConeParticleEmitter"
  18168. * @returns a string containing the class name
  18169. */
  18170. getClassName(): string;
  18171. /**
  18172. * Serializes the particle system to a JSON object.
  18173. * @returns the JSON object
  18174. */
  18175. serialize(): any;
  18176. /**
  18177. * Parse properties from a JSON object
  18178. * @param serializationObject defines the JSON object
  18179. */
  18180. parse(serializationObject: any): void;
  18181. }
  18182. }
  18183. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18184. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18185. import { Effect } from "babylonjs/Materials/effect";
  18186. import { Particle } from "babylonjs/Particles/particle";
  18187. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18188. /**
  18189. * Particle emitter emitting particles from the inside of a cylinder.
  18190. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18191. */
  18192. export class CylinderParticleEmitter implements IParticleEmitterType {
  18193. /**
  18194. * The radius of the emission cylinder.
  18195. */
  18196. radius: number;
  18197. /**
  18198. * The height of the emission cylinder.
  18199. */
  18200. height: number;
  18201. /**
  18202. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18203. */
  18204. radiusRange: number;
  18205. /**
  18206. * How much to randomize the particle direction [0-1].
  18207. */
  18208. directionRandomizer: number;
  18209. /**
  18210. * Creates a new instance CylinderParticleEmitter
  18211. * @param radius the radius of the emission cylinder (1 by default)
  18212. * @param height the height of the emission cylinder (1 by default)
  18213. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18214. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18215. */
  18216. constructor(
  18217. /**
  18218. * The radius of the emission cylinder.
  18219. */
  18220. radius?: number,
  18221. /**
  18222. * The height of the emission cylinder.
  18223. */
  18224. height?: number,
  18225. /**
  18226. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18227. */
  18228. radiusRange?: number,
  18229. /**
  18230. * How much to randomize the particle direction [0-1].
  18231. */
  18232. directionRandomizer?: number);
  18233. /**
  18234. * Called by the particle System when the direction is computed for the created particle.
  18235. * @param worldMatrix is the world matrix of the particle system
  18236. * @param directionToUpdate is the direction vector to update with the result
  18237. * @param particle is the particle we are computed the direction for
  18238. */
  18239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18240. /**
  18241. * Called by the particle System when the position is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param positionToUpdate is the position vector to update with the result
  18244. * @param particle is the particle we are computed the position for
  18245. */
  18246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Clones the current emitter and returns a copy of it
  18249. * @returns the new emitter
  18250. */
  18251. clone(): CylinderParticleEmitter;
  18252. /**
  18253. * Called by the GPUParticleSystem to setup the update shader
  18254. * @param effect defines the update shader
  18255. */
  18256. applyToShader(effect: Effect): void;
  18257. /**
  18258. * Returns a string to use to update the GPU particles update shader
  18259. * @returns a string containng the defines string
  18260. */
  18261. getEffectDefines(): string;
  18262. /**
  18263. * Returns the string "CylinderParticleEmitter"
  18264. * @returns a string containing the class name
  18265. */
  18266. getClassName(): string;
  18267. /**
  18268. * Serializes the particle system to a JSON object.
  18269. * @returns the JSON object
  18270. */
  18271. serialize(): any;
  18272. /**
  18273. * Parse properties from a JSON object
  18274. * @param serializationObject defines the JSON object
  18275. */
  18276. parse(serializationObject: any): void;
  18277. }
  18278. /**
  18279. * Particle emitter emitting particles from the inside of a cylinder.
  18280. * It emits the particles randomly between two vectors.
  18281. */
  18282. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18283. /**
  18284. * The min limit of the emission direction.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * The max limit of the emission direction.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * Creates a new instance CylinderDirectedParticleEmitter
  18293. * @param radius the radius of the emission cylinder (1 by default)
  18294. * @param height the height of the emission cylinder (1 by default)
  18295. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18296. * @param direction1 the min limit of the emission direction (up vector by default)
  18297. * @param direction2 the max limit of the emission direction (up vector by default)
  18298. */
  18299. constructor(radius?: number, height?: number, radiusRange?: number,
  18300. /**
  18301. * The min limit of the emission direction.
  18302. */
  18303. direction1?: Vector3,
  18304. /**
  18305. * The max limit of the emission direction.
  18306. */
  18307. direction2?: Vector3);
  18308. /**
  18309. * Called by the particle System when the direction is computed for the created particle.
  18310. * @param worldMatrix is the world matrix of the particle system
  18311. * @param directionToUpdate is the direction vector to update with the result
  18312. * @param particle is the particle we are computed the direction for
  18313. */
  18314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18315. /**
  18316. * Clones the current emitter and returns a copy of it
  18317. * @returns the new emitter
  18318. */
  18319. clone(): CylinderDirectedParticleEmitter;
  18320. /**
  18321. * Called by the GPUParticleSystem to setup the update shader
  18322. * @param effect defines the update shader
  18323. */
  18324. applyToShader(effect: Effect): void;
  18325. /**
  18326. * Returns a string to use to update the GPU particles update shader
  18327. * @returns a string containng the defines string
  18328. */
  18329. getEffectDefines(): string;
  18330. /**
  18331. * Returns the string "CylinderDirectedParticleEmitter"
  18332. * @returns a string containing the class name
  18333. */
  18334. getClassName(): string;
  18335. /**
  18336. * Serializes the particle system to a JSON object.
  18337. * @returns the JSON object
  18338. */
  18339. serialize(): any;
  18340. /**
  18341. * Parse properties from a JSON object
  18342. * @param serializationObject defines the JSON object
  18343. */
  18344. parse(serializationObject: any): void;
  18345. }
  18346. }
  18347. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18348. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18349. import { Effect } from "babylonjs/Materials/effect";
  18350. import { Particle } from "babylonjs/Particles/particle";
  18351. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18352. /**
  18353. * Particle emitter emitting particles from the inside of a hemisphere.
  18354. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18355. */
  18356. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18357. /**
  18358. * The radius of the emission hemisphere.
  18359. */
  18360. radius: number;
  18361. /**
  18362. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18363. */
  18364. radiusRange: number;
  18365. /**
  18366. * How much to randomize the particle direction [0-1].
  18367. */
  18368. directionRandomizer: number;
  18369. /**
  18370. * Creates a new instance HemisphericParticleEmitter
  18371. * @param radius the radius of the emission hemisphere (1 by default)
  18372. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18373. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18374. */
  18375. constructor(
  18376. /**
  18377. * The radius of the emission hemisphere.
  18378. */
  18379. radius?: number,
  18380. /**
  18381. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18382. */
  18383. radiusRange?: number,
  18384. /**
  18385. * How much to randomize the particle direction [0-1].
  18386. */
  18387. directionRandomizer?: number);
  18388. /**
  18389. * Called by the particle System when the direction is computed for the created particle.
  18390. * @param worldMatrix is the world matrix of the particle system
  18391. * @param directionToUpdate is the direction vector to update with the result
  18392. * @param particle is the particle we are computed the direction for
  18393. */
  18394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18395. /**
  18396. * Called by the particle System when the position is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param positionToUpdate is the position vector to update with the result
  18399. * @param particle is the particle we are computed the position for
  18400. */
  18401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Clones the current emitter and returns a copy of it
  18404. * @returns the new emitter
  18405. */
  18406. clone(): HemisphericParticleEmitter;
  18407. /**
  18408. * Called by the GPUParticleSystem to setup the update shader
  18409. * @param effect defines the update shader
  18410. */
  18411. applyToShader(effect: Effect): void;
  18412. /**
  18413. * Returns a string to use to update the GPU particles update shader
  18414. * @returns a string containng the defines string
  18415. */
  18416. getEffectDefines(): string;
  18417. /**
  18418. * Returns the string "HemisphericParticleEmitter"
  18419. * @returns a string containing the class name
  18420. */
  18421. getClassName(): string;
  18422. /**
  18423. * Serializes the particle system to a JSON object.
  18424. * @returns the JSON object
  18425. */
  18426. serialize(): any;
  18427. /**
  18428. * Parse properties from a JSON object
  18429. * @param serializationObject defines the JSON object
  18430. */
  18431. parse(serializationObject: any): void;
  18432. }
  18433. }
  18434. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18435. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18436. import { Effect } from "babylonjs/Materials/effect";
  18437. import { Particle } from "babylonjs/Particles/particle";
  18438. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18439. /**
  18440. * Particle emitter emitting particles from a point.
  18441. * It emits the particles randomly between 2 given directions.
  18442. */
  18443. export class PointParticleEmitter implements IParticleEmitterType {
  18444. /**
  18445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18446. */
  18447. direction1: Vector3;
  18448. /**
  18449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18450. */
  18451. direction2: Vector3;
  18452. /**
  18453. * Creates a new instance PointParticleEmitter
  18454. */
  18455. constructor();
  18456. /**
  18457. * Called by the particle System when the direction is computed for the created particle.
  18458. * @param worldMatrix is the world matrix of the particle system
  18459. * @param directionToUpdate is the direction vector to update with the result
  18460. * @param particle is the particle we are computed the direction for
  18461. */
  18462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18463. /**
  18464. * Called by the particle System when the position is computed for the created particle.
  18465. * @param worldMatrix is the world matrix of the particle system
  18466. * @param positionToUpdate is the position vector to update with the result
  18467. * @param particle is the particle we are computed the position for
  18468. */
  18469. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18470. /**
  18471. * Clones the current emitter and returns a copy of it
  18472. * @returns the new emitter
  18473. */
  18474. clone(): PointParticleEmitter;
  18475. /**
  18476. * Called by the GPUParticleSystem to setup the update shader
  18477. * @param effect defines the update shader
  18478. */
  18479. applyToShader(effect: Effect): void;
  18480. /**
  18481. * Returns a string to use to update the GPU particles update shader
  18482. * @returns a string containng the defines string
  18483. */
  18484. getEffectDefines(): string;
  18485. /**
  18486. * Returns the string "PointParticleEmitter"
  18487. * @returns a string containing the class name
  18488. */
  18489. getClassName(): string;
  18490. /**
  18491. * Serializes the particle system to a JSON object.
  18492. * @returns the JSON object
  18493. */
  18494. serialize(): any;
  18495. /**
  18496. * Parse properties from a JSON object
  18497. * @param serializationObject defines the JSON object
  18498. */
  18499. parse(serializationObject: any): void;
  18500. }
  18501. }
  18502. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18503. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18504. import { Effect } from "babylonjs/Materials/effect";
  18505. import { Particle } from "babylonjs/Particles/particle";
  18506. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18507. /**
  18508. * Particle emitter emitting particles from the inside of a sphere.
  18509. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18510. */
  18511. export class SphereParticleEmitter implements IParticleEmitterType {
  18512. /**
  18513. * The radius of the emission sphere.
  18514. */
  18515. radius: number;
  18516. /**
  18517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18518. */
  18519. radiusRange: number;
  18520. /**
  18521. * How much to randomize the particle direction [0-1].
  18522. */
  18523. directionRandomizer: number;
  18524. /**
  18525. * Creates a new instance SphereParticleEmitter
  18526. * @param radius the radius of the emission sphere (1 by default)
  18527. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18529. */
  18530. constructor(
  18531. /**
  18532. * The radius of the emission sphere.
  18533. */
  18534. radius?: number,
  18535. /**
  18536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18537. */
  18538. radiusRange?: number,
  18539. /**
  18540. * How much to randomize the particle direction [0-1].
  18541. */
  18542. directionRandomizer?: number);
  18543. /**
  18544. * Called by the particle System when the direction is computed for the created particle.
  18545. * @param worldMatrix is the world matrix of the particle system
  18546. * @param directionToUpdate is the direction vector to update with the result
  18547. * @param particle is the particle we are computed the direction for
  18548. */
  18549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18550. /**
  18551. * Called by the particle System when the position is computed for the created particle.
  18552. * @param worldMatrix is the world matrix of the particle system
  18553. * @param positionToUpdate is the position vector to update with the result
  18554. * @param particle is the particle we are computed the position for
  18555. */
  18556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18557. /**
  18558. * Clones the current emitter and returns a copy of it
  18559. * @returns the new emitter
  18560. */
  18561. clone(): SphereParticleEmitter;
  18562. /**
  18563. * Called by the GPUParticleSystem to setup the update shader
  18564. * @param effect defines the update shader
  18565. */
  18566. applyToShader(effect: Effect): void;
  18567. /**
  18568. * Returns a string to use to update the GPU particles update shader
  18569. * @returns a string containng the defines string
  18570. */
  18571. getEffectDefines(): string;
  18572. /**
  18573. * Returns the string "SphereParticleEmitter"
  18574. * @returns a string containing the class name
  18575. */
  18576. getClassName(): string;
  18577. /**
  18578. * Serializes the particle system to a JSON object.
  18579. * @returns the JSON object
  18580. */
  18581. serialize(): any;
  18582. /**
  18583. * Parse properties from a JSON object
  18584. * @param serializationObject defines the JSON object
  18585. */
  18586. parse(serializationObject: any): void;
  18587. }
  18588. /**
  18589. * Particle emitter emitting particles from the inside of a sphere.
  18590. * It emits the particles randomly between two vectors.
  18591. */
  18592. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18593. /**
  18594. * The min limit of the emission direction.
  18595. */
  18596. direction1: Vector3;
  18597. /**
  18598. * The max limit of the emission direction.
  18599. */
  18600. direction2: Vector3;
  18601. /**
  18602. * Creates a new instance SphereDirectedParticleEmitter
  18603. * @param radius the radius of the emission sphere (1 by default)
  18604. * @param direction1 the min limit of the emission direction (up vector by default)
  18605. * @param direction2 the max limit of the emission direction (up vector by default)
  18606. */
  18607. constructor(radius?: number,
  18608. /**
  18609. * The min limit of the emission direction.
  18610. */
  18611. direction1?: Vector3,
  18612. /**
  18613. * The max limit of the emission direction.
  18614. */
  18615. direction2?: Vector3);
  18616. /**
  18617. * Called by the particle System when the direction is computed for the created particle.
  18618. * @param worldMatrix is the world matrix of the particle system
  18619. * @param directionToUpdate is the direction vector to update with the result
  18620. * @param particle is the particle we are computed the direction for
  18621. */
  18622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18623. /**
  18624. * Clones the current emitter and returns a copy of it
  18625. * @returns the new emitter
  18626. */
  18627. clone(): SphereDirectedParticleEmitter;
  18628. /**
  18629. * Called by the GPUParticleSystem to setup the update shader
  18630. * @param effect defines the update shader
  18631. */
  18632. applyToShader(effect: Effect): void;
  18633. /**
  18634. * Returns a string to use to update the GPU particles update shader
  18635. * @returns a string containng the defines string
  18636. */
  18637. getEffectDefines(): string;
  18638. /**
  18639. * Returns the string "SphereDirectedParticleEmitter"
  18640. * @returns a string containing the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Serializes the particle system to a JSON object.
  18645. * @returns the JSON object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Parse properties from a JSON object
  18650. * @param serializationObject defines the JSON object
  18651. */
  18652. parse(serializationObject: any): void;
  18653. }
  18654. }
  18655. declare module "babylonjs/Particles/EmitterTypes/index" {
  18656. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18657. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18658. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18659. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18660. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18661. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18662. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18663. }
  18664. declare module "babylonjs/Particles/IParticleSystem" {
  18665. import { Nullable } from "babylonjs/types";
  18666. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18667. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18670. import { Texture } from "babylonjs/Materials/Textures/texture";
  18671. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18672. import { Scene } from "babylonjs/scene";
  18673. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18674. import { Animation } from "babylonjs/Animations/animation";
  18675. /**
  18676. * Interface representing a particle system in Babylon.js.
  18677. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18678. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18679. */
  18680. export interface IParticleSystem {
  18681. /**
  18682. * List of animations used by the particle system.
  18683. */
  18684. animations: Animation[];
  18685. /**
  18686. * The id of the Particle system.
  18687. */
  18688. id: string;
  18689. /**
  18690. * The name of the Particle system.
  18691. */
  18692. name: string;
  18693. /**
  18694. * The emitter represents the Mesh or position we are attaching the particle system to.
  18695. */
  18696. emitter: Nullable<AbstractMesh | Vector3>;
  18697. /**
  18698. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18699. */
  18700. isBillboardBased: boolean;
  18701. /**
  18702. * The rendering group used by the Particle system to chose when to render.
  18703. */
  18704. renderingGroupId: number;
  18705. /**
  18706. * The layer mask we are rendering the particles through.
  18707. */
  18708. layerMask: number;
  18709. /**
  18710. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18711. */
  18712. updateSpeed: number;
  18713. /**
  18714. * The amount of time the particle system is running (depends of the overall update speed).
  18715. */
  18716. targetStopDuration: number;
  18717. /**
  18718. * The texture used to render each particle. (this can be a spritesheet)
  18719. */
  18720. particleTexture: Nullable<Texture>;
  18721. /**
  18722. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18723. */
  18724. blendMode: number;
  18725. /**
  18726. * Minimum life time of emitting particles.
  18727. */
  18728. minLifeTime: number;
  18729. /**
  18730. * Maximum life time of emitting particles.
  18731. */
  18732. maxLifeTime: number;
  18733. /**
  18734. * Minimum Size of emitting particles.
  18735. */
  18736. minSize: number;
  18737. /**
  18738. * Maximum Size of emitting particles.
  18739. */
  18740. maxSize: number;
  18741. /**
  18742. * Minimum scale of emitting particles on X axis.
  18743. */
  18744. minScaleX: number;
  18745. /**
  18746. * Maximum scale of emitting particles on X axis.
  18747. */
  18748. maxScaleX: number;
  18749. /**
  18750. * Minimum scale of emitting particles on Y axis.
  18751. */
  18752. minScaleY: number;
  18753. /**
  18754. * Maximum scale of emitting particles on Y axis.
  18755. */
  18756. maxScaleY: number;
  18757. /**
  18758. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18759. */
  18760. color1: Color4;
  18761. /**
  18762. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18763. */
  18764. color2: Color4;
  18765. /**
  18766. * Color the particle will have at the end of its lifetime.
  18767. */
  18768. colorDead: Color4;
  18769. /**
  18770. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18771. */
  18772. emitRate: number;
  18773. /**
  18774. * You can use gravity if you want to give an orientation to your particles.
  18775. */
  18776. gravity: Vector3;
  18777. /**
  18778. * Minimum power of emitting particles.
  18779. */
  18780. minEmitPower: number;
  18781. /**
  18782. * Maximum power of emitting particles.
  18783. */
  18784. maxEmitPower: number;
  18785. /**
  18786. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18787. */
  18788. minAngularSpeed: number;
  18789. /**
  18790. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18791. */
  18792. maxAngularSpeed: number;
  18793. /**
  18794. * Gets or sets the minimal initial rotation in radians.
  18795. */
  18796. minInitialRotation: number;
  18797. /**
  18798. * Gets or sets the maximal initial rotation in radians.
  18799. */
  18800. maxInitialRotation: number;
  18801. /**
  18802. * The particle emitter type defines the emitter used by the particle system.
  18803. * It can be for example box, sphere, or cone...
  18804. */
  18805. particleEmitterType: Nullable<IParticleEmitterType>;
  18806. /**
  18807. * Defines the delay in milliseconds before starting the system (0 by default)
  18808. */
  18809. startDelay: number;
  18810. /**
  18811. * 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
  18812. */
  18813. preWarmCycles: number;
  18814. /**
  18815. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18816. */
  18817. preWarmStepOffset: number;
  18818. /**
  18819. * 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)
  18820. */
  18821. spriteCellChangeSpeed: number;
  18822. /**
  18823. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18824. */
  18825. startSpriteCellID: number;
  18826. /**
  18827. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18828. */
  18829. endSpriteCellID: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18832. */
  18833. spriteCellWidth: number;
  18834. /**
  18835. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18836. */
  18837. spriteCellHeight: number;
  18838. /**
  18839. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18840. */
  18841. spriteRandomStartCell: boolean;
  18842. /**
  18843. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18844. */
  18845. isAnimationSheetEnabled: boolean;
  18846. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18847. translationPivot: Vector2;
  18848. /**
  18849. * Gets or sets a texture used to add random noise to particle positions
  18850. */
  18851. noiseTexture: Nullable<BaseTexture>;
  18852. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18853. noiseStrength: Vector3;
  18854. /**
  18855. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18856. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18857. */
  18858. billboardMode: number;
  18859. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18860. limitVelocityDamping: number;
  18861. /**
  18862. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18863. */
  18864. beginAnimationOnStart: boolean;
  18865. /**
  18866. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18867. */
  18868. beginAnimationFrom: number;
  18869. /**
  18870. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18871. */
  18872. beginAnimationTo: number;
  18873. /**
  18874. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18875. */
  18876. beginAnimationLoop: boolean;
  18877. /**
  18878. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18879. */
  18880. disposeOnStop: boolean;
  18881. /**
  18882. * Gets the maximum number of particles active at the same time.
  18883. * @returns The max number of active particles.
  18884. */
  18885. getCapacity(): number;
  18886. /**
  18887. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18888. * @returns True if it has been started, otherwise false.
  18889. */
  18890. isStarted(): boolean;
  18891. /**
  18892. * Animates the particle system for this frame.
  18893. */
  18894. animate(): void;
  18895. /**
  18896. * Renders the particle system in its current state.
  18897. * @returns the current number of particles
  18898. */
  18899. render(): number;
  18900. /**
  18901. * Dispose the particle system and frees its associated resources.
  18902. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18903. */
  18904. dispose(disposeTexture?: boolean): void;
  18905. /**
  18906. * Clones the particle system.
  18907. * @param name The name of the cloned object
  18908. * @param newEmitter The new emitter to use
  18909. * @returns the cloned particle system
  18910. */
  18911. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18912. /**
  18913. * Serializes the particle system to a JSON object.
  18914. * @returns the JSON object
  18915. */
  18916. serialize(): any;
  18917. /**
  18918. * Rebuild the particle system
  18919. */
  18920. rebuild(): void;
  18921. /**
  18922. * Starts the particle system and begins to emit
  18923. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18924. */
  18925. start(delay?: number): void;
  18926. /**
  18927. * Stops the particle system.
  18928. */
  18929. stop(): void;
  18930. /**
  18931. * Remove all active particles
  18932. */
  18933. reset(): void;
  18934. /**
  18935. * Is this system ready to be used/rendered
  18936. * @return true if the system is ready
  18937. */
  18938. isReady(): boolean;
  18939. /**
  18940. * Adds a new color gradient
  18941. * @param gradient defines the gradient to use (between 0 and 1)
  18942. * @param color1 defines the color to affect to the specified gradient
  18943. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18944. * @returns the current particle system
  18945. */
  18946. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18947. /**
  18948. * Remove a specific color gradient
  18949. * @param gradient defines the gradient to remove
  18950. * @returns the current particle system
  18951. */
  18952. removeColorGradient(gradient: number): IParticleSystem;
  18953. /**
  18954. * Adds a new size gradient
  18955. * @param gradient defines the gradient to use (between 0 and 1)
  18956. * @param factor defines the size factor to affect to the specified gradient
  18957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18958. * @returns the current particle system
  18959. */
  18960. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18961. /**
  18962. * Remove a specific size gradient
  18963. * @param gradient defines the gradient to remove
  18964. * @returns the current particle system
  18965. */
  18966. removeSizeGradient(gradient: number): IParticleSystem;
  18967. /**
  18968. * Gets the current list of color gradients.
  18969. * You must use addColorGradient and removeColorGradient to udpate this list
  18970. * @returns the list of color gradients
  18971. */
  18972. getColorGradients(): Nullable<Array<ColorGradient>>;
  18973. /**
  18974. * Gets the current list of size gradients.
  18975. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18976. * @returns the list of size gradients
  18977. */
  18978. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18979. /**
  18980. * Gets the current list of angular speed gradients.
  18981. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18982. * @returns the list of angular speed gradients
  18983. */
  18984. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18985. /**
  18986. * Adds a new angular speed gradient
  18987. * @param gradient defines the gradient to use (between 0 and 1)
  18988. * @param factor defines the angular speed to affect to the specified gradient
  18989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18990. * @returns the current particle system
  18991. */
  18992. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18993. /**
  18994. * Remove a specific angular speed gradient
  18995. * @param gradient defines the gradient to remove
  18996. * @returns the current particle system
  18997. */
  18998. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18999. /**
  19000. * Gets the current list of velocity gradients.
  19001. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19002. * @returns the list of velocity gradients
  19003. */
  19004. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Adds a new velocity gradient
  19007. * @param gradient defines the gradient to use (between 0 and 1)
  19008. * @param factor defines the velocity to affect to the specified gradient
  19009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19010. * @returns the current particle system
  19011. */
  19012. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19013. /**
  19014. * Remove a specific velocity gradient
  19015. * @param gradient defines the gradient to remove
  19016. * @returns the current particle system
  19017. */
  19018. removeVelocityGradient(gradient: number): IParticleSystem;
  19019. /**
  19020. * Gets the current list of limit velocity gradients.
  19021. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19022. * @returns the list of limit velocity gradients
  19023. */
  19024. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19025. /**
  19026. * Adds a new limit velocity gradient
  19027. * @param gradient defines the gradient to use (between 0 and 1)
  19028. * @param factor defines the limit velocity to affect to the specified gradient
  19029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19030. * @returns the current particle system
  19031. */
  19032. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19033. /**
  19034. * Remove a specific limit velocity gradient
  19035. * @param gradient defines the gradient to remove
  19036. * @returns the current particle system
  19037. */
  19038. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19039. /**
  19040. * Adds a new drag gradient
  19041. * @param gradient defines the gradient to use (between 0 and 1)
  19042. * @param factor defines the drag to affect to the specified gradient
  19043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19044. * @returns the current particle system
  19045. */
  19046. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19047. /**
  19048. * Remove a specific drag gradient
  19049. * @param gradient defines the gradient to remove
  19050. * @returns the current particle system
  19051. */
  19052. removeDragGradient(gradient: number): IParticleSystem;
  19053. /**
  19054. * Gets the current list of drag gradients.
  19055. * You must use addDragGradient and removeDragGradient to udpate this list
  19056. * @returns the list of drag gradients
  19057. */
  19058. getDragGradients(): Nullable<Array<FactorGradient>>;
  19059. /**
  19060. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19061. * @param gradient defines the gradient to use (between 0 and 1)
  19062. * @param factor defines the emit rate to affect to the specified gradient
  19063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19064. * @returns the current particle system
  19065. */
  19066. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19067. /**
  19068. * Remove a specific emit rate gradient
  19069. * @param gradient defines the gradient to remove
  19070. * @returns the current particle system
  19071. */
  19072. removeEmitRateGradient(gradient: number): IParticleSystem;
  19073. /**
  19074. * Gets the current list of emit rate gradients.
  19075. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19076. * @returns the list of emit rate gradients
  19077. */
  19078. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19079. /**
  19080. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19081. * @param gradient defines the gradient to use (between 0 and 1)
  19082. * @param factor defines the start size to affect to the specified gradient
  19083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19084. * @returns the current particle system
  19085. */
  19086. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19087. /**
  19088. * Remove a specific start size gradient
  19089. * @param gradient defines the gradient to remove
  19090. * @returns the current particle system
  19091. */
  19092. removeStartSizeGradient(gradient: number): IParticleSystem;
  19093. /**
  19094. * Gets the current list of start size gradients.
  19095. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19096. * @returns the list of start size gradients
  19097. */
  19098. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19099. /**
  19100. * Adds a new life time gradient
  19101. * @param gradient defines the gradient to use (between 0 and 1)
  19102. * @param factor defines the life time factor to affect to the specified gradient
  19103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19104. * @returns the current particle system
  19105. */
  19106. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19107. /**
  19108. * Remove a specific life time gradient
  19109. * @param gradient defines the gradient to remove
  19110. * @returns the current particle system
  19111. */
  19112. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19113. /**
  19114. * Gets the current list of life time gradients.
  19115. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19116. * @returns the list of life time gradients
  19117. */
  19118. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19119. /**
  19120. * Gets the current list of color gradients.
  19121. * You must use addColorGradient and removeColorGradient to udpate this list
  19122. * @returns the list of color gradients
  19123. */
  19124. getColorGradients(): Nullable<Array<ColorGradient>>;
  19125. /**
  19126. * Adds a new ramp gradient used to remap particle colors
  19127. * @param gradient defines the gradient to use (between 0 and 1)
  19128. * @param color defines the color to affect to the specified gradient
  19129. * @returns the current particle system
  19130. */
  19131. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19132. /**
  19133. * Gets the current list of ramp gradients.
  19134. * You must use addRampGradient and removeRampGradient to udpate this list
  19135. * @returns the list of ramp gradients
  19136. */
  19137. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19138. /** Gets or sets a boolean indicating that ramp gradients must be used
  19139. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19140. */
  19141. useRampGradients: boolean;
  19142. /**
  19143. * Adds a new color remap gradient
  19144. * @param gradient defines the gradient to use (between 0 and 1)
  19145. * @param min defines the color remap minimal range
  19146. * @param max defines the color remap maximal range
  19147. * @returns the current particle system
  19148. */
  19149. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19150. /**
  19151. * Gets the current list of color remap gradients.
  19152. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19153. * @returns the list of color remap gradients
  19154. */
  19155. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19156. /**
  19157. * Adds a new alpha remap gradient
  19158. * @param gradient defines the gradient to use (between 0 and 1)
  19159. * @param min defines the alpha remap minimal range
  19160. * @param max defines the alpha remap maximal range
  19161. * @returns the current particle system
  19162. */
  19163. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19164. /**
  19165. * Gets the current list of alpha remap gradients.
  19166. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19167. * @returns the list of alpha remap gradients
  19168. */
  19169. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19170. /**
  19171. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19172. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19173. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19174. * @returns the emitter
  19175. */
  19176. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19177. /**
  19178. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19179. * @param radius The radius of the hemisphere to emit from
  19180. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19181. * @returns the emitter
  19182. */
  19183. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19184. /**
  19185. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19186. * @param radius The radius of the sphere to emit from
  19187. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19188. * @returns the emitter
  19189. */
  19190. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19191. /**
  19192. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19193. * @param radius The radius of the sphere to emit from
  19194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19196. * @returns the emitter
  19197. */
  19198. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19199. /**
  19200. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19201. * @param radius The radius of the emission cylinder
  19202. * @param height The height of the emission cylinder
  19203. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19204. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19205. * @returns the emitter
  19206. */
  19207. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19208. /**
  19209. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19210. * @param radius The radius of the cylinder to emit from
  19211. * @param height The height of the emission cylinder
  19212. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19215. * @returns the emitter
  19216. */
  19217. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19218. /**
  19219. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19220. * @param radius The radius of the cone to emit from
  19221. * @param angle The base angle of the cone
  19222. * @returns the emitter
  19223. */
  19224. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19225. /**
  19226. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19227. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19228. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19229. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19230. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19231. * @returns the emitter
  19232. */
  19233. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19234. /**
  19235. * Get hosting scene
  19236. * @returns the scene
  19237. */
  19238. getScene(): Scene;
  19239. }
  19240. }
  19241. declare module "babylonjs/Meshes/instancedMesh" {
  19242. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19243. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19244. import { Camera } from "babylonjs/Cameras/camera";
  19245. import { Node } from "babylonjs/node";
  19246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19247. import { Mesh } from "babylonjs/Meshes/mesh";
  19248. import { Material } from "babylonjs/Materials/material";
  19249. import { Skeleton } from "babylonjs/Bones/skeleton";
  19250. import { Light } from "babylonjs/Lights/light";
  19251. /**
  19252. * Creates an instance based on a source mesh.
  19253. */
  19254. export class InstancedMesh extends AbstractMesh {
  19255. private _sourceMesh;
  19256. private _currentLOD;
  19257. /** @hidden */
  19258. _indexInSourceMeshInstanceArray: number;
  19259. constructor(name: string, source: Mesh);
  19260. /**
  19261. * Returns the string "InstancedMesh".
  19262. */
  19263. getClassName(): string;
  19264. /** Gets the list of lights affecting that mesh */
  19265. readonly lightSources: Light[];
  19266. _resyncLightSources(): void;
  19267. _resyncLighSource(light: Light): void;
  19268. _removeLightSource(light: Light, dispose: boolean): void;
  19269. /**
  19270. * If the source mesh receives shadows
  19271. */
  19272. readonly receiveShadows: boolean;
  19273. /**
  19274. * The material of the source mesh
  19275. */
  19276. readonly material: Nullable<Material>;
  19277. /**
  19278. * Visibility of the source mesh
  19279. */
  19280. readonly visibility: number;
  19281. /**
  19282. * Skeleton of the source mesh
  19283. */
  19284. readonly skeleton: Nullable<Skeleton>;
  19285. /**
  19286. * Rendering ground id of the source mesh
  19287. */
  19288. renderingGroupId: number;
  19289. /**
  19290. * Returns the total number of vertices (integer).
  19291. */
  19292. getTotalVertices(): number;
  19293. /**
  19294. * Returns a positive integer : the total number of indices in this mesh geometry.
  19295. * @returns the numner of indices or zero if the mesh has no geometry.
  19296. */
  19297. getTotalIndices(): number;
  19298. /**
  19299. * The source mesh of the instance
  19300. */
  19301. readonly sourceMesh: Mesh;
  19302. /**
  19303. * Is this node ready to be used/rendered
  19304. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19305. * @return {boolean} is it ready
  19306. */
  19307. isReady(completeCheck?: boolean): boolean;
  19308. /**
  19309. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19310. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19311. * @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.
  19312. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19313. */
  19314. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19315. /**
  19316. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19317. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19318. * The `data` are either a numeric array either a Float32Array.
  19319. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19320. * 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).
  19321. * Note that a new underlying VertexBuffer object is created each call.
  19322. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19323. *
  19324. * Possible `kind` values :
  19325. * - VertexBuffer.PositionKind
  19326. * - VertexBuffer.UVKind
  19327. * - VertexBuffer.UV2Kind
  19328. * - VertexBuffer.UV3Kind
  19329. * - VertexBuffer.UV4Kind
  19330. * - VertexBuffer.UV5Kind
  19331. * - VertexBuffer.UV6Kind
  19332. * - VertexBuffer.ColorKind
  19333. * - VertexBuffer.MatricesIndicesKind
  19334. * - VertexBuffer.MatricesIndicesExtraKind
  19335. * - VertexBuffer.MatricesWeightsKind
  19336. * - VertexBuffer.MatricesWeightsExtraKind
  19337. *
  19338. * Returns the Mesh.
  19339. */
  19340. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19341. /**
  19342. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19343. * If the mesh has no geometry, it is simply returned as it is.
  19344. * The `data` are either a numeric array either a Float32Array.
  19345. * No new underlying VertexBuffer object is created.
  19346. * 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.
  19347. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19348. *
  19349. * Possible `kind` values :
  19350. * - VertexBuffer.PositionKind
  19351. * - VertexBuffer.UVKind
  19352. * - VertexBuffer.UV2Kind
  19353. * - VertexBuffer.UV3Kind
  19354. * - VertexBuffer.UV4Kind
  19355. * - VertexBuffer.UV5Kind
  19356. * - VertexBuffer.UV6Kind
  19357. * - VertexBuffer.ColorKind
  19358. * - VertexBuffer.MatricesIndicesKind
  19359. * - VertexBuffer.MatricesIndicesExtraKind
  19360. * - VertexBuffer.MatricesWeightsKind
  19361. * - VertexBuffer.MatricesWeightsExtraKind
  19362. *
  19363. * Returns the Mesh.
  19364. */
  19365. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19366. /**
  19367. * Sets the mesh indices.
  19368. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19370. * This method creates a new index buffer each call.
  19371. * Returns the Mesh.
  19372. */
  19373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19374. /**
  19375. * Boolean : True if the mesh owns the requested kind of data.
  19376. */
  19377. isVerticesDataPresent(kind: string): boolean;
  19378. /**
  19379. * Returns an array of indices (IndicesArray).
  19380. */
  19381. getIndices(): Nullable<IndicesArray>;
  19382. readonly _positions: Nullable<Vector3[]>;
  19383. /**
  19384. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19385. * This means the mesh underlying bounding box and sphere are recomputed.
  19386. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19387. * @returns the current mesh
  19388. */
  19389. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19390. /** @hidden */
  19391. _preActivate(): InstancedMesh;
  19392. /** @hidden */
  19393. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19394. /** @hidden */
  19395. _postActivate(): void;
  19396. getWorldMatrix(): Matrix;
  19397. readonly isAnInstance: boolean;
  19398. /**
  19399. * Returns the current associated LOD AbstractMesh.
  19400. */
  19401. getLOD(camera: Camera): AbstractMesh;
  19402. /** @hidden */
  19403. _syncSubMeshes(): InstancedMesh;
  19404. /** @hidden */
  19405. _generatePointsArray(): boolean;
  19406. /**
  19407. * Creates a new InstancedMesh from the current mesh.
  19408. * - name (string) : the cloned mesh name
  19409. * - newParent (optional Node) : the optional Node to parent the clone to.
  19410. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19411. *
  19412. * Returns the clone.
  19413. */
  19414. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19415. /**
  19416. * Disposes the InstancedMesh.
  19417. * Returns nothing.
  19418. */
  19419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19420. }
  19421. }
  19422. declare module "babylonjs/Materials/shaderMaterial" {
  19423. import { Scene } from "babylonjs/scene";
  19424. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19426. import { Mesh } from "babylonjs/Meshes/mesh";
  19427. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19429. import { Texture } from "babylonjs/Materials/Textures/texture";
  19430. import { Material } from "babylonjs/Materials/material";
  19431. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19432. /**
  19433. * Defines the options associated with the creation of a shader material.
  19434. */
  19435. export interface IShaderMaterialOptions {
  19436. /**
  19437. * Does the material work in alpha blend mode
  19438. */
  19439. needAlphaBlending: boolean;
  19440. /**
  19441. * Does the material work in alpha test mode
  19442. */
  19443. needAlphaTesting: boolean;
  19444. /**
  19445. * The list of attribute names used in the shader
  19446. */
  19447. attributes: string[];
  19448. /**
  19449. * The list of unifrom names used in the shader
  19450. */
  19451. uniforms: string[];
  19452. /**
  19453. * The list of UBO names used in the shader
  19454. */
  19455. uniformBuffers: string[];
  19456. /**
  19457. * The list of sampler names used in the shader
  19458. */
  19459. samplers: string[];
  19460. /**
  19461. * The list of defines used in the shader
  19462. */
  19463. defines: string[];
  19464. }
  19465. /**
  19466. * 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.
  19467. *
  19468. * This returned material effects how the mesh will look based on the code in the shaders.
  19469. *
  19470. * @see http://doc.babylonjs.com/how_to/shader_material
  19471. */
  19472. export class ShaderMaterial extends Material {
  19473. private _shaderPath;
  19474. private _options;
  19475. private _textures;
  19476. private _textureArrays;
  19477. private _floats;
  19478. private _ints;
  19479. private _floatsArrays;
  19480. private _colors3;
  19481. private _colors3Arrays;
  19482. private _colors4;
  19483. private _colors4Arrays;
  19484. private _vectors2;
  19485. private _vectors3;
  19486. private _vectors4;
  19487. private _matrices;
  19488. private _matrices3x3;
  19489. private _matrices2x2;
  19490. private _vectors2Arrays;
  19491. private _vectors3Arrays;
  19492. private _vectors4Arrays;
  19493. private _cachedWorldViewMatrix;
  19494. private _cachedWorldViewProjectionMatrix;
  19495. private _renderId;
  19496. /**
  19497. * Instantiate a new shader material.
  19498. * 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.
  19499. * This returned material effects how the mesh will look based on the code in the shaders.
  19500. * @see http://doc.babylonjs.com/how_to/shader_material
  19501. * @param name Define the name of the material in the scene
  19502. * @param scene Define the scene the material belongs to
  19503. * @param shaderPath Defines the route to the shader code in one of three ways:
  19504. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19505. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19506. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19507. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19508. * @param options Define the options used to create the shader
  19509. */
  19510. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19511. /**
  19512. * Gets the options used to compile the shader.
  19513. * They can be modified to trigger a new compilation
  19514. */
  19515. readonly options: IShaderMaterialOptions;
  19516. /**
  19517. * Gets the current class name of the material e.g. "ShaderMaterial"
  19518. * Mainly use in serialization.
  19519. * @returns the class name
  19520. */
  19521. getClassName(): string;
  19522. /**
  19523. * Specifies if the material will require alpha blending
  19524. * @returns a boolean specifying if alpha blending is needed
  19525. */
  19526. needAlphaBlending(): boolean;
  19527. /**
  19528. * Specifies if this material should be rendered in alpha test mode
  19529. * @returns a boolean specifying if an alpha test is needed.
  19530. */
  19531. needAlphaTesting(): boolean;
  19532. private _checkUniform;
  19533. /**
  19534. * Set a texture in the shader.
  19535. * @param name Define the name of the uniform samplers as defined in the shader
  19536. * @param texture Define the texture to bind to this sampler
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setTexture(name: string, texture: Texture): ShaderMaterial;
  19540. /**
  19541. * Set a texture array in the shader.
  19542. * @param name Define the name of the uniform sampler array as defined in the shader
  19543. * @param textures Define the list of textures to bind to this sampler
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19547. /**
  19548. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  19554. /**
  19555. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  19561. /**
  19562. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  19568. /**
  19569. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a Color3 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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  19589. /**
  19590. * Set a vec4 array in the shader from a Color4 array.
  19591. * @param name Define the name of the uniform as defined in the shader
  19592. * @param value Define the value to give to the uniform
  19593. * @return the material itself allowing "fluent" like uniform updates
  19594. */
  19595. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19596. /**
  19597. * Set a vec2 in the shader from a Vector2.
  19598. * @param name Define the name of the uniform as defined in the shader
  19599. * @param value Define the value to give to the uniform
  19600. * @return the material itself allowing "fluent" like uniform updates
  19601. */
  19602. setVector2(name: string, value: Vector2): ShaderMaterial;
  19603. /**
  19604. * Set a vec3 in the shader from a Vector3.
  19605. * @param name Define the name of the uniform as defined in the shader
  19606. * @param value Define the value to give to the uniform
  19607. * @return the material itself allowing "fluent" like uniform updates
  19608. */
  19609. setVector3(name: string, value: Vector3): ShaderMaterial;
  19610. /**
  19611. * Set a vec4 in the shader from a Vector4.
  19612. * @param name Define the name of the uniform as defined in the shader
  19613. * @param value Define the value to give to the uniform
  19614. * @return the material itself allowing "fluent" like uniform updates
  19615. */
  19616. setVector4(name: string, value: Vector4): ShaderMaterial;
  19617. /**
  19618. * Set a mat4 in the shader from a Matrix.
  19619. * @param name Define the name of the uniform as defined in the shader
  19620. * @param value Define the value to give to the uniform
  19621. * @return the material itself allowing "fluent" like uniform updates
  19622. */
  19623. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19624. /**
  19625. * Set a mat3 in the shader from a Float32Array.
  19626. * @param name Define the name of the uniform as defined in the shader
  19627. * @param value Define the value to give to the uniform
  19628. * @return the material itself allowing "fluent" like uniform updates
  19629. */
  19630. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19631. /**
  19632. * Set a mat2 in the shader from a Float32Array.
  19633. * @param name Define the name of the uniform as defined in the shader
  19634. * @param value Define the value to give to the uniform
  19635. * @return the material itself allowing "fluent" like uniform updates
  19636. */
  19637. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19638. /**
  19639. * Set a vec2 array in the shader from a number array.
  19640. * @param name Define the name of the uniform as defined in the shader
  19641. * @param value Define the value to give to the uniform
  19642. * @return the material itself allowing "fluent" like uniform updates
  19643. */
  19644. setArray2(name: string, value: number[]): ShaderMaterial;
  19645. /**
  19646. * Set a vec3 array in the shader from a number array.
  19647. * @param name Define the name of the uniform as defined in the shader
  19648. * @param value Define the value to give to the uniform
  19649. * @return the material itself allowing "fluent" like uniform updates
  19650. */
  19651. setArray3(name: string, value: number[]): ShaderMaterial;
  19652. /**
  19653. * Set a vec4 array in the shader from a number array.
  19654. * @param name Define the name of the uniform as defined in the shader
  19655. * @param value Define the value to give to the uniform
  19656. * @return the material itself allowing "fluent" like uniform updates
  19657. */
  19658. setArray4(name: string, value: number[]): ShaderMaterial;
  19659. private _checkCache;
  19660. /**
  19661. * Specifies that the submesh is ready to be used
  19662. * @param mesh defines the mesh to check
  19663. * @param subMesh defines which submesh to check
  19664. * @param useInstances specifies that instances should be used
  19665. * @returns a boolean indicating that the submesh is ready or not
  19666. */
  19667. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19668. /**
  19669. * Checks if the material is ready to render the requested mesh
  19670. * @param mesh Define the mesh to render
  19671. * @param useInstances Define whether or not the material is used with instances
  19672. * @returns true if ready, otherwise false
  19673. */
  19674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19675. /**
  19676. * Binds the world matrix to the material
  19677. * @param world defines the world transformation matrix
  19678. */
  19679. bindOnlyWorldMatrix(world: Matrix): void;
  19680. /**
  19681. * Binds the material to the mesh
  19682. * @param world defines the world transformation matrix
  19683. * @param mesh defines the mesh to bind the material to
  19684. */
  19685. bind(world: Matrix, mesh?: Mesh): void;
  19686. /**
  19687. * Gets the active textures from the material
  19688. * @returns an array of textures
  19689. */
  19690. getActiveTextures(): BaseTexture[];
  19691. /**
  19692. * Specifies if the material uses a texture
  19693. * @param texture defines the texture to check against the material
  19694. * @returns a boolean specifying if the material uses the texture
  19695. */
  19696. hasTexture(texture: BaseTexture): boolean;
  19697. /**
  19698. * Makes a duplicate of the material, and gives it a new name
  19699. * @param name defines the new name for the duplicated material
  19700. * @returns the cloned material
  19701. */
  19702. clone(name: string): ShaderMaterial;
  19703. /**
  19704. * Disposes the material
  19705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19706. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19707. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19708. */
  19709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19710. /**
  19711. * Serializes this material in a JSON representation
  19712. * @returns the serialized material object
  19713. */
  19714. serialize(): any;
  19715. /**
  19716. * Creates a shader material from parsed shader material data
  19717. * @param source defines the JSON represnetation of the material
  19718. * @param scene defines the hosting scene
  19719. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19720. * @returns a new material
  19721. */
  19722. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19723. }
  19724. }
  19725. declare module "babylonjs/Shaders/color.fragment" {
  19726. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19728. /** @hidden */
  19729. export var colorPixelShader: {
  19730. name: string;
  19731. shader: string;
  19732. };
  19733. }
  19734. declare module "babylonjs/Shaders/color.vertex" {
  19735. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19737. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19738. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19739. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19741. /** @hidden */
  19742. export var colorVertexShader: {
  19743. name: string;
  19744. shader: string;
  19745. };
  19746. }
  19747. declare module "babylonjs/Meshes/linesMesh" {
  19748. import { Nullable } from "babylonjs/types";
  19749. import { Scene } from "babylonjs/scene";
  19750. import { Color3 } from "babylonjs/Maths/math.color";
  19751. import { Node } from "babylonjs/node";
  19752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19753. import { Mesh } from "babylonjs/Meshes/mesh";
  19754. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19755. import { Effect } from "babylonjs/Materials/effect";
  19756. import { Material } from "babylonjs/Materials/material";
  19757. import "babylonjs/Shaders/color.fragment";
  19758. import "babylonjs/Shaders/color.vertex";
  19759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19760. /**
  19761. * Line mesh
  19762. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19763. */
  19764. export class LinesMesh extends Mesh {
  19765. /**
  19766. * If vertex color should be applied to the mesh
  19767. */
  19768. readonly useVertexColor?: boolean | undefined;
  19769. /**
  19770. * If vertex alpha should be applied to the mesh
  19771. */
  19772. readonly useVertexAlpha?: boolean | undefined;
  19773. /**
  19774. * Color of the line (Default: White)
  19775. */
  19776. color: Color3;
  19777. /**
  19778. * Alpha of the line (Default: 1)
  19779. */
  19780. alpha: number;
  19781. /**
  19782. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19783. * This margin is expressed in world space coordinates, so its value may vary.
  19784. * Default value is 0.1
  19785. */
  19786. intersectionThreshold: number;
  19787. private _colorShader;
  19788. private color4;
  19789. /**
  19790. * Creates a new LinesMesh
  19791. * @param name defines the name
  19792. * @param scene defines the hosting scene
  19793. * @param parent defines the parent mesh if any
  19794. * @param source defines the optional source LinesMesh used to clone data from
  19795. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19796. * When false, achieved by calling a clone(), also passing False.
  19797. * This will make creation of children, recursive.
  19798. * @param useVertexColor defines if this LinesMesh supports vertex color
  19799. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19800. */
  19801. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19802. /**
  19803. * If vertex color should be applied to the mesh
  19804. */
  19805. useVertexColor?: boolean | undefined,
  19806. /**
  19807. * If vertex alpha should be applied to the mesh
  19808. */
  19809. useVertexAlpha?: boolean | undefined);
  19810. private _addClipPlaneDefine;
  19811. private _removeClipPlaneDefine;
  19812. isReady(): boolean;
  19813. /**
  19814. * Returns the string "LineMesh"
  19815. */
  19816. getClassName(): string;
  19817. /**
  19818. * @hidden
  19819. */
  19820. /**
  19821. * @hidden
  19822. */
  19823. material: Material;
  19824. /**
  19825. * @hidden
  19826. */
  19827. readonly checkCollisions: boolean;
  19828. /** @hidden */
  19829. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19830. /** @hidden */
  19831. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19832. /**
  19833. * Disposes of the line mesh
  19834. * @param doNotRecurse If children should be disposed
  19835. */
  19836. dispose(doNotRecurse?: boolean): void;
  19837. /**
  19838. * Returns a new LineMesh object cloned from the current one.
  19839. */
  19840. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19841. /**
  19842. * Creates a new InstancedLinesMesh object from the mesh model.
  19843. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19844. * @param name defines the name of the new instance
  19845. * @returns a new InstancedLinesMesh
  19846. */
  19847. createInstance(name: string): InstancedLinesMesh;
  19848. }
  19849. /**
  19850. * Creates an instance based on a source LinesMesh
  19851. */
  19852. export class InstancedLinesMesh extends InstancedMesh {
  19853. /**
  19854. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19855. * This margin is expressed in world space coordinates, so its value may vary.
  19856. * Initilized with the intersectionThreshold value of the source LinesMesh
  19857. */
  19858. intersectionThreshold: number;
  19859. constructor(name: string, source: LinesMesh);
  19860. /**
  19861. * Returns the string "InstancedLinesMesh".
  19862. */
  19863. getClassName(): string;
  19864. }
  19865. }
  19866. declare module "babylonjs/Shaders/line.fragment" {
  19867. /** @hidden */
  19868. export var linePixelShader: {
  19869. name: string;
  19870. shader: string;
  19871. };
  19872. }
  19873. declare module "babylonjs/Shaders/line.vertex" {
  19874. /** @hidden */
  19875. export var lineVertexShader: {
  19876. name: string;
  19877. shader: string;
  19878. };
  19879. }
  19880. declare module "babylonjs/Rendering/edgesRenderer" {
  19881. import { Nullable } from "babylonjs/types";
  19882. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19884. import { Vector3 } from "babylonjs/Maths/math.vector";
  19885. import { IDisposable } from "babylonjs/scene";
  19886. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19887. import "babylonjs/Shaders/line.fragment";
  19888. import "babylonjs/Shaders/line.vertex";
  19889. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19890. module "babylonjs/Meshes/abstractMesh" {
  19891. interface AbstractMesh {
  19892. /**
  19893. * Gets the edgesRenderer associated with the mesh
  19894. */
  19895. edgesRenderer: Nullable<EdgesRenderer>;
  19896. }
  19897. }
  19898. module "babylonjs/Meshes/linesMesh" {
  19899. interface LinesMesh {
  19900. /**
  19901. * Enables the edge rendering mode on the mesh.
  19902. * This mode makes the mesh edges visible
  19903. * @param epsilon defines the maximal distance between two angles to detect a face
  19904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19905. * @returns the currentAbstractMesh
  19906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19907. */
  19908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19909. }
  19910. }
  19911. module "babylonjs/Meshes/linesMesh" {
  19912. interface InstancedLinesMesh {
  19913. /**
  19914. * Enables the edge rendering mode on the mesh.
  19915. * This mode makes the mesh edges visible
  19916. * @param epsilon defines the maximal distance between two angles to detect a face
  19917. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19918. * @returns the current InstancedLinesMesh
  19919. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19920. */
  19921. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19922. }
  19923. }
  19924. /**
  19925. * Defines the minimum contract an Edges renderer should follow.
  19926. */
  19927. export interface IEdgesRenderer extends IDisposable {
  19928. /**
  19929. * Gets or sets a boolean indicating if the edgesRenderer is active
  19930. */
  19931. isEnabled: boolean;
  19932. /**
  19933. * Renders the edges of the attached mesh,
  19934. */
  19935. render(): void;
  19936. /**
  19937. * Checks wether or not the edges renderer is ready to render.
  19938. * @return true if ready, otherwise false.
  19939. */
  19940. isReady(): boolean;
  19941. }
  19942. /**
  19943. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19944. */
  19945. export class EdgesRenderer implements IEdgesRenderer {
  19946. /**
  19947. * Define the size of the edges with an orthographic camera
  19948. */
  19949. edgesWidthScalerForOrthographic: number;
  19950. /**
  19951. * Define the size of the edges with a perspective camera
  19952. */
  19953. edgesWidthScalerForPerspective: number;
  19954. protected _source: AbstractMesh;
  19955. protected _linesPositions: number[];
  19956. protected _linesNormals: number[];
  19957. protected _linesIndices: number[];
  19958. protected _epsilon: number;
  19959. protected _indicesCount: number;
  19960. protected _lineShader: ShaderMaterial;
  19961. protected _ib: DataBuffer;
  19962. protected _buffers: {
  19963. [key: string]: Nullable<VertexBuffer>;
  19964. };
  19965. protected _checkVerticesInsteadOfIndices: boolean;
  19966. private _meshRebuildObserver;
  19967. private _meshDisposeObserver;
  19968. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19969. isEnabled: boolean;
  19970. /**
  19971. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19972. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19973. * @param source Mesh used to create edges
  19974. * @param epsilon sum of angles in adjacency to check for edge
  19975. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19976. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19977. */
  19978. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19979. protected _prepareRessources(): void;
  19980. /** @hidden */
  19981. _rebuild(): void;
  19982. /**
  19983. * Releases the required resources for the edges renderer
  19984. */
  19985. dispose(): void;
  19986. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19987. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19988. /**
  19989. * Checks if the pair of p0 and p1 is en edge
  19990. * @param faceIndex
  19991. * @param edge
  19992. * @param faceNormals
  19993. * @param p0
  19994. * @param p1
  19995. * @private
  19996. */
  19997. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19998. /**
  19999. * push line into the position, normal and index buffer
  20000. * @protected
  20001. */
  20002. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20003. /**
  20004. * Generates lines edges from adjacencjes
  20005. * @private
  20006. */
  20007. _generateEdgesLines(): void;
  20008. /**
  20009. * Checks wether or not the edges renderer is ready to render.
  20010. * @return true if ready, otherwise false.
  20011. */
  20012. isReady(): boolean;
  20013. /**
  20014. * Renders the edges of the attached mesh,
  20015. */
  20016. render(): void;
  20017. }
  20018. /**
  20019. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20020. */
  20021. export class LineEdgesRenderer extends EdgesRenderer {
  20022. /**
  20023. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20024. * @param source LineMesh used to generate edges
  20025. * @param epsilon not important (specified angle for edge detection)
  20026. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20027. */
  20028. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20029. /**
  20030. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20031. */
  20032. _generateEdgesLines(): void;
  20033. }
  20034. }
  20035. declare module "babylonjs/Rendering/renderingGroup" {
  20036. import { SmartArray } from "babylonjs/Misc/smartArray";
  20037. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20039. import { Nullable } from "babylonjs/types";
  20040. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20041. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20042. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20043. import { Material } from "babylonjs/Materials/material";
  20044. import { Scene } from "babylonjs/scene";
  20045. /**
  20046. * This represents the object necessary to create a rendering group.
  20047. * This is exclusively used and created by the rendering manager.
  20048. * To modify the behavior, you use the available helpers in your scene or meshes.
  20049. * @hidden
  20050. */
  20051. export class RenderingGroup {
  20052. index: number;
  20053. private static _zeroVector;
  20054. private _scene;
  20055. private _opaqueSubMeshes;
  20056. private _transparentSubMeshes;
  20057. private _alphaTestSubMeshes;
  20058. private _depthOnlySubMeshes;
  20059. private _particleSystems;
  20060. private _spriteManagers;
  20061. private _opaqueSortCompareFn;
  20062. private _alphaTestSortCompareFn;
  20063. private _transparentSortCompareFn;
  20064. private _renderOpaque;
  20065. private _renderAlphaTest;
  20066. private _renderTransparent;
  20067. /** @hidden */
  20068. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20069. onBeforeTransparentRendering: () => void;
  20070. /**
  20071. * Set the opaque sort comparison function.
  20072. * If null the sub meshes will be render in the order they were created
  20073. */
  20074. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20075. /**
  20076. * Set the alpha test sort comparison function.
  20077. * If null the sub meshes will be render in the order they were created
  20078. */
  20079. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20080. /**
  20081. * Set the transparent sort comparison function.
  20082. * If null the sub meshes will be render in the order they were created
  20083. */
  20084. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20085. /**
  20086. * Creates a new rendering group.
  20087. * @param index The rendering group index
  20088. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20089. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20090. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20091. */
  20092. 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>);
  20093. /**
  20094. * Render all the sub meshes contained in the group.
  20095. * @param customRenderFunction Used to override the default render behaviour of the group.
  20096. * @returns true if rendered some submeshes.
  20097. */
  20098. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20099. /**
  20100. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20101. * @param subMeshes The submeshes to render
  20102. */
  20103. private renderOpaqueSorted;
  20104. /**
  20105. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20106. * @param subMeshes The submeshes to render
  20107. */
  20108. private renderAlphaTestSorted;
  20109. /**
  20110. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20111. * @param subMeshes The submeshes to render
  20112. */
  20113. private renderTransparentSorted;
  20114. /**
  20115. * Renders the submeshes in a specified order.
  20116. * @param subMeshes The submeshes to sort before render
  20117. * @param sortCompareFn The comparison function use to sort
  20118. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20119. * @param transparent Specifies to activate blending if true
  20120. */
  20121. private static renderSorted;
  20122. /**
  20123. * Renders the submeshes in the order they were dispatched (no sort applied).
  20124. * @param subMeshes The submeshes to render
  20125. */
  20126. private static renderUnsorted;
  20127. /**
  20128. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20129. * are rendered back to front if in the same alpha index.
  20130. *
  20131. * @param a The first submesh
  20132. * @param b The second submesh
  20133. * @returns The result of the comparison
  20134. */
  20135. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20136. /**
  20137. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20138. * are rendered back to front.
  20139. *
  20140. * @param a The first submesh
  20141. * @param b The second submesh
  20142. * @returns The result of the comparison
  20143. */
  20144. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20145. /**
  20146. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20147. * are rendered front to back (prevent overdraw).
  20148. *
  20149. * @param a The first submesh
  20150. * @param b The second submesh
  20151. * @returns The result of the comparison
  20152. */
  20153. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20154. /**
  20155. * Resets the different lists of submeshes to prepare a new frame.
  20156. */
  20157. prepare(): void;
  20158. dispose(): void;
  20159. /**
  20160. * Inserts the submesh in its correct queue depending on its material.
  20161. * @param subMesh The submesh to dispatch
  20162. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20163. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20164. */
  20165. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20166. dispatchSprites(spriteManager: ISpriteManager): void;
  20167. dispatchParticles(particleSystem: IParticleSystem): void;
  20168. private _renderParticles;
  20169. private _renderSprites;
  20170. }
  20171. }
  20172. declare module "babylonjs/Rendering/renderingManager" {
  20173. import { Nullable } from "babylonjs/types";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20176. import { SmartArray } from "babylonjs/Misc/smartArray";
  20177. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20179. import { Material } from "babylonjs/Materials/material";
  20180. import { Scene } from "babylonjs/scene";
  20181. import { Camera } from "babylonjs/Cameras/camera";
  20182. /**
  20183. * Interface describing the different options available in the rendering manager
  20184. * regarding Auto Clear between groups.
  20185. */
  20186. export interface IRenderingManagerAutoClearSetup {
  20187. /**
  20188. * Defines whether or not autoclear is enable.
  20189. */
  20190. autoClear: boolean;
  20191. /**
  20192. * Defines whether or not to autoclear the depth buffer.
  20193. */
  20194. depth: boolean;
  20195. /**
  20196. * Defines whether or not to autoclear the stencil buffer.
  20197. */
  20198. stencil: boolean;
  20199. }
  20200. /**
  20201. * This class is used by the onRenderingGroupObservable
  20202. */
  20203. export class RenderingGroupInfo {
  20204. /**
  20205. * The Scene that being rendered
  20206. */
  20207. scene: Scene;
  20208. /**
  20209. * The camera currently used for the rendering pass
  20210. */
  20211. camera: Nullable<Camera>;
  20212. /**
  20213. * The ID of the renderingGroup being processed
  20214. */
  20215. renderingGroupId: number;
  20216. }
  20217. /**
  20218. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20219. * It is enable to manage the different groups as well as the different necessary sort functions.
  20220. * This should not be used directly aside of the few static configurations
  20221. */
  20222. export class RenderingManager {
  20223. /**
  20224. * The max id used for rendering groups (not included)
  20225. */
  20226. static MAX_RENDERINGGROUPS: number;
  20227. /**
  20228. * The min id used for rendering groups (included)
  20229. */
  20230. static MIN_RENDERINGGROUPS: number;
  20231. /**
  20232. * Used to globally prevent autoclearing scenes.
  20233. */
  20234. static AUTOCLEAR: boolean;
  20235. /**
  20236. * @hidden
  20237. */
  20238. _useSceneAutoClearSetup: boolean;
  20239. private _scene;
  20240. private _renderingGroups;
  20241. private _depthStencilBufferAlreadyCleaned;
  20242. private _autoClearDepthStencil;
  20243. private _customOpaqueSortCompareFn;
  20244. private _customAlphaTestSortCompareFn;
  20245. private _customTransparentSortCompareFn;
  20246. private _renderingGroupInfo;
  20247. /**
  20248. * Instantiates a new rendering group for a particular scene
  20249. * @param scene Defines the scene the groups belongs to
  20250. */
  20251. constructor(scene: Scene);
  20252. private _clearDepthStencilBuffer;
  20253. /**
  20254. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20255. * @hidden
  20256. */
  20257. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20258. /**
  20259. * Resets the different information of the group to prepare a new frame
  20260. * @hidden
  20261. */
  20262. reset(): void;
  20263. /**
  20264. * Dispose and release the group and its associated resources.
  20265. * @hidden
  20266. */
  20267. dispose(): void;
  20268. /**
  20269. * Clear the info related to rendering groups preventing retention points during dispose.
  20270. */
  20271. freeRenderingGroups(): void;
  20272. private _prepareRenderingGroup;
  20273. /**
  20274. * Add a sprite manager to the rendering manager in order to render it this frame.
  20275. * @param spriteManager Define the sprite manager to render
  20276. */
  20277. dispatchSprites(spriteManager: ISpriteManager): void;
  20278. /**
  20279. * Add a particle system to the rendering manager in order to render it this frame.
  20280. * @param particleSystem Define the particle system to render
  20281. */
  20282. dispatchParticles(particleSystem: IParticleSystem): void;
  20283. /**
  20284. * Add a submesh to the manager in order to render it this frame
  20285. * @param subMesh The submesh to dispatch
  20286. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20287. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20288. */
  20289. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20290. /**
  20291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20292. * This allowed control for front to back rendering or reversly depending of the special needs.
  20293. *
  20294. * @param renderingGroupId The rendering group id corresponding to its index
  20295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20298. */
  20299. 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;
  20300. /**
  20301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20302. *
  20303. * @param renderingGroupId The rendering group id corresponding to its index
  20304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20307. */
  20308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20309. /**
  20310. * Gets the current auto clear configuration for one rendering group of the rendering
  20311. * manager.
  20312. * @param index the rendering group index to get the information for
  20313. * @returns The auto clear setup for the requested rendering group
  20314. */
  20315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20316. }
  20317. }
  20318. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20319. import { Observable } from "babylonjs/Misc/observable";
  20320. import { SmartArray } from "babylonjs/Misc/smartArray";
  20321. import { Nullable } from "babylonjs/types";
  20322. import { Camera } from "babylonjs/Cameras/camera";
  20323. import { Scene } from "babylonjs/scene";
  20324. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20325. import { Color4 } from "babylonjs/Maths/math.color";
  20326. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20330. import { Texture } from "babylonjs/Materials/Textures/texture";
  20331. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20332. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20333. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20334. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20335. import { Engine } from "babylonjs/Engines/engine";
  20336. /**
  20337. * This Helps creating a texture that will be created from a camera in your scene.
  20338. * It is basically a dynamic texture that could be used to create special effects for instance.
  20339. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20340. */
  20341. export class RenderTargetTexture extends Texture {
  20342. isCube: boolean;
  20343. /**
  20344. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20345. */
  20346. static readonly REFRESHRATE_RENDER_ONCE: number;
  20347. /**
  20348. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20349. */
  20350. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20351. /**
  20352. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20353. * the central point of your effect and can save a lot of performances.
  20354. */
  20355. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20356. /**
  20357. * Use this predicate to dynamically define the list of mesh you want to render.
  20358. * If set, the renderList property will be overwritten.
  20359. */
  20360. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20361. private _renderList;
  20362. /**
  20363. * Use this list to define the list of mesh you want to render.
  20364. */
  20365. renderList: Nullable<Array<AbstractMesh>>;
  20366. private _hookArray;
  20367. /**
  20368. * Define if particles should be rendered in your texture.
  20369. */
  20370. renderParticles: boolean;
  20371. /**
  20372. * Define if sprites should be rendered in your texture.
  20373. */
  20374. renderSprites: boolean;
  20375. /**
  20376. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20377. */
  20378. coordinatesMode: number;
  20379. /**
  20380. * Define the camera used to render the texture.
  20381. */
  20382. activeCamera: Nullable<Camera>;
  20383. /**
  20384. * Override the render function of the texture with your own one.
  20385. */
  20386. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20387. /**
  20388. * Define if camera post processes should be use while rendering the texture.
  20389. */
  20390. useCameraPostProcesses: boolean;
  20391. /**
  20392. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20393. */
  20394. ignoreCameraViewport: boolean;
  20395. private _postProcessManager;
  20396. private _postProcesses;
  20397. private _resizeObserver;
  20398. /**
  20399. * An event triggered when the texture is unbind.
  20400. */
  20401. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20402. /**
  20403. * An event triggered when the texture is unbind.
  20404. */
  20405. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20406. private _onAfterUnbindObserver;
  20407. /**
  20408. * Set a after unbind callback in the texture.
  20409. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20410. */
  20411. onAfterUnbind: () => void;
  20412. /**
  20413. * An event triggered before rendering the texture
  20414. */
  20415. onBeforeRenderObservable: Observable<number>;
  20416. private _onBeforeRenderObserver;
  20417. /**
  20418. * Set a before render callback in the texture.
  20419. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20420. */
  20421. onBeforeRender: (faceIndex: number) => void;
  20422. /**
  20423. * An event triggered after rendering the texture
  20424. */
  20425. onAfterRenderObservable: Observable<number>;
  20426. private _onAfterRenderObserver;
  20427. /**
  20428. * Set a after render callback in the texture.
  20429. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20430. */
  20431. onAfterRender: (faceIndex: number) => void;
  20432. /**
  20433. * An event triggered after the texture clear
  20434. */
  20435. onClearObservable: Observable<Engine>;
  20436. private _onClearObserver;
  20437. /**
  20438. * Set a clear callback in the texture.
  20439. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20440. */
  20441. onClear: (Engine: Engine) => void;
  20442. /**
  20443. * An event triggered when the texture is resized.
  20444. */
  20445. onResizeObservable: Observable<RenderTargetTexture>;
  20446. /**
  20447. * Define the clear color of the Render Target if it should be different from the scene.
  20448. */
  20449. clearColor: Color4;
  20450. protected _size: number | {
  20451. width: number;
  20452. height: number;
  20453. };
  20454. protected _initialSizeParameter: number | {
  20455. width: number;
  20456. height: number;
  20457. } | {
  20458. ratio: number;
  20459. };
  20460. protected _sizeRatio: Nullable<number>;
  20461. /** @hidden */
  20462. _generateMipMaps: boolean;
  20463. protected _renderingManager: RenderingManager;
  20464. /** @hidden */
  20465. _waitingRenderList: string[];
  20466. protected _doNotChangeAspectRatio: boolean;
  20467. protected _currentRefreshId: number;
  20468. protected _refreshRate: number;
  20469. protected _textureMatrix: Matrix;
  20470. protected _samples: number;
  20471. protected _renderTargetOptions: RenderTargetCreationOptions;
  20472. /**
  20473. * Gets render target creation options that were used.
  20474. */
  20475. readonly renderTargetOptions: RenderTargetCreationOptions;
  20476. protected _engine: Engine;
  20477. protected _onRatioRescale(): void;
  20478. /**
  20479. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20480. * It must define where the camera used to render the texture is set
  20481. */
  20482. boundingBoxPosition: Vector3;
  20483. private _boundingBoxSize;
  20484. /**
  20485. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20486. * When defined, the cubemap will switch to local mode
  20487. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20488. * @example https://www.babylonjs-playground.com/#RNASML
  20489. */
  20490. boundingBoxSize: Vector3;
  20491. /**
  20492. * In case the RTT has been created with a depth texture, get the associated
  20493. * depth texture.
  20494. * Otherwise, return null.
  20495. */
  20496. depthStencilTexture: Nullable<InternalTexture>;
  20497. /**
  20498. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20499. * or used a shadow, depth texture...
  20500. * @param name The friendly name of the texture
  20501. * @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)
  20502. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20503. * @param generateMipMaps True if mip maps need to be generated after render.
  20504. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20505. * @param type The type of the buffer in the RTT (int, half float, float...)
  20506. * @param isCube True if a cube texture needs to be created
  20507. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20508. * @param generateDepthBuffer True to generate a depth buffer
  20509. * @param generateStencilBuffer True to generate a stencil buffer
  20510. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20511. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20512. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20513. */
  20514. constructor(name: string, size: number | {
  20515. width: number;
  20516. height: number;
  20517. } | {
  20518. ratio: number;
  20519. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20520. /**
  20521. * Creates a depth stencil texture.
  20522. * This is only available in WebGL 2 or with the depth texture extension available.
  20523. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20524. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20525. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20526. */
  20527. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20528. private _processSizeParameter;
  20529. /**
  20530. * Define the number of samples to use in case of MSAA.
  20531. * It defaults to one meaning no MSAA has been enabled.
  20532. */
  20533. samples: number;
  20534. /**
  20535. * Resets the refresh counter of the texture and start bak from scratch.
  20536. * Could be useful to regenerate the texture if it is setup to render only once.
  20537. */
  20538. resetRefreshCounter(): void;
  20539. /**
  20540. * Define the refresh rate of the texture or the rendering frequency.
  20541. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20542. */
  20543. refreshRate: number;
  20544. /**
  20545. * Adds a post process to the render target rendering passes.
  20546. * @param postProcess define the post process to add
  20547. */
  20548. addPostProcess(postProcess: PostProcess): void;
  20549. /**
  20550. * Clear all the post processes attached to the render target
  20551. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20552. */
  20553. clearPostProcesses(dispose?: boolean): void;
  20554. /**
  20555. * Remove one of the post process from the list of attached post processes to the texture
  20556. * @param postProcess define the post process to remove from the list
  20557. */
  20558. removePostProcess(postProcess: PostProcess): void;
  20559. /** @hidden */
  20560. _shouldRender(): boolean;
  20561. /**
  20562. * Gets the actual render size of the texture.
  20563. * @returns the width of the render size
  20564. */
  20565. getRenderSize(): number;
  20566. /**
  20567. * Gets the actual render width of the texture.
  20568. * @returns the width of the render size
  20569. */
  20570. getRenderWidth(): number;
  20571. /**
  20572. * Gets the actual render height of the texture.
  20573. * @returns the height of the render size
  20574. */
  20575. getRenderHeight(): number;
  20576. /**
  20577. * Get if the texture can be rescaled or not.
  20578. */
  20579. readonly canRescale: boolean;
  20580. /**
  20581. * Resize the texture using a ratio.
  20582. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20583. */
  20584. scale(ratio: number): void;
  20585. /**
  20586. * Get the texture reflection matrix used to rotate/transform the reflection.
  20587. * @returns the reflection matrix
  20588. */
  20589. getReflectionTextureMatrix(): Matrix;
  20590. /**
  20591. * Resize the texture to a new desired size.
  20592. * Be carrefull as it will recreate all the data in the new texture.
  20593. * @param size Define the new size. It can be:
  20594. * - a number for squared texture,
  20595. * - an object containing { width: number, height: number }
  20596. * - or an object containing a ratio { ratio: number }
  20597. */
  20598. resize(size: number | {
  20599. width: number;
  20600. height: number;
  20601. } | {
  20602. ratio: number;
  20603. }): void;
  20604. /**
  20605. * Renders all the objects from the render list into the texture.
  20606. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20607. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20608. */
  20609. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20610. private _bestReflectionRenderTargetDimension;
  20611. /**
  20612. * @hidden
  20613. * @param faceIndex face index to bind to if this is a cubetexture
  20614. */
  20615. _bindFrameBuffer(faceIndex?: number): void;
  20616. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20617. private renderToTarget;
  20618. /**
  20619. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20620. * This allowed control for front to back rendering or reversly depending of the special needs.
  20621. *
  20622. * @param renderingGroupId The rendering group id corresponding to its index
  20623. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20624. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20625. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20626. */
  20627. 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;
  20628. /**
  20629. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20630. *
  20631. * @param renderingGroupId The rendering group id corresponding to its index
  20632. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20633. */
  20634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20635. /**
  20636. * Clones the texture.
  20637. * @returns the cloned texture
  20638. */
  20639. clone(): RenderTargetTexture;
  20640. /**
  20641. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20642. * @returns The JSON representation of the texture
  20643. */
  20644. serialize(): any;
  20645. /**
  20646. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20647. */
  20648. disposeFramebufferObjects(): void;
  20649. /**
  20650. * Dispose the texture and release its associated resources.
  20651. */
  20652. dispose(): void;
  20653. /** @hidden */
  20654. _rebuild(): void;
  20655. /**
  20656. * Clear the info related to rendering groups preventing retention point in material dispose.
  20657. */
  20658. freeRenderingGroups(): void;
  20659. /**
  20660. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20661. * @returns the view count
  20662. */
  20663. getViewCount(): number;
  20664. }
  20665. }
  20666. declare module "babylonjs/Materials/material" {
  20667. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20668. import { SmartArray } from "babylonjs/Misc/smartArray";
  20669. import { Observable } from "babylonjs/Misc/observable";
  20670. import { Nullable } from "babylonjs/types";
  20671. import { Scene } from "babylonjs/scene";
  20672. import { Matrix } from "babylonjs/Maths/math.vector";
  20673. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20675. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20676. import { Effect } from "babylonjs/Materials/effect";
  20677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20678. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20679. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20680. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20681. import { Mesh } from "babylonjs/Meshes/mesh";
  20682. import { Animation } from "babylonjs/Animations/animation";
  20683. /**
  20684. * Base class for the main features of a material in Babylon.js
  20685. */
  20686. export class Material implements IAnimatable {
  20687. /**
  20688. * Returns the triangle fill mode
  20689. */
  20690. static readonly TriangleFillMode: number;
  20691. /**
  20692. * Returns the wireframe mode
  20693. */
  20694. static readonly WireFrameFillMode: number;
  20695. /**
  20696. * Returns the point fill mode
  20697. */
  20698. static readonly PointFillMode: number;
  20699. /**
  20700. * Returns the point list draw mode
  20701. */
  20702. static readonly PointListDrawMode: number;
  20703. /**
  20704. * Returns the line list draw mode
  20705. */
  20706. static readonly LineListDrawMode: number;
  20707. /**
  20708. * Returns the line loop draw mode
  20709. */
  20710. static readonly LineLoopDrawMode: number;
  20711. /**
  20712. * Returns the line strip draw mode
  20713. */
  20714. static readonly LineStripDrawMode: number;
  20715. /**
  20716. * Returns the triangle strip draw mode
  20717. */
  20718. static readonly TriangleStripDrawMode: number;
  20719. /**
  20720. * Returns the triangle fan draw mode
  20721. */
  20722. static readonly TriangleFanDrawMode: number;
  20723. /**
  20724. * Stores the clock-wise side orientation
  20725. */
  20726. static readonly ClockWiseSideOrientation: number;
  20727. /**
  20728. * Stores the counter clock-wise side orientation
  20729. */
  20730. static readonly CounterClockWiseSideOrientation: number;
  20731. /**
  20732. * The dirty texture flag value
  20733. */
  20734. static readonly TextureDirtyFlag: number;
  20735. /**
  20736. * The dirty light flag value
  20737. */
  20738. static readonly LightDirtyFlag: number;
  20739. /**
  20740. * The dirty fresnel flag value
  20741. */
  20742. static readonly FresnelDirtyFlag: number;
  20743. /**
  20744. * The dirty attribute flag value
  20745. */
  20746. static readonly AttributesDirtyFlag: number;
  20747. /**
  20748. * The dirty misc flag value
  20749. */
  20750. static readonly MiscDirtyFlag: number;
  20751. /**
  20752. * The all dirty flag value
  20753. */
  20754. static readonly AllDirtyFlag: number;
  20755. /**
  20756. * The ID of the material
  20757. */
  20758. id: string;
  20759. /**
  20760. * Gets or sets the unique id of the material
  20761. */
  20762. uniqueId: number;
  20763. /**
  20764. * The name of the material
  20765. */
  20766. name: string;
  20767. /**
  20768. * Gets or sets user defined metadata
  20769. */
  20770. metadata: any;
  20771. /**
  20772. * For internal use only. Please do not use.
  20773. */
  20774. reservedDataStore: any;
  20775. /**
  20776. * Specifies if the ready state should be checked on each call
  20777. */
  20778. checkReadyOnEveryCall: boolean;
  20779. /**
  20780. * Specifies if the ready state should be checked once
  20781. */
  20782. checkReadyOnlyOnce: boolean;
  20783. /**
  20784. * The state of the material
  20785. */
  20786. state: string;
  20787. /**
  20788. * The alpha value of the material
  20789. */
  20790. protected _alpha: number;
  20791. /**
  20792. * List of inspectable custom properties (used by the Inspector)
  20793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20794. */
  20795. inspectableCustomProperties: IInspectable[];
  20796. /**
  20797. * Sets the alpha value of the material
  20798. */
  20799. /**
  20800. * Gets the alpha value of the material
  20801. */
  20802. alpha: number;
  20803. /**
  20804. * Specifies if back face culling is enabled
  20805. */
  20806. protected _backFaceCulling: boolean;
  20807. /**
  20808. * Sets the back-face culling state
  20809. */
  20810. /**
  20811. * Gets the back-face culling state
  20812. */
  20813. backFaceCulling: boolean;
  20814. /**
  20815. * Stores the value for side orientation
  20816. */
  20817. sideOrientation: number;
  20818. /**
  20819. * Callback triggered when the material is compiled
  20820. */
  20821. onCompiled: Nullable<(effect: Effect) => void>;
  20822. /**
  20823. * Callback triggered when an error occurs
  20824. */
  20825. onError: Nullable<(effect: Effect, errors: string) => void>;
  20826. /**
  20827. * Callback triggered to get the render target textures
  20828. */
  20829. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20830. /**
  20831. * Gets a boolean indicating that current material needs to register RTT
  20832. */
  20833. readonly hasRenderTargetTextures: boolean;
  20834. /**
  20835. * Specifies if the material should be serialized
  20836. */
  20837. doNotSerialize: boolean;
  20838. /**
  20839. * @hidden
  20840. */
  20841. _storeEffectOnSubMeshes: boolean;
  20842. /**
  20843. * Stores the animations for the material
  20844. */
  20845. animations: Nullable<Array<Animation>>;
  20846. /**
  20847. * An event triggered when the material is disposed
  20848. */
  20849. onDisposeObservable: Observable<Material>;
  20850. /**
  20851. * An observer which watches for dispose events
  20852. */
  20853. private _onDisposeObserver;
  20854. private _onUnBindObservable;
  20855. /**
  20856. * Called during a dispose event
  20857. */
  20858. onDispose: () => void;
  20859. private _onBindObservable;
  20860. /**
  20861. * An event triggered when the material is bound
  20862. */
  20863. readonly onBindObservable: Observable<AbstractMesh>;
  20864. /**
  20865. * An observer which watches for bind events
  20866. */
  20867. private _onBindObserver;
  20868. /**
  20869. * Called during a bind event
  20870. */
  20871. onBind: (Mesh: AbstractMesh) => void;
  20872. /**
  20873. * An event triggered when the material is unbound
  20874. */
  20875. readonly onUnBindObservable: Observable<Material>;
  20876. /**
  20877. * Stores the value of the alpha mode
  20878. */
  20879. private _alphaMode;
  20880. /**
  20881. * Sets the value of the alpha mode.
  20882. *
  20883. * | Value | Type | Description |
  20884. * | --- | --- | --- |
  20885. * | 0 | ALPHA_DISABLE | |
  20886. * | 1 | ALPHA_ADD | |
  20887. * | 2 | ALPHA_COMBINE | |
  20888. * | 3 | ALPHA_SUBTRACT | |
  20889. * | 4 | ALPHA_MULTIPLY | |
  20890. * | 5 | ALPHA_MAXIMIZED | |
  20891. * | 6 | ALPHA_ONEONE | |
  20892. * | 7 | ALPHA_PREMULTIPLIED | |
  20893. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20894. * | 9 | ALPHA_INTERPOLATE | |
  20895. * | 10 | ALPHA_SCREENMODE | |
  20896. *
  20897. */
  20898. /**
  20899. * Gets the value of the alpha mode
  20900. */
  20901. alphaMode: number;
  20902. /**
  20903. * Stores the state of the need depth pre-pass value
  20904. */
  20905. private _needDepthPrePass;
  20906. /**
  20907. * Sets the need depth pre-pass value
  20908. */
  20909. /**
  20910. * Gets the depth pre-pass value
  20911. */
  20912. needDepthPrePass: boolean;
  20913. /**
  20914. * Specifies if depth writing should be disabled
  20915. */
  20916. disableDepthWrite: boolean;
  20917. /**
  20918. * Specifies if depth writing should be forced
  20919. */
  20920. forceDepthWrite: boolean;
  20921. /**
  20922. * Specifies if there should be a separate pass for culling
  20923. */
  20924. separateCullingPass: boolean;
  20925. /**
  20926. * Stores the state specifing if fog should be enabled
  20927. */
  20928. private _fogEnabled;
  20929. /**
  20930. * Sets the state for enabling fog
  20931. */
  20932. /**
  20933. * Gets the value of the fog enabled state
  20934. */
  20935. fogEnabled: boolean;
  20936. /**
  20937. * Stores the size of points
  20938. */
  20939. pointSize: number;
  20940. /**
  20941. * Stores the z offset value
  20942. */
  20943. zOffset: number;
  20944. /**
  20945. * Gets a value specifying if wireframe mode is enabled
  20946. */
  20947. /**
  20948. * Sets the state of wireframe mode
  20949. */
  20950. wireframe: boolean;
  20951. /**
  20952. * Gets the value specifying if point clouds are enabled
  20953. */
  20954. /**
  20955. * Sets the state of point cloud mode
  20956. */
  20957. pointsCloud: boolean;
  20958. /**
  20959. * Gets the material fill mode
  20960. */
  20961. /**
  20962. * Sets the material fill mode
  20963. */
  20964. fillMode: number;
  20965. /**
  20966. * @hidden
  20967. * Stores the effects for the material
  20968. */
  20969. _effect: Nullable<Effect>;
  20970. /**
  20971. * @hidden
  20972. * Specifies if the material was previously ready
  20973. */
  20974. _wasPreviouslyReady: boolean;
  20975. /**
  20976. * Specifies if uniform buffers should be used
  20977. */
  20978. private _useUBO;
  20979. /**
  20980. * Stores a reference to the scene
  20981. */
  20982. private _scene;
  20983. /**
  20984. * Stores the fill mode state
  20985. */
  20986. private _fillMode;
  20987. /**
  20988. * Specifies if the depth write state should be cached
  20989. */
  20990. private _cachedDepthWriteState;
  20991. /**
  20992. * Stores the uniform buffer
  20993. */
  20994. protected _uniformBuffer: UniformBuffer;
  20995. /** @hidden */
  20996. _indexInSceneMaterialArray: number;
  20997. /** @hidden */
  20998. meshMap: Nullable<{
  20999. [id: string]: AbstractMesh | undefined;
  21000. }>;
  21001. /**
  21002. * Creates a material instance
  21003. * @param name defines the name of the material
  21004. * @param scene defines the scene to reference
  21005. * @param doNotAdd specifies if the material should be added to the scene
  21006. */
  21007. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21008. /**
  21009. * Returns a string representation of the current material
  21010. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21011. * @returns a string with material information
  21012. */
  21013. toString(fullDetails?: boolean): string;
  21014. /**
  21015. * Gets the class name of the material
  21016. * @returns a string with the class name of the material
  21017. */
  21018. getClassName(): string;
  21019. /**
  21020. * Specifies if updates for the material been locked
  21021. */
  21022. readonly isFrozen: boolean;
  21023. /**
  21024. * Locks updates for the material
  21025. */
  21026. freeze(): void;
  21027. /**
  21028. * Unlocks updates for the material
  21029. */
  21030. unfreeze(): void;
  21031. /**
  21032. * Specifies if the material is ready to be used
  21033. * @param mesh defines the mesh to check
  21034. * @param useInstances specifies if instances should be used
  21035. * @returns a boolean indicating if the material is ready to be used
  21036. */
  21037. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21038. /**
  21039. * Specifies that the submesh is ready to be used
  21040. * @param mesh defines the mesh to check
  21041. * @param subMesh defines which submesh to check
  21042. * @param useInstances specifies that instances should be used
  21043. * @returns a boolean indicating that the submesh is ready or not
  21044. */
  21045. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21046. /**
  21047. * Returns the material effect
  21048. * @returns the effect associated with the material
  21049. */
  21050. getEffect(): Nullable<Effect>;
  21051. /**
  21052. * Returns the current scene
  21053. * @returns a Scene
  21054. */
  21055. getScene(): Scene;
  21056. /**
  21057. * Specifies if the material will require alpha blending
  21058. * @returns a boolean specifying if alpha blending is needed
  21059. */
  21060. needAlphaBlending(): boolean;
  21061. /**
  21062. * Specifies if the mesh will require alpha blending
  21063. * @param mesh defines the mesh to check
  21064. * @returns a boolean specifying if alpha blending is needed for the mesh
  21065. */
  21066. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21067. /**
  21068. * Specifies if this material should be rendered in alpha test mode
  21069. * @returns a boolean specifying if an alpha test is needed.
  21070. */
  21071. needAlphaTesting(): boolean;
  21072. /**
  21073. * Gets the texture used for the alpha test
  21074. * @returns the texture to use for alpha testing
  21075. */
  21076. getAlphaTestTexture(): Nullable<BaseTexture>;
  21077. /**
  21078. * Marks the material to indicate that it needs to be re-calculated
  21079. */
  21080. markDirty(): void;
  21081. /** @hidden */
  21082. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21083. /**
  21084. * Binds the material to the mesh
  21085. * @param world defines the world transformation matrix
  21086. * @param mesh defines the mesh to bind the material to
  21087. */
  21088. bind(world: Matrix, mesh?: Mesh): void;
  21089. /**
  21090. * Binds the submesh to the material
  21091. * @param world defines the world transformation matrix
  21092. * @param mesh defines the mesh containing the submesh
  21093. * @param subMesh defines the submesh to bind the material to
  21094. */
  21095. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21096. /**
  21097. * Binds the world matrix to the material
  21098. * @param world defines the world transformation matrix
  21099. */
  21100. bindOnlyWorldMatrix(world: Matrix): void;
  21101. /**
  21102. * Binds the scene's uniform buffer to the effect.
  21103. * @param effect defines the effect to bind to the scene uniform buffer
  21104. * @param sceneUbo defines the uniform buffer storing scene data
  21105. */
  21106. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21107. /**
  21108. * Binds the view matrix to the effect
  21109. * @param effect defines the effect to bind the view matrix to
  21110. */
  21111. bindView(effect: Effect): void;
  21112. /**
  21113. * Binds the view projection matrix to the effect
  21114. * @param effect defines the effect to bind the view projection matrix to
  21115. */
  21116. bindViewProjection(effect: Effect): void;
  21117. /**
  21118. * Specifies if material alpha testing should be turned on for the mesh
  21119. * @param mesh defines the mesh to check
  21120. */
  21121. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21122. /**
  21123. * Processes to execute after binding the material to a mesh
  21124. * @param mesh defines the rendered mesh
  21125. */
  21126. protected _afterBind(mesh?: Mesh): void;
  21127. /**
  21128. * Unbinds the material from the mesh
  21129. */
  21130. unbind(): void;
  21131. /**
  21132. * Gets the active textures from the material
  21133. * @returns an array of textures
  21134. */
  21135. getActiveTextures(): BaseTexture[];
  21136. /**
  21137. * Specifies if the material uses a texture
  21138. * @param texture defines the texture to check against the material
  21139. * @returns a boolean specifying if the material uses the texture
  21140. */
  21141. hasTexture(texture: BaseTexture): boolean;
  21142. /**
  21143. * Makes a duplicate of the material, and gives it a new name
  21144. * @param name defines the new name for the duplicated material
  21145. * @returns the cloned material
  21146. */
  21147. clone(name: string): Nullable<Material>;
  21148. /**
  21149. * Gets the meshes bound to the material
  21150. * @returns an array of meshes bound to the material
  21151. */
  21152. getBindedMeshes(): AbstractMesh[];
  21153. /**
  21154. * Force shader compilation
  21155. * @param mesh defines the mesh associated with this material
  21156. * @param onCompiled defines a function to execute once the material is compiled
  21157. * @param options defines the options to configure the compilation
  21158. * @param onError defines a function to execute if the material fails compiling
  21159. */
  21160. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21161. clipPlane: boolean;
  21162. }>, onError?: (reason: string) => void): void;
  21163. /**
  21164. * Force shader compilation
  21165. * @param mesh defines the mesh that will use this material
  21166. * @param options defines additional options for compiling the shaders
  21167. * @returns a promise that resolves when the compilation completes
  21168. */
  21169. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21170. clipPlane: boolean;
  21171. }>): Promise<void>;
  21172. private static readonly _AllDirtyCallBack;
  21173. private static readonly _ImageProcessingDirtyCallBack;
  21174. private static readonly _TextureDirtyCallBack;
  21175. private static readonly _FresnelDirtyCallBack;
  21176. private static readonly _MiscDirtyCallBack;
  21177. private static readonly _LightsDirtyCallBack;
  21178. private static readonly _AttributeDirtyCallBack;
  21179. private static _FresnelAndMiscDirtyCallBack;
  21180. private static _TextureAndMiscDirtyCallBack;
  21181. private static readonly _DirtyCallbackArray;
  21182. private static readonly _RunDirtyCallBacks;
  21183. /**
  21184. * Marks a define in the material to indicate that it needs to be re-computed
  21185. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21186. */
  21187. markAsDirty(flag: number): void;
  21188. /**
  21189. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21190. * @param func defines a function which checks material defines against the submeshes
  21191. */
  21192. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21193. /**
  21194. * Indicates that we need to re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsAllDirty(): void;
  21197. /**
  21198. * Indicates that image processing needs to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21201. /**
  21202. * Indicates that textures need to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsTexturesDirty(): void;
  21205. /**
  21206. * Indicates that fresnel needs to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelDirty(): void;
  21209. /**
  21210. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21213. /**
  21214. * Indicates that lights need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsLightsDirty(): void;
  21217. /**
  21218. * Indicates that attributes need to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsAttributesDirty(): void;
  21221. /**
  21222. * Indicates that misc needs to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsMiscDirty(): void;
  21225. /**
  21226. * Indicates that textures and misc need to be re-calculated for all submeshes
  21227. */
  21228. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21229. /**
  21230. * Disposes the material
  21231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21233. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21234. */
  21235. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21236. /** @hidden */
  21237. private releaseVertexArrayObject;
  21238. /**
  21239. * Serializes this material
  21240. * @returns the serialized material object
  21241. */
  21242. serialize(): any;
  21243. /**
  21244. * Creates a material from parsed material data
  21245. * @param parsedMaterial defines parsed material data
  21246. * @param scene defines the hosting scene
  21247. * @param rootUrl defines the root URL to use to load textures
  21248. * @returns a new material
  21249. */
  21250. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21251. }
  21252. }
  21253. declare module "babylonjs/Materials/multiMaterial" {
  21254. import { Nullable } from "babylonjs/types";
  21255. import { Scene } from "babylonjs/scene";
  21256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21257. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21259. import { Material } from "babylonjs/Materials/material";
  21260. /**
  21261. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21262. * separate meshes. This can be use to improve performances.
  21263. * @see http://doc.babylonjs.com/how_to/multi_materials
  21264. */
  21265. export class MultiMaterial extends Material {
  21266. private _subMaterials;
  21267. /**
  21268. * Gets or Sets the list of Materials used within the multi material.
  21269. * They need to be ordered according to the submeshes order in the associated mesh
  21270. */
  21271. subMaterials: Nullable<Material>[];
  21272. /**
  21273. * Function used to align with Node.getChildren()
  21274. * @returns the list of Materials used within the multi material
  21275. */
  21276. getChildren(): Nullable<Material>[];
  21277. /**
  21278. * Instantiates a new Multi Material
  21279. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21280. * separate meshes. This can be use to improve performances.
  21281. * @see http://doc.babylonjs.com/how_to/multi_materials
  21282. * @param name Define the name in the scene
  21283. * @param scene Define the scene the material belongs to
  21284. */
  21285. constructor(name: string, scene: Scene);
  21286. private _hookArray;
  21287. /**
  21288. * Get one of the submaterial by its index in the submaterials array
  21289. * @param index The index to look the sub material at
  21290. * @returns The Material if the index has been defined
  21291. */
  21292. getSubMaterial(index: number): Nullable<Material>;
  21293. /**
  21294. * Get the list of active textures for the whole sub materials list.
  21295. * @returns All the textures that will be used during the rendering
  21296. */
  21297. getActiveTextures(): BaseTexture[];
  21298. /**
  21299. * Gets the current class name of the material e.g. "MultiMaterial"
  21300. * Mainly use in serialization.
  21301. * @returns the class name
  21302. */
  21303. getClassName(): string;
  21304. /**
  21305. * Checks if the material is ready to render the requested sub mesh
  21306. * @param mesh Define the mesh the submesh belongs to
  21307. * @param subMesh Define the sub mesh to look readyness for
  21308. * @param useInstances Define whether or not the material is used with instances
  21309. * @returns true if ready, otherwise false
  21310. */
  21311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21312. /**
  21313. * Clones the current material and its related sub materials
  21314. * @param name Define the name of the newly cloned material
  21315. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21316. * @returns the cloned material
  21317. */
  21318. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21319. /**
  21320. * Serializes the materials into a JSON representation.
  21321. * @returns the JSON representation
  21322. */
  21323. serialize(): any;
  21324. /**
  21325. * Dispose the material and release its associated resources
  21326. * @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)
  21327. * @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)
  21328. * @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)
  21329. */
  21330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21331. /**
  21332. * Creates a MultiMaterial from parsed MultiMaterial data.
  21333. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21334. * @param scene defines the hosting scene
  21335. * @returns a new MultiMaterial
  21336. */
  21337. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21338. }
  21339. }
  21340. declare module "babylonjs/Meshes/subMesh" {
  21341. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21342. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21343. import { Engine } from "babylonjs/Engines/engine";
  21344. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21345. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21346. import { Effect } from "babylonjs/Materials/effect";
  21347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21348. import { Plane } from "babylonjs/Maths/math.plane";
  21349. import { Collider } from "babylonjs/Collisions/collider";
  21350. import { Material } from "babylonjs/Materials/material";
  21351. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21353. import { Mesh } from "babylonjs/Meshes/mesh";
  21354. import { Ray } from "babylonjs/Culling/ray";
  21355. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21356. /**
  21357. * Base class for submeshes
  21358. */
  21359. export class BaseSubMesh {
  21360. /** @hidden */
  21361. _materialDefines: Nullable<MaterialDefines>;
  21362. /** @hidden */
  21363. _materialEffect: Nullable<Effect>;
  21364. /**
  21365. * Gets associated effect
  21366. */
  21367. readonly effect: Nullable<Effect>;
  21368. /**
  21369. * Sets associated effect (effect used to render this submesh)
  21370. * @param effect defines the effect to associate with
  21371. * @param defines defines the set of defines used to compile this effect
  21372. */
  21373. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21374. }
  21375. /**
  21376. * Defines a subdivision inside a mesh
  21377. */
  21378. export class SubMesh extends BaseSubMesh implements ICullable {
  21379. /** the material index to use */
  21380. materialIndex: number;
  21381. /** vertex index start */
  21382. verticesStart: number;
  21383. /** vertices count */
  21384. verticesCount: number;
  21385. /** index start */
  21386. indexStart: number;
  21387. /** indices count */
  21388. indexCount: number;
  21389. /** @hidden */
  21390. _linesIndexCount: number;
  21391. private _mesh;
  21392. private _renderingMesh;
  21393. private _boundingInfo;
  21394. private _linesIndexBuffer;
  21395. /** @hidden */
  21396. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21397. /** @hidden */
  21398. _trianglePlanes: Plane[];
  21399. /** @hidden */
  21400. _lastColliderTransformMatrix: Nullable<Matrix>;
  21401. /** @hidden */
  21402. _renderId: number;
  21403. /** @hidden */
  21404. _alphaIndex: number;
  21405. /** @hidden */
  21406. _distanceToCamera: number;
  21407. /** @hidden */
  21408. _id: number;
  21409. private _currentMaterial;
  21410. /**
  21411. * Add a new submesh to a mesh
  21412. * @param materialIndex defines the material index to use
  21413. * @param verticesStart defines vertex index start
  21414. * @param verticesCount defines vertices count
  21415. * @param indexStart defines index start
  21416. * @param indexCount defines indices count
  21417. * @param mesh defines the parent mesh
  21418. * @param renderingMesh defines an optional rendering mesh
  21419. * @param createBoundingBox defines if bounding box should be created for this submesh
  21420. * @returns the new submesh
  21421. */
  21422. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21423. /**
  21424. * Creates a new submesh
  21425. * @param materialIndex defines the material index to use
  21426. * @param verticesStart defines vertex index start
  21427. * @param verticesCount defines vertices count
  21428. * @param indexStart defines index start
  21429. * @param indexCount defines indices count
  21430. * @param mesh defines the parent mesh
  21431. * @param renderingMesh defines an optional rendering mesh
  21432. * @param createBoundingBox defines if bounding box should be created for this submesh
  21433. */
  21434. constructor(
  21435. /** the material index to use */
  21436. materialIndex: number,
  21437. /** vertex index start */
  21438. verticesStart: number,
  21439. /** vertices count */
  21440. verticesCount: number,
  21441. /** index start */
  21442. indexStart: number,
  21443. /** indices count */
  21444. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21445. /**
  21446. * Returns true if this submesh covers the entire parent mesh
  21447. * @ignorenaming
  21448. */
  21449. readonly IsGlobal: boolean;
  21450. /**
  21451. * Returns the submesh BoudingInfo object
  21452. * @returns current bounding info (or mesh's one if the submesh is global)
  21453. */
  21454. getBoundingInfo(): BoundingInfo;
  21455. /**
  21456. * Sets the submesh BoundingInfo
  21457. * @param boundingInfo defines the new bounding info to use
  21458. * @returns the SubMesh
  21459. */
  21460. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21461. /**
  21462. * Returns the mesh of the current submesh
  21463. * @return the parent mesh
  21464. */
  21465. getMesh(): AbstractMesh;
  21466. /**
  21467. * Returns the rendering mesh of the submesh
  21468. * @returns the rendering mesh (could be different from parent mesh)
  21469. */
  21470. getRenderingMesh(): Mesh;
  21471. /**
  21472. * Returns the submesh material
  21473. * @returns null or the current material
  21474. */
  21475. getMaterial(): Nullable<Material>;
  21476. /**
  21477. * Sets a new updated BoundingInfo object to the submesh
  21478. * @param data defines an optional position array to use to determine the bounding info
  21479. * @returns the SubMesh
  21480. */
  21481. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21482. /** @hidden */
  21483. _checkCollision(collider: Collider): boolean;
  21484. /**
  21485. * Updates the submesh BoundingInfo
  21486. * @param world defines the world matrix to use to update the bounding info
  21487. * @returns the submesh
  21488. */
  21489. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21490. /**
  21491. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21492. * @param frustumPlanes defines the frustum planes
  21493. * @returns true if the submesh is intersecting with the frustum
  21494. */
  21495. isInFrustum(frustumPlanes: Plane[]): boolean;
  21496. /**
  21497. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21498. * @param frustumPlanes defines the frustum planes
  21499. * @returns true if the submesh is inside the frustum
  21500. */
  21501. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21502. /**
  21503. * Renders the submesh
  21504. * @param enableAlphaMode defines if alpha needs to be used
  21505. * @returns the submesh
  21506. */
  21507. render(enableAlphaMode: boolean): SubMesh;
  21508. /**
  21509. * @hidden
  21510. */
  21511. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21512. /**
  21513. * Checks if the submesh intersects with a ray
  21514. * @param ray defines the ray to test
  21515. * @returns true is the passed ray intersects the submesh bounding box
  21516. */
  21517. canIntersects(ray: Ray): boolean;
  21518. /**
  21519. * Intersects current submesh with a ray
  21520. * @param ray defines the ray to test
  21521. * @param positions defines mesh's positions array
  21522. * @param indices defines mesh's indices array
  21523. * @param fastCheck defines if only bounding info should be used
  21524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21525. * @returns intersection info or null if no intersection
  21526. */
  21527. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21528. /** @hidden */
  21529. private _intersectLines;
  21530. /** @hidden */
  21531. private _intersectUnIndexedLines;
  21532. /** @hidden */
  21533. private _intersectTriangles;
  21534. /** @hidden */
  21535. private _intersectUnIndexedTriangles;
  21536. /** @hidden */
  21537. _rebuild(): void;
  21538. /**
  21539. * Creates a new submesh from the passed mesh
  21540. * @param newMesh defines the new hosting mesh
  21541. * @param newRenderingMesh defines an optional rendering mesh
  21542. * @returns the new submesh
  21543. */
  21544. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21545. /**
  21546. * Release associated resources
  21547. */
  21548. dispose(): void;
  21549. /**
  21550. * Gets the class name
  21551. * @returns the string "SubMesh".
  21552. */
  21553. getClassName(): string;
  21554. /**
  21555. * Creates a new submesh from indices data
  21556. * @param materialIndex the index of the main mesh material
  21557. * @param startIndex the index where to start the copy in the mesh indices array
  21558. * @param indexCount the number of indices to copy then from the startIndex
  21559. * @param mesh the main mesh to create the submesh from
  21560. * @param renderingMesh the optional rendering mesh
  21561. * @returns a new submesh
  21562. */
  21563. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21564. }
  21565. }
  21566. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21567. /**
  21568. * Class used to represent data loading progression
  21569. */
  21570. export class SceneLoaderFlags {
  21571. private static _ForceFullSceneLoadingForIncremental;
  21572. private static _ShowLoadingScreen;
  21573. private static _CleanBoneMatrixWeights;
  21574. private static _loggingLevel;
  21575. /**
  21576. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21577. */
  21578. static ForceFullSceneLoadingForIncremental: boolean;
  21579. /**
  21580. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21581. */
  21582. static ShowLoadingScreen: boolean;
  21583. /**
  21584. * Defines the current logging level (while loading the scene)
  21585. * @ignorenaming
  21586. */
  21587. static loggingLevel: number;
  21588. /**
  21589. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21590. */
  21591. static CleanBoneMatrixWeights: boolean;
  21592. }
  21593. }
  21594. declare module "babylonjs/Meshes/geometry" {
  21595. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21596. import { Scene } from "babylonjs/scene";
  21597. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21598. import { Engine } from "babylonjs/Engines/engine";
  21599. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21600. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21601. import { Effect } from "babylonjs/Materials/effect";
  21602. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21603. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21604. import { Mesh } from "babylonjs/Meshes/mesh";
  21605. /**
  21606. * Class used to store geometry data (vertex buffers + index buffer)
  21607. */
  21608. export class Geometry implements IGetSetVerticesData {
  21609. /**
  21610. * Gets or sets the ID of the geometry
  21611. */
  21612. id: string;
  21613. /**
  21614. * Gets or sets the unique ID of the geometry
  21615. */
  21616. uniqueId: number;
  21617. /**
  21618. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21619. */
  21620. delayLoadState: number;
  21621. /**
  21622. * Gets the file containing the data to load when running in delay load state
  21623. */
  21624. delayLoadingFile: Nullable<string>;
  21625. /**
  21626. * Callback called when the geometry is updated
  21627. */
  21628. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21629. private _scene;
  21630. private _engine;
  21631. private _meshes;
  21632. private _totalVertices;
  21633. /** @hidden */
  21634. _indices: IndicesArray;
  21635. /** @hidden */
  21636. _vertexBuffers: {
  21637. [key: string]: VertexBuffer;
  21638. };
  21639. private _isDisposed;
  21640. private _extend;
  21641. private _boundingBias;
  21642. /** @hidden */
  21643. _delayInfo: Array<string>;
  21644. private _indexBuffer;
  21645. private _indexBufferIsUpdatable;
  21646. /** @hidden */
  21647. _boundingInfo: Nullable<BoundingInfo>;
  21648. /** @hidden */
  21649. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21650. /** @hidden */
  21651. _softwareSkinningFrameId: number;
  21652. private _vertexArrayObjects;
  21653. private _updatable;
  21654. /** @hidden */
  21655. _positions: Nullable<Vector3[]>;
  21656. /**
  21657. * 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
  21658. */
  21659. /**
  21660. * 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
  21661. */
  21662. boundingBias: Vector2;
  21663. /**
  21664. * Static function used to attach a new empty geometry to a mesh
  21665. * @param mesh defines the mesh to attach the geometry to
  21666. * @returns the new Geometry
  21667. */
  21668. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21669. /**
  21670. * Creates a new geometry
  21671. * @param id defines the unique ID
  21672. * @param scene defines the hosting scene
  21673. * @param vertexData defines the VertexData used to get geometry data
  21674. * @param updatable defines if geometry must be updatable (false by default)
  21675. * @param mesh defines the mesh that will be associated with the geometry
  21676. */
  21677. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21678. /**
  21679. * Gets the current extend of the geometry
  21680. */
  21681. readonly extend: {
  21682. minimum: Vector3;
  21683. maximum: Vector3;
  21684. };
  21685. /**
  21686. * Gets the hosting scene
  21687. * @returns the hosting Scene
  21688. */
  21689. getScene(): Scene;
  21690. /**
  21691. * Gets the hosting engine
  21692. * @returns the hosting Engine
  21693. */
  21694. getEngine(): Engine;
  21695. /**
  21696. * Defines if the geometry is ready to use
  21697. * @returns true if the geometry is ready to be used
  21698. */
  21699. isReady(): boolean;
  21700. /**
  21701. * Gets a value indicating that the geometry should not be serialized
  21702. */
  21703. readonly doNotSerialize: boolean;
  21704. /** @hidden */
  21705. _rebuild(): void;
  21706. /**
  21707. * Affects all geometry data in one call
  21708. * @param vertexData defines the geometry data
  21709. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21710. */
  21711. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21712. /**
  21713. * Set specific vertex data
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @param data defines the vertex data to use
  21716. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21717. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21718. */
  21719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21720. /**
  21721. * Removes a specific vertex data
  21722. * @param kind defines the data kind (Position, normal, etc...)
  21723. */
  21724. removeVerticesData(kind: string): void;
  21725. /**
  21726. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21727. * @param buffer defines the vertex buffer to use
  21728. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21729. */
  21730. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21731. /**
  21732. * Update a specific vertex buffer
  21733. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21734. * It will do nothing if the buffer is not updatable
  21735. * @param kind defines the data kind (Position, normal, etc...)
  21736. * @param data defines the data to use
  21737. * @param offset defines the offset in the target buffer where to store the data
  21738. * @param useBytes set to true if the offset is in bytes
  21739. */
  21740. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21741. /**
  21742. * Update a specific vertex buffer
  21743. * This function will create a new buffer if the current one is not updatable
  21744. * @param kind defines the data kind (Position, normal, etc...)
  21745. * @param data defines the data to use
  21746. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21747. */
  21748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21749. private _updateBoundingInfo;
  21750. /** @hidden */
  21751. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21752. /**
  21753. * Gets total number of vertices
  21754. * @returns the total number of vertices
  21755. */
  21756. getTotalVertices(): number;
  21757. /**
  21758. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21759. * @param kind defines the data kind (Position, normal, etc...)
  21760. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21762. * @returns a float array containing vertex data
  21763. */
  21764. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21765. /**
  21766. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21767. * @param kind defines the data kind (Position, normal, etc...)
  21768. * @returns true if the vertex buffer with the specified kind is updatable
  21769. */
  21770. isVertexBufferUpdatable(kind: string): boolean;
  21771. /**
  21772. * Gets a specific vertex buffer
  21773. * @param kind defines the data kind (Position, normal, etc...)
  21774. * @returns a VertexBuffer
  21775. */
  21776. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21777. /**
  21778. * Returns all vertex buffers
  21779. * @return an object holding all vertex buffers indexed by kind
  21780. */
  21781. getVertexBuffers(): Nullable<{
  21782. [key: string]: VertexBuffer;
  21783. }>;
  21784. /**
  21785. * Gets a boolean indicating if specific vertex buffer is present
  21786. * @param kind defines the data kind (Position, normal, etc...)
  21787. * @returns true if data is present
  21788. */
  21789. isVerticesDataPresent(kind: string): boolean;
  21790. /**
  21791. * Gets a list of all attached data kinds (Position, normal, etc...)
  21792. * @returns a list of string containing all kinds
  21793. */
  21794. getVerticesDataKinds(): string[];
  21795. /**
  21796. * Update index buffer
  21797. * @param indices defines the indices to store in the index buffer
  21798. * @param offset defines the offset in the target buffer where to store the data
  21799. * @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)
  21800. */
  21801. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21802. /**
  21803. * Creates a new index buffer
  21804. * @param indices defines the indices to store in the index buffer
  21805. * @param totalVertices defines the total number of vertices (could be null)
  21806. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21807. */
  21808. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21809. /**
  21810. * Return the total number of indices
  21811. * @returns the total number of indices
  21812. */
  21813. getTotalIndices(): number;
  21814. /**
  21815. * Gets the index buffer array
  21816. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21817. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21818. * @returns the index buffer array
  21819. */
  21820. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21821. /**
  21822. * Gets the index buffer
  21823. * @return the index buffer
  21824. */
  21825. getIndexBuffer(): Nullable<DataBuffer>;
  21826. /** @hidden */
  21827. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21828. /**
  21829. * Release the associated resources for a specific mesh
  21830. * @param mesh defines the source mesh
  21831. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21832. */
  21833. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21834. /**
  21835. * Apply current geometry to a given mesh
  21836. * @param mesh defines the mesh to apply geometry to
  21837. */
  21838. applyToMesh(mesh: Mesh): void;
  21839. private _updateExtend;
  21840. private _applyToMesh;
  21841. private notifyUpdate;
  21842. /**
  21843. * Load the geometry if it was flagged as delay loaded
  21844. * @param scene defines the hosting scene
  21845. * @param onLoaded defines a callback called when the geometry is loaded
  21846. */
  21847. load(scene: Scene, onLoaded?: () => void): void;
  21848. private _queueLoad;
  21849. /**
  21850. * Invert the geometry to move from a right handed system to a left handed one.
  21851. */
  21852. toLeftHanded(): void;
  21853. /** @hidden */
  21854. _resetPointsArrayCache(): void;
  21855. /** @hidden */
  21856. _generatePointsArray(): boolean;
  21857. /**
  21858. * Gets a value indicating if the geometry is disposed
  21859. * @returns true if the geometry was disposed
  21860. */
  21861. isDisposed(): boolean;
  21862. private _disposeVertexArrayObjects;
  21863. /**
  21864. * Free all associated resources
  21865. */
  21866. dispose(): void;
  21867. /**
  21868. * Clone the current geometry into a new geometry
  21869. * @param id defines the unique ID of the new geometry
  21870. * @returns a new geometry object
  21871. */
  21872. copy(id: string): Geometry;
  21873. /**
  21874. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21875. * @return a JSON representation of the current geometry data (without the vertices data)
  21876. */
  21877. serialize(): any;
  21878. private toNumberArray;
  21879. /**
  21880. * Serialize all vertices data into a JSON oject
  21881. * @returns a JSON representation of the current geometry data
  21882. */
  21883. serializeVerticeData(): any;
  21884. /**
  21885. * Extracts a clone of a mesh geometry
  21886. * @param mesh defines the source mesh
  21887. * @param id defines the unique ID of the new geometry object
  21888. * @returns the new geometry object
  21889. */
  21890. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21891. /**
  21892. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21893. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21894. * Be aware Math.random() could cause collisions, but:
  21895. * "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"
  21896. * @returns a string containing a new GUID
  21897. */
  21898. static RandomId(): string;
  21899. /** @hidden */
  21900. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21901. private static _CleanMatricesWeights;
  21902. /**
  21903. * Create a new geometry from persisted data (Using .babylon file format)
  21904. * @param parsedVertexData defines the persisted data
  21905. * @param scene defines the hosting scene
  21906. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21907. * @returns the new geometry object
  21908. */
  21909. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21910. }
  21911. }
  21912. declare module "babylonjs/Meshes/mesh.vertexData" {
  21913. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21914. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21915. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21916. import { Geometry } from "babylonjs/Meshes/geometry";
  21917. import { Mesh } from "babylonjs/Meshes/mesh";
  21918. /**
  21919. * Define an interface for all classes that will get and set the data on vertices
  21920. */
  21921. export interface IGetSetVerticesData {
  21922. /**
  21923. * Gets a boolean indicating if specific vertex data is present
  21924. * @param kind defines the vertex data kind to use
  21925. * @returns true is data kind is present
  21926. */
  21927. isVerticesDataPresent(kind: string): boolean;
  21928. /**
  21929. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21930. * @param kind defines the data kind (Position, normal, etc...)
  21931. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21933. * @returns a float array containing vertex data
  21934. */
  21935. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21936. /**
  21937. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21938. * @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.
  21939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21940. * @returns the indices array or an empty array if the mesh has no geometry
  21941. */
  21942. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21943. /**
  21944. * Set specific vertex data
  21945. * @param kind defines the data kind (Position, normal, etc...)
  21946. * @param data defines the vertex data to use
  21947. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21948. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21949. */
  21950. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21951. /**
  21952. * Update a specific associated vertex buffer
  21953. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21954. * - VertexBuffer.PositionKind
  21955. * - VertexBuffer.UVKind
  21956. * - VertexBuffer.UV2Kind
  21957. * - VertexBuffer.UV3Kind
  21958. * - VertexBuffer.UV4Kind
  21959. * - VertexBuffer.UV5Kind
  21960. * - VertexBuffer.UV6Kind
  21961. * - VertexBuffer.ColorKind
  21962. * - VertexBuffer.MatricesIndicesKind
  21963. * - VertexBuffer.MatricesIndicesExtraKind
  21964. * - VertexBuffer.MatricesWeightsKind
  21965. * - VertexBuffer.MatricesWeightsExtraKind
  21966. * @param data defines the data source
  21967. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21968. * @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)
  21969. */
  21970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21971. /**
  21972. * Creates a new index buffer
  21973. * @param indices defines the indices to store in the index buffer
  21974. * @param totalVertices defines the total number of vertices (could be null)
  21975. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21976. */
  21977. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21978. }
  21979. /**
  21980. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21981. */
  21982. export class VertexData {
  21983. /**
  21984. * Mesh side orientation : usually the external or front surface
  21985. */
  21986. static readonly FRONTSIDE: number;
  21987. /**
  21988. * Mesh side orientation : usually the internal or back surface
  21989. */
  21990. static readonly BACKSIDE: number;
  21991. /**
  21992. * Mesh side orientation : both internal and external or front and back surfaces
  21993. */
  21994. static readonly DOUBLESIDE: number;
  21995. /**
  21996. * Mesh side orientation : by default, `FRONTSIDE`
  21997. */
  21998. static readonly DEFAULTSIDE: number;
  21999. /**
  22000. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22001. */
  22002. positions: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22005. */
  22006. normals: Nullable<FloatArray>;
  22007. /**
  22008. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22009. */
  22010. tangents: Nullable<FloatArray>;
  22011. /**
  22012. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs: Nullable<FloatArray>;
  22015. /**
  22016. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22017. */
  22018. uvs2: Nullable<FloatArray>;
  22019. /**
  22020. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22021. */
  22022. uvs3: Nullable<FloatArray>;
  22023. /**
  22024. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22025. */
  22026. uvs4: Nullable<FloatArray>;
  22027. /**
  22028. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22029. */
  22030. uvs5: Nullable<FloatArray>;
  22031. /**
  22032. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22033. */
  22034. uvs6: Nullable<FloatArray>;
  22035. /**
  22036. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22037. */
  22038. colors: Nullable<FloatArray>;
  22039. /**
  22040. * 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).
  22041. */
  22042. matricesIndices: Nullable<FloatArray>;
  22043. /**
  22044. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22045. */
  22046. matricesWeights: Nullable<FloatArray>;
  22047. /**
  22048. * An array extending the number of possible indices
  22049. */
  22050. matricesIndicesExtra: Nullable<FloatArray>;
  22051. /**
  22052. * An array extending the number of possible weights when the number of indices is extended
  22053. */
  22054. matricesWeightsExtra: Nullable<FloatArray>;
  22055. /**
  22056. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22057. */
  22058. indices: Nullable<IndicesArray>;
  22059. /**
  22060. * Uses the passed data array to set the set the values for the specified kind of data
  22061. * @param data a linear array of floating numbers
  22062. * @param kind the type of data that is being set, eg positions, colors etc
  22063. */
  22064. set(data: FloatArray, kind: string): void;
  22065. /**
  22066. * Associates the vertexData to the passed Mesh.
  22067. * Sets it as updatable or not (default `false`)
  22068. * @param mesh the mesh the vertexData is applied to
  22069. * @param updatable when used and having the value true allows new data to update the vertexData
  22070. * @returns the VertexData
  22071. */
  22072. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22073. /**
  22074. * Associates the vertexData to the passed Geometry.
  22075. * Sets it as updatable or not (default `false`)
  22076. * @param geometry the geometry the vertexData is applied to
  22077. * @param updatable when used and having the value true allows new data to update the vertexData
  22078. * @returns VertexData
  22079. */
  22080. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22081. /**
  22082. * Updates the associated mesh
  22083. * @param mesh the mesh to be updated
  22084. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22085. * @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
  22086. * @returns VertexData
  22087. */
  22088. updateMesh(mesh: Mesh): VertexData;
  22089. /**
  22090. * Updates the associated geometry
  22091. * @param geometry the geometry to be updated
  22092. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22093. * @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
  22094. * @returns VertexData.
  22095. */
  22096. updateGeometry(geometry: Geometry): VertexData;
  22097. private _applyTo;
  22098. private _update;
  22099. /**
  22100. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22101. * @param matrix the transforming matrix
  22102. * @returns the VertexData
  22103. */
  22104. transform(matrix: Matrix): VertexData;
  22105. /**
  22106. * Merges the passed VertexData into the current one
  22107. * @param other the VertexData to be merged into the current one
  22108. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22109. * @returns the modified VertexData
  22110. */
  22111. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22112. private _mergeElement;
  22113. private _validate;
  22114. /**
  22115. * Serializes the VertexData
  22116. * @returns a serialized object
  22117. */
  22118. serialize(): any;
  22119. /**
  22120. * Extracts the vertexData from a mesh
  22121. * @param mesh the mesh from which to extract the VertexData
  22122. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22123. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22124. * @returns the object VertexData associated to the passed mesh
  22125. */
  22126. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22127. /**
  22128. * Extracts the vertexData from the geometry
  22129. * @param geometry the geometry from which to extract the VertexData
  22130. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22131. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22132. * @returns the object VertexData associated to the passed mesh
  22133. */
  22134. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22135. private static _ExtractFrom;
  22136. /**
  22137. * Creates the VertexData for a Ribbon
  22138. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22139. * * pathArray array of paths, each of which an array of successive Vector3
  22140. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22141. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22142. * * 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
  22143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22144. * * 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)
  22145. * * 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)
  22146. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22147. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22148. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22149. * @returns the VertexData of the ribbon
  22150. */
  22151. static CreateRibbon(options: {
  22152. pathArray: Vector3[][];
  22153. closeArray?: boolean;
  22154. closePath?: boolean;
  22155. offset?: number;
  22156. sideOrientation?: number;
  22157. frontUVs?: Vector4;
  22158. backUVs?: Vector4;
  22159. invertUV?: boolean;
  22160. uvs?: Vector2[];
  22161. colors?: Color4[];
  22162. }): VertexData;
  22163. /**
  22164. * Creates the VertexData for a box
  22165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22166. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22167. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22168. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22169. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22170. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22171. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22173. * * 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)
  22174. * * 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)
  22175. * @returns the VertexData of the box
  22176. */
  22177. static CreateBox(options: {
  22178. size?: number;
  22179. width?: number;
  22180. height?: number;
  22181. depth?: number;
  22182. faceUV?: Vector4[];
  22183. faceColors?: Color4[];
  22184. sideOrientation?: number;
  22185. frontUVs?: Vector4;
  22186. backUVs?: Vector4;
  22187. }): VertexData;
  22188. /**
  22189. * Creates the VertexData for a tiled box
  22190. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22191. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22192. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22193. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22195. * @returns the VertexData of the box
  22196. */
  22197. static CreateTiledBox(options: {
  22198. pattern?: number;
  22199. width?: number;
  22200. height?: number;
  22201. depth?: number;
  22202. tileSize?: number;
  22203. tileWidth?: number;
  22204. tileHeight?: number;
  22205. alignHorizontal?: number;
  22206. alignVertical?: number;
  22207. faceUV?: Vector4[];
  22208. faceColors?: Color4[];
  22209. sideOrientation?: number;
  22210. }): VertexData;
  22211. /**
  22212. * Creates the VertexData for a tiled plane
  22213. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22214. * * pattern a limited pattern arrangement depending on the number
  22215. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22216. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22217. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22219. * * 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)
  22220. * * 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)
  22221. * @returns the VertexData of the tiled plane
  22222. */
  22223. static CreateTiledPlane(options: {
  22224. pattern?: number;
  22225. tileSize?: number;
  22226. tileWidth?: number;
  22227. tileHeight?: number;
  22228. size?: number;
  22229. width?: number;
  22230. height?: number;
  22231. alignHorizontal?: number;
  22232. alignVertical?: number;
  22233. sideOrientation?: number;
  22234. frontUVs?: Vector4;
  22235. backUVs?: Vector4;
  22236. }): VertexData;
  22237. /**
  22238. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22240. * * segments sets the number of horizontal strips optional, default 32
  22241. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22242. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22243. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22244. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22245. * * 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
  22246. * * 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
  22247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22248. * * 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)
  22249. * * 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)
  22250. * @returns the VertexData of the ellipsoid
  22251. */
  22252. static CreateSphere(options: {
  22253. segments?: number;
  22254. diameter?: number;
  22255. diameterX?: number;
  22256. diameterY?: number;
  22257. diameterZ?: number;
  22258. arc?: number;
  22259. slice?: number;
  22260. sideOrientation?: number;
  22261. frontUVs?: Vector4;
  22262. backUVs?: Vector4;
  22263. }): VertexData;
  22264. /**
  22265. * Creates the VertexData for a cylinder, cone or prism
  22266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22267. * * height sets the height (y direction) of the cylinder, optional, default 2
  22268. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22269. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22270. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22272. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22273. * * 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
  22274. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22275. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22276. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22277. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22279. * * 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)
  22280. * * 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)
  22281. * @returns the VertexData of the cylinder, cone or prism
  22282. */
  22283. static CreateCylinder(options: {
  22284. height?: number;
  22285. diameterTop?: number;
  22286. diameterBottom?: number;
  22287. diameter?: number;
  22288. tessellation?: number;
  22289. subdivisions?: number;
  22290. arc?: number;
  22291. faceColors?: Color4[];
  22292. faceUV?: Vector4[];
  22293. hasRings?: boolean;
  22294. enclose?: boolean;
  22295. sideOrientation?: number;
  22296. frontUVs?: Vector4;
  22297. backUVs?: Vector4;
  22298. }): VertexData;
  22299. /**
  22300. * Creates the VertexData for a torus
  22301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22302. * * diameter the diameter of the torus, optional default 1
  22303. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22304. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22306. * * 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)
  22307. * * 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)
  22308. * @returns the VertexData of the torus
  22309. */
  22310. static CreateTorus(options: {
  22311. diameter?: number;
  22312. thickness?: number;
  22313. tessellation?: number;
  22314. sideOrientation?: number;
  22315. frontUVs?: Vector4;
  22316. backUVs?: Vector4;
  22317. }): VertexData;
  22318. /**
  22319. * Creates the VertexData of the LineSystem
  22320. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22321. * - lines an array of lines, each line being an array of successive Vector3
  22322. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22323. * @returns the VertexData of the LineSystem
  22324. */
  22325. static CreateLineSystem(options: {
  22326. lines: Vector3[][];
  22327. colors?: Nullable<Color4[][]>;
  22328. }): VertexData;
  22329. /**
  22330. * Create the VertexData for a DashedLines
  22331. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22332. * - points an array successive Vector3
  22333. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22334. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22335. * - dashNb the intended total number of dashes, optional, default 200
  22336. * @returns the VertexData for the DashedLines
  22337. */
  22338. static CreateDashedLines(options: {
  22339. points: Vector3[];
  22340. dashSize?: number;
  22341. gapSize?: number;
  22342. dashNb?: number;
  22343. }): VertexData;
  22344. /**
  22345. * Creates the VertexData for a Ground
  22346. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22347. * - width the width (x direction) of the ground, optional, default 1
  22348. * - height the height (z direction) of the ground, optional, default 1
  22349. * - subdivisions the number of subdivisions per side, optional, default 1
  22350. * @returns the VertexData of the Ground
  22351. */
  22352. static CreateGround(options: {
  22353. width?: number;
  22354. height?: number;
  22355. subdivisions?: number;
  22356. subdivisionsX?: number;
  22357. subdivisionsY?: number;
  22358. }): VertexData;
  22359. /**
  22360. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22361. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22362. * * xmin the ground minimum X coordinate, optional, default -1
  22363. * * zmin the ground minimum Z coordinate, optional, default -1
  22364. * * xmax the ground maximum X coordinate, optional, default 1
  22365. * * zmax the ground maximum Z coordinate, optional, default 1
  22366. * * 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}
  22367. * * 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}
  22368. * @returns the VertexData of the TiledGround
  22369. */
  22370. static CreateTiledGround(options: {
  22371. xmin: number;
  22372. zmin: number;
  22373. xmax: number;
  22374. zmax: number;
  22375. subdivisions?: {
  22376. w: number;
  22377. h: number;
  22378. };
  22379. precision?: {
  22380. w: number;
  22381. h: number;
  22382. };
  22383. }): VertexData;
  22384. /**
  22385. * Creates the VertexData of the Ground designed from a heightmap
  22386. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22387. * * width the width (x direction) of the ground
  22388. * * height the height (z direction) of the ground
  22389. * * subdivisions the number of subdivisions per side
  22390. * * minHeight the minimum altitude on the ground, optional, default 0
  22391. * * maxHeight the maximum altitude on the ground, optional default 1
  22392. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22393. * * buffer the array holding the image color data
  22394. * * bufferWidth the width of image
  22395. * * bufferHeight the height of image
  22396. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22397. * @returns the VertexData of the Ground designed from a heightmap
  22398. */
  22399. static CreateGroundFromHeightMap(options: {
  22400. width: number;
  22401. height: number;
  22402. subdivisions: number;
  22403. minHeight: number;
  22404. maxHeight: number;
  22405. colorFilter: Color3;
  22406. buffer: Uint8Array;
  22407. bufferWidth: number;
  22408. bufferHeight: number;
  22409. alphaFilter: number;
  22410. }): VertexData;
  22411. /**
  22412. * Creates the VertexData for a Plane
  22413. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22414. * * size sets the width and height of the plane to the value of size, optional default 1
  22415. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22416. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22418. * * 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)
  22419. * * 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)
  22420. * @returns the VertexData of the box
  22421. */
  22422. static CreatePlane(options: {
  22423. size?: number;
  22424. width?: number;
  22425. height?: number;
  22426. sideOrientation?: number;
  22427. frontUVs?: Vector4;
  22428. backUVs?: Vector4;
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData of the Disc or regular Polygon
  22432. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22433. * * radius the radius of the disc, optional default 0.5
  22434. * * tessellation the number of polygon sides, optional, default 64
  22435. * * 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
  22436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22437. * * 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)
  22438. * * 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)
  22439. * @returns the VertexData of the box
  22440. */
  22441. static CreateDisc(options: {
  22442. radius?: number;
  22443. tessellation?: number;
  22444. arc?: number;
  22445. sideOrientation?: number;
  22446. frontUVs?: Vector4;
  22447. backUVs?: Vector4;
  22448. }): VertexData;
  22449. /**
  22450. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22451. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22452. * @param polygon a mesh built from polygonTriangulation.build()
  22453. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22454. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22455. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22456. * @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)
  22457. * @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)
  22458. * @returns the VertexData of the Polygon
  22459. */
  22460. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22461. /**
  22462. * Creates the VertexData of the IcoSphere
  22463. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22464. * * radius the radius of the IcoSphere, optional default 1
  22465. * * radiusX allows stretching in the x direction, optional, default radius
  22466. * * radiusY allows stretching in the y direction, optional, default radius
  22467. * * radiusZ allows stretching in the z direction, optional, default radius
  22468. * * flat when true creates a flat shaded mesh, optional, default true
  22469. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22471. * * 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)
  22472. * * 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)
  22473. * @returns the VertexData of the IcoSphere
  22474. */
  22475. static CreateIcoSphere(options: {
  22476. radius?: number;
  22477. radiusX?: number;
  22478. radiusY?: number;
  22479. radiusZ?: number;
  22480. flat?: boolean;
  22481. subdivisions?: number;
  22482. sideOrientation?: number;
  22483. frontUVs?: Vector4;
  22484. backUVs?: Vector4;
  22485. }): VertexData;
  22486. /**
  22487. * Creates the VertexData for a Polyhedron
  22488. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22489. * * type provided types are:
  22490. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22491. * * 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)
  22492. * * size the size of the IcoSphere, optional default 1
  22493. * * sizeX allows stretching in the x direction, optional, default size
  22494. * * sizeY allows stretching in the y direction, optional, default size
  22495. * * sizeZ allows stretching in the z direction, optional, default size
  22496. * * 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
  22497. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22498. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22499. * * flat when true creates a flat shaded mesh, optional, default true
  22500. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22502. * * 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)
  22503. * * 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)
  22504. * @returns the VertexData of the Polyhedron
  22505. */
  22506. static CreatePolyhedron(options: {
  22507. type?: number;
  22508. size?: number;
  22509. sizeX?: number;
  22510. sizeY?: number;
  22511. sizeZ?: number;
  22512. custom?: any;
  22513. faceUV?: Vector4[];
  22514. faceColors?: Color4[];
  22515. flat?: boolean;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for a TorusKnot
  22522. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22523. * * radius the radius of the torus knot, optional, default 2
  22524. * * tube the thickness of the tube, optional, default 0.5
  22525. * * radialSegments the number of sides on each tube segments, optional, default 32
  22526. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22527. * * p the number of windings around the z axis, optional, default 2
  22528. * * q the number of windings around the x axis, optional, default 3
  22529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * * 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)
  22531. * * 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)
  22532. * @returns the VertexData of the Torus Knot
  22533. */
  22534. static CreateTorusKnot(options: {
  22535. radius?: number;
  22536. tube?: number;
  22537. radialSegments?: number;
  22538. tubularSegments?: number;
  22539. p?: number;
  22540. q?: number;
  22541. sideOrientation?: number;
  22542. frontUVs?: Vector4;
  22543. backUVs?: Vector4;
  22544. }): VertexData;
  22545. /**
  22546. * Compute normals for given positions and indices
  22547. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22548. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22549. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22550. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22551. * * facetNormals : optional array of facet normals (vector3)
  22552. * * facetPositions : optional array of facet positions (vector3)
  22553. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22554. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22555. * * bInfo : optional bounding info, required for facetPartitioning computation
  22556. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22557. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22558. * * useRightHandedSystem: optional boolean to for right handed system computation
  22559. * * depthSort : optional boolean to enable the facet depth sort computation
  22560. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22561. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22562. */
  22563. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22564. facetNormals?: any;
  22565. facetPositions?: any;
  22566. facetPartitioning?: any;
  22567. ratio?: number;
  22568. bInfo?: any;
  22569. bbSize?: Vector3;
  22570. subDiv?: any;
  22571. useRightHandedSystem?: boolean;
  22572. depthSort?: boolean;
  22573. distanceTo?: Vector3;
  22574. depthSortedFacets?: any;
  22575. }): void;
  22576. /** @hidden */
  22577. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22578. /**
  22579. * Applies VertexData created from the imported parameters to the geometry
  22580. * @param parsedVertexData the parsed data from an imported file
  22581. * @param geometry the geometry to apply the VertexData to
  22582. */
  22583. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22584. }
  22585. }
  22586. declare module "babylonjs/Morph/morphTarget" {
  22587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22588. import { Observable } from "babylonjs/Misc/observable";
  22589. import { Nullable, FloatArray } from "babylonjs/types";
  22590. import { Scene } from "babylonjs/scene";
  22591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22592. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22593. /**
  22594. * Defines a target to use with MorphTargetManager
  22595. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22596. */
  22597. export class MorphTarget implements IAnimatable {
  22598. /** defines the name of the target */
  22599. name: string;
  22600. /**
  22601. * Gets or sets the list of animations
  22602. */
  22603. animations: import("babylonjs/Animations/animation").Animation[];
  22604. private _scene;
  22605. private _positions;
  22606. private _normals;
  22607. private _tangents;
  22608. private _uvs;
  22609. private _influence;
  22610. /**
  22611. * Observable raised when the influence changes
  22612. */
  22613. onInfluenceChanged: Observable<boolean>;
  22614. /** @hidden */
  22615. _onDataLayoutChanged: Observable<void>;
  22616. /**
  22617. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22618. */
  22619. influence: number;
  22620. /**
  22621. * Gets or sets the id of the morph Target
  22622. */
  22623. id: string;
  22624. private _animationPropertiesOverride;
  22625. /**
  22626. * Gets or sets the animation properties override
  22627. */
  22628. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22629. /**
  22630. * Creates a new MorphTarget
  22631. * @param name defines the name of the target
  22632. * @param influence defines the influence to use
  22633. * @param scene defines the scene the morphtarget belongs to
  22634. */
  22635. constructor(
  22636. /** defines the name of the target */
  22637. name: string, influence?: number, scene?: Nullable<Scene>);
  22638. /**
  22639. * Gets a boolean defining if the target contains position data
  22640. */
  22641. readonly hasPositions: boolean;
  22642. /**
  22643. * Gets a boolean defining if the target contains normal data
  22644. */
  22645. readonly hasNormals: boolean;
  22646. /**
  22647. * Gets a boolean defining if the target contains tangent data
  22648. */
  22649. readonly hasTangents: boolean;
  22650. /**
  22651. * Gets a boolean defining if the target contains texture coordinates data
  22652. */
  22653. readonly hasUVs: boolean;
  22654. /**
  22655. * Affects position data to this target
  22656. * @param data defines the position data to use
  22657. */
  22658. setPositions(data: Nullable<FloatArray>): void;
  22659. /**
  22660. * Gets the position data stored in this target
  22661. * @returns a FloatArray containing the position data (or null if not present)
  22662. */
  22663. getPositions(): Nullable<FloatArray>;
  22664. /**
  22665. * Affects normal data to this target
  22666. * @param data defines the normal data to use
  22667. */
  22668. setNormals(data: Nullable<FloatArray>): void;
  22669. /**
  22670. * Gets the normal data stored in this target
  22671. * @returns a FloatArray containing the normal data (or null if not present)
  22672. */
  22673. getNormals(): Nullable<FloatArray>;
  22674. /**
  22675. * Affects tangent data to this target
  22676. * @param data defines the tangent data to use
  22677. */
  22678. setTangents(data: Nullable<FloatArray>): void;
  22679. /**
  22680. * Gets the tangent data stored in this target
  22681. * @returns a FloatArray containing the tangent data (or null if not present)
  22682. */
  22683. getTangents(): Nullable<FloatArray>;
  22684. /**
  22685. * Affects texture coordinates data to this target
  22686. * @param data defines the texture coordinates data to use
  22687. */
  22688. setUVs(data: Nullable<FloatArray>): void;
  22689. /**
  22690. * Gets the texture coordinates data stored in this target
  22691. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22692. */
  22693. getUVs(): Nullable<FloatArray>;
  22694. /**
  22695. * Serializes the current target into a Serialization object
  22696. * @returns the serialized object
  22697. */
  22698. serialize(): any;
  22699. /**
  22700. * Returns the string "MorphTarget"
  22701. * @returns "MorphTarget"
  22702. */
  22703. getClassName(): string;
  22704. /**
  22705. * Creates a new target from serialized data
  22706. * @param serializationObject defines the serialized data to use
  22707. * @returns a new MorphTarget
  22708. */
  22709. static Parse(serializationObject: any): MorphTarget;
  22710. /**
  22711. * Creates a MorphTarget from mesh data
  22712. * @param mesh defines the source mesh
  22713. * @param name defines the name to use for the new target
  22714. * @param influence defines the influence to attach to the target
  22715. * @returns a new MorphTarget
  22716. */
  22717. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22718. }
  22719. }
  22720. declare module "babylonjs/Morph/morphTargetManager" {
  22721. import { Nullable } from "babylonjs/types";
  22722. import { Scene } from "babylonjs/scene";
  22723. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22724. /**
  22725. * This class is used to deform meshes using morphing between different targets
  22726. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22727. */
  22728. export class MorphTargetManager {
  22729. private _targets;
  22730. private _targetInfluenceChangedObservers;
  22731. private _targetDataLayoutChangedObservers;
  22732. private _activeTargets;
  22733. private _scene;
  22734. private _influences;
  22735. private _supportsNormals;
  22736. private _supportsTangents;
  22737. private _supportsUVs;
  22738. private _vertexCount;
  22739. private _uniqueId;
  22740. private _tempInfluences;
  22741. /**
  22742. * Gets or sets a boolean indicating if normals must be morphed
  22743. */
  22744. enableNormalMorphing: boolean;
  22745. /**
  22746. * Gets or sets a boolean indicating if tangents must be morphed
  22747. */
  22748. enableTangentMorphing: boolean;
  22749. /**
  22750. * Gets or sets a boolean indicating if UV must be morphed
  22751. */
  22752. enableUVMorphing: boolean;
  22753. /**
  22754. * Creates a new MorphTargetManager
  22755. * @param scene defines the current scene
  22756. */
  22757. constructor(scene?: Nullable<Scene>);
  22758. /**
  22759. * Gets the unique ID of this manager
  22760. */
  22761. readonly uniqueId: number;
  22762. /**
  22763. * Gets the number of vertices handled by this manager
  22764. */
  22765. readonly vertexCount: number;
  22766. /**
  22767. * Gets a boolean indicating if this manager supports morphing of normals
  22768. */
  22769. readonly supportsNormals: boolean;
  22770. /**
  22771. * Gets a boolean indicating if this manager supports morphing of tangents
  22772. */
  22773. readonly supportsTangents: boolean;
  22774. /**
  22775. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22776. */
  22777. readonly supportsUVs: boolean;
  22778. /**
  22779. * Gets the number of targets stored in this manager
  22780. */
  22781. readonly numTargets: number;
  22782. /**
  22783. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22784. */
  22785. readonly numInfluencers: number;
  22786. /**
  22787. * Gets the list of influences (one per target)
  22788. */
  22789. readonly influences: Float32Array;
  22790. /**
  22791. * Gets the active target at specified index. An active target is a target with an influence > 0
  22792. * @param index defines the index to check
  22793. * @returns the requested target
  22794. */
  22795. getActiveTarget(index: number): MorphTarget;
  22796. /**
  22797. * Gets the target at specified index
  22798. * @param index defines the index to check
  22799. * @returns the requested target
  22800. */
  22801. getTarget(index: number): MorphTarget;
  22802. /**
  22803. * Add a new target to this manager
  22804. * @param target defines the target to add
  22805. */
  22806. addTarget(target: MorphTarget): void;
  22807. /**
  22808. * Removes a target from the manager
  22809. * @param target defines the target to remove
  22810. */
  22811. removeTarget(target: MorphTarget): void;
  22812. /**
  22813. * Serializes the current manager into a Serialization object
  22814. * @returns the serialized object
  22815. */
  22816. serialize(): any;
  22817. private _syncActiveTargets;
  22818. /**
  22819. * Syncrhonize the targets with all the meshes using this morph target manager
  22820. */
  22821. synchronize(): void;
  22822. /**
  22823. * Creates a new MorphTargetManager from serialized data
  22824. * @param serializationObject defines the serialized data
  22825. * @param scene defines the hosting scene
  22826. * @returns the new MorphTargetManager
  22827. */
  22828. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22829. }
  22830. }
  22831. declare module "babylonjs/Meshes/meshLODLevel" {
  22832. import { Mesh } from "babylonjs/Meshes/mesh";
  22833. import { Nullable } from "babylonjs/types";
  22834. /**
  22835. * Class used to represent a specific level of detail of a mesh
  22836. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22837. */
  22838. export class MeshLODLevel {
  22839. /** Defines the distance where this level should start being displayed */
  22840. distance: number;
  22841. /** Defines the mesh to use to render this level */
  22842. mesh: Nullable<Mesh>;
  22843. /**
  22844. * Creates a new LOD level
  22845. * @param distance defines the distance where this level should star being displayed
  22846. * @param mesh defines the mesh to use to render this level
  22847. */
  22848. constructor(
  22849. /** Defines the distance where this level should start being displayed */
  22850. distance: number,
  22851. /** Defines the mesh to use to render this level */
  22852. mesh: Nullable<Mesh>);
  22853. }
  22854. }
  22855. declare module "babylonjs/Meshes/groundMesh" {
  22856. import { Scene } from "babylonjs/scene";
  22857. import { Vector3 } from "babylonjs/Maths/math.vector";
  22858. import { Mesh } from "babylonjs/Meshes/mesh";
  22859. /**
  22860. * Mesh representing the gorund
  22861. */
  22862. export class GroundMesh extends Mesh {
  22863. /** If octree should be generated */
  22864. generateOctree: boolean;
  22865. private _heightQuads;
  22866. /** @hidden */
  22867. _subdivisionsX: number;
  22868. /** @hidden */
  22869. _subdivisionsY: number;
  22870. /** @hidden */
  22871. _width: number;
  22872. /** @hidden */
  22873. _height: number;
  22874. /** @hidden */
  22875. _minX: number;
  22876. /** @hidden */
  22877. _maxX: number;
  22878. /** @hidden */
  22879. _minZ: number;
  22880. /** @hidden */
  22881. _maxZ: number;
  22882. constructor(name: string, scene: Scene);
  22883. /**
  22884. * "GroundMesh"
  22885. * @returns "GroundMesh"
  22886. */
  22887. getClassName(): string;
  22888. /**
  22889. * The minimum of x and y subdivisions
  22890. */
  22891. readonly subdivisions: number;
  22892. /**
  22893. * X subdivisions
  22894. */
  22895. readonly subdivisionsX: number;
  22896. /**
  22897. * Y subdivisions
  22898. */
  22899. readonly subdivisionsY: number;
  22900. /**
  22901. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22902. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22903. * @param chunksCount the number of subdivisions for x and y
  22904. * @param octreeBlocksSize (Default: 32)
  22905. */
  22906. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22907. /**
  22908. * Returns a height (y) value in the Worl system :
  22909. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22910. * @param x x coordinate
  22911. * @param z z coordinate
  22912. * @returns the ground y position if (x, z) are outside the ground surface.
  22913. */
  22914. getHeightAtCoordinates(x: number, z: number): number;
  22915. /**
  22916. * Returns a normalized vector (Vector3) orthogonal to the ground
  22917. * at the ground coordinates (x, z) expressed in the World system.
  22918. * @param x x coordinate
  22919. * @param z z coordinate
  22920. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22921. */
  22922. getNormalAtCoordinates(x: number, z: number): Vector3;
  22923. /**
  22924. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22925. * at the ground coordinates (x, z) expressed in the World system.
  22926. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22927. * @param x x coordinate
  22928. * @param z z coordinate
  22929. * @param ref vector to store the result
  22930. * @returns the GroundMesh.
  22931. */
  22932. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22933. /**
  22934. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22935. * if the ground has been updated.
  22936. * This can be used in the render loop.
  22937. * @returns the GroundMesh.
  22938. */
  22939. updateCoordinateHeights(): GroundMesh;
  22940. private _getFacetAt;
  22941. private _initHeightQuads;
  22942. private _computeHeightQuads;
  22943. /**
  22944. * Serializes this ground mesh
  22945. * @param serializationObject object to write serialization to
  22946. */
  22947. serialize(serializationObject: any): void;
  22948. /**
  22949. * Parses a serialized ground mesh
  22950. * @param parsedMesh the serialized mesh
  22951. * @param scene the scene to create the ground mesh in
  22952. * @returns the created ground mesh
  22953. */
  22954. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22955. }
  22956. }
  22957. declare module "babylonjs/Physics/physicsJoint" {
  22958. import { Vector3 } from "babylonjs/Maths/math.vector";
  22959. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22960. /**
  22961. * Interface for Physics-Joint data
  22962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22963. */
  22964. export interface PhysicsJointData {
  22965. /**
  22966. * The main pivot of the joint
  22967. */
  22968. mainPivot?: Vector3;
  22969. /**
  22970. * The connected pivot of the joint
  22971. */
  22972. connectedPivot?: Vector3;
  22973. /**
  22974. * The main axis of the joint
  22975. */
  22976. mainAxis?: Vector3;
  22977. /**
  22978. * The connected axis of the joint
  22979. */
  22980. connectedAxis?: Vector3;
  22981. /**
  22982. * The collision of the joint
  22983. */
  22984. collision?: boolean;
  22985. /**
  22986. * Native Oimo/Cannon/Energy data
  22987. */
  22988. nativeParams?: any;
  22989. }
  22990. /**
  22991. * This is a holder class for the physics joint created by the physics plugin
  22992. * It holds a set of functions to control the underlying joint
  22993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22994. */
  22995. export class PhysicsJoint {
  22996. /**
  22997. * The type of the physics joint
  22998. */
  22999. type: number;
  23000. /**
  23001. * The data for the physics joint
  23002. */
  23003. jointData: PhysicsJointData;
  23004. private _physicsJoint;
  23005. protected _physicsPlugin: IPhysicsEnginePlugin;
  23006. /**
  23007. * Initializes the physics joint
  23008. * @param type The type of the physics joint
  23009. * @param jointData The data for the physics joint
  23010. */
  23011. constructor(
  23012. /**
  23013. * The type of the physics joint
  23014. */
  23015. type: number,
  23016. /**
  23017. * The data for the physics joint
  23018. */
  23019. jointData: PhysicsJointData);
  23020. /**
  23021. * Gets the physics joint
  23022. */
  23023. /**
  23024. * Sets the physics joint
  23025. */
  23026. physicsJoint: any;
  23027. /**
  23028. * Sets the physics plugin
  23029. */
  23030. physicsPlugin: IPhysicsEnginePlugin;
  23031. /**
  23032. * Execute a function that is physics-plugin specific.
  23033. * @param {Function} func the function that will be executed.
  23034. * It accepts two parameters: the physics world and the physics joint
  23035. */
  23036. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23037. /**
  23038. * Distance-Joint type
  23039. */
  23040. static DistanceJoint: number;
  23041. /**
  23042. * Hinge-Joint type
  23043. */
  23044. static HingeJoint: number;
  23045. /**
  23046. * Ball-and-Socket joint type
  23047. */
  23048. static BallAndSocketJoint: number;
  23049. /**
  23050. * Wheel-Joint type
  23051. */
  23052. static WheelJoint: number;
  23053. /**
  23054. * Slider-Joint type
  23055. */
  23056. static SliderJoint: number;
  23057. /**
  23058. * Prismatic-Joint type
  23059. */
  23060. static PrismaticJoint: number;
  23061. /**
  23062. * Universal-Joint type
  23063. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23064. */
  23065. static UniversalJoint: number;
  23066. /**
  23067. * Hinge-Joint 2 type
  23068. */
  23069. static Hinge2Joint: number;
  23070. /**
  23071. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23072. */
  23073. static PointToPointJoint: number;
  23074. /**
  23075. * Spring-Joint type
  23076. */
  23077. static SpringJoint: number;
  23078. /**
  23079. * Lock-Joint type
  23080. */
  23081. static LockJoint: number;
  23082. }
  23083. /**
  23084. * A class representing a physics distance joint
  23085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23086. */
  23087. export class DistanceJoint extends PhysicsJoint {
  23088. /**
  23089. *
  23090. * @param jointData The data for the Distance-Joint
  23091. */
  23092. constructor(jointData: DistanceJointData);
  23093. /**
  23094. * Update the predefined distance.
  23095. * @param maxDistance The maximum preferred distance
  23096. * @param minDistance The minimum preferred distance
  23097. */
  23098. updateDistance(maxDistance: number, minDistance?: number): void;
  23099. }
  23100. /**
  23101. * Represents a Motor-Enabled Joint
  23102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23103. */
  23104. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23105. /**
  23106. * Initializes the Motor-Enabled Joint
  23107. * @param type The type of the joint
  23108. * @param jointData The physica joint data for the joint
  23109. */
  23110. constructor(type: number, jointData: PhysicsJointData);
  23111. /**
  23112. * Set the motor values.
  23113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23114. * @param force the force to apply
  23115. * @param maxForce max force for this motor.
  23116. */
  23117. setMotor(force?: number, maxForce?: number): void;
  23118. /**
  23119. * Set the motor's limits.
  23120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23121. * @param upperLimit The upper limit of the motor
  23122. * @param lowerLimit The lower limit of the motor
  23123. */
  23124. setLimit(upperLimit: number, lowerLimit?: number): void;
  23125. }
  23126. /**
  23127. * This class represents a single physics Hinge-Joint
  23128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23129. */
  23130. export class HingeJoint extends MotorEnabledJoint {
  23131. /**
  23132. * Initializes the Hinge-Joint
  23133. * @param jointData The joint data for the Hinge-Joint
  23134. */
  23135. constructor(jointData: PhysicsJointData);
  23136. /**
  23137. * Set the motor values.
  23138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23139. * @param {number} force the force to apply
  23140. * @param {number} maxForce max force for this motor.
  23141. */
  23142. setMotor(force?: number, maxForce?: number): void;
  23143. /**
  23144. * Set the motor's limits.
  23145. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23146. * @param upperLimit The upper limit of the motor
  23147. * @param lowerLimit The lower limit of the motor
  23148. */
  23149. setLimit(upperLimit: number, lowerLimit?: number): void;
  23150. }
  23151. /**
  23152. * This class represents a dual hinge physics joint (same as wheel joint)
  23153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23154. */
  23155. export class Hinge2Joint extends MotorEnabledJoint {
  23156. /**
  23157. * Initializes the Hinge2-Joint
  23158. * @param jointData The joint data for the Hinge2-Joint
  23159. */
  23160. constructor(jointData: PhysicsJointData);
  23161. /**
  23162. * Set the motor values.
  23163. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23164. * @param {number} targetSpeed the speed the motor is to reach
  23165. * @param {number} maxForce max force for this motor.
  23166. * @param {motorIndex} the motor's index, 0 or 1.
  23167. */
  23168. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23169. /**
  23170. * Set the motor limits.
  23171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23172. * @param {number} upperLimit the upper limit
  23173. * @param {number} lowerLimit lower limit
  23174. * @param {motorIndex} the motor's index, 0 or 1.
  23175. */
  23176. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23177. }
  23178. /**
  23179. * Interface for a motor enabled joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export interface IMotorEnabledJoint {
  23183. /**
  23184. * Physics joint
  23185. */
  23186. physicsJoint: any;
  23187. /**
  23188. * Sets the motor of the motor-enabled joint
  23189. * @param force The force of the motor
  23190. * @param maxForce The maximum force of the motor
  23191. * @param motorIndex The index of the motor
  23192. */
  23193. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23194. /**
  23195. * Sets the limit of the motor
  23196. * @param upperLimit The upper limit of the motor
  23197. * @param lowerLimit The lower limit of the motor
  23198. * @param motorIndex The index of the motor
  23199. */
  23200. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23201. }
  23202. /**
  23203. * Joint data for a Distance-Joint
  23204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23205. */
  23206. export interface DistanceJointData extends PhysicsJointData {
  23207. /**
  23208. * Max distance the 2 joint objects can be apart
  23209. */
  23210. maxDistance: number;
  23211. }
  23212. /**
  23213. * Joint data from a spring joint
  23214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23215. */
  23216. export interface SpringJointData extends PhysicsJointData {
  23217. /**
  23218. * Length of the spring
  23219. */
  23220. length: number;
  23221. /**
  23222. * Stiffness of the spring
  23223. */
  23224. stiffness: number;
  23225. /**
  23226. * Damping of the spring
  23227. */
  23228. damping: number;
  23229. /** this callback will be called when applying the force to the impostors. */
  23230. forceApplicationCallback: () => void;
  23231. }
  23232. }
  23233. declare module "babylonjs/Physics/physicsRaycastResult" {
  23234. import { Vector3 } from "babylonjs/Maths/math.vector";
  23235. /**
  23236. * Holds the data for the raycast result
  23237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23238. */
  23239. export class PhysicsRaycastResult {
  23240. private _hasHit;
  23241. private _hitDistance;
  23242. private _hitNormalWorld;
  23243. private _hitPointWorld;
  23244. private _rayFromWorld;
  23245. private _rayToWorld;
  23246. /**
  23247. * Gets if there was a hit
  23248. */
  23249. readonly hasHit: boolean;
  23250. /**
  23251. * Gets the distance from the hit
  23252. */
  23253. readonly hitDistance: number;
  23254. /**
  23255. * Gets the hit normal/direction in the world
  23256. */
  23257. readonly hitNormalWorld: Vector3;
  23258. /**
  23259. * Gets the hit point in the world
  23260. */
  23261. readonly hitPointWorld: Vector3;
  23262. /**
  23263. * Gets the ray "start point" of the ray in the world
  23264. */
  23265. readonly rayFromWorld: Vector3;
  23266. /**
  23267. * Gets the ray "end point" of the ray in the world
  23268. */
  23269. readonly rayToWorld: Vector3;
  23270. /**
  23271. * Sets the hit data (normal & point in world space)
  23272. * @param hitNormalWorld defines the normal in world space
  23273. * @param hitPointWorld defines the point in world space
  23274. */
  23275. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23276. /**
  23277. * Sets the distance from the start point to the hit point
  23278. * @param distance
  23279. */
  23280. setHitDistance(distance: number): void;
  23281. /**
  23282. * Calculates the distance manually
  23283. */
  23284. calculateHitDistance(): void;
  23285. /**
  23286. * Resets all the values to default
  23287. * @param from The from point on world space
  23288. * @param to The to point on world space
  23289. */
  23290. reset(from?: Vector3, to?: Vector3): void;
  23291. }
  23292. /**
  23293. * Interface for the size containing width and height
  23294. */
  23295. interface IXYZ {
  23296. /**
  23297. * X
  23298. */
  23299. x: number;
  23300. /**
  23301. * Y
  23302. */
  23303. y: number;
  23304. /**
  23305. * Z
  23306. */
  23307. z: number;
  23308. }
  23309. }
  23310. declare module "babylonjs/Physics/IPhysicsEngine" {
  23311. import { Nullable } from "babylonjs/types";
  23312. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23314. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23315. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23316. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23317. /**
  23318. * Interface used to describe a physics joint
  23319. */
  23320. export interface PhysicsImpostorJoint {
  23321. /** Defines the main impostor to which the joint is linked */
  23322. mainImpostor: PhysicsImpostor;
  23323. /** Defines the impostor that is connected to the main impostor using this joint */
  23324. connectedImpostor: PhysicsImpostor;
  23325. /** Defines the joint itself */
  23326. joint: PhysicsJoint;
  23327. }
  23328. /** @hidden */
  23329. export interface IPhysicsEnginePlugin {
  23330. world: any;
  23331. name: string;
  23332. setGravity(gravity: Vector3): void;
  23333. setTimeStep(timeStep: number): void;
  23334. getTimeStep(): number;
  23335. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23339. removePhysicsBody(impostor: PhysicsImpostor): void;
  23340. generateJoint(joint: PhysicsImpostorJoint): void;
  23341. removeJoint(joint: PhysicsImpostorJoint): void;
  23342. isSupported(): boolean;
  23343. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23345. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23346. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23347. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23348. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23349. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23350. getBodyMass(impostor: PhysicsImpostor): number;
  23351. getBodyFriction(impostor: PhysicsImpostor): number;
  23352. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23353. getBodyRestitution(impostor: PhysicsImpostor): number;
  23354. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23355. getBodyPressure?(impostor: PhysicsImpostor): number;
  23356. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23357. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23358. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23359. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23360. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23361. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23362. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23363. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23364. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23365. sleepBody(impostor: PhysicsImpostor): void;
  23366. wakeUpBody(impostor: PhysicsImpostor): void;
  23367. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23368. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23369. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23371. getRadius(impostor: PhysicsImpostor): number;
  23372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23373. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23374. dispose(): void;
  23375. }
  23376. /**
  23377. * Interface used to define a physics engine
  23378. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23379. */
  23380. export interface IPhysicsEngine {
  23381. /**
  23382. * Gets the gravity vector used by the simulation
  23383. */
  23384. gravity: Vector3;
  23385. /**
  23386. * Sets the gravity vector used by the simulation
  23387. * @param gravity defines the gravity vector to use
  23388. */
  23389. setGravity(gravity: Vector3): void;
  23390. /**
  23391. * Set the time step of the physics engine.
  23392. * Default is 1/60.
  23393. * To slow it down, enter 1/600 for example.
  23394. * To speed it up, 1/30
  23395. * @param newTimeStep the new timestep to apply to this world.
  23396. */
  23397. setTimeStep(newTimeStep: number): void;
  23398. /**
  23399. * Get the time step of the physics engine.
  23400. * @returns the current time step
  23401. */
  23402. getTimeStep(): number;
  23403. /**
  23404. * Release all resources
  23405. */
  23406. dispose(): void;
  23407. /**
  23408. * Gets the name of the current physics plugin
  23409. * @returns the name of the plugin
  23410. */
  23411. getPhysicsPluginName(): string;
  23412. /**
  23413. * Adding a new impostor for the impostor tracking.
  23414. * This will be done by the impostor itself.
  23415. * @param impostor the impostor to add
  23416. */
  23417. addImpostor(impostor: PhysicsImpostor): void;
  23418. /**
  23419. * Remove an impostor from the engine.
  23420. * This impostor and its mesh will not longer be updated by the physics engine.
  23421. * @param impostor the impostor to remove
  23422. */
  23423. removeImpostor(impostor: PhysicsImpostor): void;
  23424. /**
  23425. * Add a joint to the physics engine
  23426. * @param mainImpostor defines the main impostor to which the joint is added.
  23427. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23428. * @param joint defines the joint that will connect both impostors.
  23429. */
  23430. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23431. /**
  23432. * Removes a joint from the simulation
  23433. * @param mainImpostor defines the impostor used with the joint
  23434. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23435. * @param joint defines the joint to remove
  23436. */
  23437. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23438. /**
  23439. * Gets the current plugin used to run the simulation
  23440. * @returns current plugin
  23441. */
  23442. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23443. /**
  23444. * Gets the list of physic impostors
  23445. * @returns an array of PhysicsImpostor
  23446. */
  23447. getImpostors(): Array<PhysicsImpostor>;
  23448. /**
  23449. * Gets the impostor for a physics enabled object
  23450. * @param object defines the object impersonated by the impostor
  23451. * @returns the PhysicsImpostor or null if not found
  23452. */
  23453. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23454. /**
  23455. * Gets the impostor for a physics body object
  23456. * @param body defines physics body used by the impostor
  23457. * @returns the PhysicsImpostor or null if not found
  23458. */
  23459. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23460. /**
  23461. * Does a raycast in the physics world
  23462. * @param from when should the ray start?
  23463. * @param to when should the ray end?
  23464. * @returns PhysicsRaycastResult
  23465. */
  23466. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23467. /**
  23468. * Called by the scene. No need to call it.
  23469. * @param delta defines the timespam between frames
  23470. */
  23471. _step(delta: number): void;
  23472. }
  23473. }
  23474. declare module "babylonjs/Physics/physicsImpostor" {
  23475. import { Nullable, IndicesArray } from "babylonjs/types";
  23476. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23477. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23479. import { Scene } from "babylonjs/scene";
  23480. import { Bone } from "babylonjs/Bones/bone";
  23481. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23482. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23483. import { Space } from "babylonjs/Maths/math.axis";
  23484. /**
  23485. * The interface for the physics imposter parameters
  23486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23487. */
  23488. export interface PhysicsImpostorParameters {
  23489. /**
  23490. * The mass of the physics imposter
  23491. */
  23492. mass: number;
  23493. /**
  23494. * The friction of the physics imposter
  23495. */
  23496. friction?: number;
  23497. /**
  23498. * The coefficient of restitution of the physics imposter
  23499. */
  23500. restitution?: number;
  23501. /**
  23502. * The native options of the physics imposter
  23503. */
  23504. nativeOptions?: any;
  23505. /**
  23506. * Specifies if the parent should be ignored
  23507. */
  23508. ignoreParent?: boolean;
  23509. /**
  23510. * Specifies if bi-directional transformations should be disabled
  23511. */
  23512. disableBidirectionalTransformation?: boolean;
  23513. /**
  23514. * The pressure inside the physics imposter, soft object only
  23515. */
  23516. pressure?: number;
  23517. /**
  23518. * The stiffness the physics imposter, soft object only
  23519. */
  23520. stiffness?: number;
  23521. /**
  23522. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23523. */
  23524. velocityIterations?: number;
  23525. /**
  23526. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23527. */
  23528. positionIterations?: number;
  23529. /**
  23530. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23531. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23532. * Add to fix multiple points
  23533. */
  23534. fixedPoints?: number;
  23535. /**
  23536. * The collision margin around a soft object
  23537. */
  23538. margin?: number;
  23539. /**
  23540. * The collision margin around a soft object
  23541. */
  23542. damping?: number;
  23543. /**
  23544. * The path for a rope based on an extrusion
  23545. */
  23546. path?: any;
  23547. /**
  23548. * The shape of an extrusion used for a rope based on an extrusion
  23549. */
  23550. shape?: any;
  23551. }
  23552. /**
  23553. * Interface for a physics-enabled object
  23554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23555. */
  23556. export interface IPhysicsEnabledObject {
  23557. /**
  23558. * The position of the physics-enabled object
  23559. */
  23560. position: Vector3;
  23561. /**
  23562. * The rotation of the physics-enabled object
  23563. */
  23564. rotationQuaternion: Nullable<Quaternion>;
  23565. /**
  23566. * The scale of the physics-enabled object
  23567. */
  23568. scaling: Vector3;
  23569. /**
  23570. * The rotation of the physics-enabled object
  23571. */
  23572. rotation?: Vector3;
  23573. /**
  23574. * The parent of the physics-enabled object
  23575. */
  23576. parent?: any;
  23577. /**
  23578. * The bounding info of the physics-enabled object
  23579. * @returns The bounding info of the physics-enabled object
  23580. */
  23581. getBoundingInfo(): BoundingInfo;
  23582. /**
  23583. * Computes the world matrix
  23584. * @param force Specifies if the world matrix should be computed by force
  23585. * @returns A world matrix
  23586. */
  23587. computeWorldMatrix(force: boolean): Matrix;
  23588. /**
  23589. * Gets the world matrix
  23590. * @returns A world matrix
  23591. */
  23592. getWorldMatrix?(): Matrix;
  23593. /**
  23594. * Gets the child meshes
  23595. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23596. * @returns An array of abstract meshes
  23597. */
  23598. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23599. /**
  23600. * Gets the vertex data
  23601. * @param kind The type of vertex data
  23602. * @returns A nullable array of numbers, or a float32 array
  23603. */
  23604. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23605. /**
  23606. * Gets the indices from the mesh
  23607. * @returns A nullable array of index arrays
  23608. */
  23609. getIndices?(): Nullable<IndicesArray>;
  23610. /**
  23611. * Gets the scene from the mesh
  23612. * @returns the indices array or null
  23613. */
  23614. getScene?(): Scene;
  23615. /**
  23616. * Gets the absolute position from the mesh
  23617. * @returns the absolute position
  23618. */
  23619. getAbsolutePosition(): Vector3;
  23620. /**
  23621. * Gets the absolute pivot point from the mesh
  23622. * @returns the absolute pivot point
  23623. */
  23624. getAbsolutePivotPoint(): Vector3;
  23625. /**
  23626. * Rotates the mesh
  23627. * @param axis The axis of rotation
  23628. * @param amount The amount of rotation
  23629. * @param space The space of the rotation
  23630. * @returns The rotation transform node
  23631. */
  23632. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23633. /**
  23634. * Translates the mesh
  23635. * @param axis The axis of translation
  23636. * @param distance The distance of translation
  23637. * @param space The space of the translation
  23638. * @returns The transform node
  23639. */
  23640. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23641. /**
  23642. * Sets the absolute position of the mesh
  23643. * @param absolutePosition The absolute position of the mesh
  23644. * @returns The transform node
  23645. */
  23646. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23647. /**
  23648. * Gets the class name of the mesh
  23649. * @returns The class name
  23650. */
  23651. getClassName(): string;
  23652. }
  23653. /**
  23654. * Represents a physics imposter
  23655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23656. */
  23657. export class PhysicsImpostor {
  23658. /**
  23659. * The physics-enabled object used as the physics imposter
  23660. */
  23661. object: IPhysicsEnabledObject;
  23662. /**
  23663. * The type of the physics imposter
  23664. */
  23665. type: number;
  23666. private _options;
  23667. private _scene?;
  23668. /**
  23669. * The default object size of the imposter
  23670. */
  23671. static DEFAULT_OBJECT_SIZE: Vector3;
  23672. /**
  23673. * The identity quaternion of the imposter
  23674. */
  23675. static IDENTITY_QUATERNION: Quaternion;
  23676. /** @hidden */
  23677. _pluginData: any;
  23678. private _physicsEngine;
  23679. private _physicsBody;
  23680. private _bodyUpdateRequired;
  23681. private _onBeforePhysicsStepCallbacks;
  23682. private _onAfterPhysicsStepCallbacks;
  23683. /** @hidden */
  23684. _onPhysicsCollideCallbacks: Array<{
  23685. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23686. otherImpostors: Array<PhysicsImpostor>;
  23687. }>;
  23688. private _deltaPosition;
  23689. private _deltaRotation;
  23690. private _deltaRotationConjugated;
  23691. /** @hidden */
  23692. _isFromLine: boolean;
  23693. private _parent;
  23694. private _isDisposed;
  23695. private static _tmpVecs;
  23696. private static _tmpQuat;
  23697. /**
  23698. * Specifies if the physics imposter is disposed
  23699. */
  23700. readonly isDisposed: boolean;
  23701. /**
  23702. * Gets the mass of the physics imposter
  23703. */
  23704. mass: number;
  23705. /**
  23706. * Gets the coefficient of friction
  23707. */
  23708. /**
  23709. * Sets the coefficient of friction
  23710. */
  23711. friction: number;
  23712. /**
  23713. * Gets the coefficient of restitution
  23714. */
  23715. /**
  23716. * Sets the coefficient of restitution
  23717. */
  23718. restitution: number;
  23719. /**
  23720. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23721. */
  23722. /**
  23723. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. pressure: number;
  23726. /**
  23727. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23728. */
  23729. /**
  23730. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23731. */
  23732. stiffness: number;
  23733. /**
  23734. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23735. */
  23736. /**
  23737. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23738. */
  23739. velocityIterations: number;
  23740. /**
  23741. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23742. */
  23743. /**
  23744. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23745. */
  23746. positionIterations: number;
  23747. /**
  23748. * The unique id of the physics imposter
  23749. * set by the physics engine when adding this impostor to the array
  23750. */
  23751. uniqueId: number;
  23752. /**
  23753. * @hidden
  23754. */
  23755. soft: boolean;
  23756. /**
  23757. * @hidden
  23758. */
  23759. segments: number;
  23760. private _joints;
  23761. /**
  23762. * Initializes the physics imposter
  23763. * @param object The physics-enabled object used as the physics imposter
  23764. * @param type The type of the physics imposter
  23765. * @param _options The options for the physics imposter
  23766. * @param _scene The Babylon scene
  23767. */
  23768. constructor(
  23769. /**
  23770. * The physics-enabled object used as the physics imposter
  23771. */
  23772. object: IPhysicsEnabledObject,
  23773. /**
  23774. * The type of the physics imposter
  23775. */
  23776. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23777. /**
  23778. * This function will completly initialize this impostor.
  23779. * It will create a new body - but only if this mesh has no parent.
  23780. * If it has, this impostor will not be used other than to define the impostor
  23781. * of the child mesh.
  23782. * @hidden
  23783. */
  23784. _init(): void;
  23785. private _getPhysicsParent;
  23786. /**
  23787. * Should a new body be generated.
  23788. * @returns boolean specifying if body initialization is required
  23789. */
  23790. isBodyInitRequired(): boolean;
  23791. /**
  23792. * Sets the updated scaling
  23793. * @param updated Specifies if the scaling is updated
  23794. */
  23795. setScalingUpdated(): void;
  23796. /**
  23797. * Force a regeneration of this or the parent's impostor's body.
  23798. * Use under cautious - This will remove all joints already implemented.
  23799. */
  23800. forceUpdate(): void;
  23801. /**
  23802. * Gets the body that holds this impostor. Either its own, or its parent.
  23803. */
  23804. /**
  23805. * Set the physics body. Used mainly by the physics engine/plugin
  23806. */
  23807. physicsBody: any;
  23808. /**
  23809. * Get the parent of the physics imposter
  23810. * @returns Physics imposter or null
  23811. */
  23812. /**
  23813. * Sets the parent of the physics imposter
  23814. */
  23815. parent: Nullable<PhysicsImpostor>;
  23816. /**
  23817. * Resets the update flags
  23818. */
  23819. resetUpdateFlags(): void;
  23820. /**
  23821. * Gets the object extend size
  23822. * @returns the object extend size
  23823. */
  23824. getObjectExtendSize(): Vector3;
  23825. /**
  23826. * Gets the object center
  23827. * @returns The object center
  23828. */
  23829. getObjectCenter(): Vector3;
  23830. /**
  23831. * Get a specific parametes from the options parameter
  23832. * @param paramName The object parameter name
  23833. * @returns The object parameter
  23834. */
  23835. getParam(paramName: string): any;
  23836. /**
  23837. * Sets a specific parameter in the options given to the physics plugin
  23838. * @param paramName The parameter name
  23839. * @param value The value of the parameter
  23840. */
  23841. setParam(paramName: string, value: number): void;
  23842. /**
  23843. * Specifically change the body's mass option. Won't recreate the physics body object
  23844. * @param mass The mass of the physics imposter
  23845. */
  23846. setMass(mass: number): void;
  23847. /**
  23848. * Gets the linear velocity
  23849. * @returns linear velocity or null
  23850. */
  23851. getLinearVelocity(): Nullable<Vector3>;
  23852. /**
  23853. * Sets the linear velocity
  23854. * @param velocity linear velocity or null
  23855. */
  23856. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23857. /**
  23858. * Gets the angular velocity
  23859. * @returns angular velocity or null
  23860. */
  23861. getAngularVelocity(): Nullable<Vector3>;
  23862. /**
  23863. * Sets the angular velocity
  23864. * @param velocity The velocity or null
  23865. */
  23866. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23867. /**
  23868. * Execute a function with the physics plugin native code
  23869. * Provide a function the will have two variables - the world object and the physics body object
  23870. * @param func The function to execute with the physics plugin native code
  23871. */
  23872. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23873. /**
  23874. * Register a function that will be executed before the physics world is stepping forward
  23875. * @param func The function to execute before the physics world is stepped forward
  23876. */
  23877. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23878. /**
  23879. * Unregister a function that will be executed before the physics world is stepping forward
  23880. * @param func The function to execute before the physics world is stepped forward
  23881. */
  23882. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23883. /**
  23884. * Register a function that will be executed after the physics step
  23885. * @param func The function to execute after physics step
  23886. */
  23887. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23888. /**
  23889. * Unregisters a function that will be executed after the physics step
  23890. * @param func The function to execute after physics step
  23891. */
  23892. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23893. /**
  23894. * register a function that will be executed when this impostor collides against a different body
  23895. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23896. * @param func Callback that is executed on collision
  23897. */
  23898. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23899. /**
  23900. * Unregisters the physics imposter on contact
  23901. * @param collideAgainst The physics object to collide against
  23902. * @param func Callback to execute on collision
  23903. */
  23904. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23905. private _tmpQuat;
  23906. private _tmpQuat2;
  23907. /**
  23908. * Get the parent rotation
  23909. * @returns The parent rotation
  23910. */
  23911. getParentsRotation(): Quaternion;
  23912. /**
  23913. * this function is executed by the physics engine.
  23914. */
  23915. beforeStep: () => void;
  23916. /**
  23917. * this function is executed by the physics engine
  23918. */
  23919. afterStep: () => void;
  23920. /**
  23921. * Legacy collision detection event support
  23922. */
  23923. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23924. /**
  23925. * event and body object due to cannon's event-based architecture.
  23926. */
  23927. onCollide: (e: {
  23928. body: any;
  23929. }) => void;
  23930. /**
  23931. * Apply a force
  23932. * @param force The force to apply
  23933. * @param contactPoint The contact point for the force
  23934. * @returns The physics imposter
  23935. */
  23936. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23937. /**
  23938. * Apply an impulse
  23939. * @param force The impulse force
  23940. * @param contactPoint The contact point for the impulse force
  23941. * @returns The physics imposter
  23942. */
  23943. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23944. /**
  23945. * A help function to create a joint
  23946. * @param otherImpostor A physics imposter used to create a joint
  23947. * @param jointType The type of joint
  23948. * @param jointData The data for the joint
  23949. * @returns The physics imposter
  23950. */
  23951. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23952. /**
  23953. * Add a joint to this impostor with a different impostor
  23954. * @param otherImpostor A physics imposter used to add a joint
  23955. * @param joint The joint to add
  23956. * @returns The physics imposter
  23957. */
  23958. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23959. /**
  23960. * Add an anchor to a cloth impostor
  23961. * @param otherImpostor rigid impostor to anchor to
  23962. * @param width ratio across width from 0 to 1
  23963. * @param height ratio up height from 0 to 1
  23964. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23965. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23966. * @returns impostor the soft imposter
  23967. */
  23968. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23969. /**
  23970. * Add a hook to a rope impostor
  23971. * @param otherImpostor rigid impostor to anchor to
  23972. * @param length ratio across rope from 0 to 1
  23973. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23974. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23975. * @returns impostor the rope imposter
  23976. */
  23977. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23978. /**
  23979. * Will keep this body still, in a sleep mode.
  23980. * @returns the physics imposter
  23981. */
  23982. sleep(): PhysicsImpostor;
  23983. /**
  23984. * Wake the body up.
  23985. * @returns The physics imposter
  23986. */
  23987. wakeUp(): PhysicsImpostor;
  23988. /**
  23989. * Clones the physics imposter
  23990. * @param newObject The physics imposter clones to this physics-enabled object
  23991. * @returns A nullable physics imposter
  23992. */
  23993. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23994. /**
  23995. * Disposes the physics imposter
  23996. */
  23997. dispose(): void;
  23998. /**
  23999. * Sets the delta position
  24000. * @param position The delta position amount
  24001. */
  24002. setDeltaPosition(position: Vector3): void;
  24003. /**
  24004. * Sets the delta rotation
  24005. * @param rotation The delta rotation amount
  24006. */
  24007. setDeltaRotation(rotation: Quaternion): void;
  24008. /**
  24009. * Gets the box size of the physics imposter and stores the result in the input parameter
  24010. * @param result Stores the box size
  24011. * @returns The physics imposter
  24012. */
  24013. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24014. /**
  24015. * Gets the radius of the physics imposter
  24016. * @returns Radius of the physics imposter
  24017. */
  24018. getRadius(): number;
  24019. /**
  24020. * Sync a bone with this impostor
  24021. * @param bone The bone to sync to the impostor.
  24022. * @param boneMesh The mesh that the bone is influencing.
  24023. * @param jointPivot The pivot of the joint / bone in local space.
  24024. * @param distToJoint Optional distance from the impostor to the joint.
  24025. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24026. */
  24027. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24028. /**
  24029. * Sync impostor to a bone
  24030. * @param bone The bone that the impostor will be synced to.
  24031. * @param boneMesh The mesh that the bone is influencing.
  24032. * @param jointPivot The pivot of the joint / bone in local space.
  24033. * @param distToJoint Optional distance from the impostor to the joint.
  24034. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24035. * @param boneAxis Optional vector3 axis the bone is aligned with
  24036. */
  24037. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24038. /**
  24039. * No-Imposter type
  24040. */
  24041. static NoImpostor: number;
  24042. /**
  24043. * Sphere-Imposter type
  24044. */
  24045. static SphereImpostor: number;
  24046. /**
  24047. * Box-Imposter type
  24048. */
  24049. static BoxImpostor: number;
  24050. /**
  24051. * Plane-Imposter type
  24052. */
  24053. static PlaneImpostor: number;
  24054. /**
  24055. * Mesh-imposter type
  24056. */
  24057. static MeshImpostor: number;
  24058. /**
  24059. * Capsule-Impostor type (Ammo.js plugin only)
  24060. */
  24061. static CapsuleImpostor: number;
  24062. /**
  24063. * Cylinder-Imposter type
  24064. */
  24065. static CylinderImpostor: number;
  24066. /**
  24067. * Particle-Imposter type
  24068. */
  24069. static ParticleImpostor: number;
  24070. /**
  24071. * Heightmap-Imposter type
  24072. */
  24073. static HeightmapImpostor: number;
  24074. /**
  24075. * ConvexHull-Impostor type (Ammo.js plugin only)
  24076. */
  24077. static ConvexHullImpostor: number;
  24078. /**
  24079. * Rope-Imposter type
  24080. */
  24081. static RopeImpostor: number;
  24082. /**
  24083. * Cloth-Imposter type
  24084. */
  24085. static ClothImpostor: number;
  24086. /**
  24087. * Softbody-Imposter type
  24088. */
  24089. static SoftbodyImpostor: number;
  24090. }
  24091. }
  24092. declare module "babylonjs/Meshes/mesh" {
  24093. import { Observable } from "babylonjs/Misc/observable";
  24094. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24095. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24096. import { Camera } from "babylonjs/Cameras/camera";
  24097. import { Scene } from "babylonjs/scene";
  24098. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24099. import { Color4 } from "babylonjs/Maths/math.color";
  24100. import { Engine } from "babylonjs/Engines/engine";
  24101. import { Node } from "babylonjs/node";
  24102. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24103. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24104. import { Buffer } from "babylonjs/Meshes/buffer";
  24105. import { Geometry } from "babylonjs/Meshes/geometry";
  24106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24108. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24109. import { Effect } from "babylonjs/Materials/effect";
  24110. import { Material } from "babylonjs/Materials/material";
  24111. import { Skeleton } from "babylonjs/Bones/skeleton";
  24112. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24113. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24114. import { Path3D } from "babylonjs/Maths/math.path";
  24115. import { Plane } from "babylonjs/Maths/math.plane";
  24116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24117. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24118. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24119. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24120. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24121. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24122. /**
  24123. * @hidden
  24124. **/
  24125. export class _CreationDataStorage {
  24126. closePath?: boolean;
  24127. closeArray?: boolean;
  24128. idx: number[];
  24129. dashSize: number;
  24130. gapSize: number;
  24131. path3D: Path3D;
  24132. pathArray: Vector3[][];
  24133. arc: number;
  24134. radius: number;
  24135. cap: number;
  24136. tessellation: number;
  24137. }
  24138. /**
  24139. * @hidden
  24140. **/
  24141. class _InstanceDataStorage {
  24142. visibleInstances: any;
  24143. batchCache: _InstancesBatch;
  24144. instancesBufferSize: number;
  24145. instancesBuffer: Nullable<Buffer>;
  24146. instancesData: Float32Array;
  24147. overridenInstanceCount: number;
  24148. isFrozen: boolean;
  24149. previousBatch: Nullable<_InstancesBatch>;
  24150. hardwareInstancedRendering: boolean;
  24151. sideOrientation: number;
  24152. }
  24153. /**
  24154. * @hidden
  24155. **/
  24156. export class _InstancesBatch {
  24157. mustReturn: boolean;
  24158. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24159. renderSelf: boolean[];
  24160. hardwareInstancedRendering: boolean[];
  24161. }
  24162. /**
  24163. * Class used to represent renderable models
  24164. */
  24165. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24166. /**
  24167. * Mesh side orientation : usually the external or front surface
  24168. */
  24169. static readonly FRONTSIDE: number;
  24170. /**
  24171. * Mesh side orientation : usually the internal or back surface
  24172. */
  24173. static readonly BACKSIDE: number;
  24174. /**
  24175. * Mesh side orientation : both internal and external or front and back surfaces
  24176. */
  24177. static readonly DOUBLESIDE: number;
  24178. /**
  24179. * Mesh side orientation : by default, `FRONTSIDE`
  24180. */
  24181. static readonly DEFAULTSIDE: number;
  24182. /**
  24183. * Mesh cap setting : no cap
  24184. */
  24185. static readonly NO_CAP: number;
  24186. /**
  24187. * Mesh cap setting : one cap at the beginning of the mesh
  24188. */
  24189. static readonly CAP_START: number;
  24190. /**
  24191. * Mesh cap setting : one cap at the end of the mesh
  24192. */
  24193. static readonly CAP_END: number;
  24194. /**
  24195. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24196. */
  24197. static readonly CAP_ALL: number;
  24198. /**
  24199. * Mesh pattern setting : no flip or rotate
  24200. */
  24201. static readonly NO_FLIP: number;
  24202. /**
  24203. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24204. */
  24205. static readonly FLIP_TILE: number;
  24206. /**
  24207. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24208. */
  24209. static readonly ROTATE_TILE: number;
  24210. /**
  24211. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24212. */
  24213. static readonly FLIP_ROW: number;
  24214. /**
  24215. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24216. */
  24217. static readonly ROTATE_ROW: number;
  24218. /**
  24219. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24220. */
  24221. static readonly FLIP_N_ROTATE_TILE: number;
  24222. /**
  24223. * Mesh pattern setting : rotate pattern and rotate
  24224. */
  24225. static readonly FLIP_N_ROTATE_ROW: number;
  24226. /**
  24227. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24228. */
  24229. static readonly CENTER: number;
  24230. /**
  24231. * Mesh tile positioning : part tiles on left
  24232. */
  24233. static readonly LEFT: number;
  24234. /**
  24235. * Mesh tile positioning : part tiles on right
  24236. */
  24237. static readonly RIGHT: number;
  24238. /**
  24239. * Mesh tile positioning : part tiles on top
  24240. */
  24241. static readonly TOP: number;
  24242. /**
  24243. * Mesh tile positioning : part tiles on bottom
  24244. */
  24245. static readonly BOTTOM: number;
  24246. /**
  24247. * Gets the default side orientation.
  24248. * @param orientation the orientation to value to attempt to get
  24249. * @returns the default orientation
  24250. * @hidden
  24251. */
  24252. static _GetDefaultSideOrientation(orientation?: number): number;
  24253. private _internalMeshDataInfo;
  24254. /**
  24255. * An event triggered before rendering the mesh
  24256. */
  24257. readonly onBeforeRenderObservable: Observable<Mesh>;
  24258. /**
  24259. * An event triggered before binding the mesh
  24260. */
  24261. readonly onBeforeBindObservable: Observable<Mesh>;
  24262. /**
  24263. * An event triggered after rendering the mesh
  24264. */
  24265. readonly onAfterRenderObservable: Observable<Mesh>;
  24266. /**
  24267. * An event triggered before drawing the mesh
  24268. */
  24269. readonly onBeforeDrawObservable: Observable<Mesh>;
  24270. private _onBeforeDrawObserver;
  24271. /**
  24272. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24273. */
  24274. onBeforeDraw: () => void;
  24275. readonly hasInstances: boolean;
  24276. /**
  24277. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24278. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24279. */
  24280. delayLoadState: number;
  24281. /**
  24282. * Gets the list of instances created from this mesh
  24283. * it is not supposed to be modified manually.
  24284. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24285. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24286. */
  24287. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24288. /**
  24289. * Gets the file containing delay loading data for this mesh
  24290. */
  24291. delayLoadingFile: string;
  24292. /** @hidden */
  24293. _binaryInfo: any;
  24294. /**
  24295. * User defined function used to change how LOD level selection is done
  24296. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24297. */
  24298. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24299. /**
  24300. * Gets or sets the morph target manager
  24301. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24302. */
  24303. morphTargetManager: Nullable<MorphTargetManager>;
  24304. /** @hidden */
  24305. _creationDataStorage: Nullable<_CreationDataStorage>;
  24306. /** @hidden */
  24307. _geometry: Nullable<Geometry>;
  24308. /** @hidden */
  24309. _delayInfo: Array<string>;
  24310. /** @hidden */
  24311. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24312. /** @hidden */
  24313. _instanceDataStorage: _InstanceDataStorage;
  24314. private _effectiveMaterial;
  24315. /** @hidden */
  24316. _shouldGenerateFlatShading: boolean;
  24317. /** @hidden */
  24318. _originalBuilderSideOrientation: number;
  24319. /**
  24320. * Use this property to change the original side orientation defined at construction time
  24321. */
  24322. overrideMaterialSideOrientation: Nullable<number>;
  24323. /**
  24324. * Gets the source mesh (the one used to clone this one from)
  24325. */
  24326. readonly source: Nullable<Mesh>;
  24327. /**
  24328. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24329. */
  24330. isUnIndexed: boolean;
  24331. /**
  24332. * @constructor
  24333. * @param name The value used by scene.getMeshByName() to do a lookup.
  24334. * @param scene The scene to add this mesh to.
  24335. * @param parent The parent of this mesh, if it has one
  24336. * @param source An optional Mesh from which geometry is shared, cloned.
  24337. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24338. * When false, achieved by calling a clone(), also passing False.
  24339. * This will make creation of children, recursive.
  24340. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24341. */
  24342. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24343. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24344. /**
  24345. * Gets the class name
  24346. * @returns the string "Mesh".
  24347. */
  24348. getClassName(): string;
  24349. /** @hidden */
  24350. readonly _isMesh: boolean;
  24351. /**
  24352. * Returns a description of this mesh
  24353. * @param fullDetails define if full details about this mesh must be used
  24354. * @returns a descriptive string representing this mesh
  24355. */
  24356. toString(fullDetails?: boolean): string;
  24357. /** @hidden */
  24358. _unBindEffect(): void;
  24359. /**
  24360. * Gets a boolean indicating if this mesh has LOD
  24361. */
  24362. readonly hasLODLevels: boolean;
  24363. /**
  24364. * Gets the list of MeshLODLevel associated with the current mesh
  24365. * @returns an array of MeshLODLevel
  24366. */
  24367. getLODLevels(): MeshLODLevel[];
  24368. private _sortLODLevels;
  24369. /**
  24370. * Add a mesh as LOD level triggered at the given distance.
  24371. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24372. * @param distance The distance from the center of the object to show this level
  24373. * @param mesh The mesh to be added as LOD level (can be null)
  24374. * @return This mesh (for chaining)
  24375. */
  24376. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24377. /**
  24378. * Returns the LOD level mesh at the passed distance or null if not found.
  24379. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24380. * @param distance The distance from the center of the object to show this level
  24381. * @returns a Mesh or `null`
  24382. */
  24383. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24384. /**
  24385. * Remove a mesh from the LOD array
  24386. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24387. * @param mesh defines the mesh to be removed
  24388. * @return This mesh (for chaining)
  24389. */
  24390. removeLODLevel(mesh: Mesh): Mesh;
  24391. /**
  24392. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24393. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24394. * @param camera defines the camera to use to compute distance
  24395. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24396. * @return This mesh (for chaining)
  24397. */
  24398. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24399. /**
  24400. * Gets the mesh internal Geometry object
  24401. */
  24402. readonly geometry: Nullable<Geometry>;
  24403. /**
  24404. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24405. * @returns the total number of vertices
  24406. */
  24407. getTotalVertices(): number;
  24408. /**
  24409. * Returns the content of an associated vertex buffer
  24410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24411. * - VertexBuffer.PositionKind
  24412. * - VertexBuffer.UVKind
  24413. * - VertexBuffer.UV2Kind
  24414. * - VertexBuffer.UV3Kind
  24415. * - VertexBuffer.UV4Kind
  24416. * - VertexBuffer.UV5Kind
  24417. * - VertexBuffer.UV6Kind
  24418. * - VertexBuffer.ColorKind
  24419. * - VertexBuffer.MatricesIndicesKind
  24420. * - VertexBuffer.MatricesIndicesExtraKind
  24421. * - VertexBuffer.MatricesWeightsKind
  24422. * - VertexBuffer.MatricesWeightsExtraKind
  24423. * @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
  24424. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24425. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24426. */
  24427. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24428. /**
  24429. * Returns the mesh VertexBuffer object from the requested `kind`
  24430. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24431. * - VertexBuffer.PositionKind
  24432. * - VertexBuffer.NormalKind
  24433. * - VertexBuffer.UVKind
  24434. * - VertexBuffer.UV2Kind
  24435. * - VertexBuffer.UV3Kind
  24436. * - VertexBuffer.UV4Kind
  24437. * - VertexBuffer.UV5Kind
  24438. * - VertexBuffer.UV6Kind
  24439. * - VertexBuffer.ColorKind
  24440. * - VertexBuffer.MatricesIndicesKind
  24441. * - VertexBuffer.MatricesIndicesExtraKind
  24442. * - VertexBuffer.MatricesWeightsKind
  24443. * - VertexBuffer.MatricesWeightsExtraKind
  24444. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24445. */
  24446. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24447. /**
  24448. * Tests if a specific vertex buffer is associated with this mesh
  24449. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24450. * - VertexBuffer.PositionKind
  24451. * - VertexBuffer.NormalKind
  24452. * - VertexBuffer.UVKind
  24453. * - VertexBuffer.UV2Kind
  24454. * - VertexBuffer.UV3Kind
  24455. * - VertexBuffer.UV4Kind
  24456. * - VertexBuffer.UV5Kind
  24457. * - VertexBuffer.UV6Kind
  24458. * - VertexBuffer.ColorKind
  24459. * - VertexBuffer.MatricesIndicesKind
  24460. * - VertexBuffer.MatricesIndicesExtraKind
  24461. * - VertexBuffer.MatricesWeightsKind
  24462. * - VertexBuffer.MatricesWeightsExtraKind
  24463. * @returns a boolean
  24464. */
  24465. isVerticesDataPresent(kind: string): boolean;
  24466. /**
  24467. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24468. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24469. * - VertexBuffer.PositionKind
  24470. * - VertexBuffer.UVKind
  24471. * - VertexBuffer.UV2Kind
  24472. * - VertexBuffer.UV3Kind
  24473. * - VertexBuffer.UV4Kind
  24474. * - VertexBuffer.UV5Kind
  24475. * - VertexBuffer.UV6Kind
  24476. * - VertexBuffer.ColorKind
  24477. * - VertexBuffer.MatricesIndicesKind
  24478. * - VertexBuffer.MatricesIndicesExtraKind
  24479. * - VertexBuffer.MatricesWeightsKind
  24480. * - VertexBuffer.MatricesWeightsExtraKind
  24481. * @returns a boolean
  24482. */
  24483. isVertexBufferUpdatable(kind: string): boolean;
  24484. /**
  24485. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24486. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24487. * - VertexBuffer.PositionKind
  24488. * - VertexBuffer.NormalKind
  24489. * - VertexBuffer.UVKind
  24490. * - VertexBuffer.UV2Kind
  24491. * - VertexBuffer.UV3Kind
  24492. * - VertexBuffer.UV4Kind
  24493. * - VertexBuffer.UV5Kind
  24494. * - VertexBuffer.UV6Kind
  24495. * - VertexBuffer.ColorKind
  24496. * - VertexBuffer.MatricesIndicesKind
  24497. * - VertexBuffer.MatricesIndicesExtraKind
  24498. * - VertexBuffer.MatricesWeightsKind
  24499. * - VertexBuffer.MatricesWeightsExtraKind
  24500. * @returns an array of strings
  24501. */
  24502. getVerticesDataKinds(): string[];
  24503. /**
  24504. * Returns a positive integer : the total number of indices in this mesh geometry.
  24505. * @returns the numner of indices or zero if the mesh has no geometry.
  24506. */
  24507. getTotalIndices(): number;
  24508. /**
  24509. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24510. * @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.
  24511. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24512. * @returns the indices array or an empty array if the mesh has no geometry
  24513. */
  24514. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24515. readonly isBlocked: boolean;
  24516. /**
  24517. * Determine if the current mesh is ready to be rendered
  24518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24519. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24520. * @returns true if all associated assets are ready (material, textures, shaders)
  24521. */
  24522. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24523. /**
  24524. * 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.
  24525. */
  24526. readonly areNormalsFrozen: boolean;
  24527. /**
  24528. * 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.
  24529. * @returns the current mesh
  24530. */
  24531. freezeNormals(): Mesh;
  24532. /**
  24533. * 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
  24534. * @returns the current mesh
  24535. */
  24536. unfreezeNormals(): Mesh;
  24537. /**
  24538. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24539. */
  24540. overridenInstanceCount: number;
  24541. /** @hidden */
  24542. _preActivate(): Mesh;
  24543. /** @hidden */
  24544. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24545. /** @hidden */
  24546. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24547. /**
  24548. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24549. * This means the mesh underlying bounding box and sphere are recomputed.
  24550. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24551. * @returns the current mesh
  24552. */
  24553. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24554. /** @hidden */
  24555. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24556. /**
  24557. * This function will subdivide the mesh into multiple submeshes
  24558. * @param count defines the expected number of submeshes
  24559. */
  24560. subdivide(count: number): void;
  24561. /**
  24562. * Copy a FloatArray into a specific associated vertex buffer
  24563. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24564. * - VertexBuffer.PositionKind
  24565. * - VertexBuffer.UVKind
  24566. * - VertexBuffer.UV2Kind
  24567. * - VertexBuffer.UV3Kind
  24568. * - VertexBuffer.UV4Kind
  24569. * - VertexBuffer.UV5Kind
  24570. * - VertexBuffer.UV6Kind
  24571. * - VertexBuffer.ColorKind
  24572. * - VertexBuffer.MatricesIndicesKind
  24573. * - VertexBuffer.MatricesIndicesExtraKind
  24574. * - VertexBuffer.MatricesWeightsKind
  24575. * - VertexBuffer.MatricesWeightsExtraKind
  24576. * @param data defines the data source
  24577. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24578. * @param stride defines the data stride size (can be null)
  24579. * @returns the current mesh
  24580. */
  24581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24582. /**
  24583. * Flags an associated vertex buffer as updatable
  24584. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24585. * - VertexBuffer.PositionKind
  24586. * - VertexBuffer.UVKind
  24587. * - VertexBuffer.UV2Kind
  24588. * - VertexBuffer.UV3Kind
  24589. * - VertexBuffer.UV4Kind
  24590. * - VertexBuffer.UV5Kind
  24591. * - VertexBuffer.UV6Kind
  24592. * - VertexBuffer.ColorKind
  24593. * - VertexBuffer.MatricesIndicesKind
  24594. * - VertexBuffer.MatricesIndicesExtraKind
  24595. * - VertexBuffer.MatricesWeightsKind
  24596. * - VertexBuffer.MatricesWeightsExtraKind
  24597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24598. */
  24599. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24600. /**
  24601. * Sets the mesh global Vertex Buffer
  24602. * @param buffer defines the buffer to use
  24603. * @returns the current mesh
  24604. */
  24605. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24606. /**
  24607. * Update a specific associated vertex buffer
  24608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24609. * - VertexBuffer.PositionKind
  24610. * - VertexBuffer.UVKind
  24611. * - VertexBuffer.UV2Kind
  24612. * - VertexBuffer.UV3Kind
  24613. * - VertexBuffer.UV4Kind
  24614. * - VertexBuffer.UV5Kind
  24615. * - VertexBuffer.UV6Kind
  24616. * - VertexBuffer.ColorKind
  24617. * - VertexBuffer.MatricesIndicesKind
  24618. * - VertexBuffer.MatricesIndicesExtraKind
  24619. * - VertexBuffer.MatricesWeightsKind
  24620. * - VertexBuffer.MatricesWeightsExtraKind
  24621. * @param data defines the data source
  24622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24623. * @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)
  24624. * @returns the current mesh
  24625. */
  24626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24627. /**
  24628. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24629. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24630. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24631. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24632. * @returns the current mesh
  24633. */
  24634. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24635. /**
  24636. * Creates a un-shared specific occurence of the geometry for the mesh.
  24637. * @returns the current mesh
  24638. */
  24639. makeGeometryUnique(): Mesh;
  24640. /**
  24641. * Set the index buffer of this mesh
  24642. * @param indices defines the source data
  24643. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24644. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24645. * @returns the current mesh
  24646. */
  24647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24648. /**
  24649. * Update the current index buffer
  24650. * @param indices defines the source data
  24651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24652. * @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)
  24653. * @returns the current mesh
  24654. */
  24655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24656. /**
  24657. * Invert the geometry to move from a right handed system to a left handed one.
  24658. * @returns the current mesh
  24659. */
  24660. toLeftHanded(): Mesh;
  24661. /** @hidden */
  24662. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24663. /** @hidden */
  24664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24665. /**
  24666. * Registers for this mesh a javascript function called just before the rendering process
  24667. * @param func defines the function to call before rendering this mesh
  24668. * @returns the current mesh
  24669. */
  24670. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24671. /**
  24672. * Disposes a previously registered javascript function called before the rendering
  24673. * @param func defines the function to remove
  24674. * @returns the current mesh
  24675. */
  24676. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24677. /**
  24678. * Registers for this mesh a javascript function called just after the rendering is complete
  24679. * @param func defines the function to call after rendering this mesh
  24680. * @returns the current mesh
  24681. */
  24682. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24683. /**
  24684. * Disposes a previously registered javascript function called after the rendering.
  24685. * @param func defines the function to remove
  24686. * @returns the current mesh
  24687. */
  24688. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24689. /** @hidden */
  24690. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24691. /** @hidden */
  24692. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24693. /** @hidden */
  24694. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24695. /** @hidden */
  24696. _rebuild(): void;
  24697. /** @hidden */
  24698. _freeze(): void;
  24699. /** @hidden */
  24700. _unFreeze(): void;
  24701. /**
  24702. * 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
  24703. * @param subMesh defines the subMesh to render
  24704. * @param enableAlphaMode defines if alpha mode can be changed
  24705. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24706. * @returns the current mesh
  24707. */
  24708. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24709. private _onBeforeDraw;
  24710. /**
  24711. * Renormalize the mesh and patch it up if there are no weights
  24712. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24713. * However in the case of zero weights then we set just a single influence to 1.
  24714. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24715. */
  24716. cleanMatrixWeights(): void;
  24717. private normalizeSkinFourWeights;
  24718. private normalizeSkinWeightsAndExtra;
  24719. /**
  24720. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24721. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24722. * the user know there was an issue with importing the mesh
  24723. * @returns a validation object with skinned, valid and report string
  24724. */
  24725. validateSkinning(): {
  24726. skinned: boolean;
  24727. valid: boolean;
  24728. report: string;
  24729. };
  24730. /** @hidden */
  24731. _checkDelayState(): Mesh;
  24732. private _queueLoad;
  24733. /**
  24734. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24735. * A mesh is in the frustum if its bounding box intersects the frustum
  24736. * @param frustumPlanes defines the frustum to test
  24737. * @returns true if the mesh is in the frustum planes
  24738. */
  24739. isInFrustum(frustumPlanes: Plane[]): boolean;
  24740. /**
  24741. * Sets the mesh material by the material or multiMaterial `id` property
  24742. * @param id is a string identifying the material or the multiMaterial
  24743. * @returns the current mesh
  24744. */
  24745. setMaterialByID(id: string): Mesh;
  24746. /**
  24747. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24748. * @returns an array of IAnimatable
  24749. */
  24750. getAnimatables(): IAnimatable[];
  24751. /**
  24752. * Modifies the mesh geometry according to the passed transformation matrix.
  24753. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24754. * The mesh normals are modified using the same transformation.
  24755. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24756. * @param transform defines the transform matrix to use
  24757. * @see http://doc.babylonjs.com/resources/baking_transformations
  24758. * @returns the current mesh
  24759. */
  24760. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24761. /**
  24762. * Modifies the mesh geometry according to its own current World Matrix.
  24763. * The mesh World Matrix is then reset.
  24764. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24765. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24766. * @see http://doc.babylonjs.com/resources/baking_transformations
  24767. * @returns the current mesh
  24768. */
  24769. bakeCurrentTransformIntoVertices(): Mesh;
  24770. /** @hidden */
  24771. readonly _positions: Nullable<Vector3[]>;
  24772. /** @hidden */
  24773. _resetPointsArrayCache(): Mesh;
  24774. /** @hidden */
  24775. _generatePointsArray(): boolean;
  24776. /**
  24777. * Returns a new Mesh object generated from the current mesh properties.
  24778. * This method must not get confused with createInstance()
  24779. * @param name is a string, the name given to the new mesh
  24780. * @param newParent can be any Node object (default `null`)
  24781. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24782. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24783. * @returns a new mesh
  24784. */
  24785. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24786. /**
  24787. * Releases resources associated with this mesh.
  24788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24790. */
  24791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24792. /**
  24793. * Modifies the mesh geometry according to a displacement map.
  24794. * 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.
  24795. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24796. * @param url is a string, the URL from the image file is to be downloaded.
  24797. * @param minHeight is the lower limit of the displacement.
  24798. * @param maxHeight is the upper limit of the displacement.
  24799. * @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.
  24800. * @param uvOffset is an optional vector2 used to offset UV.
  24801. * @param uvScale is an optional vector2 used to scale UV.
  24802. * @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.
  24803. * @returns the Mesh.
  24804. */
  24805. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24806. /**
  24807. * Modifies the mesh geometry according to a displacementMap buffer.
  24808. * 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.
  24809. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24810. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24811. * @param heightMapWidth is the width of the buffer image.
  24812. * @param heightMapHeight is the height of the buffer image.
  24813. * @param minHeight is the lower limit of the displacement.
  24814. * @param maxHeight is the upper limit of the displacement.
  24815. * @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.
  24816. * @param uvOffset is an optional vector2 used to offset UV.
  24817. * @param uvScale is an optional vector2 used to scale UV.
  24818. * @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.
  24819. * @returns the Mesh.
  24820. */
  24821. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24822. /**
  24823. * Modify the mesh to get a flat shading rendering.
  24824. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24825. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24826. * @returns current mesh
  24827. */
  24828. convertToFlatShadedMesh(): Mesh;
  24829. /**
  24830. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24831. * In other words, more vertices, no more indices and a single bigger VBO.
  24832. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24833. * @returns current mesh
  24834. */
  24835. convertToUnIndexedMesh(): Mesh;
  24836. /**
  24837. * Inverses facet orientations.
  24838. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24839. * @param flipNormals will also inverts the normals
  24840. * @returns current mesh
  24841. */
  24842. flipFaces(flipNormals?: boolean): Mesh;
  24843. /**
  24844. * Increase the number of facets and hence vertices in a mesh
  24845. * Vertex normals are interpolated from existing vertex normals
  24846. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24847. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24848. */
  24849. increaseVertices(numberPerEdge: number): void;
  24850. /**
  24851. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24852. * This will undo any application of covertToFlatShadedMesh
  24853. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24854. */
  24855. forceSharedVertices(): void;
  24856. /** @hidden */
  24857. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24858. /** @hidden */
  24859. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24860. /**
  24861. * Creates a new InstancedMesh object from the mesh model.
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24863. * @param name defines the name of the new instance
  24864. * @returns a new InstancedMesh
  24865. */
  24866. createInstance(name: string): InstancedMesh;
  24867. /**
  24868. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24869. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24870. * @returns the current mesh
  24871. */
  24872. synchronizeInstances(): Mesh;
  24873. /**
  24874. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24875. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24876. * This should be used together with the simplification to avoid disappearing triangles.
  24877. * @param successCallback an optional success callback to be called after the optimization finished.
  24878. * @returns the current mesh
  24879. */
  24880. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24881. /**
  24882. * Serialize current mesh
  24883. * @param serializationObject defines the object which will receive the serialization data
  24884. */
  24885. serialize(serializationObject: any): void;
  24886. /** @hidden */
  24887. _syncGeometryWithMorphTargetManager(): void;
  24888. /** @hidden */
  24889. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24890. /**
  24891. * Returns a new Mesh object parsed from the source provided.
  24892. * @param parsedMesh is the source
  24893. * @param scene defines the hosting scene
  24894. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24895. * @returns a new Mesh
  24896. */
  24897. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24898. /**
  24899. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24900. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24901. * @param name defines the name of the mesh to create
  24902. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24903. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24904. * @param closePath creates a seam between the first and the last points of each path of the path array
  24905. * @param offset is taken in account only if the `pathArray` is containing a single path
  24906. * @param scene defines the hosting scene
  24907. * @param updatable defines if the mesh must be flagged as updatable
  24908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24909. * @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)
  24910. * @returns a new Mesh
  24911. */
  24912. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24913. /**
  24914. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24915. * @param name defines the name of the mesh to create
  24916. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24917. * @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
  24918. * @param scene defines the hosting scene
  24919. * @param updatable defines if the mesh must be flagged as updatable
  24920. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24921. * @returns a new Mesh
  24922. */
  24923. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24924. /**
  24925. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24926. * @param name defines the name of the mesh to create
  24927. * @param size sets the size (float) of each box side (default 1)
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @returns a new Mesh
  24932. */
  24933. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24934. /**
  24935. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24936. * @param name defines the name of the mesh to create
  24937. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24938. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24945. /**
  24946. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24947. * @param name defines the name of the mesh to create
  24948. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24949. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24950. * @param scene defines the hosting scene
  24951. * @returns a new Mesh
  24952. */
  24953. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24954. /**
  24955. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24956. * @param name defines the name of the mesh to create
  24957. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24958. * @param diameterTop set the top cap diameter (floats, default 1)
  24959. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24960. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24961. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24962. * @param scene defines the hosting scene
  24963. * @param updatable defines if the mesh must be flagged as updatable
  24964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24965. * @returns a new Mesh
  24966. */
  24967. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24968. /**
  24969. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24970. * @param name defines the name of the mesh to create
  24971. * @param diameter sets the diameter size (float) of the torus (default 1)
  24972. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24973. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24974. * @param scene defines the hosting scene
  24975. * @param updatable defines if the mesh must be flagged as updatable
  24976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24977. * @returns a new Mesh
  24978. */
  24979. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24980. /**
  24981. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24982. * @param name defines the name of the mesh to create
  24983. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24984. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24985. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24986. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24987. * @param p the number of windings on X axis (positive integers, default 2)
  24988. * @param q the number of windings on Y axis (positive integers, default 3)
  24989. * @param scene defines the hosting scene
  24990. * @param updatable defines if the mesh must be flagged as updatable
  24991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24992. * @returns a new Mesh
  24993. */
  24994. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24995. /**
  24996. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24997. * @param name defines the name of the mesh to create
  24998. * @param points is an array successive Vector3
  24999. * @param scene defines the hosting scene
  25000. * @param updatable defines if the mesh must be flagged as updatable
  25001. * @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).
  25002. * @returns a new Mesh
  25003. */
  25004. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25005. /**
  25006. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25007. * @param name defines the name of the mesh to create
  25008. * @param points is an array successive Vector3
  25009. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25010. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25011. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25012. * @param scene defines the hosting scene
  25013. * @param updatable defines if the mesh must be flagged as updatable
  25014. * @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)
  25015. * @returns a new Mesh
  25016. */
  25017. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25018. /**
  25019. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25021. * 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.
  25022. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25023. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25024. * Remember you can only change the shape positions, not their number when updating a polygon.
  25025. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25026. * @param name defines the name of the mesh to create
  25027. * @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
  25028. * @param scene defines the hosting scene
  25029. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @param earcutInjection can be used to inject your own earcut reference
  25033. * @returns a new Mesh
  25034. */
  25035. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25036. /**
  25037. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25038. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25039. * @param name defines the name of the mesh to create
  25040. * @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
  25041. * @param depth defines the height of extrusion
  25042. * @param scene defines the hosting scene
  25043. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25044. * @param updatable defines if the mesh must be flagged as updatable
  25045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25046. * @param earcutInjection can be used to inject your own earcut reference
  25047. * @returns a new Mesh
  25048. */
  25049. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25050. /**
  25051. * Creates an extruded shape mesh.
  25052. * 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
  25053. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25054. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25055. * @param name defines the name of the mesh to create
  25056. * @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
  25057. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25058. * @param scale is the value to scale the shape
  25059. * @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
  25060. * @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
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @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)
  25065. * @returns a new Mesh
  25066. */
  25067. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25068. /**
  25069. * Creates an custom extruded shape mesh.
  25070. * The custom extrusion is a parametric shape.
  25071. * It has no predefined shape. Its final shape will depend on the input parameters.
  25072. * Please consider using the same method from the MeshBuilder class instead
  25073. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25074. * @param name defines the name of the mesh to create
  25075. * @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
  25076. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25077. * @param scaleFunction is a custom Javascript function called on each path point
  25078. * @param rotationFunction is a custom Javascript function called on each path point
  25079. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25080. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25081. * @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
  25082. * @param scene defines the hosting scene
  25083. * @param updatable defines if the mesh must be flagged as updatable
  25084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25085. * @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)
  25086. * @returns a new Mesh
  25087. */
  25088. 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;
  25089. /**
  25090. * Creates lathe mesh.
  25091. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25092. * Please consider using the same method from the MeshBuilder class instead
  25093. * @param name defines the name of the mesh to create
  25094. * @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
  25095. * @param radius is the radius value of the lathe
  25096. * @param tessellation is the side number of the lathe.
  25097. * @param scene defines the hosting scene
  25098. * @param updatable defines if the mesh must be flagged as updatable
  25099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25100. * @returns a new Mesh
  25101. */
  25102. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25103. /**
  25104. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25105. * @param name defines the name of the mesh to create
  25106. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25107. * @param scene defines the hosting scene
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25110. * @returns a new Mesh
  25111. */
  25112. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25113. /**
  25114. * Creates a ground mesh.
  25115. * Please consider using the same method from the MeshBuilder class instead
  25116. * @param name defines the name of the mesh to create
  25117. * @param width set the width of the ground
  25118. * @param height set the height of the ground
  25119. * @param subdivisions sets the number of subdivisions per side
  25120. * @param scene defines the hosting scene
  25121. * @param updatable defines if the mesh must be flagged as updatable
  25122. * @returns a new Mesh
  25123. */
  25124. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25125. /**
  25126. * Creates a tiled ground mesh.
  25127. * Please consider using the same method from the MeshBuilder class instead
  25128. * @param name defines the name of the mesh to create
  25129. * @param xmin set the ground minimum X coordinate
  25130. * @param zmin set the ground minimum Y coordinate
  25131. * @param xmax set the ground maximum X coordinate
  25132. * @param zmax set the ground maximum Z coordinate
  25133. * @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
  25134. * @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
  25135. * @param scene defines the hosting scene
  25136. * @param updatable defines if the mesh must be flagged as updatable
  25137. * @returns a new Mesh
  25138. */
  25139. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25140. w: number;
  25141. h: number;
  25142. }, precision: {
  25143. w: number;
  25144. h: number;
  25145. }, scene: Scene, updatable?: boolean): Mesh;
  25146. /**
  25147. * Creates a ground mesh from a height map.
  25148. * Please consider using the same method from the MeshBuilder class instead
  25149. * @see http://doc.babylonjs.com/babylon101/height_map
  25150. * @param name defines the name of the mesh to create
  25151. * @param url sets the URL of the height map image resource
  25152. * @param width set the ground width size
  25153. * @param height set the ground height size
  25154. * @param subdivisions sets the number of subdivision per side
  25155. * @param minHeight is the minimum altitude on the ground
  25156. * @param maxHeight is the maximum altitude on the ground
  25157. * @param scene defines the hosting scene
  25158. * @param updatable defines if the mesh must be flagged as updatable
  25159. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25160. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25161. * @returns a new Mesh
  25162. */
  25163. 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;
  25164. /**
  25165. * Creates a tube mesh.
  25166. * The tube is a parametric shape.
  25167. * It has no predefined shape. Its final shape will depend on the input parameters.
  25168. * Please consider using the same method from the MeshBuilder class instead
  25169. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25170. * @param name defines the name of the mesh to create
  25171. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25172. * @param radius sets the tube radius size
  25173. * @param tessellation is the number of sides on the tubular surface
  25174. * @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
  25175. * @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
  25176. * @param scene defines the hosting scene
  25177. * @param updatable defines if the mesh must be flagged as updatable
  25178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25179. * @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)
  25180. * @returns a new Mesh
  25181. */
  25182. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25183. (i: number, distance: number): number;
  25184. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25185. /**
  25186. * Creates a polyhedron mesh.
  25187. * Please consider using the same method from the MeshBuilder class instead.
  25188. * * 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
  25189. * * The parameter `size` (positive float, default 1) sets the polygon size
  25190. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25191. * * 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`
  25192. * * 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
  25193. * * 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)`)
  25194. * * 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
  25195. * * 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
  25196. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25197. * * If you create a double-sided mesh, you can choose what parts of 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
  25198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25199. * @param name defines the name of the mesh to create
  25200. * @param options defines the options used to create the mesh
  25201. * @param scene defines the hosting scene
  25202. * @returns a new Mesh
  25203. */
  25204. static CreatePolyhedron(name: string, options: {
  25205. type?: number;
  25206. size?: number;
  25207. sizeX?: number;
  25208. sizeY?: number;
  25209. sizeZ?: number;
  25210. custom?: any;
  25211. faceUV?: Vector4[];
  25212. faceColors?: Color4[];
  25213. updatable?: boolean;
  25214. sideOrientation?: number;
  25215. }, scene: Scene): Mesh;
  25216. /**
  25217. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25218. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25219. * * 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`)
  25220. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25221. * * 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
  25222. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25223. * * If you create a double-sided mesh, you can choose what parts of 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
  25224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25225. * @param name defines the name of the mesh
  25226. * @param options defines the options used to create the mesh
  25227. * @param scene defines the hosting scene
  25228. * @returns a new Mesh
  25229. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25230. */
  25231. static CreateIcoSphere(name: string, options: {
  25232. radius?: number;
  25233. flat?: boolean;
  25234. subdivisions?: number;
  25235. sideOrientation?: number;
  25236. updatable?: boolean;
  25237. }, scene: Scene): Mesh;
  25238. /**
  25239. * Creates a decal mesh.
  25240. * Please consider using the same method from the MeshBuilder class instead.
  25241. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25242. * @param name defines the name of the mesh
  25243. * @param sourceMesh defines the mesh receiving the decal
  25244. * @param position sets the position of the decal in world coordinates
  25245. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25246. * @param size sets the decal scaling
  25247. * @param angle sets the angle to rotate the decal
  25248. * @returns a new Mesh
  25249. */
  25250. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25251. /**
  25252. * Prepare internal position array for software CPU skinning
  25253. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25254. */
  25255. setPositionsForCPUSkinning(): Float32Array;
  25256. /**
  25257. * Prepare internal normal array for software CPU skinning
  25258. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25259. */
  25260. setNormalsForCPUSkinning(): Float32Array;
  25261. /**
  25262. * Updates the vertex buffer by applying transformation from the bones
  25263. * @param skeleton defines the skeleton to apply to current mesh
  25264. * @returns the current mesh
  25265. */
  25266. applySkeleton(skeleton: Skeleton): Mesh;
  25267. /**
  25268. * 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
  25269. * @param meshes defines the list of meshes to scan
  25270. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25271. */
  25272. static MinMax(meshes: AbstractMesh[]): {
  25273. min: Vector3;
  25274. max: Vector3;
  25275. };
  25276. /**
  25277. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25278. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25279. * @returns a vector3
  25280. */
  25281. static Center(meshesOrMinMaxVector: {
  25282. min: Vector3;
  25283. max: Vector3;
  25284. } | AbstractMesh[]): Vector3;
  25285. /**
  25286. * Merge the array of meshes into a single mesh for performance reasons.
  25287. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25288. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25289. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25290. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25291. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25292. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25293. * @returns a new mesh
  25294. */
  25295. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25296. /** @hidden */
  25297. addInstance(instance: InstancedMesh): void;
  25298. /** @hidden */
  25299. removeInstance(instance: InstancedMesh): void;
  25300. }
  25301. }
  25302. declare module "babylonjs/Cameras/camera" {
  25303. import { SmartArray } from "babylonjs/Misc/smartArray";
  25304. import { Observable } from "babylonjs/Misc/observable";
  25305. import { Nullable } from "babylonjs/types";
  25306. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25307. import { Scene } from "babylonjs/scene";
  25308. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25309. import { Node } from "babylonjs/node";
  25310. import { Mesh } from "babylonjs/Meshes/mesh";
  25311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25312. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25313. import { Viewport } from "babylonjs/Maths/math.viewport";
  25314. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25316. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25317. import { Ray } from "babylonjs/Culling/ray";
  25318. /**
  25319. * This is the base class of all the camera used in the application.
  25320. * @see http://doc.babylonjs.com/features/cameras
  25321. */
  25322. export class Camera extends Node {
  25323. /** @hidden */
  25324. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25325. /**
  25326. * This is the default projection mode used by the cameras.
  25327. * It helps recreating a feeling of perspective and better appreciate depth.
  25328. * This is the best way to simulate real life cameras.
  25329. */
  25330. static readonly PERSPECTIVE_CAMERA: number;
  25331. /**
  25332. * This helps creating camera with an orthographic mode.
  25333. * 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.
  25334. */
  25335. static readonly ORTHOGRAPHIC_CAMERA: number;
  25336. /**
  25337. * This is the default FOV mode for perspective cameras.
  25338. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25339. */
  25340. static readonly FOVMODE_VERTICAL_FIXED: number;
  25341. /**
  25342. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25343. */
  25344. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25345. /**
  25346. * This specifies ther is no need for a camera rig.
  25347. * Basically only one eye is rendered corresponding to the camera.
  25348. */
  25349. static readonly RIG_MODE_NONE: number;
  25350. /**
  25351. * Simulates a camera Rig with one blue eye and one red eye.
  25352. * This can be use with 3d blue and red glasses.
  25353. */
  25354. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25355. /**
  25356. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25357. */
  25358. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25359. /**
  25360. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25361. */
  25362. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25363. /**
  25364. * Defines that both eyes of the camera will be rendered over under each other.
  25365. */
  25366. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25367. /**
  25368. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25369. */
  25370. static readonly RIG_MODE_VR: number;
  25371. /**
  25372. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25373. */
  25374. static readonly RIG_MODE_WEBVR: number;
  25375. /**
  25376. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25377. */
  25378. static readonly RIG_MODE_CUSTOM: number;
  25379. /**
  25380. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25381. */
  25382. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25383. /**
  25384. * Define the input manager associated with the camera.
  25385. */
  25386. inputs: CameraInputsManager<Camera>;
  25387. /** @hidden */
  25388. _position: Vector3;
  25389. /**
  25390. * Define the current local position of the camera in the scene
  25391. */
  25392. position: Vector3;
  25393. /**
  25394. * The vector the camera should consider as up.
  25395. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25396. */
  25397. upVector: Vector3;
  25398. /**
  25399. * Define the current limit on the left side for an orthographic camera
  25400. * In scene unit
  25401. */
  25402. orthoLeft: Nullable<number>;
  25403. /**
  25404. * Define the current limit on the right side for an orthographic camera
  25405. * In scene unit
  25406. */
  25407. orthoRight: Nullable<number>;
  25408. /**
  25409. * Define the current limit on the bottom side for an orthographic camera
  25410. * In scene unit
  25411. */
  25412. orthoBottom: Nullable<number>;
  25413. /**
  25414. * Define the current limit on the top side for an orthographic camera
  25415. * In scene unit
  25416. */
  25417. orthoTop: Nullable<number>;
  25418. /**
  25419. * Field Of View is set in Radians. (default is 0.8)
  25420. */
  25421. fov: number;
  25422. /**
  25423. * Define the minimum distance the camera can see from.
  25424. * This is important to note that the depth buffer are not infinite and the closer it starts
  25425. * the more your scene might encounter depth fighting issue.
  25426. */
  25427. minZ: number;
  25428. /**
  25429. * Define the maximum distance the camera can see to.
  25430. * This is important to note that the depth buffer are not infinite and the further it end
  25431. * the more your scene might encounter depth fighting issue.
  25432. */
  25433. maxZ: number;
  25434. /**
  25435. * Define the default inertia of the camera.
  25436. * This helps giving a smooth feeling to the camera movement.
  25437. */
  25438. inertia: number;
  25439. /**
  25440. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25441. */
  25442. mode: number;
  25443. /**
  25444. * Define wether the camera is intermediate.
  25445. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25446. */
  25447. isIntermediate: boolean;
  25448. /**
  25449. * Define the viewport of the camera.
  25450. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25451. */
  25452. viewport: Viewport;
  25453. /**
  25454. * Restricts the camera to viewing objects with the same layerMask.
  25455. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25456. */
  25457. layerMask: number;
  25458. /**
  25459. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25460. */
  25461. fovMode: number;
  25462. /**
  25463. * Rig mode of the camera.
  25464. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25465. * This is normally controlled byt the camera themselves as internal use.
  25466. */
  25467. cameraRigMode: number;
  25468. /**
  25469. * Defines the distance between both "eyes" in case of a RIG
  25470. */
  25471. interaxialDistance: number;
  25472. /**
  25473. * Defines if stereoscopic rendering is done side by side or over under.
  25474. */
  25475. isStereoscopicSideBySide: boolean;
  25476. /**
  25477. * 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
  25478. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25479. * else in the scene. (Eg. security camera)
  25480. *
  25481. * 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)
  25482. */
  25483. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25484. /**
  25485. * When set, the camera will render to this render target instead of the default canvas
  25486. *
  25487. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25488. */
  25489. outputRenderTarget: Nullable<RenderTargetTexture>;
  25490. /**
  25491. * Observable triggered when the camera view matrix has changed.
  25492. */
  25493. onViewMatrixChangedObservable: Observable<Camera>;
  25494. /**
  25495. * Observable triggered when the camera Projection matrix has changed.
  25496. */
  25497. onProjectionMatrixChangedObservable: Observable<Camera>;
  25498. /**
  25499. * Observable triggered when the inputs have been processed.
  25500. */
  25501. onAfterCheckInputsObservable: Observable<Camera>;
  25502. /**
  25503. * Observable triggered when reset has been called and applied to the camera.
  25504. */
  25505. onRestoreStateObservable: Observable<Camera>;
  25506. /** @hidden */
  25507. _cameraRigParams: any;
  25508. /** @hidden */
  25509. _rigCameras: Camera[];
  25510. /** @hidden */
  25511. _rigPostProcess: Nullable<PostProcess>;
  25512. protected _webvrViewMatrix: Matrix;
  25513. /** @hidden */
  25514. _skipRendering: boolean;
  25515. /** @hidden */
  25516. _projectionMatrix: Matrix;
  25517. /** @hidden */
  25518. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25519. /** @hidden */
  25520. _activeMeshes: SmartArray<AbstractMesh>;
  25521. protected _globalPosition: Vector3;
  25522. /** @hidden */
  25523. _computedViewMatrix: Matrix;
  25524. private _doNotComputeProjectionMatrix;
  25525. private _transformMatrix;
  25526. private _frustumPlanes;
  25527. private _refreshFrustumPlanes;
  25528. private _storedFov;
  25529. private _stateStored;
  25530. /**
  25531. * Instantiates a new camera object.
  25532. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25533. * @see http://doc.babylonjs.com/features/cameras
  25534. * @param name Defines the name of the camera in the scene
  25535. * @param position Defines the position of the camera
  25536. * @param scene Defines the scene the camera belongs too
  25537. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25538. */
  25539. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25540. /**
  25541. * Store current camera state (fov, position, etc..)
  25542. * @returns the camera
  25543. */
  25544. storeState(): Camera;
  25545. /**
  25546. * Restores the camera state values if it has been stored. You must call storeState() first
  25547. */
  25548. protected _restoreStateValues(): boolean;
  25549. /**
  25550. * Restored camera state. You must call storeState() first.
  25551. * @returns true if restored and false otherwise
  25552. */
  25553. restoreState(): boolean;
  25554. /**
  25555. * Gets the class name of the camera.
  25556. * @returns the class name
  25557. */
  25558. getClassName(): string;
  25559. /** @hidden */
  25560. readonly _isCamera: boolean;
  25561. /**
  25562. * Gets a string representation of the camera useful for debug purpose.
  25563. * @param fullDetails Defines that a more verboe level of logging is required
  25564. * @returns the string representation
  25565. */
  25566. toString(fullDetails?: boolean): string;
  25567. /**
  25568. * Gets the current world space position of the camera.
  25569. */
  25570. readonly globalPosition: Vector3;
  25571. /**
  25572. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25573. * @returns the active meshe list
  25574. */
  25575. getActiveMeshes(): SmartArray<AbstractMesh>;
  25576. /**
  25577. * Check wether a mesh is part of the current active mesh list of the camera
  25578. * @param mesh Defines the mesh to check
  25579. * @returns true if active, false otherwise
  25580. */
  25581. isActiveMesh(mesh: Mesh): boolean;
  25582. /**
  25583. * Is this camera ready to be used/rendered
  25584. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25585. * @return true if the camera is ready
  25586. */
  25587. isReady(completeCheck?: boolean): boolean;
  25588. /** @hidden */
  25589. _initCache(): void;
  25590. /** @hidden */
  25591. _updateCache(ignoreParentClass?: boolean): void;
  25592. /** @hidden */
  25593. _isSynchronized(): boolean;
  25594. /** @hidden */
  25595. _isSynchronizedViewMatrix(): boolean;
  25596. /** @hidden */
  25597. _isSynchronizedProjectionMatrix(): boolean;
  25598. /**
  25599. * Attach the input controls to a specific dom element to get the input from.
  25600. * @param element Defines the element the controls should be listened from
  25601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25602. */
  25603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25604. /**
  25605. * Detach the current controls from the specified dom element.
  25606. * @param element Defines the element to stop listening the inputs from
  25607. */
  25608. detachControl(element: HTMLElement): void;
  25609. /**
  25610. * Update the camera state according to the different inputs gathered during the frame.
  25611. */
  25612. update(): void;
  25613. /** @hidden */
  25614. _checkInputs(): void;
  25615. /** @hidden */
  25616. readonly rigCameras: Camera[];
  25617. /**
  25618. * Gets the post process used by the rig cameras
  25619. */
  25620. readonly rigPostProcess: Nullable<PostProcess>;
  25621. /**
  25622. * Internal, gets the first post proces.
  25623. * @returns the first post process to be run on this camera.
  25624. */
  25625. _getFirstPostProcess(): Nullable<PostProcess>;
  25626. private _cascadePostProcessesToRigCams;
  25627. /**
  25628. * Attach a post process to the camera.
  25629. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25630. * @param postProcess The post process to attach to the camera
  25631. * @param insertAt The position of the post process in case several of them are in use in the scene
  25632. * @returns the position the post process has been inserted at
  25633. */
  25634. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25635. /**
  25636. * Detach a post process to the camera.
  25637. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25638. * @param postProcess The post process to detach from the camera
  25639. */
  25640. detachPostProcess(postProcess: PostProcess): void;
  25641. /**
  25642. * Gets the current world matrix of the camera
  25643. */
  25644. getWorldMatrix(): Matrix;
  25645. /** @hidden */
  25646. _getViewMatrix(): Matrix;
  25647. /**
  25648. * Gets the current view matrix of the camera.
  25649. * @param force forces the camera to recompute the matrix without looking at the cached state
  25650. * @returns the view matrix
  25651. */
  25652. getViewMatrix(force?: boolean): Matrix;
  25653. /**
  25654. * Freeze the projection matrix.
  25655. * It will prevent the cache check of the camera projection compute and can speed up perf
  25656. * if no parameter of the camera are meant to change
  25657. * @param projection Defines manually a projection if necessary
  25658. */
  25659. freezeProjectionMatrix(projection?: Matrix): void;
  25660. /**
  25661. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25662. */
  25663. unfreezeProjectionMatrix(): void;
  25664. /**
  25665. * Gets the current projection matrix of the camera.
  25666. * @param force forces the camera to recompute the matrix without looking at the cached state
  25667. * @returns the projection matrix
  25668. */
  25669. getProjectionMatrix(force?: boolean): Matrix;
  25670. /**
  25671. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25672. * @returns a Matrix
  25673. */
  25674. getTransformationMatrix(): Matrix;
  25675. private _updateFrustumPlanes;
  25676. /**
  25677. * Checks if a cullable object (mesh...) is in the camera frustum
  25678. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25679. * @param target The object to check
  25680. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25681. * @returns true if the object is in frustum otherwise false
  25682. */
  25683. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25684. /**
  25685. * Checks if a cullable object (mesh...) is in the camera frustum
  25686. * Unlike isInFrustum this cheks the full bounding box
  25687. * @param target The object to check
  25688. * @returns true if the object is in frustum otherwise false
  25689. */
  25690. isCompletelyInFrustum(target: ICullable): boolean;
  25691. /**
  25692. * Gets a ray in the forward direction from the camera.
  25693. * @param length Defines the length of the ray to create
  25694. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25695. * @param origin Defines the start point of the ray which defaults to the camera position
  25696. * @returns the forward ray
  25697. */
  25698. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25699. /**
  25700. * Releases resources associated with this node.
  25701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25703. */
  25704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25705. /** @hidden */
  25706. _isLeftCamera: boolean;
  25707. /**
  25708. * Gets the left camera of a rig setup in case of Rigged Camera
  25709. */
  25710. readonly isLeftCamera: boolean;
  25711. /** @hidden */
  25712. _isRightCamera: boolean;
  25713. /**
  25714. * Gets the right camera of a rig setup in case of Rigged Camera
  25715. */
  25716. readonly isRightCamera: boolean;
  25717. /**
  25718. * Gets the left camera of a rig setup in case of Rigged Camera
  25719. */
  25720. readonly leftCamera: Nullable<FreeCamera>;
  25721. /**
  25722. * Gets the right camera of a rig setup in case of Rigged Camera
  25723. */
  25724. readonly rightCamera: Nullable<FreeCamera>;
  25725. /**
  25726. * Gets the left camera target of a rig setup in case of Rigged Camera
  25727. * @returns the target position
  25728. */
  25729. getLeftTarget(): Nullable<Vector3>;
  25730. /**
  25731. * Gets the right camera target of a rig setup in case of Rigged Camera
  25732. * @returns the target position
  25733. */
  25734. getRightTarget(): Nullable<Vector3>;
  25735. /**
  25736. * @hidden
  25737. */
  25738. setCameraRigMode(mode: number, rigParams: any): void;
  25739. /** @hidden */
  25740. static _setStereoscopicRigMode(camera: Camera): void;
  25741. /** @hidden */
  25742. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25743. /** @hidden */
  25744. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25745. /** @hidden */
  25746. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25747. /** @hidden */
  25748. _getVRProjectionMatrix(): Matrix;
  25749. protected _updateCameraRotationMatrix(): void;
  25750. protected _updateWebVRCameraRotationMatrix(): void;
  25751. /**
  25752. * This function MUST be overwritten by the different WebVR cameras available.
  25753. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25754. * @hidden
  25755. */
  25756. _getWebVRProjectionMatrix(): Matrix;
  25757. /**
  25758. * This function MUST be overwritten by the different WebVR cameras available.
  25759. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25760. * @hidden
  25761. */
  25762. _getWebVRViewMatrix(): Matrix;
  25763. /** @hidden */
  25764. setCameraRigParameter(name: string, value: any): void;
  25765. /**
  25766. * needs to be overridden by children so sub has required properties to be copied
  25767. * @hidden
  25768. */
  25769. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25770. /**
  25771. * May need to be overridden by children
  25772. * @hidden
  25773. */
  25774. _updateRigCameras(): void;
  25775. /** @hidden */
  25776. _setupInputs(): void;
  25777. /**
  25778. * Serialiaze the camera setup to a json represention
  25779. * @returns the JSON representation
  25780. */
  25781. serialize(): any;
  25782. /**
  25783. * Clones the current camera.
  25784. * @param name The cloned camera name
  25785. * @returns the cloned camera
  25786. */
  25787. clone(name: string): Camera;
  25788. /**
  25789. * Gets the direction of the camera relative to a given local axis.
  25790. * @param localAxis Defines the reference axis to provide a relative direction.
  25791. * @return the direction
  25792. */
  25793. getDirection(localAxis: Vector3): Vector3;
  25794. /**
  25795. * Returns the current camera absolute rotation
  25796. */
  25797. readonly absoluteRotation: Quaternion;
  25798. /**
  25799. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25800. * @param localAxis Defines the reference axis to provide a relative direction.
  25801. * @param result Defines the vector to store the result in
  25802. */
  25803. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25804. /**
  25805. * Gets a camera constructor for a given camera type
  25806. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25807. * @param name The name of the camera the result will be able to instantiate
  25808. * @param scene The scene the result will construct the camera in
  25809. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25810. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25811. * @returns a factory method to construc the camera
  25812. */
  25813. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25814. /**
  25815. * Compute the world matrix of the camera.
  25816. * @returns the camera workd matrix
  25817. */
  25818. computeWorldMatrix(): Matrix;
  25819. /**
  25820. * Parse a JSON and creates the camera from the parsed information
  25821. * @param parsedCamera The JSON to parse
  25822. * @param scene The scene to instantiate the camera in
  25823. * @returns the newly constructed camera
  25824. */
  25825. static Parse(parsedCamera: any, scene: Scene): Camera;
  25826. }
  25827. }
  25828. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25829. import { Nullable } from "babylonjs/types";
  25830. import { Scene } from "babylonjs/scene";
  25831. import { Vector4 } from "babylonjs/Maths/math.vector";
  25832. import { Mesh } from "babylonjs/Meshes/mesh";
  25833. /**
  25834. * Class containing static functions to help procedurally build meshes
  25835. */
  25836. export class DiscBuilder {
  25837. /**
  25838. * Creates a plane polygonal mesh. By default, this is a disc
  25839. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25840. * * 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
  25841. * * 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
  25842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25845. * @param name defines the name of the mesh
  25846. * @param options defines the options used to create the mesh
  25847. * @param scene defines the hosting scene
  25848. * @returns the plane polygonal mesh
  25849. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25850. */
  25851. static CreateDisc(name: string, options: {
  25852. radius?: number;
  25853. tessellation?: number;
  25854. arc?: number;
  25855. updatable?: boolean;
  25856. sideOrientation?: number;
  25857. frontUVs?: Vector4;
  25858. backUVs?: Vector4;
  25859. }, scene?: Nullable<Scene>): Mesh;
  25860. }
  25861. }
  25862. declare module "babylonjs/Particles/solidParticleSystem" {
  25863. import { Vector3 } from "babylonjs/Maths/math.vector";
  25864. import { Mesh } from "babylonjs/Meshes/mesh";
  25865. import { Scene, IDisposable } from "babylonjs/scene";
  25866. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25867. /**
  25868. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25869. *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.
  25870. * The SPS is also a particle system. It provides some methods to manage the particles.
  25871. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25872. *
  25873. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25874. */
  25875. export class SolidParticleSystem implements IDisposable {
  25876. /**
  25877. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25878. * Example : var p = SPS.particles[i];
  25879. */
  25880. particles: SolidParticle[];
  25881. /**
  25882. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25883. */
  25884. nbParticles: number;
  25885. /**
  25886. * If the particles must ever face the camera (default false). Useful for planar particles.
  25887. */
  25888. billboard: boolean;
  25889. /**
  25890. * Recompute normals when adding a shape
  25891. */
  25892. recomputeNormals: boolean;
  25893. /**
  25894. * This a counter ofr your own usage. It's not set by any SPS functions.
  25895. */
  25896. counter: number;
  25897. /**
  25898. * The SPS name. This name is also given to the underlying mesh.
  25899. */
  25900. name: string;
  25901. /**
  25902. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25903. */
  25904. mesh: Mesh;
  25905. /**
  25906. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25907. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25908. */
  25909. vars: any;
  25910. /**
  25911. * This array is populated when the SPS is set as 'pickable'.
  25912. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25913. * Each element of this array is an object `{idx: int, faceId: int}`.
  25914. * `idx` is the picked particle index in the `SPS.particles` array
  25915. * `faceId` is the picked face index counted within this particle.
  25916. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25917. */
  25918. pickedParticles: {
  25919. idx: number;
  25920. faceId: number;
  25921. }[];
  25922. /**
  25923. * This array is populated when `enableDepthSort` is set to true.
  25924. * Each element of this array is an instance of the class DepthSortedParticle.
  25925. */
  25926. depthSortedParticles: DepthSortedParticle[];
  25927. /**
  25928. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25929. * @hidden
  25930. */
  25931. _bSphereOnly: boolean;
  25932. /**
  25933. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25934. * @hidden
  25935. */
  25936. _bSphereRadiusFactor: number;
  25937. private _scene;
  25938. private _positions;
  25939. private _indices;
  25940. private _normals;
  25941. private _colors;
  25942. private _uvs;
  25943. private _indices32;
  25944. private _positions32;
  25945. private _normals32;
  25946. private _fixedNormal32;
  25947. private _colors32;
  25948. private _uvs32;
  25949. private _index;
  25950. private _updatable;
  25951. private _pickable;
  25952. private _isVisibilityBoxLocked;
  25953. private _alwaysVisible;
  25954. private _depthSort;
  25955. private _expandable;
  25956. private _shapeCounter;
  25957. private _copy;
  25958. private _color;
  25959. private _computeParticleColor;
  25960. private _computeParticleTexture;
  25961. private _computeParticleRotation;
  25962. private _computeParticleVertex;
  25963. private _computeBoundingBox;
  25964. private _depthSortParticles;
  25965. private _camera;
  25966. private _mustUnrotateFixedNormals;
  25967. private _particlesIntersect;
  25968. private _needs32Bits;
  25969. /**
  25970. * Creates a SPS (Solid Particle System) object.
  25971. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25972. * @param scene (Scene) is the scene in which the SPS is added.
  25973. * @param options defines the options of the sps e.g.
  25974. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25975. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25976. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25977. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25978. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25979. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25980. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25981. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25982. */
  25983. constructor(name: string, scene: Scene, options?: {
  25984. updatable?: boolean;
  25985. isPickable?: boolean;
  25986. enableDepthSort?: boolean;
  25987. particleIntersection?: boolean;
  25988. boundingSphereOnly?: boolean;
  25989. bSphereRadiusFactor?: number;
  25990. expandable?: boolean;
  25991. });
  25992. /**
  25993. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25994. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25995. * @returns the created mesh
  25996. */
  25997. buildMesh(): Mesh;
  25998. /**
  25999. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26000. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26001. * Thus the particles generated from `digest()` have their property `position` set yet.
  26002. * @param mesh ( Mesh ) is the mesh to be digested
  26003. * @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
  26004. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26005. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26006. * @returns the current SPS
  26007. */
  26008. digest(mesh: Mesh, options?: {
  26009. facetNb?: number;
  26010. number?: number;
  26011. delta?: number;
  26012. }): SolidParticleSystem;
  26013. private _unrotateFixedNormals;
  26014. private _resetCopy;
  26015. private _meshBuilder;
  26016. private _posToShape;
  26017. private _uvsToShapeUV;
  26018. private _addParticle;
  26019. /**
  26020. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26021. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26022. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26023. * @param nb (positive integer) the number of particles to be created from this model
  26024. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26025. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26026. * @returns the number of shapes in the system
  26027. */
  26028. addShape(mesh: Mesh, nb: number, options?: {
  26029. positionFunction?: any;
  26030. vertexFunction?: any;
  26031. }): number;
  26032. private _rebuildParticle;
  26033. /**
  26034. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26035. * @returns the SPS.
  26036. */
  26037. rebuildMesh(): SolidParticleSystem;
  26038. /**
  26039. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26040. * This method calls `updateParticle()` for each particle of the SPS.
  26041. * For an animated SPS, it is usually called within the render loop.
  26042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26045. * @returns the SPS.
  26046. */
  26047. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26048. /**
  26049. * Disposes the SPS.
  26050. */
  26051. dispose(): void;
  26052. /**
  26053. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26054. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26055. * @returns the SPS.
  26056. */
  26057. refreshVisibleSize(): SolidParticleSystem;
  26058. /**
  26059. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26060. * @param size the size (float) of the visibility box
  26061. * note : this doesn't lock the SPS mesh bounding box.
  26062. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26063. */
  26064. setVisibilityBox(size: number): void;
  26065. /**
  26066. * Gets whether the SPS as always visible or not
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26068. */
  26069. /**
  26070. * Sets the SPS as always visible or not
  26071. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26072. */
  26073. isAlwaysVisible: boolean;
  26074. /**
  26075. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26077. */
  26078. /**
  26079. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26080. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26081. */
  26082. isVisibilityBoxLocked: boolean;
  26083. /**
  26084. * Tells to `setParticles()` to compute the particle rotations or not.
  26085. * Default value : true. The SPS is faster when it's set to false.
  26086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26087. */
  26088. /**
  26089. * Gets if `setParticles()` computes the particle rotations or not.
  26090. * Default value : true. The SPS is faster when it's set to false.
  26091. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26092. */
  26093. computeParticleRotation: boolean;
  26094. /**
  26095. * Tells to `setParticles()` to compute the particle colors or not.
  26096. * Default value : true. The SPS is faster when it's set to false.
  26097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26098. */
  26099. /**
  26100. * Gets if `setParticles()` computes the particle colors or not.
  26101. * Default value : true. The SPS is faster when it's set to false.
  26102. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26103. */
  26104. computeParticleColor: boolean;
  26105. /**
  26106. * Gets if `setParticles()` computes the particle textures or not.
  26107. * Default value : true. The SPS is faster when it's set to false.
  26108. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26109. */
  26110. computeParticleTexture: boolean;
  26111. /**
  26112. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26113. * Default value : false. The SPS is faster when it's set to false.
  26114. * Note : the particle custom vertex positions aren't stored values.
  26115. */
  26116. /**
  26117. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26118. * Default value : false. The SPS is faster when it's set to false.
  26119. * Note : the particle custom vertex positions aren't stored values.
  26120. */
  26121. computeParticleVertex: boolean;
  26122. /**
  26123. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26124. */
  26125. /**
  26126. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26127. */
  26128. computeBoundingBox: boolean;
  26129. /**
  26130. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26131. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26132. * Default : `true`
  26133. */
  26134. /**
  26135. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26136. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26137. * Default : `true`
  26138. */
  26139. depthSortParticles: boolean;
  26140. /**
  26141. * Gets if the SPS is created as expandable at construction time.
  26142. * Default : `false`
  26143. */
  26144. readonly expandable: boolean;
  26145. /**
  26146. * This function does nothing. It may be overwritten to set all the particle first values.
  26147. * The SPS doesn't call this function, you may have to call it by your own.
  26148. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26149. */
  26150. initParticles(): void;
  26151. /**
  26152. * This function does nothing. It may be overwritten to recycle a particle.
  26153. * The SPS doesn't call this function, you may have to call it by your own.
  26154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26155. * @param particle The particle to recycle
  26156. * @returns the recycled particle
  26157. */
  26158. recycleParticle(particle: SolidParticle): SolidParticle;
  26159. /**
  26160. * Updates a particle : this function should be overwritten by the user.
  26161. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26162. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26163. * @example : just set a particle position or velocity and recycle conditions
  26164. * @param particle The particle to update
  26165. * @returns the updated particle
  26166. */
  26167. updateParticle(particle: SolidParticle): SolidParticle;
  26168. /**
  26169. * Updates a vertex of a particle : it can be overwritten by the user.
  26170. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26171. * @param particle the current particle
  26172. * @param vertex the current index of the current particle
  26173. * @param pt the index of the current vertex in the particle shape
  26174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26175. * @example : just set a vertex particle position
  26176. * @returns the updated vertex
  26177. */
  26178. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26179. /**
  26180. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26181. * This does nothing and may be overwritten by the user.
  26182. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26183. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26184. * @param update the boolean update value actually passed to setParticles()
  26185. */
  26186. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26187. /**
  26188. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26189. * This will be passed three parameters.
  26190. * This does nothing and may be overwritten by the user.
  26191. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26192. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26193. * @param update the boolean update value actually passed to setParticles()
  26194. */
  26195. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26196. }
  26197. }
  26198. declare module "babylonjs/Particles/solidParticle" {
  26199. import { Nullable } from "babylonjs/types";
  26200. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26201. import { Color4 } from "babylonjs/Maths/math.color";
  26202. import { Mesh } from "babylonjs/Meshes/mesh";
  26203. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26204. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26205. import { Plane } from "babylonjs/Maths/math.plane";
  26206. /**
  26207. * Represents one particle of a solid particle system.
  26208. */
  26209. export class SolidParticle {
  26210. /**
  26211. * particle global index
  26212. */
  26213. idx: number;
  26214. /**
  26215. * The color of the particle
  26216. */
  26217. color: Nullable<Color4>;
  26218. /**
  26219. * The world space position of the particle.
  26220. */
  26221. position: Vector3;
  26222. /**
  26223. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26224. */
  26225. rotation: Vector3;
  26226. /**
  26227. * The world space rotation quaternion of the particle.
  26228. */
  26229. rotationQuaternion: Nullable<Quaternion>;
  26230. /**
  26231. * The scaling of the particle.
  26232. */
  26233. scaling: Vector3;
  26234. /**
  26235. * The uvs of the particle.
  26236. */
  26237. uvs: Vector4;
  26238. /**
  26239. * The current speed of the particle.
  26240. */
  26241. velocity: Vector3;
  26242. /**
  26243. * The pivot point in the particle local space.
  26244. */
  26245. pivot: Vector3;
  26246. /**
  26247. * Must the particle be translated from its pivot point in its local space ?
  26248. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26249. * Default : false
  26250. */
  26251. translateFromPivot: boolean;
  26252. /**
  26253. * Is the particle active or not ?
  26254. */
  26255. alive: boolean;
  26256. /**
  26257. * Is the particle visible or not ?
  26258. */
  26259. isVisible: boolean;
  26260. /**
  26261. * Index of this particle in the global "positions" array (Internal use)
  26262. * @hidden
  26263. */
  26264. _pos: number;
  26265. /**
  26266. * @hidden Index of this particle in the global "indices" array (Internal use)
  26267. */
  26268. _ind: number;
  26269. /**
  26270. * @hidden ModelShape of this particle (Internal use)
  26271. */
  26272. _model: ModelShape;
  26273. /**
  26274. * ModelShape id of this particle
  26275. */
  26276. shapeId: number;
  26277. /**
  26278. * Index of the particle in its shape id
  26279. */
  26280. idxInShape: number;
  26281. /**
  26282. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26283. */
  26284. _modelBoundingInfo: BoundingInfo;
  26285. /**
  26286. * @hidden Particle BoundingInfo object (Internal use)
  26287. */
  26288. _boundingInfo: BoundingInfo;
  26289. /**
  26290. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26291. */
  26292. _sps: SolidParticleSystem;
  26293. /**
  26294. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26295. */
  26296. _stillInvisible: boolean;
  26297. /**
  26298. * @hidden Last computed particle rotation matrix
  26299. */
  26300. _rotationMatrix: number[];
  26301. /**
  26302. * Parent particle Id, if any.
  26303. * Default null.
  26304. */
  26305. parentId: Nullable<number>;
  26306. /**
  26307. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26308. * The possible values are :
  26309. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26310. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26313. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26314. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26315. * */
  26316. cullingStrategy: number;
  26317. /**
  26318. * @hidden Internal global position in the SPS.
  26319. */
  26320. _globalPosition: Vector3;
  26321. /**
  26322. * Creates a Solid Particle object.
  26323. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26324. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26328. * @param shapeId (integer) is the model shape identifier in the SPS.
  26329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26330. * @param sps defines the sps it is associated to
  26331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26332. */
  26333. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26334. /**
  26335. * Legacy support, changed scale to scaling
  26336. */
  26337. /**
  26338. * Legacy support, changed scale to scaling
  26339. */
  26340. scale: Vector3;
  26341. /**
  26342. * Legacy support, changed quaternion to rotationQuaternion
  26343. */
  26344. /**
  26345. * Legacy support, changed quaternion to rotationQuaternion
  26346. */
  26347. quaternion: Nullable<Quaternion>;
  26348. /**
  26349. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26350. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26351. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26352. * @returns true if it intersects
  26353. */
  26354. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26355. /**
  26356. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26357. * A particle is in the frustum if its bounding box intersects the frustum
  26358. * @param frustumPlanes defines the frustum to test
  26359. * @returns true if the particle is in the frustum planes
  26360. */
  26361. isInFrustum(frustumPlanes: Plane[]): boolean;
  26362. /**
  26363. * get the rotation matrix of the particle
  26364. * @hidden
  26365. */
  26366. getRotationMatrix(m: Matrix): void;
  26367. }
  26368. /**
  26369. * Represents the shape of the model used by one particle of a solid particle system.
  26370. * SPS internal tool, don't use it manually.
  26371. */
  26372. export class ModelShape {
  26373. /**
  26374. * The shape id
  26375. * @hidden
  26376. */
  26377. shapeID: number;
  26378. /**
  26379. * flat array of model positions (internal use)
  26380. * @hidden
  26381. */
  26382. _shape: Vector3[];
  26383. /**
  26384. * flat array of model UVs (internal use)
  26385. * @hidden
  26386. */
  26387. _shapeUV: number[];
  26388. /**
  26389. * length of the shape in the model indices array (internal use)
  26390. * @hidden
  26391. */
  26392. _indicesLength: number;
  26393. /**
  26394. * Custom position function (internal use)
  26395. * @hidden
  26396. */
  26397. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26398. /**
  26399. * Custom vertex function (internal use)
  26400. * @hidden
  26401. */
  26402. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26403. /**
  26404. * 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.
  26405. * SPS internal tool, don't use it manually.
  26406. * @hidden
  26407. */
  26408. 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>);
  26409. }
  26410. /**
  26411. * Represents a Depth Sorted Particle in the solid particle system.
  26412. */
  26413. export class DepthSortedParticle {
  26414. /**
  26415. * Index of the particle in the "indices" array
  26416. */
  26417. ind: number;
  26418. /**
  26419. * Length of the particle shape in the "indices" array
  26420. */
  26421. indicesLength: number;
  26422. /**
  26423. * Squared distance from the particle to the camera
  26424. */
  26425. sqDistance: number;
  26426. }
  26427. }
  26428. declare module "babylonjs/Collisions/meshCollisionData" {
  26429. import { Collider } from "babylonjs/Collisions/collider";
  26430. import { Vector3 } from "babylonjs/Maths/math.vector";
  26431. import { Nullable } from "babylonjs/types";
  26432. import { Observer } from "babylonjs/Misc/observable";
  26433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26434. /**
  26435. * @hidden
  26436. */
  26437. export class _MeshCollisionData {
  26438. _checkCollisions: boolean;
  26439. _collisionMask: number;
  26440. _collisionGroup: number;
  26441. _collider: Nullable<Collider>;
  26442. _oldPositionForCollisions: Vector3;
  26443. _diffPositionForCollisions: Vector3;
  26444. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26445. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26446. }
  26447. }
  26448. declare module "babylonjs/Meshes/abstractMesh" {
  26449. import { Observable } from "babylonjs/Misc/observable";
  26450. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26451. import { Camera } from "babylonjs/Cameras/camera";
  26452. import { Scene, IDisposable } from "babylonjs/scene";
  26453. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26454. import { Node } from "babylonjs/node";
  26455. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26456. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26457. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26458. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26459. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26460. import { Material } from "babylonjs/Materials/material";
  26461. import { Light } from "babylonjs/Lights/light";
  26462. import { Skeleton } from "babylonjs/Bones/skeleton";
  26463. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26464. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26465. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26467. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26468. import { Plane } from "babylonjs/Maths/math.plane";
  26469. import { Ray } from "babylonjs/Culling/ray";
  26470. import { Collider } from "babylonjs/Collisions/collider";
  26471. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26472. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26473. /** @hidden */
  26474. class _FacetDataStorage {
  26475. facetPositions: Vector3[];
  26476. facetNormals: Vector3[];
  26477. facetPartitioning: number[][];
  26478. facetNb: number;
  26479. partitioningSubdivisions: number;
  26480. partitioningBBoxRatio: number;
  26481. facetDataEnabled: boolean;
  26482. facetParameters: any;
  26483. bbSize: Vector3;
  26484. subDiv: {
  26485. max: number;
  26486. X: number;
  26487. Y: number;
  26488. Z: number;
  26489. };
  26490. facetDepthSort: boolean;
  26491. facetDepthSortEnabled: boolean;
  26492. depthSortedIndices: IndicesArray;
  26493. depthSortedFacets: {
  26494. ind: number;
  26495. sqDistance: number;
  26496. }[];
  26497. facetDepthSortFunction: (f1: {
  26498. ind: number;
  26499. sqDistance: number;
  26500. }, f2: {
  26501. ind: number;
  26502. sqDistance: number;
  26503. }) => number;
  26504. facetDepthSortFrom: Vector3;
  26505. facetDepthSortOrigin: Vector3;
  26506. invertedMatrix: Matrix;
  26507. }
  26508. /**
  26509. * @hidden
  26510. **/
  26511. class _InternalAbstractMeshDataInfo {
  26512. _hasVertexAlpha: boolean;
  26513. _useVertexColors: boolean;
  26514. _numBoneInfluencers: number;
  26515. _applyFog: boolean;
  26516. _receiveShadows: boolean;
  26517. _facetData: _FacetDataStorage;
  26518. _visibility: number;
  26519. _skeleton: Nullable<Skeleton>;
  26520. _layerMask: number;
  26521. _computeBonesUsingShaders: boolean;
  26522. _isActive: boolean;
  26523. _onlyForInstances: boolean;
  26524. _isActiveIntermediate: boolean;
  26525. _onlyForInstancesIntermediate: boolean;
  26526. _actAsRegularMesh: boolean;
  26527. }
  26528. /**
  26529. * Class used to store all common mesh properties
  26530. */
  26531. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26532. /** No occlusion */
  26533. static OCCLUSION_TYPE_NONE: number;
  26534. /** Occlusion set to optimisitic */
  26535. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26536. /** Occlusion set to strict */
  26537. static OCCLUSION_TYPE_STRICT: number;
  26538. /** Use an accurante occlusion algorithm */
  26539. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26540. /** Use a conservative occlusion algorithm */
  26541. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26542. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26543. * Test order :
  26544. * Is the bounding sphere outside the frustum ?
  26545. * If not, are the bounding box vertices outside the frustum ?
  26546. * It not, then the cullable object is in the frustum.
  26547. */
  26548. static readonly CULLINGSTRATEGY_STANDARD: number;
  26549. /** Culling strategy : Bounding Sphere Only.
  26550. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26551. * It's also less accurate than the standard because some not visible objects can still be selected.
  26552. * Test : is the bounding sphere outside the frustum ?
  26553. * If not, then the cullable object is in the frustum.
  26554. */
  26555. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26556. /** Culling strategy : Optimistic Inclusion.
  26557. * This in an inclusion test first, then the standard exclusion test.
  26558. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26559. * 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.
  26560. * Anyway, it's as accurate as the standard strategy.
  26561. * Test :
  26562. * Is the cullable object bounding sphere center in the frustum ?
  26563. * If not, apply the default culling strategy.
  26564. */
  26565. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26566. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26567. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26568. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26569. * 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.
  26570. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26571. * Test :
  26572. * Is the cullable object bounding sphere center in the frustum ?
  26573. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26574. */
  26575. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26576. /**
  26577. * No billboard
  26578. */
  26579. static readonly BILLBOARDMODE_NONE: number;
  26580. /** Billboard on X axis */
  26581. static readonly BILLBOARDMODE_X: number;
  26582. /** Billboard on Y axis */
  26583. static readonly BILLBOARDMODE_Y: number;
  26584. /** Billboard on Z axis */
  26585. static readonly BILLBOARDMODE_Z: number;
  26586. /** Billboard on all axes */
  26587. static readonly BILLBOARDMODE_ALL: number;
  26588. /** Billboard on using position instead of orientation */
  26589. static readonly BILLBOARDMODE_USE_POSITION: number;
  26590. /** @hidden */
  26591. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26592. /**
  26593. * The culling strategy to use to check whether the mesh must be rendered or not.
  26594. * This value can be changed at any time and will be used on the next render mesh selection.
  26595. * The possible values are :
  26596. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26597. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26598. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26599. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26600. * Please read each static variable documentation to get details about the culling process.
  26601. * */
  26602. cullingStrategy: number;
  26603. /**
  26604. * Gets the number of facets in the mesh
  26605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26606. */
  26607. readonly facetNb: number;
  26608. /**
  26609. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26611. */
  26612. partitioningSubdivisions: number;
  26613. /**
  26614. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26615. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26617. */
  26618. partitioningBBoxRatio: number;
  26619. /**
  26620. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26621. * Works only for updatable meshes.
  26622. * Doesn't work with multi-materials
  26623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26624. */
  26625. mustDepthSortFacets: boolean;
  26626. /**
  26627. * The location (Vector3) where the facet depth sort must be computed from.
  26628. * By default, the active camera position.
  26629. * Used only when facet depth sort is enabled
  26630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26631. */
  26632. facetDepthSortFrom: Vector3;
  26633. /**
  26634. * gets a boolean indicating if facetData is enabled
  26635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26636. */
  26637. readonly isFacetDataEnabled: boolean;
  26638. /** @hidden */
  26639. _updateNonUniformScalingState(value: boolean): boolean;
  26640. /**
  26641. * An event triggered when this mesh collides with another one
  26642. */
  26643. onCollideObservable: Observable<AbstractMesh>;
  26644. /** Set a function to call when this mesh collides with another one */
  26645. onCollide: () => void;
  26646. /**
  26647. * An event triggered when the collision's position changes
  26648. */
  26649. onCollisionPositionChangeObservable: Observable<Vector3>;
  26650. /** Set a function to call when the collision's position changes */
  26651. onCollisionPositionChange: () => void;
  26652. /**
  26653. * An event triggered when material is changed
  26654. */
  26655. onMaterialChangedObservable: Observable<AbstractMesh>;
  26656. /**
  26657. * Gets or sets the orientation for POV movement & rotation
  26658. */
  26659. definedFacingForward: boolean;
  26660. /** @hidden */
  26661. _occlusionQuery: Nullable<WebGLQuery>;
  26662. /** @hidden */
  26663. _renderingGroup: Nullable<RenderingGroup>;
  26664. /**
  26665. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26666. */
  26667. /**
  26668. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26669. */
  26670. visibility: number;
  26671. /** Gets or sets the alpha index used to sort transparent meshes
  26672. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26673. */
  26674. alphaIndex: number;
  26675. /**
  26676. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26677. */
  26678. isVisible: boolean;
  26679. /**
  26680. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26681. */
  26682. isPickable: boolean;
  26683. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26684. showSubMeshesBoundingBox: boolean;
  26685. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26687. */
  26688. isBlocker: boolean;
  26689. /**
  26690. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26691. */
  26692. enablePointerMoveEvents: boolean;
  26693. /**
  26694. * Specifies the rendering group id for this mesh (0 by default)
  26695. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26696. */
  26697. renderingGroupId: number;
  26698. private _material;
  26699. /** Gets or sets current material */
  26700. material: Nullable<Material>;
  26701. /**
  26702. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26703. * @see http://doc.babylonjs.com/babylon101/shadows
  26704. */
  26705. receiveShadows: boolean;
  26706. /** Defines color to use when rendering outline */
  26707. outlineColor: Color3;
  26708. /** Define width to use when rendering outline */
  26709. outlineWidth: number;
  26710. /** Defines color to use when rendering overlay */
  26711. overlayColor: Color3;
  26712. /** Defines alpha to use when rendering overlay */
  26713. overlayAlpha: number;
  26714. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26715. hasVertexAlpha: boolean;
  26716. /** 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) */
  26717. useVertexColors: boolean;
  26718. /**
  26719. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26720. */
  26721. computeBonesUsingShaders: boolean;
  26722. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26723. numBoneInfluencers: number;
  26724. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26725. applyFog: boolean;
  26726. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26727. useOctreeForRenderingSelection: boolean;
  26728. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26729. useOctreeForPicking: boolean;
  26730. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26731. useOctreeForCollisions: boolean;
  26732. /**
  26733. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26734. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26735. */
  26736. layerMask: number;
  26737. /**
  26738. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26739. */
  26740. alwaysSelectAsActiveMesh: boolean;
  26741. /**
  26742. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26743. */
  26744. doNotSyncBoundingInfo: boolean;
  26745. /**
  26746. * Gets or sets the current action manager
  26747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26748. */
  26749. actionManager: Nullable<AbstractActionManager>;
  26750. private _meshCollisionData;
  26751. /**
  26752. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26753. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26754. */
  26755. ellipsoid: Vector3;
  26756. /**
  26757. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26758. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26759. */
  26760. ellipsoidOffset: Vector3;
  26761. /**
  26762. * Gets or sets a collision mask used to mask collisions (default is -1).
  26763. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26764. */
  26765. collisionMask: number;
  26766. /**
  26767. * Gets or sets the current collision group mask (-1 by default).
  26768. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26769. */
  26770. collisionGroup: number;
  26771. /**
  26772. * Defines edge width used when edgesRenderer is enabled
  26773. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26774. */
  26775. edgesWidth: number;
  26776. /**
  26777. * Defines edge color used when edgesRenderer is enabled
  26778. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26779. */
  26780. edgesColor: Color4;
  26781. /** @hidden */
  26782. _edgesRenderer: Nullable<IEdgesRenderer>;
  26783. /** @hidden */
  26784. _masterMesh: Nullable<AbstractMesh>;
  26785. /** @hidden */
  26786. _boundingInfo: Nullable<BoundingInfo>;
  26787. /** @hidden */
  26788. _renderId: number;
  26789. /**
  26790. * Gets or sets the list of subMeshes
  26791. * @see http://doc.babylonjs.com/how_to/multi_materials
  26792. */
  26793. subMeshes: SubMesh[];
  26794. /** @hidden */
  26795. _intersectionsInProgress: AbstractMesh[];
  26796. /** @hidden */
  26797. _unIndexed: boolean;
  26798. /** @hidden */
  26799. _lightSources: Light[];
  26800. /** Gets the list of lights affecting that mesh */
  26801. readonly lightSources: Light[];
  26802. /** @hidden */
  26803. readonly _positions: Nullable<Vector3[]>;
  26804. /** @hidden */
  26805. _waitingData: {
  26806. lods: Nullable<any>;
  26807. actions: Nullable<any>;
  26808. freezeWorldMatrix: Nullable<boolean>;
  26809. };
  26810. /** @hidden */
  26811. _bonesTransformMatrices: Nullable<Float32Array>;
  26812. /** @hidden */
  26813. _transformMatrixTexture: Nullable<RawTexture>;
  26814. /**
  26815. * Gets or sets a skeleton to apply skining transformations
  26816. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26817. */
  26818. skeleton: Nullable<Skeleton>;
  26819. /**
  26820. * An event triggered when the mesh is rebuilt.
  26821. */
  26822. onRebuildObservable: Observable<AbstractMesh>;
  26823. /**
  26824. * Creates a new AbstractMesh
  26825. * @param name defines the name of the mesh
  26826. * @param scene defines the hosting scene
  26827. */
  26828. constructor(name: string, scene?: Nullable<Scene>);
  26829. /**
  26830. * Returns the string "AbstractMesh"
  26831. * @returns "AbstractMesh"
  26832. */
  26833. getClassName(): string;
  26834. /**
  26835. * Gets a string representation of the current mesh
  26836. * @param fullDetails defines a boolean indicating if full details must be included
  26837. * @returns a string representation of the current mesh
  26838. */
  26839. toString(fullDetails?: boolean): string;
  26840. /**
  26841. * @hidden
  26842. */
  26843. protected _getEffectiveParent(): Nullable<Node>;
  26844. /** @hidden */
  26845. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26846. /** @hidden */
  26847. _rebuild(): void;
  26848. /** @hidden */
  26849. _resyncLightSources(): void;
  26850. /** @hidden */
  26851. _resyncLighSource(light: Light): void;
  26852. /** @hidden */
  26853. _unBindEffect(): void;
  26854. /** @hidden */
  26855. _removeLightSource(light: Light, dispose: boolean): void;
  26856. private _markSubMeshesAsDirty;
  26857. /** @hidden */
  26858. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26859. /** @hidden */
  26860. _markSubMeshesAsAttributesDirty(): void;
  26861. /** @hidden */
  26862. _markSubMeshesAsMiscDirty(): void;
  26863. /**
  26864. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26865. */
  26866. scaling: Vector3;
  26867. /**
  26868. * Returns true if the mesh is blocked. Implemented by child classes
  26869. */
  26870. readonly isBlocked: boolean;
  26871. /**
  26872. * Returns the mesh itself by default. Implemented by child classes
  26873. * @param camera defines the camera to use to pick the right LOD level
  26874. * @returns the currentAbstractMesh
  26875. */
  26876. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26877. /**
  26878. * Returns 0 by default. Implemented by child classes
  26879. * @returns an integer
  26880. */
  26881. getTotalVertices(): number;
  26882. /**
  26883. * Returns a positive integer : the total number of indices in this mesh geometry.
  26884. * @returns the numner of indices or zero if the mesh has no geometry.
  26885. */
  26886. getTotalIndices(): number;
  26887. /**
  26888. * Returns null by default. Implemented by child classes
  26889. * @returns null
  26890. */
  26891. getIndices(): Nullable<IndicesArray>;
  26892. /**
  26893. * Returns the array of the requested vertex data kind. Implemented by child classes
  26894. * @param kind defines the vertex data kind to use
  26895. * @returns null
  26896. */
  26897. getVerticesData(kind: string): Nullable<FloatArray>;
  26898. /**
  26899. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26900. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26901. * Note that a new underlying VertexBuffer object is created each call.
  26902. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26903. * @param kind defines vertex data kind:
  26904. * * VertexBuffer.PositionKind
  26905. * * VertexBuffer.UVKind
  26906. * * VertexBuffer.UV2Kind
  26907. * * VertexBuffer.UV3Kind
  26908. * * VertexBuffer.UV4Kind
  26909. * * VertexBuffer.UV5Kind
  26910. * * VertexBuffer.UV6Kind
  26911. * * VertexBuffer.ColorKind
  26912. * * VertexBuffer.MatricesIndicesKind
  26913. * * VertexBuffer.MatricesIndicesExtraKind
  26914. * * VertexBuffer.MatricesWeightsKind
  26915. * * VertexBuffer.MatricesWeightsExtraKind
  26916. * @param data defines the data source
  26917. * @param updatable defines if the data must be flagged as updatable (or static)
  26918. * @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
  26919. * @returns the current mesh
  26920. */
  26921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26922. /**
  26923. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26924. * If the mesh has no geometry, it is simply returned as it is.
  26925. * @param kind defines vertex data kind:
  26926. * * VertexBuffer.PositionKind
  26927. * * VertexBuffer.UVKind
  26928. * * VertexBuffer.UV2Kind
  26929. * * VertexBuffer.UV3Kind
  26930. * * VertexBuffer.UV4Kind
  26931. * * VertexBuffer.UV5Kind
  26932. * * VertexBuffer.UV6Kind
  26933. * * VertexBuffer.ColorKind
  26934. * * VertexBuffer.MatricesIndicesKind
  26935. * * VertexBuffer.MatricesIndicesExtraKind
  26936. * * VertexBuffer.MatricesWeightsKind
  26937. * * VertexBuffer.MatricesWeightsExtraKind
  26938. * @param data defines the data source
  26939. * @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
  26940. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26941. * @returns the current mesh
  26942. */
  26943. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26944. /**
  26945. * Sets the mesh indices,
  26946. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26947. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26948. * @param totalVertices Defines the total number of vertices
  26949. * @returns the current mesh
  26950. */
  26951. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26952. /**
  26953. * Gets a boolean indicating if specific vertex data is present
  26954. * @param kind defines the vertex data kind to use
  26955. * @returns true is data kind is present
  26956. */
  26957. isVerticesDataPresent(kind: string): boolean;
  26958. /**
  26959. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26960. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26961. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26962. * @returns a BoundingInfo
  26963. */
  26964. getBoundingInfo(): BoundingInfo;
  26965. /**
  26966. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26967. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26968. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26969. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26970. * @returns the current mesh
  26971. */
  26972. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26973. /**
  26974. * Overwrite the current bounding info
  26975. * @param boundingInfo defines the new bounding info
  26976. * @returns the current mesh
  26977. */
  26978. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26979. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26980. readonly useBones: boolean;
  26981. /** @hidden */
  26982. _preActivate(): void;
  26983. /** @hidden */
  26984. _preActivateForIntermediateRendering(renderId: number): void;
  26985. /** @hidden */
  26986. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26987. /** @hidden */
  26988. _postActivate(): void;
  26989. /** @hidden */
  26990. _freeze(): void;
  26991. /** @hidden */
  26992. _unFreeze(): void;
  26993. /**
  26994. * Gets the current world matrix
  26995. * @returns a Matrix
  26996. */
  26997. getWorldMatrix(): Matrix;
  26998. /** @hidden */
  26999. _getWorldMatrixDeterminant(): number;
  27000. /**
  27001. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27002. */
  27003. readonly isAnInstance: boolean;
  27004. /**
  27005. * Gets a boolean indicating if this mesh has instances
  27006. */
  27007. readonly hasInstances: boolean;
  27008. /**
  27009. * Perform relative position change from the point of view of behind the front of the mesh.
  27010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27011. * Supports definition of mesh facing forward or backward
  27012. * @param amountRight defines the distance on the right axis
  27013. * @param amountUp defines the distance on the up axis
  27014. * @param amountForward defines the distance on the forward axis
  27015. * @returns the current mesh
  27016. */
  27017. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27018. /**
  27019. * Calculate relative position change from the point of view of behind the front of the mesh.
  27020. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27021. * Supports definition of mesh facing forward or backward
  27022. * @param amountRight defines the distance on the right axis
  27023. * @param amountUp defines the distance on the up axis
  27024. * @param amountForward defines the distance on the forward axis
  27025. * @returns the new displacement vector
  27026. */
  27027. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27028. /**
  27029. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27030. * Supports definition of mesh facing forward or backward
  27031. * @param flipBack defines the flip
  27032. * @param twirlClockwise defines the twirl
  27033. * @param tiltRight defines the tilt
  27034. * @returns the current mesh
  27035. */
  27036. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27037. /**
  27038. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27039. * Supports definition of mesh facing forward or backward.
  27040. * @param flipBack defines the flip
  27041. * @param twirlClockwise defines the twirl
  27042. * @param tiltRight defines the tilt
  27043. * @returns the new rotation vector
  27044. */
  27045. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27046. /**
  27047. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27048. * This means the mesh underlying bounding box and sphere are recomputed.
  27049. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27050. * @returns the current mesh
  27051. */
  27052. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27053. /** @hidden */
  27054. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27055. /** @hidden */
  27056. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27057. /** @hidden */
  27058. _updateBoundingInfo(): AbstractMesh;
  27059. /** @hidden */
  27060. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27061. /** @hidden */
  27062. protected _afterComputeWorldMatrix(): void;
  27063. /** @hidden */
  27064. readonly _effectiveMesh: AbstractMesh;
  27065. /**
  27066. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27067. * A mesh is in the frustum if its bounding box intersects the frustum
  27068. * @param frustumPlanes defines the frustum to test
  27069. * @returns true if the mesh is in the frustum planes
  27070. */
  27071. isInFrustum(frustumPlanes: Plane[]): boolean;
  27072. /**
  27073. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27074. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27075. * @param frustumPlanes defines the frustum to test
  27076. * @returns true if the mesh is completely in the frustum planes
  27077. */
  27078. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27079. /**
  27080. * True if the mesh intersects another mesh or a SolidParticle object
  27081. * @param mesh defines a target mesh or SolidParticle to test
  27082. * @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)
  27083. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27084. * @returns true if there is an intersection
  27085. */
  27086. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27087. /**
  27088. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27089. * @param point defines the point to test
  27090. * @returns true if there is an intersection
  27091. */
  27092. intersectsPoint(point: Vector3): boolean;
  27093. /**
  27094. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27095. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27096. */
  27097. checkCollisions: boolean;
  27098. /**
  27099. * Gets Collider object used to compute collisions (not physics)
  27100. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27101. */
  27102. readonly collider: Nullable<Collider>;
  27103. /**
  27104. * Move the mesh using collision engine
  27105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27106. * @param displacement defines the requested displacement vector
  27107. * @returns the current mesh
  27108. */
  27109. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27110. private _onCollisionPositionChange;
  27111. /** @hidden */
  27112. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27113. /** @hidden */
  27114. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27115. /** @hidden */
  27116. _checkCollision(collider: Collider): AbstractMesh;
  27117. /** @hidden */
  27118. _generatePointsArray(): boolean;
  27119. /**
  27120. * Checks if the passed Ray intersects with the mesh
  27121. * @param ray defines the ray to use
  27122. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27123. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27124. * @returns the picking info
  27125. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27126. */
  27127. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27128. /**
  27129. * Clones the current mesh
  27130. * @param name defines the mesh name
  27131. * @param newParent defines the new mesh parent
  27132. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27133. * @returns the new mesh
  27134. */
  27135. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27136. /**
  27137. * Disposes all the submeshes of the current meshnp
  27138. * @returns the current mesh
  27139. */
  27140. releaseSubMeshes(): AbstractMesh;
  27141. /**
  27142. * Releases resources associated with this abstract mesh.
  27143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27145. */
  27146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27147. /**
  27148. * Adds the passed mesh as a child to the current mesh
  27149. * @param mesh defines the child mesh
  27150. * @returns the current mesh
  27151. */
  27152. addChild(mesh: AbstractMesh): AbstractMesh;
  27153. /**
  27154. * Removes the passed mesh from the current mesh children list
  27155. * @param mesh defines the child mesh
  27156. * @returns the current mesh
  27157. */
  27158. removeChild(mesh: AbstractMesh): AbstractMesh;
  27159. /** @hidden */
  27160. private _initFacetData;
  27161. /**
  27162. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27163. * This method can be called within the render loop.
  27164. * 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
  27165. * @returns the current mesh
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27167. */
  27168. updateFacetData(): AbstractMesh;
  27169. /**
  27170. * Returns the facetLocalNormals array.
  27171. * The normals are expressed in the mesh local spac
  27172. * @returns an array of Vector3
  27173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27174. */
  27175. getFacetLocalNormals(): Vector3[];
  27176. /**
  27177. * Returns the facetLocalPositions array.
  27178. * The facet positions are expressed in the mesh local space
  27179. * @returns an array of Vector3
  27180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27181. */
  27182. getFacetLocalPositions(): Vector3[];
  27183. /**
  27184. * Returns the facetLocalPartioning array
  27185. * @returns an array of array of numbers
  27186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27187. */
  27188. getFacetLocalPartitioning(): number[][];
  27189. /**
  27190. * Returns the i-th facet position in the world system.
  27191. * This method allocates a new Vector3 per call
  27192. * @param i defines the facet index
  27193. * @returns a new Vector3
  27194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27195. */
  27196. getFacetPosition(i: number): Vector3;
  27197. /**
  27198. * Sets the reference Vector3 with the i-th facet position in the world system
  27199. * @param i defines the facet index
  27200. * @param ref defines the target vector
  27201. * @returns the current mesh
  27202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27203. */
  27204. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27205. /**
  27206. * Returns the i-th facet normal in the world system.
  27207. * This method allocates a new Vector3 per call
  27208. * @param i defines the facet index
  27209. * @returns a new Vector3
  27210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27211. */
  27212. getFacetNormal(i: number): Vector3;
  27213. /**
  27214. * Sets the reference Vector3 with the i-th facet normal in the world system
  27215. * @param i defines the facet index
  27216. * @param ref defines the target vector
  27217. * @returns the current mesh
  27218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27219. */
  27220. getFacetNormalToRef(i: number, ref: Vector3): this;
  27221. /**
  27222. * 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)
  27223. * @param x defines x coordinate
  27224. * @param y defines y coordinate
  27225. * @param z defines z coordinate
  27226. * @returns the array of facet indexes
  27227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27228. */
  27229. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27230. /**
  27231. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27232. * @param projected sets as the (x,y,z) world projection on the facet
  27233. * @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
  27234. * @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
  27235. * @param x defines x coordinate
  27236. * @param y defines y coordinate
  27237. * @param z defines z coordinate
  27238. * @returns the face index if found (or null instead)
  27239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27240. */
  27241. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27242. /**
  27243. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27244. * @param projected sets as the (x,y,z) local projection on the facet
  27245. * @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
  27246. * @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
  27247. * @param x defines x coordinate
  27248. * @param y defines y coordinate
  27249. * @param z defines z coordinate
  27250. * @returns the face index if found (or null instead)
  27251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27252. */
  27253. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27254. /**
  27255. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27256. * @returns the parameters
  27257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27258. */
  27259. getFacetDataParameters(): any;
  27260. /**
  27261. * Disables the feature FacetData and frees the related memory
  27262. * @returns the current mesh
  27263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27264. */
  27265. disableFacetData(): AbstractMesh;
  27266. /**
  27267. * Updates the AbstractMesh indices array
  27268. * @param indices defines the data source
  27269. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27270. * @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)
  27271. * @returns the current mesh
  27272. */
  27273. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27274. /**
  27275. * Creates new normals data for the mesh
  27276. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27277. * @returns the current mesh
  27278. */
  27279. createNormals(updatable: boolean): AbstractMesh;
  27280. /**
  27281. * Align the mesh with a normal
  27282. * @param normal defines the normal to use
  27283. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27284. * @returns the current mesh
  27285. */
  27286. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27287. /** @hidden */
  27288. _checkOcclusionQuery(): boolean;
  27289. /**
  27290. * Disables the mesh edge rendering mode
  27291. * @returns the currentAbstractMesh
  27292. */
  27293. disableEdgesRendering(): AbstractMesh;
  27294. /**
  27295. * Enables the edge rendering mode on the mesh.
  27296. * This mode makes the mesh edges visible
  27297. * @param epsilon defines the maximal distance between two angles to detect a face
  27298. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27299. * @returns the currentAbstractMesh
  27300. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27301. */
  27302. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27303. }
  27304. }
  27305. declare module "babylonjs/Actions/actionEvent" {
  27306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27307. import { Nullable } from "babylonjs/types";
  27308. import { Sprite } from "babylonjs/Sprites/sprite";
  27309. import { Scene } from "babylonjs/scene";
  27310. import { Vector2 } from "babylonjs/Maths/math.vector";
  27311. /**
  27312. * Interface used to define ActionEvent
  27313. */
  27314. export interface IActionEvent {
  27315. /** The mesh or sprite that triggered the action */
  27316. source: any;
  27317. /** The X mouse cursor position at the time of the event */
  27318. pointerX: number;
  27319. /** The Y mouse cursor position at the time of the event */
  27320. pointerY: number;
  27321. /** The mesh that is currently pointed at (can be null) */
  27322. meshUnderPointer: Nullable<AbstractMesh>;
  27323. /** the original (browser) event that triggered the ActionEvent */
  27324. sourceEvent?: any;
  27325. /** additional data for the event */
  27326. additionalData?: any;
  27327. }
  27328. /**
  27329. * ActionEvent is the event being sent when an action is triggered.
  27330. */
  27331. export class ActionEvent implements IActionEvent {
  27332. /** The mesh or sprite that triggered the action */
  27333. source: any;
  27334. /** The X mouse cursor position at the time of the event */
  27335. pointerX: number;
  27336. /** The Y mouse cursor position at the time of the event */
  27337. pointerY: number;
  27338. /** The mesh that is currently pointed at (can be null) */
  27339. meshUnderPointer: Nullable<AbstractMesh>;
  27340. /** the original (browser) event that triggered the ActionEvent */
  27341. sourceEvent?: any;
  27342. /** additional data for the event */
  27343. additionalData?: any;
  27344. /**
  27345. * Creates a new ActionEvent
  27346. * @param source The mesh or sprite that triggered the action
  27347. * @param pointerX The X mouse cursor position at the time of the event
  27348. * @param pointerY The Y mouse cursor position at the time of the event
  27349. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27350. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27351. * @param additionalData additional data for the event
  27352. */
  27353. constructor(
  27354. /** The mesh or sprite that triggered the action */
  27355. source: any,
  27356. /** The X mouse cursor position at the time of the event */
  27357. pointerX: number,
  27358. /** The Y mouse cursor position at the time of the event */
  27359. pointerY: number,
  27360. /** The mesh that is currently pointed at (can be null) */
  27361. meshUnderPointer: Nullable<AbstractMesh>,
  27362. /** the original (browser) event that triggered the ActionEvent */
  27363. sourceEvent?: any,
  27364. /** additional data for the event */
  27365. additionalData?: any);
  27366. /**
  27367. * Helper function to auto-create an ActionEvent from a source mesh.
  27368. * @param source The source mesh that triggered the event
  27369. * @param evt The original (browser) event
  27370. * @param additionalData additional data for the event
  27371. * @returns the new ActionEvent
  27372. */
  27373. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27374. /**
  27375. * Helper function to auto-create an ActionEvent from a source sprite
  27376. * @param source The source sprite that triggered the event
  27377. * @param scene Scene associated with the sprite
  27378. * @param evt The original (browser) event
  27379. * @param additionalData additional data for the event
  27380. * @returns the new ActionEvent
  27381. */
  27382. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27383. /**
  27384. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27385. * @param scene the scene where the event occurred
  27386. * @param evt The original (browser) event
  27387. * @returns the new ActionEvent
  27388. */
  27389. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27390. /**
  27391. * Helper function to auto-create an ActionEvent from a primitive
  27392. * @param prim defines the target primitive
  27393. * @param pointerPos defines the pointer position
  27394. * @param evt The original (browser) event
  27395. * @param additionalData additional data for the event
  27396. * @returns the new ActionEvent
  27397. */
  27398. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27399. }
  27400. }
  27401. declare module "babylonjs/Actions/abstractActionManager" {
  27402. import { IDisposable } from "babylonjs/scene";
  27403. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27404. import { IAction } from "babylonjs/Actions/action";
  27405. import { Nullable } from "babylonjs/types";
  27406. /**
  27407. * Abstract class used to decouple action Manager from scene and meshes.
  27408. * Do not instantiate.
  27409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27410. */
  27411. export abstract class AbstractActionManager implements IDisposable {
  27412. /** Gets the list of active triggers */
  27413. static Triggers: {
  27414. [key: string]: number;
  27415. };
  27416. /** Gets the cursor to use when hovering items */
  27417. hoverCursor: string;
  27418. /** Gets the list of actions */
  27419. actions: IAction[];
  27420. /**
  27421. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27422. */
  27423. isRecursive: boolean;
  27424. /**
  27425. * Releases all associated resources
  27426. */
  27427. abstract dispose(): void;
  27428. /**
  27429. * Does this action manager has pointer triggers
  27430. */
  27431. abstract readonly hasPointerTriggers: boolean;
  27432. /**
  27433. * Does this action manager has pick triggers
  27434. */
  27435. abstract readonly hasPickTriggers: boolean;
  27436. /**
  27437. * Process a specific trigger
  27438. * @param trigger defines the trigger to process
  27439. * @param evt defines the event details to be processed
  27440. */
  27441. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27442. /**
  27443. * Does this action manager handles actions of any of the given triggers
  27444. * @param triggers defines the triggers to be tested
  27445. * @return a boolean indicating whether one (or more) of the triggers is handled
  27446. */
  27447. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27448. /**
  27449. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27450. * speed.
  27451. * @param triggerA defines the trigger to be tested
  27452. * @param triggerB defines the trigger to be tested
  27453. * @return a boolean indicating whether one (or more) of the triggers is handled
  27454. */
  27455. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27456. /**
  27457. * Does this action manager handles actions of a given trigger
  27458. * @param trigger defines the trigger to be tested
  27459. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27460. * @return whether the trigger is handled
  27461. */
  27462. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27463. /**
  27464. * Serialize this manager to a JSON object
  27465. * @param name defines the property name to store this manager
  27466. * @returns a JSON representation of this manager
  27467. */
  27468. abstract serialize(name: string): any;
  27469. /**
  27470. * Registers an action to this action manager
  27471. * @param action defines the action to be registered
  27472. * @return the action amended (prepared) after registration
  27473. */
  27474. abstract registerAction(action: IAction): Nullable<IAction>;
  27475. /**
  27476. * Unregisters an action to this action manager
  27477. * @param action defines the action to be unregistered
  27478. * @return a boolean indicating whether the action has been unregistered
  27479. */
  27480. abstract unregisterAction(action: IAction): Boolean;
  27481. /**
  27482. * Does exist one action manager with at least one trigger
  27483. **/
  27484. static readonly HasTriggers: boolean;
  27485. /**
  27486. * Does exist one action manager with at least one pick trigger
  27487. **/
  27488. static readonly HasPickTriggers: boolean;
  27489. /**
  27490. * Does exist one action manager that handles actions of a given trigger
  27491. * @param trigger defines the trigger to be tested
  27492. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27493. **/
  27494. static HasSpecificTrigger(trigger: number): boolean;
  27495. }
  27496. }
  27497. declare module "babylonjs/node" {
  27498. import { Scene } from "babylonjs/scene";
  27499. import { Nullable } from "babylonjs/types";
  27500. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27501. import { Engine } from "babylonjs/Engines/engine";
  27502. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27503. import { Observable } from "babylonjs/Misc/observable";
  27504. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27505. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27506. import { Animatable } from "babylonjs/Animations/animatable";
  27507. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27508. import { Animation } from "babylonjs/Animations/animation";
  27509. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27511. /**
  27512. * Defines how a node can be built from a string name.
  27513. */
  27514. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27515. /**
  27516. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27517. */
  27518. export class Node implements IBehaviorAware<Node> {
  27519. /** @hidden */
  27520. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27521. private static _NodeConstructors;
  27522. /**
  27523. * Add a new node constructor
  27524. * @param type defines the type name of the node to construct
  27525. * @param constructorFunc defines the constructor function
  27526. */
  27527. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27528. /**
  27529. * Returns a node constructor based on type name
  27530. * @param type defines the type name
  27531. * @param name defines the new node name
  27532. * @param scene defines the hosting scene
  27533. * @param options defines optional options to transmit to constructors
  27534. * @returns the new constructor or null
  27535. */
  27536. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27537. /**
  27538. * Gets or sets the name of the node
  27539. */
  27540. name: string;
  27541. /**
  27542. * Gets or sets the id of the node
  27543. */
  27544. id: string;
  27545. /**
  27546. * Gets or sets the unique id of the node
  27547. */
  27548. uniqueId: number;
  27549. /**
  27550. * Gets or sets a string used to store user defined state for the node
  27551. */
  27552. state: string;
  27553. /**
  27554. * Gets or sets an object used to store user defined information for the node
  27555. */
  27556. metadata: any;
  27557. /**
  27558. * For internal use only. Please do not use.
  27559. */
  27560. reservedDataStore: any;
  27561. /**
  27562. * List of inspectable custom properties (used by the Inspector)
  27563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27564. */
  27565. inspectableCustomProperties: IInspectable[];
  27566. private _doNotSerialize;
  27567. /**
  27568. * Gets or sets a boolean used to define if the node must be serialized
  27569. */
  27570. doNotSerialize: boolean;
  27571. /** @hidden */
  27572. _isDisposed: boolean;
  27573. /**
  27574. * Gets a list of Animations associated with the node
  27575. */
  27576. animations: import("babylonjs/Animations/animation").Animation[];
  27577. protected _ranges: {
  27578. [name: string]: Nullable<AnimationRange>;
  27579. };
  27580. /**
  27581. * Callback raised when the node is ready to be used
  27582. */
  27583. onReady: Nullable<(node: Node) => void>;
  27584. private _isEnabled;
  27585. private _isParentEnabled;
  27586. private _isReady;
  27587. /** @hidden */
  27588. _currentRenderId: number;
  27589. private _parentUpdateId;
  27590. /** @hidden */
  27591. _childUpdateId: number;
  27592. /** @hidden */
  27593. _waitingParentId: Nullable<string>;
  27594. /** @hidden */
  27595. _scene: Scene;
  27596. /** @hidden */
  27597. _cache: any;
  27598. private _parentNode;
  27599. private _children;
  27600. /** @hidden */
  27601. _worldMatrix: Matrix;
  27602. /** @hidden */
  27603. _worldMatrixDeterminant: number;
  27604. /** @hidden */
  27605. _worldMatrixDeterminantIsDirty: boolean;
  27606. /** @hidden */
  27607. private _sceneRootNodesIndex;
  27608. /**
  27609. * Gets a boolean indicating if the node has been disposed
  27610. * @returns true if the node was disposed
  27611. */
  27612. isDisposed(): boolean;
  27613. /**
  27614. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27615. * @see https://doc.babylonjs.com/how_to/parenting
  27616. */
  27617. parent: Nullable<Node>;
  27618. private addToSceneRootNodes;
  27619. private removeFromSceneRootNodes;
  27620. private _animationPropertiesOverride;
  27621. /**
  27622. * Gets or sets the animation properties override
  27623. */
  27624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27625. /**
  27626. * Gets a string idenfifying the name of the class
  27627. * @returns "Node" string
  27628. */
  27629. getClassName(): string;
  27630. /** @hidden */
  27631. readonly _isNode: boolean;
  27632. /**
  27633. * An event triggered when the mesh is disposed
  27634. */
  27635. onDisposeObservable: Observable<Node>;
  27636. private _onDisposeObserver;
  27637. /**
  27638. * Sets a callback that will be raised when the node will be disposed
  27639. */
  27640. onDispose: () => void;
  27641. /**
  27642. * Creates a new Node
  27643. * @param name the name and id to be given to this node
  27644. * @param scene the scene this node will be added to
  27645. * @param addToRootNodes the node will be added to scene.rootNodes
  27646. */
  27647. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27648. /**
  27649. * Gets the scene of the node
  27650. * @returns a scene
  27651. */
  27652. getScene(): Scene;
  27653. /**
  27654. * Gets the engine of the node
  27655. * @returns a Engine
  27656. */
  27657. getEngine(): Engine;
  27658. private _behaviors;
  27659. /**
  27660. * Attach a behavior to the node
  27661. * @see http://doc.babylonjs.com/features/behaviour
  27662. * @param behavior defines the behavior to attach
  27663. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27664. * @returns the current Node
  27665. */
  27666. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27667. /**
  27668. * Remove an attached behavior
  27669. * @see http://doc.babylonjs.com/features/behaviour
  27670. * @param behavior defines the behavior to attach
  27671. * @returns the current Node
  27672. */
  27673. removeBehavior(behavior: Behavior<Node>): Node;
  27674. /**
  27675. * Gets the list of attached behaviors
  27676. * @see http://doc.babylonjs.com/features/behaviour
  27677. */
  27678. readonly behaviors: Behavior<Node>[];
  27679. /**
  27680. * Gets an attached behavior by name
  27681. * @param name defines the name of the behavior to look for
  27682. * @see http://doc.babylonjs.com/features/behaviour
  27683. * @returns null if behavior was not found else the requested behavior
  27684. */
  27685. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27686. /**
  27687. * Returns the latest update of the World matrix
  27688. * @returns a Matrix
  27689. */
  27690. getWorldMatrix(): Matrix;
  27691. /** @hidden */
  27692. _getWorldMatrixDeterminant(): number;
  27693. /**
  27694. * Returns directly the latest state of the mesh World matrix.
  27695. * A Matrix is returned.
  27696. */
  27697. readonly worldMatrixFromCache: Matrix;
  27698. /** @hidden */
  27699. _initCache(): void;
  27700. /** @hidden */
  27701. updateCache(force?: boolean): void;
  27702. /** @hidden */
  27703. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27704. /** @hidden */
  27705. _updateCache(ignoreParentClass?: boolean): void;
  27706. /** @hidden */
  27707. _isSynchronized(): boolean;
  27708. /** @hidden */
  27709. _markSyncedWithParent(): void;
  27710. /** @hidden */
  27711. isSynchronizedWithParent(): boolean;
  27712. /** @hidden */
  27713. isSynchronized(): boolean;
  27714. /**
  27715. * Is this node ready to be used/rendered
  27716. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27717. * @return true if the node is ready
  27718. */
  27719. isReady(completeCheck?: boolean): boolean;
  27720. /**
  27721. * Is this node enabled?
  27722. * 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
  27723. * @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
  27724. * @return whether this node (and its parent) is enabled
  27725. */
  27726. isEnabled(checkAncestors?: boolean): boolean;
  27727. /** @hidden */
  27728. protected _syncParentEnabledState(): void;
  27729. /**
  27730. * Set the enabled state of this node
  27731. * @param value defines the new enabled state
  27732. */
  27733. setEnabled(value: boolean): void;
  27734. /**
  27735. * Is this node a descendant of the given node?
  27736. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27737. * @param ancestor defines the parent node to inspect
  27738. * @returns a boolean indicating if this node is a descendant of the given node
  27739. */
  27740. isDescendantOf(ancestor: Node): boolean;
  27741. /** @hidden */
  27742. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27743. /**
  27744. * Will return all nodes that have this node as ascendant
  27745. * @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
  27746. * @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
  27747. * @return all children nodes of all types
  27748. */
  27749. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27750. /**
  27751. * Get all child-meshes of this node
  27752. * @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)
  27753. * @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
  27754. * @returns an array of AbstractMesh
  27755. */
  27756. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27757. /**
  27758. * Get all direct children of this node
  27759. * @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
  27760. * @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)
  27761. * @returns an array of Node
  27762. */
  27763. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27764. /** @hidden */
  27765. _setReady(state: boolean): void;
  27766. /**
  27767. * Get an animation by name
  27768. * @param name defines the name of the animation to look for
  27769. * @returns null if not found else the requested animation
  27770. */
  27771. getAnimationByName(name: string): Nullable<Animation>;
  27772. /**
  27773. * Creates an animation range for this node
  27774. * @param name defines the name of the range
  27775. * @param from defines the starting key
  27776. * @param to defines the end key
  27777. */
  27778. createAnimationRange(name: string, from: number, to: number): void;
  27779. /**
  27780. * Delete a specific animation range
  27781. * @param name defines the name of the range to delete
  27782. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27783. */
  27784. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27785. /**
  27786. * Get an animation range by name
  27787. * @param name defines the name of the animation range to look for
  27788. * @returns null if not found else the requested animation range
  27789. */
  27790. getAnimationRange(name: string): Nullable<AnimationRange>;
  27791. /**
  27792. * Gets the list of all animation ranges defined on this node
  27793. * @returns an array
  27794. */
  27795. getAnimationRanges(): Nullable<AnimationRange>[];
  27796. /**
  27797. * Will start the animation sequence
  27798. * @param name defines the range frames for animation sequence
  27799. * @param loop defines if the animation should loop (false by default)
  27800. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27801. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27802. * @returns the object created for this animation. If range does not exist, it will return null
  27803. */
  27804. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27805. /**
  27806. * Serialize animation ranges into a JSON compatible object
  27807. * @returns serialization object
  27808. */
  27809. serializeAnimationRanges(): any;
  27810. /**
  27811. * Computes the world matrix of the node
  27812. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27813. * @returns the world matrix
  27814. */
  27815. computeWorldMatrix(force?: boolean): Matrix;
  27816. /**
  27817. * Releases resources associated with this node.
  27818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27820. */
  27821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27822. /**
  27823. * Parse animation range data from a serialization object and store them into a given node
  27824. * @param node defines where to store the animation ranges
  27825. * @param parsedNode defines the serialization object to read data from
  27826. * @param scene defines the hosting scene
  27827. */
  27828. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27829. /**
  27830. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27831. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27832. * @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
  27833. * @returns the new bounding vectors
  27834. */
  27835. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27836. min: Vector3;
  27837. max: Vector3;
  27838. };
  27839. }
  27840. }
  27841. declare module "babylonjs/Animations/animation" {
  27842. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27843. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27844. import { Color3 } from "babylonjs/Maths/math.color";
  27845. import { Nullable } from "babylonjs/types";
  27846. import { Scene } from "babylonjs/scene";
  27847. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27848. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27849. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27850. import { Node } from "babylonjs/node";
  27851. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27852. import { Size } from "babylonjs/Maths/math.size";
  27853. import { Animatable } from "babylonjs/Animations/animatable";
  27854. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27855. /**
  27856. * @hidden
  27857. */
  27858. export class _IAnimationState {
  27859. key: number;
  27860. repeatCount: number;
  27861. workValue?: any;
  27862. loopMode?: number;
  27863. offsetValue?: any;
  27864. highLimitValue?: any;
  27865. }
  27866. /**
  27867. * Class used to store any kind of animation
  27868. */
  27869. export class Animation {
  27870. /**Name of the animation */
  27871. name: string;
  27872. /**Property to animate */
  27873. targetProperty: string;
  27874. /**The frames per second of the animation */
  27875. framePerSecond: number;
  27876. /**The data type of the animation */
  27877. dataType: number;
  27878. /**The loop mode of the animation */
  27879. loopMode?: number | undefined;
  27880. /**Specifies if blending should be enabled */
  27881. enableBlending?: boolean | undefined;
  27882. /**
  27883. * Use matrix interpolation instead of using direct key value when animating matrices
  27884. */
  27885. static AllowMatricesInterpolation: boolean;
  27886. /**
  27887. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27888. */
  27889. static AllowMatrixDecomposeForInterpolation: boolean;
  27890. /**
  27891. * Stores the key frames of the animation
  27892. */
  27893. private _keys;
  27894. /**
  27895. * Stores the easing function of the animation
  27896. */
  27897. private _easingFunction;
  27898. /**
  27899. * @hidden Internal use only
  27900. */
  27901. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27902. /**
  27903. * The set of event that will be linked to this animation
  27904. */
  27905. private _events;
  27906. /**
  27907. * Stores an array of target property paths
  27908. */
  27909. targetPropertyPath: string[];
  27910. /**
  27911. * Stores the blending speed of the animation
  27912. */
  27913. blendingSpeed: number;
  27914. /**
  27915. * Stores the animation ranges for the animation
  27916. */
  27917. private _ranges;
  27918. /**
  27919. * @hidden Internal use
  27920. */
  27921. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27922. /**
  27923. * Sets up an animation
  27924. * @param property The property to animate
  27925. * @param animationType The animation type to apply
  27926. * @param framePerSecond The frames per second of the animation
  27927. * @param easingFunction The easing function used in the animation
  27928. * @returns The created animation
  27929. */
  27930. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27931. /**
  27932. * Create and start an animation on a node
  27933. * @param name defines the name of the global animation that will be run on all nodes
  27934. * @param node defines the root node where the animation will take place
  27935. * @param targetProperty defines property to animate
  27936. * @param framePerSecond defines the number of frame per second yo use
  27937. * @param totalFrame defines the number of frames in total
  27938. * @param from defines the initial value
  27939. * @param to defines the final value
  27940. * @param loopMode defines which loop mode you want to use (off by default)
  27941. * @param easingFunction defines the easing function to use (linear by default)
  27942. * @param onAnimationEnd defines the callback to call when animation end
  27943. * @returns the animatable created for this animation
  27944. */
  27945. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27946. /**
  27947. * Create and start an animation on a node and its descendants
  27948. * @param name defines the name of the global animation that will be run on all nodes
  27949. * @param node defines the root node where the animation will take place
  27950. * @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
  27951. * @param targetProperty defines property to animate
  27952. * @param framePerSecond defines the number of frame per second to use
  27953. * @param totalFrame defines the number of frames in total
  27954. * @param from defines the initial value
  27955. * @param to defines the final value
  27956. * @param loopMode defines which loop mode you want to use (off by default)
  27957. * @param easingFunction defines the easing function to use (linear by default)
  27958. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27959. * @returns the list of animatables created for all nodes
  27960. * @example https://www.babylonjs-playground.com/#MH0VLI
  27961. */
  27962. 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[]>;
  27963. /**
  27964. * Creates a new animation, merges it with the existing animations and starts it
  27965. * @param name Name of the animation
  27966. * @param node Node which contains the scene that begins the animations
  27967. * @param targetProperty Specifies which property to animate
  27968. * @param framePerSecond The frames per second of the animation
  27969. * @param totalFrame The total number of frames
  27970. * @param from The frame at the beginning of the animation
  27971. * @param to The frame at the end of the animation
  27972. * @param loopMode Specifies the loop mode of the animation
  27973. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27974. * @param onAnimationEnd Callback to run once the animation is complete
  27975. * @returns Nullable animation
  27976. */
  27977. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27978. /**
  27979. * Transition property of an host to the target Value
  27980. * @param property The property to transition
  27981. * @param targetValue The target Value of the property
  27982. * @param host The object where the property to animate belongs
  27983. * @param scene Scene used to run the animation
  27984. * @param frameRate Framerate (in frame/s) to use
  27985. * @param transition The transition type we want to use
  27986. * @param duration The duration of the animation, in milliseconds
  27987. * @param onAnimationEnd Callback trigger at the end of the animation
  27988. * @returns Nullable animation
  27989. */
  27990. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27991. /**
  27992. * Return the array of runtime animations currently using this animation
  27993. */
  27994. readonly runtimeAnimations: RuntimeAnimation[];
  27995. /**
  27996. * Specifies if any of the runtime animations are currently running
  27997. */
  27998. readonly hasRunningRuntimeAnimations: boolean;
  27999. /**
  28000. * Initializes the animation
  28001. * @param name Name of the animation
  28002. * @param targetProperty Property to animate
  28003. * @param framePerSecond The frames per second of the animation
  28004. * @param dataType The data type of the animation
  28005. * @param loopMode The loop mode of the animation
  28006. * @param enableBlending Specifies if blending should be enabled
  28007. */
  28008. constructor(
  28009. /**Name of the animation */
  28010. name: string,
  28011. /**Property to animate */
  28012. targetProperty: string,
  28013. /**The frames per second of the animation */
  28014. framePerSecond: number,
  28015. /**The data type of the animation */
  28016. dataType: number,
  28017. /**The loop mode of the animation */
  28018. loopMode?: number | undefined,
  28019. /**Specifies if blending should be enabled */
  28020. enableBlending?: boolean | undefined);
  28021. /**
  28022. * Converts the animation to a string
  28023. * @param fullDetails support for multiple levels of logging within scene loading
  28024. * @returns String form of the animation
  28025. */
  28026. toString(fullDetails?: boolean): string;
  28027. /**
  28028. * Add an event to this animation
  28029. * @param event Event to add
  28030. */
  28031. addEvent(event: AnimationEvent): void;
  28032. /**
  28033. * Remove all events found at the given frame
  28034. * @param frame The frame to remove events from
  28035. */
  28036. removeEvents(frame: number): void;
  28037. /**
  28038. * Retrieves all the events from the animation
  28039. * @returns Events from the animation
  28040. */
  28041. getEvents(): AnimationEvent[];
  28042. /**
  28043. * Creates an animation range
  28044. * @param name Name of the animation range
  28045. * @param from Starting frame of the animation range
  28046. * @param to Ending frame of the animation
  28047. */
  28048. createRange(name: string, from: number, to: number): void;
  28049. /**
  28050. * Deletes an animation range by name
  28051. * @param name Name of the animation range to delete
  28052. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28053. */
  28054. deleteRange(name: string, deleteFrames?: boolean): void;
  28055. /**
  28056. * Gets the animation range by name, or null if not defined
  28057. * @param name Name of the animation range
  28058. * @returns Nullable animation range
  28059. */
  28060. getRange(name: string): Nullable<AnimationRange>;
  28061. /**
  28062. * Gets the key frames from the animation
  28063. * @returns The key frames of the animation
  28064. */
  28065. getKeys(): Array<IAnimationKey>;
  28066. /**
  28067. * Gets the highest frame rate of the animation
  28068. * @returns Highest frame rate of the animation
  28069. */
  28070. getHighestFrame(): number;
  28071. /**
  28072. * Gets the easing function of the animation
  28073. * @returns Easing function of the animation
  28074. */
  28075. getEasingFunction(): IEasingFunction;
  28076. /**
  28077. * Sets the easing function of the animation
  28078. * @param easingFunction A custom mathematical formula for animation
  28079. */
  28080. setEasingFunction(easingFunction: EasingFunction): void;
  28081. /**
  28082. * Interpolates a scalar linearly
  28083. * @param startValue Start value of the animation curve
  28084. * @param endValue End value of the animation curve
  28085. * @param gradient Scalar amount to interpolate
  28086. * @returns Interpolated scalar value
  28087. */
  28088. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28089. /**
  28090. * Interpolates a scalar cubically
  28091. * @param startValue Start value of the animation curve
  28092. * @param outTangent End tangent of the animation
  28093. * @param endValue End value of the animation curve
  28094. * @param inTangent Start tangent of the animation curve
  28095. * @param gradient Scalar amount to interpolate
  28096. * @returns Interpolated scalar value
  28097. */
  28098. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28099. /**
  28100. * Interpolates a quaternion using a spherical linear interpolation
  28101. * @param startValue Start value of the animation curve
  28102. * @param endValue End value of the animation curve
  28103. * @param gradient Scalar amount to interpolate
  28104. * @returns Interpolated quaternion value
  28105. */
  28106. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28107. /**
  28108. * Interpolates a quaternion cubically
  28109. * @param startValue Start value of the animation curve
  28110. * @param outTangent End tangent of the animation curve
  28111. * @param endValue End value of the animation curve
  28112. * @param inTangent Start tangent of the animation curve
  28113. * @param gradient Scalar amount to interpolate
  28114. * @returns Interpolated quaternion value
  28115. */
  28116. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28117. /**
  28118. * Interpolates a Vector3 linearl
  28119. * @param startValue Start value of the animation curve
  28120. * @param endValue End value of the animation curve
  28121. * @param gradient Scalar amount to interpolate
  28122. * @returns Interpolated scalar value
  28123. */
  28124. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28125. /**
  28126. * Interpolates a Vector3 cubically
  28127. * @param startValue Start value of the animation curve
  28128. * @param outTangent End tangent of the animation
  28129. * @param endValue End value of the animation curve
  28130. * @param inTangent Start tangent of the animation curve
  28131. * @param gradient Scalar amount to interpolate
  28132. * @returns InterpolatedVector3 value
  28133. */
  28134. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28135. /**
  28136. * Interpolates a Vector2 linearly
  28137. * @param startValue Start value of the animation curve
  28138. * @param endValue End value of the animation curve
  28139. * @param gradient Scalar amount to interpolate
  28140. * @returns Interpolated Vector2 value
  28141. */
  28142. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28143. /**
  28144. * Interpolates a Vector2 cubically
  28145. * @param startValue Start value of the animation curve
  28146. * @param outTangent End tangent of the animation
  28147. * @param endValue End value of the animation curve
  28148. * @param inTangent Start tangent of the animation curve
  28149. * @param gradient Scalar amount to interpolate
  28150. * @returns Interpolated Vector2 value
  28151. */
  28152. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28153. /**
  28154. * Interpolates a size linearly
  28155. * @param startValue Start value of the animation curve
  28156. * @param endValue End value of the animation curve
  28157. * @param gradient Scalar amount to interpolate
  28158. * @returns Interpolated Size value
  28159. */
  28160. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28161. /**
  28162. * Interpolates a Color3 linearly
  28163. * @param startValue Start value of the animation curve
  28164. * @param endValue End value of the animation curve
  28165. * @param gradient Scalar amount to interpolate
  28166. * @returns Interpolated Color3 value
  28167. */
  28168. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28169. /**
  28170. * @hidden Internal use only
  28171. */
  28172. _getKeyValue(value: any): any;
  28173. /**
  28174. * @hidden Internal use only
  28175. */
  28176. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28177. /**
  28178. * Defines the function to use to interpolate matrices
  28179. * @param startValue defines the start matrix
  28180. * @param endValue defines the end matrix
  28181. * @param gradient defines the gradient between both matrices
  28182. * @param result defines an optional target matrix where to store the interpolation
  28183. * @returns the interpolated matrix
  28184. */
  28185. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28186. /**
  28187. * Makes a copy of the animation
  28188. * @returns Cloned animation
  28189. */
  28190. clone(): Animation;
  28191. /**
  28192. * Sets the key frames of the animation
  28193. * @param values The animation key frames to set
  28194. */
  28195. setKeys(values: Array<IAnimationKey>): void;
  28196. /**
  28197. * Serializes the animation to an object
  28198. * @returns Serialized object
  28199. */
  28200. serialize(): any;
  28201. /**
  28202. * Float animation type
  28203. */
  28204. private static _ANIMATIONTYPE_FLOAT;
  28205. /**
  28206. * Vector3 animation type
  28207. */
  28208. private static _ANIMATIONTYPE_VECTOR3;
  28209. /**
  28210. * Quaternion animation type
  28211. */
  28212. private static _ANIMATIONTYPE_QUATERNION;
  28213. /**
  28214. * Matrix animation type
  28215. */
  28216. private static _ANIMATIONTYPE_MATRIX;
  28217. /**
  28218. * Color3 animation type
  28219. */
  28220. private static _ANIMATIONTYPE_COLOR3;
  28221. /**
  28222. * Vector2 animation type
  28223. */
  28224. private static _ANIMATIONTYPE_VECTOR2;
  28225. /**
  28226. * Size animation type
  28227. */
  28228. private static _ANIMATIONTYPE_SIZE;
  28229. /**
  28230. * Relative Loop Mode
  28231. */
  28232. private static _ANIMATIONLOOPMODE_RELATIVE;
  28233. /**
  28234. * Cycle Loop Mode
  28235. */
  28236. private static _ANIMATIONLOOPMODE_CYCLE;
  28237. /**
  28238. * Constant Loop Mode
  28239. */
  28240. private static _ANIMATIONLOOPMODE_CONSTANT;
  28241. /**
  28242. * Get the float animation type
  28243. */
  28244. static readonly ANIMATIONTYPE_FLOAT: number;
  28245. /**
  28246. * Get the Vector3 animation type
  28247. */
  28248. static readonly ANIMATIONTYPE_VECTOR3: number;
  28249. /**
  28250. * Get the Vector2 animation type
  28251. */
  28252. static readonly ANIMATIONTYPE_VECTOR2: number;
  28253. /**
  28254. * Get the Size animation type
  28255. */
  28256. static readonly ANIMATIONTYPE_SIZE: number;
  28257. /**
  28258. * Get the Quaternion animation type
  28259. */
  28260. static readonly ANIMATIONTYPE_QUATERNION: number;
  28261. /**
  28262. * Get the Matrix animation type
  28263. */
  28264. static readonly ANIMATIONTYPE_MATRIX: number;
  28265. /**
  28266. * Get the Color3 animation type
  28267. */
  28268. static readonly ANIMATIONTYPE_COLOR3: number;
  28269. /**
  28270. * Get the Relative Loop Mode
  28271. */
  28272. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28273. /**
  28274. * Get the Cycle Loop Mode
  28275. */
  28276. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28277. /**
  28278. * Get the Constant Loop Mode
  28279. */
  28280. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28281. /** @hidden */
  28282. static _UniversalLerp(left: any, right: any, amount: number): any;
  28283. /**
  28284. * Parses an animation object and creates an animation
  28285. * @param parsedAnimation Parsed animation object
  28286. * @returns Animation object
  28287. */
  28288. static Parse(parsedAnimation: any): Animation;
  28289. /**
  28290. * Appends the serialized animations from the source animations
  28291. * @param source Source containing the animations
  28292. * @param destination Target to store the animations
  28293. */
  28294. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28295. }
  28296. }
  28297. declare module "babylonjs/Animations/animatable.interface" {
  28298. import { Nullable } from "babylonjs/types";
  28299. import { Animation } from "babylonjs/Animations/animation";
  28300. /**
  28301. * Interface containing an array of animations
  28302. */
  28303. export interface IAnimatable {
  28304. /**
  28305. * Array of animations
  28306. */
  28307. animations: Nullable<Array<Animation>>;
  28308. }
  28309. }
  28310. declare module "babylonjs/Materials/fresnelParameters" {
  28311. import { Color3 } from "babylonjs/Maths/math.color";
  28312. /**
  28313. * This represents all the required information to add a fresnel effect on a material:
  28314. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28315. */
  28316. export class FresnelParameters {
  28317. private _isEnabled;
  28318. /**
  28319. * Define if the fresnel effect is enable or not.
  28320. */
  28321. isEnabled: boolean;
  28322. /**
  28323. * Define the color used on edges (grazing angle)
  28324. */
  28325. leftColor: Color3;
  28326. /**
  28327. * Define the color used on center
  28328. */
  28329. rightColor: Color3;
  28330. /**
  28331. * Define bias applied to computed fresnel term
  28332. */
  28333. bias: number;
  28334. /**
  28335. * Defined the power exponent applied to fresnel term
  28336. */
  28337. power: number;
  28338. /**
  28339. * Clones the current fresnel and its valuues
  28340. * @returns a clone fresnel configuration
  28341. */
  28342. clone(): FresnelParameters;
  28343. /**
  28344. * Serializes the current fresnel parameters to a JSON representation.
  28345. * @return the JSON serialization
  28346. */
  28347. serialize(): any;
  28348. /**
  28349. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28350. * @param parsedFresnelParameters Define the JSON representation
  28351. * @returns the parsed parameters
  28352. */
  28353. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28354. }
  28355. }
  28356. declare module "babylonjs/Misc/decorators" {
  28357. import { Nullable } from "babylonjs/types";
  28358. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28359. import { Scene } from "babylonjs/scene";
  28360. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28361. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28362. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28363. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28365. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28366. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28367. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28368. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28369. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28370. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28371. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28372. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28373. /**
  28374. * Decorator used to define property that can be serialized as reference to a camera
  28375. * @param sourceName defines the name of the property to decorate
  28376. */
  28377. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28378. /**
  28379. * Class used to help serialization objects
  28380. */
  28381. export class SerializationHelper {
  28382. /** @hidden */
  28383. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28384. /** @hidden */
  28385. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28386. /** @hidden */
  28387. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28388. /** @hidden */
  28389. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28390. /**
  28391. * Appends the serialized animations from the source animations
  28392. * @param source Source containing the animations
  28393. * @param destination Target to store the animations
  28394. */
  28395. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28396. /**
  28397. * Static function used to serialized a specific entity
  28398. * @param entity defines the entity to serialize
  28399. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28400. * @returns a JSON compatible object representing the serialization of the entity
  28401. */
  28402. static Serialize<T>(entity: T, serializationObject?: any): any;
  28403. /**
  28404. * Creates a new entity from a serialization data object
  28405. * @param creationFunction defines a function used to instanciated the new entity
  28406. * @param source defines the source serialization data
  28407. * @param scene defines the hosting scene
  28408. * @param rootUrl defines the root url for resources
  28409. * @returns a new entity
  28410. */
  28411. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28412. /**
  28413. * Clones an object
  28414. * @param creationFunction defines the function used to instanciate the new object
  28415. * @param source defines the source object
  28416. * @returns the cloned object
  28417. */
  28418. static Clone<T>(creationFunction: () => T, source: T): T;
  28419. /**
  28420. * Instanciates a new object based on a source one (some data will be shared between both object)
  28421. * @param creationFunction defines the function used to instanciate the new object
  28422. * @param source defines the source object
  28423. * @returns the new object
  28424. */
  28425. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/guid" {
  28429. /**
  28430. * Class used to manipulate GUIDs
  28431. */
  28432. export class GUID {
  28433. /**
  28434. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28435. * Be aware Math.random() could cause collisions, but:
  28436. * "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"
  28437. * @returns a pseudo random id
  28438. */
  28439. static RandomId(): string;
  28440. }
  28441. }
  28442. declare module "babylonjs/Materials/Textures/baseTexture" {
  28443. import { Observable } from "babylonjs/Misc/observable";
  28444. import { Nullable } from "babylonjs/types";
  28445. import { Scene } from "babylonjs/scene";
  28446. import { Matrix } from "babylonjs/Maths/math.vector";
  28447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28449. import { ISize } from "babylonjs/Maths/math.size";
  28450. /**
  28451. * Base class of all the textures in babylon.
  28452. * It groups all the common properties the materials, post process, lights... might need
  28453. * in order to make a correct use of the texture.
  28454. */
  28455. export class BaseTexture implements IAnimatable {
  28456. /**
  28457. * Default anisotropic filtering level for the application.
  28458. * It is set to 4 as a good tradeoff between perf and quality.
  28459. */
  28460. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28461. /**
  28462. * Gets or sets the unique id of the texture
  28463. */
  28464. uniqueId: number;
  28465. /**
  28466. * Define the name of the texture.
  28467. */
  28468. name: string;
  28469. /**
  28470. * Gets or sets an object used to store user defined information.
  28471. */
  28472. metadata: any;
  28473. /**
  28474. * For internal use only. Please do not use.
  28475. */
  28476. reservedDataStore: any;
  28477. private _hasAlpha;
  28478. /**
  28479. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28480. */
  28481. hasAlpha: boolean;
  28482. /**
  28483. * Defines if the alpha value should be determined via the rgb values.
  28484. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28485. */
  28486. getAlphaFromRGB: boolean;
  28487. /**
  28488. * Intensity or strength of the texture.
  28489. * It is commonly used by materials to fine tune the intensity of the texture
  28490. */
  28491. level: number;
  28492. /**
  28493. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28494. * This is part of the texture as textures usually maps to one uv set.
  28495. */
  28496. coordinatesIndex: number;
  28497. private _coordinatesMode;
  28498. /**
  28499. * How a texture is mapped.
  28500. *
  28501. * | Value | Type | Description |
  28502. * | ----- | ----------------------------------- | ----------- |
  28503. * | 0 | EXPLICIT_MODE | |
  28504. * | 1 | SPHERICAL_MODE | |
  28505. * | 2 | PLANAR_MODE | |
  28506. * | 3 | CUBIC_MODE | |
  28507. * | 4 | PROJECTION_MODE | |
  28508. * | 5 | SKYBOX_MODE | |
  28509. * | 6 | INVCUBIC_MODE | |
  28510. * | 7 | EQUIRECTANGULAR_MODE | |
  28511. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28512. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28513. */
  28514. coordinatesMode: number;
  28515. /**
  28516. * | Value | Type | Description |
  28517. * | ----- | ------------------ | ----------- |
  28518. * | 0 | CLAMP_ADDRESSMODE | |
  28519. * | 1 | WRAP_ADDRESSMODE | |
  28520. * | 2 | MIRROR_ADDRESSMODE | |
  28521. */
  28522. wrapU: number;
  28523. /**
  28524. * | Value | Type | Description |
  28525. * | ----- | ------------------ | ----------- |
  28526. * | 0 | CLAMP_ADDRESSMODE | |
  28527. * | 1 | WRAP_ADDRESSMODE | |
  28528. * | 2 | MIRROR_ADDRESSMODE | |
  28529. */
  28530. wrapV: number;
  28531. /**
  28532. * | Value | Type | Description |
  28533. * | ----- | ------------------ | ----------- |
  28534. * | 0 | CLAMP_ADDRESSMODE | |
  28535. * | 1 | WRAP_ADDRESSMODE | |
  28536. * | 2 | MIRROR_ADDRESSMODE | |
  28537. */
  28538. wrapR: number;
  28539. /**
  28540. * With compliant hardware and browser (supporting anisotropic filtering)
  28541. * this defines the level of anisotropic filtering in the texture.
  28542. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28543. */
  28544. anisotropicFilteringLevel: number;
  28545. /**
  28546. * Define if the texture is a cube texture or if false a 2d texture.
  28547. */
  28548. isCube: boolean;
  28549. /**
  28550. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28551. */
  28552. is3D: boolean;
  28553. /**
  28554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28555. * HDR texture are usually stored in linear space.
  28556. * This only impacts the PBR and Background materials
  28557. */
  28558. gammaSpace: boolean;
  28559. /**
  28560. * Gets or sets whether or not the texture contains RGBD data.
  28561. */
  28562. isRGBD: boolean;
  28563. /**
  28564. * Is Z inverted in the texture (useful in a cube texture).
  28565. */
  28566. invertZ: boolean;
  28567. /**
  28568. * Are mip maps generated for this texture or not.
  28569. */
  28570. readonly noMipmap: boolean;
  28571. /**
  28572. * @hidden
  28573. */
  28574. lodLevelInAlpha: boolean;
  28575. /**
  28576. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28577. */
  28578. lodGenerationOffset: number;
  28579. /**
  28580. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28581. */
  28582. lodGenerationScale: number;
  28583. /**
  28584. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28585. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28586. * average roughness values.
  28587. */
  28588. linearSpecularLOD: boolean;
  28589. /**
  28590. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28591. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28592. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28593. */
  28594. irradianceTexture: Nullable<BaseTexture>;
  28595. /**
  28596. * Define if the texture is a render target.
  28597. */
  28598. isRenderTarget: boolean;
  28599. /**
  28600. * Define the unique id of the texture in the scene.
  28601. */
  28602. readonly uid: string;
  28603. /**
  28604. * Return a string representation of the texture.
  28605. * @returns the texture as a string
  28606. */
  28607. toString(): string;
  28608. /**
  28609. * Get the class name of the texture.
  28610. * @returns "BaseTexture"
  28611. */
  28612. getClassName(): string;
  28613. /**
  28614. * Define the list of animation attached to the texture.
  28615. */
  28616. animations: import("babylonjs/Animations/animation").Animation[];
  28617. /**
  28618. * An event triggered when the texture is disposed.
  28619. */
  28620. onDisposeObservable: Observable<BaseTexture>;
  28621. private _onDisposeObserver;
  28622. /**
  28623. * Callback triggered when the texture has been disposed.
  28624. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28625. */
  28626. onDispose: () => void;
  28627. /**
  28628. * Define the current state of the loading sequence when in delayed load mode.
  28629. */
  28630. delayLoadState: number;
  28631. private _scene;
  28632. /** @hidden */
  28633. _texture: Nullable<InternalTexture>;
  28634. private _uid;
  28635. /**
  28636. * Define if the texture is preventinga material to render or not.
  28637. * If not and the texture is not ready, the engine will use a default black texture instead.
  28638. */
  28639. readonly isBlocking: boolean;
  28640. /**
  28641. * Instantiates a new BaseTexture.
  28642. * Base class of all the textures in babylon.
  28643. * It groups all the common properties the materials, post process, lights... might need
  28644. * in order to make a correct use of the texture.
  28645. * @param scene Define the scene the texture blongs to
  28646. */
  28647. constructor(scene: Nullable<Scene>);
  28648. /**
  28649. * Get the scene the texture belongs to.
  28650. * @returns the scene or null if undefined
  28651. */
  28652. getScene(): Nullable<Scene>;
  28653. /**
  28654. * Get the texture transform matrix used to offset tile the texture for istance.
  28655. * @returns the transformation matrix
  28656. */
  28657. getTextureMatrix(): Matrix;
  28658. /**
  28659. * Get the texture reflection matrix used to rotate/transform the reflection.
  28660. * @returns the reflection matrix
  28661. */
  28662. getReflectionTextureMatrix(): Matrix;
  28663. /**
  28664. * Get the underlying lower level texture from Babylon.
  28665. * @returns the insternal texture
  28666. */
  28667. getInternalTexture(): Nullable<InternalTexture>;
  28668. /**
  28669. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28670. * @returns true if ready or not blocking
  28671. */
  28672. isReadyOrNotBlocking(): boolean;
  28673. /**
  28674. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28675. * @returns true if fully ready
  28676. */
  28677. isReady(): boolean;
  28678. private _cachedSize;
  28679. /**
  28680. * Get the size of the texture.
  28681. * @returns the texture size.
  28682. */
  28683. getSize(): ISize;
  28684. /**
  28685. * Get the base size of the texture.
  28686. * It can be different from the size if the texture has been resized for POT for instance
  28687. * @returns the base size
  28688. */
  28689. getBaseSize(): ISize;
  28690. /**
  28691. * Update the sampling mode of the texture.
  28692. * Default is Trilinear mode.
  28693. *
  28694. * | Value | Type | Description |
  28695. * | ----- | ------------------ | ----------- |
  28696. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28697. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28698. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28699. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28700. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28701. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28702. * | 7 | NEAREST_LINEAR | |
  28703. * | 8 | NEAREST_NEAREST | |
  28704. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28705. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28706. * | 11 | LINEAR_LINEAR | |
  28707. * | 12 | LINEAR_NEAREST | |
  28708. *
  28709. * > _mag_: magnification filter (close to the viewer)
  28710. * > _min_: minification filter (far from the viewer)
  28711. * > _mip_: filter used between mip map levels
  28712. *@param samplingMode Define the new sampling mode of the texture
  28713. */
  28714. updateSamplingMode(samplingMode: number): void;
  28715. /**
  28716. * Scales the texture if is `canRescale()`
  28717. * @param ratio the resize factor we want to use to rescale
  28718. */
  28719. scale(ratio: number): void;
  28720. /**
  28721. * Get if the texture can rescale.
  28722. */
  28723. readonly canRescale: boolean;
  28724. /** @hidden */
  28725. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28726. /** @hidden */
  28727. _rebuild(): void;
  28728. /**
  28729. * Triggers the load sequence in delayed load mode.
  28730. */
  28731. delayLoad(): void;
  28732. /**
  28733. * Clones the texture.
  28734. * @returns the cloned texture
  28735. */
  28736. clone(): Nullable<BaseTexture>;
  28737. /**
  28738. * Get the texture underlying type (INT, FLOAT...)
  28739. */
  28740. readonly textureType: number;
  28741. /**
  28742. * Get the texture underlying format (RGB, RGBA...)
  28743. */
  28744. readonly textureFormat: number;
  28745. /**
  28746. * Indicates that textures need to be re-calculated for all materials
  28747. */
  28748. protected _markAllSubMeshesAsTexturesDirty(): void;
  28749. /**
  28750. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28751. * This will returns an RGBA array buffer containing either in values (0-255) or
  28752. * float values (0-1) depending of the underlying buffer type.
  28753. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28754. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28755. * @param buffer defines a user defined buffer to fill with data (can be null)
  28756. * @returns The Array buffer containing the pixels data.
  28757. */
  28758. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28759. /**
  28760. * Release and destroy the underlying lower level texture aka internalTexture.
  28761. */
  28762. releaseInternalTexture(): void;
  28763. /** @hidden */
  28764. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28765. /** @hidden */
  28766. readonly _lodTextureMid: Nullable<BaseTexture>;
  28767. /** @hidden */
  28768. readonly _lodTextureLow: Nullable<BaseTexture>;
  28769. /**
  28770. * Dispose the texture and release its associated resources.
  28771. */
  28772. dispose(): void;
  28773. /**
  28774. * Serialize the texture into a JSON representation that can be parsed later on.
  28775. * @returns the JSON representation of the texture
  28776. */
  28777. serialize(): any;
  28778. /**
  28779. * Helper function to be called back once a list of texture contains only ready textures.
  28780. * @param textures Define the list of textures to wait for
  28781. * @param callback Define the callback triggered once the entire list will be ready
  28782. */
  28783. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28784. }
  28785. }
  28786. declare module "babylonjs/Materials/effect" {
  28787. import { Observable } from "babylonjs/Misc/observable";
  28788. import { Nullable } from "babylonjs/types";
  28789. import { IDisposable } from "babylonjs/scene";
  28790. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28792. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28793. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28794. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28795. import { Engine } from "babylonjs/Engines/engine";
  28796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28799. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28800. /**
  28801. * Options to be used when creating an effect.
  28802. */
  28803. export interface IEffectCreationOptions {
  28804. /**
  28805. * Atrributes that will be used in the shader.
  28806. */
  28807. attributes: string[];
  28808. /**
  28809. * Uniform varible names that will be set in the shader.
  28810. */
  28811. uniformsNames: string[];
  28812. /**
  28813. * Uniform buffer varible names that will be set in the shader.
  28814. */
  28815. uniformBuffersNames: string[];
  28816. /**
  28817. * Sampler texture variable names that will be set in the shader.
  28818. */
  28819. samplers: string[];
  28820. /**
  28821. * Define statements that will be set in the shader.
  28822. */
  28823. defines: any;
  28824. /**
  28825. * Possible fallbacks for this effect to improve performance when needed.
  28826. */
  28827. fallbacks: Nullable<IEffectFallbacks>;
  28828. /**
  28829. * Callback that will be called when the shader is compiled.
  28830. */
  28831. onCompiled: Nullable<(effect: Effect) => void>;
  28832. /**
  28833. * Callback that will be called if an error occurs during shader compilation.
  28834. */
  28835. onError: Nullable<(effect: Effect, errors: string) => void>;
  28836. /**
  28837. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28838. */
  28839. indexParameters?: any;
  28840. /**
  28841. * Max number of lights that can be used in the shader.
  28842. */
  28843. maxSimultaneousLights?: number;
  28844. /**
  28845. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28846. */
  28847. transformFeedbackVaryings?: Nullable<string[]>;
  28848. }
  28849. /**
  28850. * Effect containing vertex and fragment shader that can be executed on an object.
  28851. */
  28852. export class Effect implements IDisposable {
  28853. /**
  28854. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28855. */
  28856. static ShadersRepository: string;
  28857. /**
  28858. * Name of the effect.
  28859. */
  28860. name: any;
  28861. /**
  28862. * String container all the define statements that should be set on the shader.
  28863. */
  28864. defines: string;
  28865. /**
  28866. * Callback that will be called when the shader is compiled.
  28867. */
  28868. onCompiled: Nullable<(effect: Effect) => void>;
  28869. /**
  28870. * Callback that will be called if an error occurs during shader compilation.
  28871. */
  28872. onError: Nullable<(effect: Effect, errors: string) => void>;
  28873. /**
  28874. * Callback that will be called when effect is bound.
  28875. */
  28876. onBind: Nullable<(effect: Effect) => void>;
  28877. /**
  28878. * Unique ID of the effect.
  28879. */
  28880. uniqueId: number;
  28881. /**
  28882. * Observable that will be called when the shader is compiled.
  28883. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28884. */
  28885. onCompileObservable: Observable<Effect>;
  28886. /**
  28887. * Observable that will be called if an error occurs during shader compilation.
  28888. */
  28889. onErrorObservable: Observable<Effect>;
  28890. /** @hidden */
  28891. _onBindObservable: Nullable<Observable<Effect>>;
  28892. /**
  28893. * Observable that will be called when effect is bound.
  28894. */
  28895. readonly onBindObservable: Observable<Effect>;
  28896. /** @hidden */
  28897. _bonesComputationForcedToCPU: boolean;
  28898. private static _uniqueIdSeed;
  28899. private _engine;
  28900. private _uniformBuffersNames;
  28901. private _uniformsNames;
  28902. private _samplerList;
  28903. private _samplers;
  28904. private _isReady;
  28905. private _compilationError;
  28906. private _allFallbacksProcessed;
  28907. private _attributesNames;
  28908. private _attributes;
  28909. private _uniforms;
  28910. /**
  28911. * Key for the effect.
  28912. * @hidden
  28913. */
  28914. _key: string;
  28915. private _indexParameters;
  28916. private _fallbacks;
  28917. private _vertexSourceCode;
  28918. private _fragmentSourceCode;
  28919. private _vertexSourceCodeOverride;
  28920. private _fragmentSourceCodeOverride;
  28921. private _transformFeedbackVaryings;
  28922. /**
  28923. * Compiled shader to webGL program.
  28924. * @hidden
  28925. */
  28926. _pipelineContext: Nullable<IPipelineContext>;
  28927. private _valueCache;
  28928. private static _baseCache;
  28929. /**
  28930. * Instantiates an effect.
  28931. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28932. * @param baseName Name of the effect.
  28933. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28934. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28935. * @param samplers List of sampler variables that will be passed to the shader.
  28936. * @param engine Engine to be used to render the effect
  28937. * @param defines Define statements to be added to the shader.
  28938. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28939. * @param onCompiled Callback that will be called when the shader is compiled.
  28940. * @param onError Callback that will be called if an error occurs during shader compilation.
  28941. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28942. */
  28943. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28944. private _useFinalCode;
  28945. /**
  28946. * Unique key for this effect
  28947. */
  28948. readonly key: string;
  28949. /**
  28950. * If the effect has been compiled and prepared.
  28951. * @returns if the effect is compiled and prepared.
  28952. */
  28953. isReady(): boolean;
  28954. private _isReadyInternal;
  28955. /**
  28956. * The engine the effect was initialized with.
  28957. * @returns the engine.
  28958. */
  28959. getEngine(): Engine;
  28960. /**
  28961. * The pipeline context for this effect
  28962. * @returns the associated pipeline context
  28963. */
  28964. getPipelineContext(): Nullable<IPipelineContext>;
  28965. /**
  28966. * The set of names of attribute variables for the shader.
  28967. * @returns An array of attribute names.
  28968. */
  28969. getAttributesNames(): string[];
  28970. /**
  28971. * Returns the attribute at the given index.
  28972. * @param index The index of the attribute.
  28973. * @returns The location of the attribute.
  28974. */
  28975. getAttributeLocation(index: number): number;
  28976. /**
  28977. * Returns the attribute based on the name of the variable.
  28978. * @param name of the attribute to look up.
  28979. * @returns the attribute location.
  28980. */
  28981. getAttributeLocationByName(name: string): number;
  28982. /**
  28983. * The number of attributes.
  28984. * @returns the numnber of attributes.
  28985. */
  28986. getAttributesCount(): number;
  28987. /**
  28988. * Gets the index of a uniform variable.
  28989. * @param uniformName of the uniform to look up.
  28990. * @returns the index.
  28991. */
  28992. getUniformIndex(uniformName: string): number;
  28993. /**
  28994. * Returns the attribute based on the name of the variable.
  28995. * @param uniformName of the uniform to look up.
  28996. * @returns the location of the uniform.
  28997. */
  28998. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28999. /**
  29000. * Returns an array of sampler variable names
  29001. * @returns The array of sampler variable neames.
  29002. */
  29003. getSamplers(): string[];
  29004. /**
  29005. * The error from the last compilation.
  29006. * @returns the error string.
  29007. */
  29008. getCompilationError(): string;
  29009. /**
  29010. * Gets a boolean indicating that all fallbacks were used during compilation
  29011. * @returns true if all fallbacks were used
  29012. */
  29013. allFallbacksProcessed(): boolean;
  29014. /**
  29015. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29016. * @param func The callback to be used.
  29017. */
  29018. executeWhenCompiled(func: (effect: Effect) => void): void;
  29019. private _checkIsReady;
  29020. private _loadShader;
  29021. /**
  29022. * Recompiles the webGL program
  29023. * @param vertexSourceCode The source code for the vertex shader.
  29024. * @param fragmentSourceCode The source code for the fragment shader.
  29025. * @param onCompiled Callback called when completed.
  29026. * @param onError Callback called on error.
  29027. * @hidden
  29028. */
  29029. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29030. /**
  29031. * Prepares the effect
  29032. * @hidden
  29033. */
  29034. _prepareEffect(): void;
  29035. private _processCompilationErrors;
  29036. /**
  29037. * Checks if the effect is supported. (Must be called after compilation)
  29038. */
  29039. readonly isSupported: boolean;
  29040. /**
  29041. * Binds a texture to the engine to be used as output of the shader.
  29042. * @param channel Name of the output variable.
  29043. * @param texture Texture to bind.
  29044. * @hidden
  29045. */
  29046. _bindTexture(channel: string, texture: InternalTexture): void;
  29047. /**
  29048. * Sets a texture on the engine to be used in the shader.
  29049. * @param channel Name of the sampler variable.
  29050. * @param texture Texture to set.
  29051. */
  29052. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29053. /**
  29054. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29055. * @param channel Name of the sampler variable.
  29056. * @param texture Texture to set.
  29057. */
  29058. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29059. /**
  29060. * Sets an array of textures on the engine to be used in the shader.
  29061. * @param channel Name of the variable.
  29062. * @param textures Textures to set.
  29063. */
  29064. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29065. /**
  29066. * 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)
  29067. * @param channel Name of the sampler variable.
  29068. * @param postProcess Post process to get the input texture from.
  29069. */
  29070. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29071. /**
  29072. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29073. * 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)
  29074. * @param channel Name of the sampler variable.
  29075. * @param postProcess Post process to get the output texture from.
  29076. */
  29077. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29078. /** @hidden */
  29079. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29080. /** @hidden */
  29081. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29082. /** @hidden */
  29083. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29084. /** @hidden */
  29085. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29086. /**
  29087. * Binds a buffer to a uniform.
  29088. * @param buffer Buffer to bind.
  29089. * @param name Name of the uniform variable to bind to.
  29090. */
  29091. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29092. /**
  29093. * Binds block to a uniform.
  29094. * @param blockName Name of the block to bind.
  29095. * @param index Index to bind.
  29096. */
  29097. bindUniformBlock(blockName: string, index: number): void;
  29098. /**
  29099. * Sets an interger value on a uniform variable.
  29100. * @param uniformName Name of the variable.
  29101. * @param value Value to be set.
  29102. * @returns this effect.
  29103. */
  29104. setInt(uniformName: string, value: number): Effect;
  29105. /**
  29106. * Sets an int array on a uniform variable.
  29107. * @param uniformName Name of the variable.
  29108. * @param array array to be set.
  29109. * @returns this effect.
  29110. */
  29111. setIntArray(uniformName: string, array: Int32Array): Effect;
  29112. /**
  29113. * 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)
  29114. * @param uniformName Name of the variable.
  29115. * @param array array to be set.
  29116. * @returns this effect.
  29117. */
  29118. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29119. /**
  29120. * 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)
  29121. * @param uniformName Name of the variable.
  29122. * @param array array to be set.
  29123. * @returns this effect.
  29124. */
  29125. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29126. /**
  29127. * 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)
  29128. * @param uniformName Name of the variable.
  29129. * @param array array to be set.
  29130. * @returns this effect.
  29131. */
  29132. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29133. /**
  29134. * Sets an float array on a uniform variable.
  29135. * @param uniformName Name of the variable.
  29136. * @param array array to be set.
  29137. * @returns this effect.
  29138. */
  29139. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29140. /**
  29141. * 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)
  29142. * @param uniformName Name of the variable.
  29143. * @param array array to be set.
  29144. * @returns this effect.
  29145. */
  29146. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29147. /**
  29148. * 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)
  29149. * @param uniformName Name of the variable.
  29150. * @param array array to be set.
  29151. * @returns this effect.
  29152. */
  29153. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29154. /**
  29155. * 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)
  29156. * @param uniformName Name of the variable.
  29157. * @param array array to be set.
  29158. * @returns this effect.
  29159. */
  29160. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29161. /**
  29162. * Sets an array on a uniform variable.
  29163. * @param uniformName Name of the variable.
  29164. * @param array array to be set.
  29165. * @returns this effect.
  29166. */
  29167. setArray(uniformName: string, array: number[]): Effect;
  29168. /**
  29169. * 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)
  29170. * @param uniformName Name of the variable.
  29171. * @param array array to be set.
  29172. * @returns this effect.
  29173. */
  29174. setArray2(uniformName: string, array: number[]): Effect;
  29175. /**
  29176. * 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)
  29177. * @param uniformName Name of the variable.
  29178. * @param array array to be set.
  29179. * @returns this effect.
  29180. */
  29181. setArray3(uniformName: string, array: number[]): Effect;
  29182. /**
  29183. * 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)
  29184. * @param uniformName Name of the variable.
  29185. * @param array array to be set.
  29186. * @returns this effect.
  29187. */
  29188. setArray4(uniformName: string, array: number[]): Effect;
  29189. /**
  29190. * Sets matrices on a uniform variable.
  29191. * @param uniformName Name of the variable.
  29192. * @param matrices matrices to be set.
  29193. * @returns this effect.
  29194. */
  29195. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29196. /**
  29197. * Sets matrix on a uniform variable.
  29198. * @param uniformName Name of the variable.
  29199. * @param matrix matrix to be set.
  29200. * @returns this effect.
  29201. */
  29202. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29203. /**
  29204. * 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)
  29205. * @param uniformName Name of the variable.
  29206. * @param matrix matrix to be set.
  29207. * @returns this effect.
  29208. */
  29209. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29210. /**
  29211. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29212. * @param uniformName Name of the variable.
  29213. * @param matrix matrix to be set.
  29214. * @returns this effect.
  29215. */
  29216. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29217. /**
  29218. * Sets a float on a uniform variable.
  29219. * @param uniformName Name of the variable.
  29220. * @param value value to be set.
  29221. * @returns this effect.
  29222. */
  29223. setFloat(uniformName: string, value: number): Effect;
  29224. /**
  29225. * Sets a boolean on a uniform variable.
  29226. * @param uniformName Name of the variable.
  29227. * @param bool value to be set.
  29228. * @returns this effect.
  29229. */
  29230. setBool(uniformName: string, bool: boolean): Effect;
  29231. /**
  29232. * Sets a Vector2 on a uniform variable.
  29233. * @param uniformName Name of the variable.
  29234. * @param vector2 vector2 to be set.
  29235. * @returns this effect.
  29236. */
  29237. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29238. /**
  29239. * Sets a float2 on a uniform variable.
  29240. * @param uniformName Name of the variable.
  29241. * @param x First float in float2.
  29242. * @param y Second float in float2.
  29243. * @returns this effect.
  29244. */
  29245. setFloat2(uniformName: string, x: number, y: number): Effect;
  29246. /**
  29247. * Sets a Vector3 on a uniform variable.
  29248. * @param uniformName Name of the variable.
  29249. * @param vector3 Value to be set.
  29250. * @returns this effect.
  29251. */
  29252. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29253. /**
  29254. * Sets a float3 on a uniform variable.
  29255. * @param uniformName Name of the variable.
  29256. * @param x First float in float3.
  29257. * @param y Second float in float3.
  29258. * @param z Third float in float3.
  29259. * @returns this effect.
  29260. */
  29261. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29262. /**
  29263. * Sets a Vector4 on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param vector4 Value to be set.
  29266. * @returns this effect.
  29267. */
  29268. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29269. /**
  29270. * Sets a float4 on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param x First float in float4.
  29273. * @param y Second float in float4.
  29274. * @param z Third float in float4.
  29275. * @param w Fourth float in float4.
  29276. * @returns this effect.
  29277. */
  29278. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29279. /**
  29280. * Sets a Color3 on a uniform variable.
  29281. * @param uniformName Name of the variable.
  29282. * @param color3 Value to be set.
  29283. * @returns this effect.
  29284. */
  29285. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29286. /**
  29287. * Sets a Color4 on a uniform variable.
  29288. * @param uniformName Name of the variable.
  29289. * @param color3 Value to be set.
  29290. * @param alpha Alpha value to be set.
  29291. * @returns this effect.
  29292. */
  29293. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29294. /**
  29295. * Sets a Color4 on a uniform variable
  29296. * @param uniformName defines the name of the variable
  29297. * @param color4 defines the value to be set
  29298. * @returns this effect.
  29299. */
  29300. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29301. /** Release all associated resources */
  29302. dispose(): void;
  29303. /**
  29304. * This function will add a new shader to the shader store
  29305. * @param name the name of the shader
  29306. * @param pixelShader optional pixel shader content
  29307. * @param vertexShader optional vertex shader content
  29308. */
  29309. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29310. /**
  29311. * Store of each shader (The can be looked up using effect.key)
  29312. */
  29313. static ShadersStore: {
  29314. [key: string]: string;
  29315. };
  29316. /**
  29317. * Store of each included file for a shader (The can be looked up using effect.key)
  29318. */
  29319. static IncludesShadersStore: {
  29320. [key: string]: string;
  29321. };
  29322. /**
  29323. * Resets the cache of effects.
  29324. */
  29325. static ResetCache(): void;
  29326. }
  29327. }
  29328. declare module "babylonjs/Engines/engineCapabilities" {
  29329. import { Nullable } from "babylonjs/types";
  29330. /**
  29331. * Class used to describe the capabilities of the engine relatively to the current browser
  29332. */
  29333. export class EngineCapabilities {
  29334. /** Maximum textures units per fragment shader */
  29335. maxTexturesImageUnits: number;
  29336. /** Maximum texture units per vertex shader */
  29337. maxVertexTextureImageUnits: number;
  29338. /** Maximum textures units in the entire pipeline */
  29339. maxCombinedTexturesImageUnits: number;
  29340. /** Maximum texture size */
  29341. maxTextureSize: number;
  29342. /** Maximum cube texture size */
  29343. maxCubemapTextureSize: number;
  29344. /** Maximum render texture size */
  29345. maxRenderTextureSize: number;
  29346. /** Maximum number of vertex attributes */
  29347. maxVertexAttribs: number;
  29348. /** Maximum number of varyings */
  29349. maxVaryingVectors: number;
  29350. /** Maximum number of uniforms per vertex shader */
  29351. maxVertexUniformVectors: number;
  29352. /** Maximum number of uniforms per fragment shader */
  29353. maxFragmentUniformVectors: number;
  29354. /** Defines if standard derivates (dx/dy) are supported */
  29355. standardDerivatives: boolean;
  29356. /** Defines if s3tc texture compression is supported */
  29357. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29358. /** Defines if pvrtc texture compression is supported */
  29359. pvrtc: any;
  29360. /** Defines if etc1 texture compression is supported */
  29361. etc1: any;
  29362. /** Defines if etc2 texture compression is supported */
  29363. etc2: any;
  29364. /** Defines if astc texture compression is supported */
  29365. astc: any;
  29366. /** Defines if float textures are supported */
  29367. textureFloat: boolean;
  29368. /** Defines if vertex array objects are supported */
  29369. vertexArrayObject: boolean;
  29370. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29371. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29372. /** Gets the maximum level of anisotropy supported */
  29373. maxAnisotropy: number;
  29374. /** Defines if instancing is supported */
  29375. instancedArrays: boolean;
  29376. /** Defines if 32 bits indices are supported */
  29377. uintIndices: boolean;
  29378. /** Defines if high precision shaders are supported */
  29379. highPrecisionShaderSupported: boolean;
  29380. /** Defines if depth reading in the fragment shader is supported */
  29381. fragmentDepthSupported: boolean;
  29382. /** Defines if float texture linear filtering is supported*/
  29383. textureFloatLinearFiltering: boolean;
  29384. /** Defines if rendering to float textures is supported */
  29385. textureFloatRender: boolean;
  29386. /** Defines if half float textures are supported*/
  29387. textureHalfFloat: boolean;
  29388. /** Defines if half float texture linear filtering is supported*/
  29389. textureHalfFloatLinearFiltering: boolean;
  29390. /** Defines if rendering to half float textures is supported */
  29391. textureHalfFloatRender: boolean;
  29392. /** Defines if textureLOD shader command is supported */
  29393. textureLOD: boolean;
  29394. /** Defines if draw buffers extension is supported */
  29395. drawBuffersExtension: boolean;
  29396. /** Defines if depth textures are supported */
  29397. depthTextureExtension: boolean;
  29398. /** Defines if float color buffer are supported */
  29399. colorBufferFloat: boolean;
  29400. /** Gets disjoint timer query extension (null if not supported) */
  29401. timerQuery: EXT_disjoint_timer_query;
  29402. /** Defines if timestamp can be used with timer query */
  29403. canUseTimestampForTimerQuery: boolean;
  29404. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29405. multiview: any;
  29406. /** Function used to let the system compiles shaders in background */
  29407. parallelShaderCompile: {
  29408. COMPLETION_STATUS_KHR: number;
  29409. };
  29410. /** Max number of texture samples for MSAA */
  29411. maxMSAASamples: number;
  29412. /** Defines if the blend min max extension is supported */
  29413. blendMinMax: boolean;
  29414. }
  29415. }
  29416. declare module "babylonjs/States/depthCullingState" {
  29417. import { Nullable } from "babylonjs/types";
  29418. /**
  29419. * @hidden
  29420. **/
  29421. export class DepthCullingState {
  29422. private _isDepthTestDirty;
  29423. private _isDepthMaskDirty;
  29424. private _isDepthFuncDirty;
  29425. private _isCullFaceDirty;
  29426. private _isCullDirty;
  29427. private _isZOffsetDirty;
  29428. private _isFrontFaceDirty;
  29429. private _depthTest;
  29430. private _depthMask;
  29431. private _depthFunc;
  29432. private _cull;
  29433. private _cullFace;
  29434. private _zOffset;
  29435. private _frontFace;
  29436. /**
  29437. * Initializes the state.
  29438. */
  29439. constructor();
  29440. readonly isDirty: boolean;
  29441. zOffset: number;
  29442. cullFace: Nullable<number>;
  29443. cull: Nullable<boolean>;
  29444. depthFunc: Nullable<number>;
  29445. depthMask: boolean;
  29446. depthTest: boolean;
  29447. frontFace: Nullable<number>;
  29448. reset(): void;
  29449. apply(gl: WebGLRenderingContext): void;
  29450. }
  29451. }
  29452. declare module "babylonjs/States/stencilState" {
  29453. /**
  29454. * @hidden
  29455. **/
  29456. export class StencilState {
  29457. /** 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 */
  29458. static readonly ALWAYS: number;
  29459. /** Passed to stencilOperation to specify that stencil value must be kept */
  29460. static readonly KEEP: number;
  29461. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29462. static readonly REPLACE: number;
  29463. private _isStencilTestDirty;
  29464. private _isStencilMaskDirty;
  29465. private _isStencilFuncDirty;
  29466. private _isStencilOpDirty;
  29467. private _stencilTest;
  29468. private _stencilMask;
  29469. private _stencilFunc;
  29470. private _stencilFuncRef;
  29471. private _stencilFuncMask;
  29472. private _stencilOpStencilFail;
  29473. private _stencilOpDepthFail;
  29474. private _stencilOpStencilDepthPass;
  29475. readonly isDirty: boolean;
  29476. stencilFunc: number;
  29477. stencilFuncRef: number;
  29478. stencilFuncMask: number;
  29479. stencilOpStencilFail: number;
  29480. stencilOpDepthFail: number;
  29481. stencilOpStencilDepthPass: number;
  29482. stencilMask: number;
  29483. stencilTest: boolean;
  29484. constructor();
  29485. reset(): void;
  29486. apply(gl: WebGLRenderingContext): void;
  29487. }
  29488. }
  29489. declare module "babylonjs/States/alphaCullingState" {
  29490. /**
  29491. * @hidden
  29492. **/
  29493. export class AlphaState {
  29494. private _isAlphaBlendDirty;
  29495. private _isBlendFunctionParametersDirty;
  29496. private _isBlendEquationParametersDirty;
  29497. private _isBlendConstantsDirty;
  29498. private _alphaBlend;
  29499. private _blendFunctionParameters;
  29500. private _blendEquationParameters;
  29501. private _blendConstants;
  29502. /**
  29503. * Initializes the state.
  29504. */
  29505. constructor();
  29506. readonly isDirty: boolean;
  29507. alphaBlend: boolean;
  29508. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29509. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29510. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29511. reset(): void;
  29512. apply(gl: WebGLRenderingContext): void;
  29513. }
  29514. }
  29515. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29516. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29517. /** @hidden */
  29518. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29519. attributeProcessor(attribute: string): string;
  29520. varyingProcessor(varying: string, isFragment: boolean): string;
  29521. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29522. }
  29523. }
  29524. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29525. /**
  29526. * Interface for attribute information associated with buffer instanciation
  29527. */
  29528. export class InstancingAttributeInfo {
  29529. /**
  29530. * Index/offset of the attribute in the vertex shader
  29531. */
  29532. index: number;
  29533. /**
  29534. * size of the attribute, 1, 2, 3 or 4
  29535. */
  29536. attributeSize: number;
  29537. /**
  29538. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29539. * default is FLOAT
  29540. */
  29541. attribyteType: number;
  29542. /**
  29543. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29544. */
  29545. normalized: boolean;
  29546. /**
  29547. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29548. */
  29549. offset: number;
  29550. /**
  29551. * Name of the GLSL attribute, for debugging purpose only
  29552. */
  29553. attributeName: string;
  29554. }
  29555. }
  29556. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29557. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29558. import { Nullable } from "babylonjs/types";
  29559. module "babylonjs/Engines/thinEngine" {
  29560. interface ThinEngine {
  29561. /**
  29562. * Update a video texture
  29563. * @param texture defines the texture to update
  29564. * @param video defines the video element to use
  29565. * @param invertY defines if data must be stored with Y axis inverted
  29566. */
  29567. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29568. }
  29569. }
  29570. }
  29571. declare module "babylonjs/Materials/Textures/videoTexture" {
  29572. import { Observable } from "babylonjs/Misc/observable";
  29573. import { Nullable } from "babylonjs/types";
  29574. import { Scene } from "babylonjs/scene";
  29575. import { Texture } from "babylonjs/Materials/Textures/texture";
  29576. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29577. /**
  29578. * Settings for finer control over video usage
  29579. */
  29580. export interface VideoTextureSettings {
  29581. /**
  29582. * Applies `autoplay` to video, if specified
  29583. */
  29584. autoPlay?: boolean;
  29585. /**
  29586. * Applies `loop` to video, if specified
  29587. */
  29588. loop?: boolean;
  29589. /**
  29590. * Automatically updates internal texture from video at every frame in the render loop
  29591. */
  29592. autoUpdateTexture: boolean;
  29593. /**
  29594. * Image src displayed during the video loading or until the user interacts with the video.
  29595. */
  29596. poster?: string;
  29597. }
  29598. /**
  29599. * If you want to display a video in your scene, this is the special texture for that.
  29600. * This special texture works similar to other textures, with the exception of a few parameters.
  29601. * @see https://doc.babylonjs.com/how_to/video_texture
  29602. */
  29603. export class VideoTexture extends Texture {
  29604. /**
  29605. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29606. */
  29607. readonly autoUpdateTexture: boolean;
  29608. /**
  29609. * The video instance used by the texture internally
  29610. */
  29611. readonly video: HTMLVideoElement;
  29612. private _onUserActionRequestedObservable;
  29613. /**
  29614. * Event triggerd when a dom action is required by the user to play the video.
  29615. * This happens due to recent changes in browser policies preventing video to auto start.
  29616. */
  29617. readonly onUserActionRequestedObservable: Observable<Texture>;
  29618. private _generateMipMaps;
  29619. private _engine;
  29620. private _stillImageCaptured;
  29621. private _displayingPosterTexture;
  29622. private _settings;
  29623. private _createInternalTextureOnEvent;
  29624. private _frameId;
  29625. /**
  29626. * Creates a video texture.
  29627. * If you want to display a video in your scene, this is the special texture for that.
  29628. * This special texture works similar to other textures, with the exception of a few parameters.
  29629. * @see https://doc.babylonjs.com/how_to/video_texture
  29630. * @param name optional name, will detect from video source, if not defined
  29631. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29632. * @param scene is obviously the current scene.
  29633. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29634. * @param invertY is false by default but can be used to invert video on Y axis
  29635. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29636. * @param settings allows finer control over video usage
  29637. */
  29638. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29639. private _getName;
  29640. private _getVideo;
  29641. private _createInternalTexture;
  29642. private reset;
  29643. /**
  29644. * @hidden Internal method to initiate `update`.
  29645. */
  29646. _rebuild(): void;
  29647. /**
  29648. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29649. */
  29650. update(): void;
  29651. /**
  29652. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29653. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29654. */
  29655. updateTexture(isVisible: boolean): void;
  29656. protected _updateInternalTexture: () => void;
  29657. /**
  29658. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29659. * @param url New url.
  29660. */
  29661. updateURL(url: string): void;
  29662. /**
  29663. * Dispose the texture and release its associated resources.
  29664. */
  29665. dispose(): void;
  29666. /**
  29667. * Creates a video texture straight from a stream.
  29668. * @param scene Define the scene the texture should be created in
  29669. * @param stream Define the stream the texture should be created from
  29670. * @returns The created video texture as a promise
  29671. */
  29672. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29673. /**
  29674. * Creates a video texture straight from your WebCam video feed.
  29675. * @param scene Define the scene the texture should be created in
  29676. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29677. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29678. * @returns The created video texture as a promise
  29679. */
  29680. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29681. minWidth: number;
  29682. maxWidth: number;
  29683. minHeight: number;
  29684. maxHeight: number;
  29685. deviceId: string;
  29686. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29687. /**
  29688. * Creates a video texture straight from your WebCam video feed.
  29689. * @param scene Define the scene the texture should be created in
  29690. * @param onReady Define a callback to triggered once the texture will be ready
  29691. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29692. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29693. */
  29694. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29695. minWidth: number;
  29696. maxWidth: number;
  29697. minHeight: number;
  29698. maxHeight: number;
  29699. deviceId: string;
  29700. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29701. }
  29702. }
  29703. declare module "babylonjs/Engines/thinEngine" {
  29704. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29705. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29706. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29707. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29708. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29709. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29710. import { Observable } from "babylonjs/Misc/observable";
  29711. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29712. import { StencilState } from "babylonjs/States/stencilState";
  29713. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29714. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29715. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29716. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29717. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29718. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29719. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29720. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29721. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29722. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29724. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29725. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29726. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29727. /**
  29728. * Defines the interface used by objects working like Scene
  29729. * @hidden
  29730. */
  29731. interface ISceneLike {
  29732. _addPendingData(data: any): void;
  29733. _removePendingData(data: any): void;
  29734. offlineProvider: IOfflineProvider;
  29735. }
  29736. /** Interface defining initialization parameters for Engine class */
  29737. export interface EngineOptions extends WebGLContextAttributes {
  29738. /**
  29739. * Defines if the engine should no exceed a specified device ratio
  29740. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29741. */
  29742. limitDeviceRatio?: number;
  29743. /**
  29744. * Defines if webvr should be enabled automatically
  29745. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29746. */
  29747. autoEnableWebVR?: boolean;
  29748. /**
  29749. * Defines if webgl2 should be turned off even if supported
  29750. * @see http://doc.babylonjs.com/features/webgl2
  29751. */
  29752. disableWebGL2Support?: boolean;
  29753. /**
  29754. * Defines if webaudio should be initialized as well
  29755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29756. */
  29757. audioEngine?: boolean;
  29758. /**
  29759. * Defines if animations should run using a deterministic lock step
  29760. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29761. */
  29762. deterministicLockstep?: boolean;
  29763. /** Defines the maximum steps to use with deterministic lock step mode */
  29764. lockstepMaxSteps?: number;
  29765. /**
  29766. * Defines that engine should ignore context lost events
  29767. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29768. */
  29769. doNotHandleContextLost?: boolean;
  29770. /**
  29771. * Defines that engine should ignore modifying touch action attribute and style
  29772. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29773. */
  29774. doNotHandleTouchAction?: boolean;
  29775. /**
  29776. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29777. */
  29778. useHighPrecisionFloats?: boolean;
  29779. }
  29780. /**
  29781. * The base engine class (root of all engines)
  29782. */
  29783. export class ThinEngine {
  29784. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29785. static ExceptionList: ({
  29786. key: string;
  29787. capture: string;
  29788. captureConstraint: number;
  29789. targets: string[];
  29790. } | {
  29791. key: string;
  29792. capture: null;
  29793. captureConstraint: null;
  29794. targets: string[];
  29795. })[];
  29796. /** @hidden */
  29797. static _TextureLoaders: IInternalTextureLoader[];
  29798. /**
  29799. * Returns the current npm package of the sdk
  29800. */
  29801. static readonly NpmPackage: string;
  29802. /**
  29803. * Returns the current version of the framework
  29804. */
  29805. static readonly Version: string;
  29806. /**
  29807. * Returns a string describing the current engine
  29808. */
  29809. readonly description: string;
  29810. /**
  29811. * Gets or sets the epsilon value used by collision engine
  29812. */
  29813. static CollisionsEpsilon: number;
  29814. /**
  29815. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29816. */
  29817. static ShadersRepository: string;
  29818. /** @hidden */
  29819. _shaderProcessor: IShaderProcessor;
  29820. /**
  29821. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29822. */
  29823. forcePOTTextures: boolean;
  29824. /**
  29825. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29826. */
  29827. isFullscreen: boolean;
  29828. /**
  29829. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29830. */
  29831. cullBackFaces: boolean;
  29832. /**
  29833. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29834. */
  29835. renderEvenInBackground: boolean;
  29836. /**
  29837. * Gets or sets a boolean indicating that cache can be kept between frames
  29838. */
  29839. preventCacheWipeBetweenFrames: boolean;
  29840. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29841. validateShaderPrograms: boolean;
  29842. /**
  29843. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29844. */
  29845. disableUniformBuffers: boolean;
  29846. /** @hidden */
  29847. _uniformBuffers: UniformBuffer[];
  29848. /**
  29849. * Gets a boolean indicating that the engine supports uniform buffers
  29850. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29851. */
  29852. readonly supportsUniformBuffers: boolean;
  29853. /** @hidden */
  29854. _gl: WebGLRenderingContext;
  29855. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29856. protected _windowIsBackground: boolean;
  29857. protected _webGLVersion: number;
  29858. protected _highPrecisionShadersAllowed: boolean;
  29859. /** @hidden */
  29860. readonly _shouldUseHighPrecisionShader: boolean;
  29861. /**
  29862. * Gets a boolean indicating that only power of 2 textures are supported
  29863. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29864. */
  29865. readonly needPOTTextures: boolean;
  29866. /** @hidden */
  29867. _badOS: boolean;
  29868. /** @hidden */
  29869. _badDesktopOS: boolean;
  29870. private _hardwareScalingLevel;
  29871. /** @hidden */
  29872. _caps: EngineCapabilities;
  29873. private _isStencilEnable;
  29874. protected _colorWrite: boolean;
  29875. private _glVersion;
  29876. private _glRenderer;
  29877. private _glVendor;
  29878. /** @hidden */
  29879. _videoTextureSupported: boolean;
  29880. protected _renderingQueueLaunched: boolean;
  29881. protected _activeRenderLoops: (() => void)[];
  29882. /**
  29883. * Observable signaled when a context lost event is raised
  29884. */
  29885. onContextLostObservable: Observable<ThinEngine>;
  29886. /**
  29887. * Observable signaled when a context restored event is raised
  29888. */
  29889. onContextRestoredObservable: Observable<ThinEngine>;
  29890. private _onContextLost;
  29891. private _onContextRestored;
  29892. protected _contextWasLost: boolean;
  29893. /** @hidden */
  29894. _doNotHandleContextLost: boolean;
  29895. /**
  29896. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29898. */
  29899. doNotHandleContextLost: boolean;
  29900. /**
  29901. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29902. */
  29903. disableVertexArrayObjects: boolean;
  29904. /** @hidden */
  29905. protected _depthCullingState: DepthCullingState;
  29906. /** @hidden */
  29907. protected _stencilState: StencilState;
  29908. /** @hidden */
  29909. protected _alphaState: AlphaState;
  29910. /** @hidden */
  29911. _internalTexturesCache: InternalTexture[];
  29912. /** @hidden */
  29913. protected _activeChannel: number;
  29914. private _currentTextureChannel;
  29915. /** @hidden */
  29916. protected _boundTexturesCache: {
  29917. [key: string]: Nullable<InternalTexture>;
  29918. };
  29919. /** @hidden */
  29920. protected _currentEffect: Nullable<Effect>;
  29921. /** @hidden */
  29922. protected _currentProgram: Nullable<WebGLProgram>;
  29923. private _compiledEffects;
  29924. private _vertexAttribArraysEnabled;
  29925. /** @hidden */
  29926. protected _cachedViewport: Nullable<IViewportLike>;
  29927. private _cachedVertexArrayObject;
  29928. /** @hidden */
  29929. protected _cachedVertexBuffers: any;
  29930. /** @hidden */
  29931. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29932. /** @hidden */
  29933. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29934. /** @hidden */
  29935. _currentRenderTarget: Nullable<InternalTexture>;
  29936. private _uintIndicesCurrentlySet;
  29937. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29938. /** @hidden */
  29939. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29940. private _currentBufferPointers;
  29941. private _currentInstanceLocations;
  29942. private _currentInstanceBuffers;
  29943. private _textureUnits;
  29944. /** @hidden */
  29945. _workingCanvas: Nullable<HTMLCanvasElement>;
  29946. /** @hidden */
  29947. _workingContext: Nullable<CanvasRenderingContext2D>;
  29948. /** @hidden */
  29949. _bindedRenderFunction: any;
  29950. private _vaoRecordInProgress;
  29951. private _mustWipeVertexAttributes;
  29952. private _emptyTexture;
  29953. private _emptyCubeTexture;
  29954. private _emptyTexture3D;
  29955. /** @hidden */
  29956. _frameHandler: number;
  29957. private _nextFreeTextureSlots;
  29958. private _maxSimultaneousTextures;
  29959. private _activeRequests;
  29960. protected _texturesSupported: string[];
  29961. /** @hidden */
  29962. _textureFormatInUse: Nullable<string>;
  29963. protected readonly _supportsHardwareTextureRescaling: boolean;
  29964. /**
  29965. * Gets the list of texture formats supported
  29966. */
  29967. readonly texturesSupported: Array<string>;
  29968. /**
  29969. * Gets the list of texture formats in use
  29970. */
  29971. readonly textureFormatInUse: Nullable<string>;
  29972. /**
  29973. * Gets the current viewport
  29974. */
  29975. readonly currentViewport: Nullable<IViewportLike>;
  29976. /**
  29977. * Gets the default empty texture
  29978. */
  29979. readonly emptyTexture: InternalTexture;
  29980. /**
  29981. * Gets the default empty 3D texture
  29982. */
  29983. readonly emptyTexture3D: InternalTexture;
  29984. /**
  29985. * Gets the default empty cube texture
  29986. */
  29987. readonly emptyCubeTexture: InternalTexture;
  29988. /**
  29989. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29990. */
  29991. readonly premultipliedAlpha: boolean;
  29992. /**
  29993. * Observable event triggered before each texture is initialized
  29994. */
  29995. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29996. /**
  29997. * Creates a new engine
  29998. * @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
  29999. * @param antialias defines enable antialiasing (default: false)
  30000. * @param options defines further options to be sent to the getContext() function
  30001. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30002. */
  30003. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30004. private _rebuildInternalTextures;
  30005. private _rebuildEffects;
  30006. /**
  30007. * Gets a boolean indicating if all created effects are ready
  30008. * @returns true if all effects are ready
  30009. */
  30010. areAllEffectsReady(): boolean;
  30011. protected _rebuildBuffers(): void;
  30012. private _initGLContext;
  30013. /**
  30014. * Gets version of the current webGL context
  30015. */
  30016. readonly webGLVersion: number;
  30017. /**
  30018. * Gets a string idenfifying the name of the class
  30019. * @returns "Engine" string
  30020. */
  30021. getClassName(): string;
  30022. /**
  30023. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30024. */
  30025. readonly isStencilEnable: boolean;
  30026. /** @hidden */
  30027. _prepareWorkingCanvas(): void;
  30028. /**
  30029. * Reset the texture cache to empty state
  30030. */
  30031. resetTextureCache(): void;
  30032. /**
  30033. * Gets an object containing information about the current webGL context
  30034. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30035. */
  30036. getGlInfo(): {
  30037. vendor: string;
  30038. renderer: string;
  30039. version: string;
  30040. };
  30041. /**
  30042. * Defines the hardware scaling level.
  30043. * By default the hardware scaling level is computed from the window device ratio.
  30044. * 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.
  30045. * @param level defines the level to use
  30046. */
  30047. setHardwareScalingLevel(level: number): void;
  30048. /**
  30049. * Gets the current hardware scaling level.
  30050. * By default the hardware scaling level is computed from the window device ratio.
  30051. * 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.
  30052. * @returns a number indicating the current hardware scaling level
  30053. */
  30054. getHardwareScalingLevel(): number;
  30055. /**
  30056. * Gets the list of loaded textures
  30057. * @returns an array containing all loaded textures
  30058. */
  30059. getLoadedTexturesCache(): InternalTexture[];
  30060. /**
  30061. * Gets the object containing all engine capabilities
  30062. * @returns the EngineCapabilities object
  30063. */
  30064. getCaps(): EngineCapabilities;
  30065. /**
  30066. * stop executing a render loop function and remove it from the execution array
  30067. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30068. */
  30069. stopRenderLoop(renderFunction?: () => void): void;
  30070. /** @hidden */
  30071. _renderLoop(): void;
  30072. /**
  30073. * Gets the HTML canvas attached with the current webGL context
  30074. * @returns a HTML canvas
  30075. */
  30076. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30077. /**
  30078. * Gets host window
  30079. * @returns the host window object
  30080. */
  30081. getHostWindow(): Window;
  30082. /**
  30083. * Gets the current render width
  30084. * @param useScreen defines if screen size must be used (or the current render target if any)
  30085. * @returns a number defining the current render width
  30086. */
  30087. getRenderWidth(useScreen?: boolean): number;
  30088. /**
  30089. * Gets the current render height
  30090. * @param useScreen defines if screen size must be used (or the current render target if any)
  30091. * @returns a number defining the current render height
  30092. */
  30093. getRenderHeight(useScreen?: boolean): number;
  30094. /**
  30095. * Can be used to override the current requestAnimationFrame requester.
  30096. * @hidden
  30097. */
  30098. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30099. /**
  30100. * Register and execute a render loop. The engine can have more than one render function
  30101. * @param renderFunction defines the function to continuously execute
  30102. */
  30103. runRenderLoop(renderFunction: () => void): void;
  30104. /**
  30105. * Clear the current render buffer or the current render target (if any is set up)
  30106. * @param color defines the color to use
  30107. * @param backBuffer defines if the back buffer must be cleared
  30108. * @param depth defines if the depth buffer must be cleared
  30109. * @param stencil defines if the stencil buffer must be cleared
  30110. */
  30111. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30112. private _viewportCached;
  30113. /** @hidden */
  30114. _viewport(x: number, y: number, width: number, height: number): void;
  30115. /**
  30116. * Set the WebGL's viewport
  30117. * @param viewport defines the viewport element to be used
  30118. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30119. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30120. */
  30121. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30122. /**
  30123. * Begin a new frame
  30124. */
  30125. beginFrame(): void;
  30126. /**
  30127. * Enf the current frame
  30128. */
  30129. endFrame(): void;
  30130. /**
  30131. * Resize the view according to the canvas' size
  30132. */
  30133. resize(): void;
  30134. /**
  30135. * Force a specific size of the canvas
  30136. * @param width defines the new canvas' width
  30137. * @param height defines the new canvas' height
  30138. */
  30139. setSize(width: number, height: number): void;
  30140. /**
  30141. * Binds the frame buffer to the specified texture.
  30142. * @param texture The texture to render to or null for the default canvas
  30143. * @param faceIndex The face of the texture to render to in case of cube texture
  30144. * @param requiredWidth The width of the target to render to
  30145. * @param requiredHeight The height of the target to render to
  30146. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30147. * @param depthStencilTexture The depth stencil texture to use to render
  30148. * @param lodLevel defines le lod level to bind to the frame buffer
  30149. */
  30150. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30151. /** @hidden */
  30152. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30153. /**
  30154. * Unbind the current render target texture from the webGL context
  30155. * @param texture defines the render target texture to unbind
  30156. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30157. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30158. */
  30159. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30160. /**
  30161. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30162. */
  30163. flushFramebuffer(): void;
  30164. /**
  30165. * Unbind the current render target and bind the default framebuffer
  30166. */
  30167. restoreDefaultFramebuffer(): void;
  30168. private _resetVertexBufferBinding;
  30169. /**
  30170. * Creates a vertex buffer
  30171. * @param data the data for the vertex buffer
  30172. * @returns the new WebGL static buffer
  30173. */
  30174. createVertexBuffer(data: DataArray): DataBuffer;
  30175. private _createVertexBuffer;
  30176. /**
  30177. * Creates a dynamic vertex buffer
  30178. * @param data the data for the dynamic vertex buffer
  30179. * @returns the new WebGL dynamic buffer
  30180. */
  30181. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30182. /**
  30183. * Updates a dynamic vertex buffer.
  30184. * @param vertexBuffer the vertex buffer to update
  30185. * @param data the data used to update the vertex buffer
  30186. * @param byteOffset the byte offset of the data
  30187. * @param byteLength the byte length of the data
  30188. */
  30189. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30190. protected _resetIndexBufferBinding(): void;
  30191. /**
  30192. * Creates a new index buffer
  30193. * @param indices defines the content of the index buffer
  30194. * @param updatable defines if the index buffer must be updatable
  30195. * @returns a new webGL buffer
  30196. */
  30197. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30198. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30199. /**
  30200. * Bind a webGL buffer to the webGL context
  30201. * @param buffer defines the buffer to bind
  30202. */
  30203. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30204. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30205. private bindBuffer;
  30206. /**
  30207. * update the bound buffer with the given data
  30208. * @param data defines the data to update
  30209. */
  30210. updateArrayBuffer(data: Float32Array): void;
  30211. private _vertexAttribPointer;
  30212. private _bindIndexBufferWithCache;
  30213. private _bindVertexBuffersAttributes;
  30214. /**
  30215. * Records a vertex array object
  30216. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30217. * @param vertexBuffers defines the list of vertex buffers to store
  30218. * @param indexBuffer defines the index buffer to store
  30219. * @param effect defines the effect to store
  30220. * @returns the new vertex array object
  30221. */
  30222. recordVertexArrayObject(vertexBuffers: {
  30223. [key: string]: VertexBuffer;
  30224. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30225. /**
  30226. * Bind a specific vertex array object
  30227. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30228. * @param vertexArrayObject defines the vertex array object to bind
  30229. * @param indexBuffer defines the index buffer to bind
  30230. */
  30231. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30232. /**
  30233. * Bind webGl buffers directly to the webGL context
  30234. * @param vertexBuffer defines the vertex buffer to bind
  30235. * @param indexBuffer defines the index buffer to bind
  30236. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30237. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30238. * @param effect defines the effect associated with the vertex buffer
  30239. */
  30240. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30241. private _unbindVertexArrayObject;
  30242. /**
  30243. * Bind a list of vertex buffers to the webGL context
  30244. * @param vertexBuffers defines the list of vertex buffers to bind
  30245. * @param indexBuffer defines the index buffer to bind
  30246. * @param effect defines the effect associated with the vertex buffers
  30247. */
  30248. bindBuffers(vertexBuffers: {
  30249. [key: string]: Nullable<VertexBuffer>;
  30250. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30251. /**
  30252. * Unbind all instance attributes
  30253. */
  30254. unbindInstanceAttributes(): void;
  30255. /**
  30256. * Release and free the memory of a vertex array object
  30257. * @param vao defines the vertex array object to delete
  30258. */
  30259. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30260. /** @hidden */
  30261. _releaseBuffer(buffer: DataBuffer): boolean;
  30262. protected _deleteBuffer(buffer: DataBuffer): void;
  30263. /**
  30264. * Creates a webGL buffer to use with instanciation
  30265. * @param capacity defines the size of the buffer
  30266. * @returns the webGL buffer
  30267. */
  30268. createInstancesBuffer(capacity: number): DataBuffer;
  30269. /**
  30270. * Delete a webGL buffer used with instanciation
  30271. * @param buffer defines the webGL buffer to delete
  30272. */
  30273. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30274. /**
  30275. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30276. * @param instancesBuffer defines the webGL buffer to update and bind
  30277. * @param data defines the data to store in the buffer
  30278. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30279. */
  30280. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30281. /**
  30282. * Apply all cached states (depth, culling, stencil and alpha)
  30283. */
  30284. applyStates(): void;
  30285. /**
  30286. * Send a draw order
  30287. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30288. * @param indexStart defines the starting index
  30289. * @param indexCount defines the number of index to draw
  30290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30291. */
  30292. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30293. /**
  30294. * Draw a list of points
  30295. * @param verticesStart defines the index of first vertex to draw
  30296. * @param verticesCount defines the count of vertices to draw
  30297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30298. */
  30299. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30300. /**
  30301. * Draw a list of unindexed primitives
  30302. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30303. * @param verticesStart defines the index of first vertex to draw
  30304. * @param verticesCount defines the count of vertices to draw
  30305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30306. */
  30307. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30308. /**
  30309. * Draw a list of indexed primitives
  30310. * @param fillMode defines the primitive to use
  30311. * @param indexStart defines the starting index
  30312. * @param indexCount defines the number of index to draw
  30313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30314. */
  30315. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30316. /**
  30317. * Draw a list of unindexed primitives
  30318. * @param fillMode defines the primitive to use
  30319. * @param verticesStart defines the index of first vertex to draw
  30320. * @param verticesCount defines the count of vertices to draw
  30321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30322. */
  30323. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30324. private _drawMode;
  30325. /** @hidden */
  30326. protected _reportDrawCall(): void;
  30327. /** @hidden */
  30328. _releaseEffect(effect: Effect): void;
  30329. /** @hidden */
  30330. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30331. /**
  30332. * Create a new effect (used to store vertex/fragment shaders)
  30333. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30334. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30335. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30336. * @param samplers defines an array of string used to represent textures
  30337. * @param defines defines the string containing the defines to use to compile the shaders
  30338. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30339. * @param onCompiled defines a function to call when the effect creation is successful
  30340. * @param onError defines a function to call when the effect creation has failed
  30341. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30342. * @returns the new Effect
  30343. */
  30344. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30345. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30346. private _compileShader;
  30347. private _compileRawShader;
  30348. /**
  30349. * Directly creates a webGL program
  30350. * @param pipelineContext defines the pipeline context to attach to
  30351. * @param vertexCode defines the vertex shader code to use
  30352. * @param fragmentCode defines the fragment shader code to use
  30353. * @param context defines the webGL context to use (if not set, the current one will be used)
  30354. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30355. * @returns the new webGL program
  30356. */
  30357. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30358. /**
  30359. * Creates a webGL program
  30360. * @param pipelineContext defines the pipeline context to attach to
  30361. * @param vertexCode defines the vertex shader code to use
  30362. * @param fragmentCode defines the fragment shader code to use
  30363. * @param defines defines the string containing the defines to use to compile the shaders
  30364. * @param context defines the webGL context to use (if not set, the current one will be used)
  30365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30366. * @returns the new webGL program
  30367. */
  30368. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30369. /**
  30370. * Creates a new pipeline context
  30371. * @returns the new pipeline
  30372. */
  30373. createPipelineContext(): IPipelineContext;
  30374. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30375. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30376. /** @hidden */
  30377. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30378. /** @hidden */
  30379. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30380. /** @hidden */
  30381. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30382. /**
  30383. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30384. * @param pipelineContext defines the pipeline context to use
  30385. * @param uniformsNames defines the list of uniform names
  30386. * @returns an array of webGL uniform locations
  30387. */
  30388. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30389. /**
  30390. * Gets the lsit of active attributes for a given webGL program
  30391. * @param pipelineContext defines the pipeline context to use
  30392. * @param attributesNames defines the list of attribute names to get
  30393. * @returns an array of indices indicating the offset of each attribute
  30394. */
  30395. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30396. /**
  30397. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30398. * @param effect defines the effect to activate
  30399. */
  30400. enableEffect(effect: Nullable<Effect>): void;
  30401. /**
  30402. * Set the value of an uniform to an array of int32
  30403. * @param uniform defines the webGL uniform location where to store the value
  30404. * @param array defines the array of int32 to store
  30405. */
  30406. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30407. /**
  30408. * Set the value of an uniform to an array of int32 (stored as vec2)
  30409. * @param uniform defines the webGL uniform location where to store the value
  30410. * @param array defines the array of int32 to store
  30411. */
  30412. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30413. /**
  30414. * Set the value of an uniform to an array of int32 (stored as vec3)
  30415. * @param uniform defines the webGL uniform location where to store the value
  30416. * @param array defines the array of int32 to store
  30417. */
  30418. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30419. /**
  30420. * Set the value of an uniform to an array of int32 (stored as vec4)
  30421. * @param uniform defines the webGL uniform location where to store the value
  30422. * @param array defines the array of int32 to store
  30423. */
  30424. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30425. /**
  30426. * Set the value of an uniform to an array of float32
  30427. * @param uniform defines the webGL uniform location where to store the value
  30428. * @param array defines the array of float32 to store
  30429. */
  30430. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30431. /**
  30432. * Set the value of an uniform to an array of float32 (stored as vec2)
  30433. * @param uniform defines the webGL uniform location where to store the value
  30434. * @param array defines the array of float32 to store
  30435. */
  30436. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30437. /**
  30438. * Set the value of an uniform to an array of float32 (stored as vec3)
  30439. * @param uniform defines the webGL uniform location where to store the value
  30440. * @param array defines the array of float32 to store
  30441. */
  30442. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30443. /**
  30444. * Set the value of an uniform to an array of float32 (stored as vec4)
  30445. * @param uniform defines the webGL uniform location where to store the value
  30446. * @param array defines the array of float32 to store
  30447. */
  30448. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30449. /**
  30450. * Set the value of an uniform to an array of number
  30451. * @param uniform defines the webGL uniform location where to store the value
  30452. * @param array defines the array of number to store
  30453. */
  30454. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30455. /**
  30456. * Set the value of an uniform to an array of number (stored as vec2)
  30457. * @param uniform defines the webGL uniform location where to store the value
  30458. * @param array defines the array of number to store
  30459. */
  30460. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30461. /**
  30462. * Set the value of an uniform to an array of number (stored as vec3)
  30463. * @param uniform defines the webGL uniform location where to store the value
  30464. * @param array defines the array of number to store
  30465. */
  30466. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30467. /**
  30468. * Set the value of an uniform to an array of number (stored as vec4)
  30469. * @param uniform defines the webGL uniform location where to store the value
  30470. * @param array defines the array of number to store
  30471. */
  30472. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30473. /**
  30474. * Set the value of an uniform to an array of float32 (stored as matrices)
  30475. * @param uniform defines the webGL uniform location where to store the value
  30476. * @param matrices defines the array of float32 to store
  30477. */
  30478. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30479. /**
  30480. * Set the value of an uniform to a matrix (3x3)
  30481. * @param uniform defines the webGL uniform location where to store the value
  30482. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30483. */
  30484. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30485. /**
  30486. * Set the value of an uniform to a matrix (2x2)
  30487. * @param uniform defines the webGL uniform location where to store the value
  30488. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30489. */
  30490. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30491. /**
  30492. * Set the value of an uniform to a number (int)
  30493. * @param uniform defines the webGL uniform location where to store the value
  30494. * @param value defines the int number to store
  30495. */
  30496. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30497. /**
  30498. * Set the value of an uniform to a number (float)
  30499. * @param uniform defines the webGL uniform location where to store the value
  30500. * @param value defines the float number to store
  30501. */
  30502. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30503. /**
  30504. * Set the value of an uniform to a vec2
  30505. * @param uniform defines the webGL uniform location where to store the value
  30506. * @param x defines the 1st component of the value
  30507. * @param y defines the 2nd component of the value
  30508. */
  30509. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30510. /**
  30511. * Set the value of an uniform to a vec3
  30512. * @param uniform defines the webGL uniform location where to store the value
  30513. * @param x defines the 1st component of the value
  30514. * @param y defines the 2nd component of the value
  30515. * @param z defines the 3rd component of the value
  30516. */
  30517. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30518. /**
  30519. * Set the value of an uniform to a boolean
  30520. * @param uniform defines the webGL uniform location where to store the value
  30521. * @param bool defines the boolean to store
  30522. */
  30523. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30524. /**
  30525. * Set the value of an uniform to a vec4
  30526. * @param uniform defines the webGL uniform location where to store the value
  30527. * @param x defines the 1st component of the value
  30528. * @param y defines the 2nd component of the value
  30529. * @param z defines the 3rd component of the value
  30530. * @param w defines the 4th component of the value
  30531. */
  30532. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30533. /**
  30534. * Sets a Color4 on a uniform variable
  30535. * @param uniform defines the uniform location
  30536. * @param color4 defines the value to be set
  30537. */
  30538. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30539. /**
  30540. * Gets the depth culling state manager
  30541. */
  30542. readonly depthCullingState: DepthCullingState;
  30543. /**
  30544. * Gets the alpha state manager
  30545. */
  30546. readonly alphaState: AlphaState;
  30547. /**
  30548. * Gets the stencil state manager
  30549. */
  30550. readonly stencilState: StencilState;
  30551. /**
  30552. * Clears the list of texture accessible through engine.
  30553. * This can help preventing texture load conflict due to name collision.
  30554. */
  30555. clearInternalTexturesCache(): void;
  30556. /**
  30557. * Force the entire cache to be cleared
  30558. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30559. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30560. */
  30561. wipeCaches(bruteForce?: boolean): void;
  30562. /** @hidden */
  30563. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30564. min: number;
  30565. mag: number;
  30566. };
  30567. /** @hidden */
  30568. _createTexture(): WebGLTexture;
  30569. /**
  30570. * Usually called from Texture.ts.
  30571. * Passed information to create a WebGLTexture
  30572. * @param urlArg defines a value which contains one of the following:
  30573. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30574. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30575. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30576. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30577. * @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)
  30578. * @param scene needed for loading to the correct scene
  30579. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30580. * @param onLoad optional callback to be called upon successful completion
  30581. * @param onError optional callback to be called upon failure
  30582. * @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
  30583. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30584. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30585. * @param forcedExtension defines the extension to use to pick the right loader
  30586. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30587. * @param mimeType defines an optional mime type
  30588. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30589. */
  30590. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30591. /**
  30592. * @hidden
  30593. */
  30594. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30595. /**
  30596. * Creates a raw texture
  30597. * @param data defines the data to store in the texture
  30598. * @param width defines the width of the texture
  30599. * @param height defines the height of the texture
  30600. * @param format defines the format of the data
  30601. * @param generateMipMaps defines if the engine should generate the mip levels
  30602. * @param invertY defines if data must be stored with Y axis inverted
  30603. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30604. * @param compression defines the compression used (null by default)
  30605. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30606. * @returns the raw texture inside an InternalTexture
  30607. */
  30608. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30609. /**
  30610. * Creates a new raw cube texture
  30611. * @param data defines the array of data to use to create each face
  30612. * @param size defines the size of the textures
  30613. * @param format defines the format of the data
  30614. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30615. * @param generateMipMaps defines if the engine should generate the mip levels
  30616. * @param invertY defines if data must be stored with Y axis inverted
  30617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30618. * @param compression defines the compression used (null by default)
  30619. * @returns the cube texture as an InternalTexture
  30620. */
  30621. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30622. /**
  30623. * Creates a new raw 3D texture
  30624. * @param data defines the data used to create the texture
  30625. * @param width defines the width of the texture
  30626. * @param height defines the height of the texture
  30627. * @param depth defines the depth of the texture
  30628. * @param format defines the format of the texture
  30629. * @param generateMipMaps defines if the engine must generate mip levels
  30630. * @param invertY defines if data must be stored with Y axis inverted
  30631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30632. * @param compression defines the compressed used (can be null)
  30633. * @param textureType defines the compressed used (can be null)
  30634. * @returns a new raw 3D texture (stored in an InternalTexture)
  30635. */
  30636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30637. private _unpackFlipYCached;
  30638. /**
  30639. * In case you are sharing the context with other applications, it might
  30640. * be interested to not cache the unpack flip y state to ensure a consistent
  30641. * value would be set.
  30642. */
  30643. enableUnpackFlipYCached: boolean;
  30644. /** @hidden */
  30645. _unpackFlipY(value: boolean): void;
  30646. /** @hidden */
  30647. _getUnpackAlignement(): number;
  30648. /**
  30649. * Update the sampling mode of a given texture
  30650. * @param samplingMode defines the required sampling mode
  30651. * @param texture defines the texture to update
  30652. */
  30653. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30654. /**
  30655. * Updates a depth texture Comparison Mode and Function.
  30656. * If the comparison Function is equal to 0, the mode will be set to none.
  30657. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30658. * @param texture The texture to set the comparison function for
  30659. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30660. */
  30661. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30662. /** @hidden */
  30663. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30664. width: number;
  30665. height: number;
  30666. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30667. /**
  30668. * Creates a depth stencil texture.
  30669. * This is only available in WebGL 2 or with the depth texture extension available.
  30670. * @param size The size of face edge in the texture.
  30671. * @param options The options defining the texture.
  30672. * @returns The texture
  30673. */
  30674. createDepthStencilTexture(size: number | {
  30675. width: number;
  30676. height: number;
  30677. }, options: DepthTextureCreationOptions): InternalTexture;
  30678. /**
  30679. * Creates a depth stencil texture.
  30680. * This is only available in WebGL 2 or with the depth texture extension available.
  30681. * @param size The size of face edge in the texture.
  30682. * @param options The options defining the texture.
  30683. * @returns The texture
  30684. */
  30685. private _createDepthStencilTexture;
  30686. /** @hidden */
  30687. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30688. /** @hidden */
  30689. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30690. /** @hidden */
  30691. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30692. /** @hidden */
  30693. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30694. /**
  30695. * @hidden
  30696. */
  30697. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30698. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30699. private _prepareWebGLTexture;
  30700. /** @hidden */
  30701. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30702. /** @hidden */
  30703. _releaseFramebufferObjects(texture: InternalTexture): void;
  30704. /** @hidden */
  30705. _releaseTexture(texture: InternalTexture): void;
  30706. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30707. protected _setProgram(program: WebGLProgram): void;
  30708. protected _boundUniforms: {
  30709. [key: number]: WebGLUniformLocation;
  30710. };
  30711. /**
  30712. * Binds an effect to the webGL context
  30713. * @param effect defines the effect to bind
  30714. */
  30715. bindSamplers(effect: Effect): void;
  30716. private _activateCurrentTexture;
  30717. /** @hidden */
  30718. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30719. /** @hidden */
  30720. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30721. /**
  30722. * Unbind all textures from the webGL context
  30723. */
  30724. unbindAllTextures(): void;
  30725. /**
  30726. * Sets a texture to the according uniform.
  30727. * @param channel The texture channel
  30728. * @param uniform The uniform to set
  30729. * @param texture The texture to apply
  30730. */
  30731. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30732. private _bindSamplerUniformToChannel;
  30733. private _getTextureWrapMode;
  30734. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30735. /**
  30736. * Sets an array of texture to the webGL context
  30737. * @param channel defines the channel where the texture array must be set
  30738. * @param uniform defines the associated uniform location
  30739. * @param textures defines the array of textures to bind
  30740. */
  30741. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30742. /** @hidden */
  30743. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30744. private _setTextureParameterFloat;
  30745. private _setTextureParameterInteger;
  30746. /**
  30747. * Unbind all vertex attributes from the webGL context
  30748. */
  30749. unbindAllAttributes(): void;
  30750. /**
  30751. * 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
  30752. */
  30753. releaseEffects(): void;
  30754. /**
  30755. * Dispose and release all associated resources
  30756. */
  30757. dispose(): void;
  30758. /**
  30759. * Attach a new callback raised when context lost event is fired
  30760. * @param callback defines the callback to call
  30761. */
  30762. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30763. /**
  30764. * Attach a new callback raised when context restored event is fired
  30765. * @param callback defines the callback to call
  30766. */
  30767. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30768. /**
  30769. * Get the current error code of the webGL context
  30770. * @returns the error code
  30771. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30772. */
  30773. getError(): number;
  30774. private _canRenderToFloatFramebuffer;
  30775. private _canRenderToHalfFloatFramebuffer;
  30776. private _canRenderToFramebuffer;
  30777. /** @hidden */
  30778. _getWebGLTextureType(type: number): number;
  30779. /** @hidden */
  30780. _getInternalFormat(format: number): number;
  30781. /** @hidden */
  30782. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30783. /** @hidden */
  30784. _getRGBAMultiSampleBufferFormat(type: number): number;
  30785. /** @hidden */
  30786. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30787. /**
  30788. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30789. * @returns true if the engine can be created
  30790. * @ignorenaming
  30791. */
  30792. static isSupported(): boolean;
  30793. /**
  30794. * Find the next highest power of two.
  30795. * @param x Number to start search from.
  30796. * @return Next highest power of two.
  30797. */
  30798. static CeilingPOT(x: number): number;
  30799. /**
  30800. * Find the next lowest power of two.
  30801. * @param x Number to start search from.
  30802. * @return Next lowest power of two.
  30803. */
  30804. static FloorPOT(x: number): number;
  30805. /**
  30806. * Find the nearest power of two.
  30807. * @param x Number to start search from.
  30808. * @return Next nearest power of two.
  30809. */
  30810. static NearestPOT(x: number): number;
  30811. /**
  30812. * Get the closest exponent of two
  30813. * @param value defines the value to approximate
  30814. * @param max defines the maximum value to return
  30815. * @param mode defines how to define the closest value
  30816. * @returns closest exponent of two of the given value
  30817. */
  30818. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30819. /**
  30820. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30821. * @param func - the function to be called
  30822. * @param requester - the object that will request the next frame. Falls back to window.
  30823. * @returns frame number
  30824. */
  30825. static QueueNewFrame(func: () => void, requester?: any): number;
  30826. }
  30827. }
  30828. declare module "babylonjs/Maths/sphericalPolynomial" {
  30829. import { Vector3 } from "babylonjs/Maths/math.vector";
  30830. import { Color3 } from "babylonjs/Maths/math.color";
  30831. /**
  30832. * Class representing spherical harmonics coefficients to the 3rd degree
  30833. */
  30834. export class SphericalHarmonics {
  30835. /**
  30836. * Defines whether or not the harmonics have been prescaled for rendering.
  30837. */
  30838. preScaled: boolean;
  30839. /**
  30840. * The l0,0 coefficients of the spherical harmonics
  30841. */
  30842. l00: Vector3;
  30843. /**
  30844. * The l1,-1 coefficients of the spherical harmonics
  30845. */
  30846. l1_1: Vector3;
  30847. /**
  30848. * The l1,0 coefficients of the spherical harmonics
  30849. */
  30850. l10: Vector3;
  30851. /**
  30852. * The l1,1 coefficients of the spherical harmonics
  30853. */
  30854. l11: Vector3;
  30855. /**
  30856. * The l2,-2 coefficients of the spherical harmonics
  30857. */
  30858. l2_2: Vector3;
  30859. /**
  30860. * The l2,-1 coefficients of the spherical harmonics
  30861. */
  30862. l2_1: Vector3;
  30863. /**
  30864. * The l2,0 coefficients of the spherical harmonics
  30865. */
  30866. l20: Vector3;
  30867. /**
  30868. * The l2,1 coefficients of the spherical harmonics
  30869. */
  30870. l21: Vector3;
  30871. /**
  30872. * The l2,2 coefficients of the spherical harmonics
  30873. */
  30874. l22: Vector3;
  30875. /**
  30876. * Adds a light to the spherical harmonics
  30877. * @param direction the direction of the light
  30878. * @param color the color of the light
  30879. * @param deltaSolidAngle the delta solid angle of the light
  30880. */
  30881. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30882. /**
  30883. * Scales the spherical harmonics by the given amount
  30884. * @param scale the amount to scale
  30885. */
  30886. scaleInPlace(scale: number): void;
  30887. /**
  30888. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30889. *
  30890. * ```
  30891. * E_lm = A_l * L_lm
  30892. * ```
  30893. *
  30894. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30895. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30896. * the scaling factors are given in equation 9.
  30897. */
  30898. convertIncidentRadianceToIrradiance(): void;
  30899. /**
  30900. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30901. *
  30902. * ```
  30903. * L = (1/pi) * E * rho
  30904. * ```
  30905. *
  30906. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30907. */
  30908. convertIrradianceToLambertianRadiance(): void;
  30909. /**
  30910. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30911. * required operations at run time.
  30912. *
  30913. * This is simply done by scaling back the SH with Ylm constants parameter.
  30914. * The trigonometric part being applied by the shader at run time.
  30915. */
  30916. preScaleForRendering(): void;
  30917. /**
  30918. * Constructs a spherical harmonics from an array.
  30919. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30920. * @returns the spherical harmonics
  30921. */
  30922. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30923. /**
  30924. * Gets the spherical harmonics from polynomial
  30925. * @param polynomial the spherical polynomial
  30926. * @returns the spherical harmonics
  30927. */
  30928. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30929. }
  30930. /**
  30931. * Class representing spherical polynomial coefficients to the 3rd degree
  30932. */
  30933. export class SphericalPolynomial {
  30934. private _harmonics;
  30935. /**
  30936. * The spherical harmonics used to create the polynomials.
  30937. */
  30938. readonly preScaledHarmonics: SphericalHarmonics;
  30939. /**
  30940. * The x coefficients of the spherical polynomial
  30941. */
  30942. x: Vector3;
  30943. /**
  30944. * The y coefficients of the spherical polynomial
  30945. */
  30946. y: Vector3;
  30947. /**
  30948. * The z coefficients of the spherical polynomial
  30949. */
  30950. z: Vector3;
  30951. /**
  30952. * The xx coefficients of the spherical polynomial
  30953. */
  30954. xx: Vector3;
  30955. /**
  30956. * The yy coefficients of the spherical polynomial
  30957. */
  30958. yy: Vector3;
  30959. /**
  30960. * The zz coefficients of the spherical polynomial
  30961. */
  30962. zz: Vector3;
  30963. /**
  30964. * The xy coefficients of the spherical polynomial
  30965. */
  30966. xy: Vector3;
  30967. /**
  30968. * The yz coefficients of the spherical polynomial
  30969. */
  30970. yz: Vector3;
  30971. /**
  30972. * The zx coefficients of the spherical polynomial
  30973. */
  30974. zx: Vector3;
  30975. /**
  30976. * Adds an ambient color to the spherical polynomial
  30977. * @param color the color to add
  30978. */
  30979. addAmbient(color: Color3): void;
  30980. /**
  30981. * Scales the spherical polynomial by the given amount
  30982. * @param scale the amount to scale
  30983. */
  30984. scaleInPlace(scale: number): void;
  30985. /**
  30986. * Gets the spherical polynomial from harmonics
  30987. * @param harmonics the spherical harmonics
  30988. * @returns the spherical polynomial
  30989. */
  30990. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30991. /**
  30992. * Constructs a spherical polynomial from an array.
  30993. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30994. * @returns the spherical polynomial
  30995. */
  30996. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30997. }
  30998. }
  30999. declare module "babylonjs/Materials/Textures/internalTexture" {
  31000. import { Observable } from "babylonjs/Misc/observable";
  31001. import { Nullable, int } from "babylonjs/types";
  31002. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31004. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31005. /**
  31006. * Defines the source of the internal texture
  31007. */
  31008. export enum InternalTextureSource {
  31009. /**
  31010. * The source of the texture data is unknown
  31011. */
  31012. Unknown = 0,
  31013. /**
  31014. * Texture data comes from an URL
  31015. */
  31016. Url = 1,
  31017. /**
  31018. * Texture data is only used for temporary storage
  31019. */
  31020. Temp = 2,
  31021. /**
  31022. * Texture data comes from raw data (ArrayBuffer)
  31023. */
  31024. Raw = 3,
  31025. /**
  31026. * Texture content is dynamic (video or dynamic texture)
  31027. */
  31028. Dynamic = 4,
  31029. /**
  31030. * Texture content is generated by rendering to it
  31031. */
  31032. RenderTarget = 5,
  31033. /**
  31034. * Texture content is part of a multi render target process
  31035. */
  31036. MultiRenderTarget = 6,
  31037. /**
  31038. * Texture data comes from a cube data file
  31039. */
  31040. Cube = 7,
  31041. /**
  31042. * Texture data comes from a raw cube data
  31043. */
  31044. CubeRaw = 8,
  31045. /**
  31046. * Texture data come from a prefiltered cube data file
  31047. */
  31048. CubePrefiltered = 9,
  31049. /**
  31050. * Texture content is raw 3D data
  31051. */
  31052. Raw3D = 10,
  31053. /**
  31054. * Texture content is a depth texture
  31055. */
  31056. Depth = 11,
  31057. /**
  31058. * Texture data comes from a raw cube data encoded with RGBD
  31059. */
  31060. CubeRawRGBD = 12
  31061. }
  31062. /**
  31063. * Class used to store data associated with WebGL texture data for the engine
  31064. * This class should not be used directly
  31065. */
  31066. export class InternalTexture {
  31067. /** @hidden */
  31068. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31069. /**
  31070. * Defines if the texture is ready
  31071. */
  31072. isReady: boolean;
  31073. /**
  31074. * Defines if the texture is a cube texture
  31075. */
  31076. isCube: boolean;
  31077. /**
  31078. * Defines if the texture contains 3D data
  31079. */
  31080. is3D: boolean;
  31081. /**
  31082. * Defines if the texture contains multiview data
  31083. */
  31084. isMultiview: boolean;
  31085. /**
  31086. * Gets the URL used to load this texture
  31087. */
  31088. url: string;
  31089. /**
  31090. * Gets the sampling mode of the texture
  31091. */
  31092. samplingMode: number;
  31093. /**
  31094. * Gets a boolean indicating if the texture needs mipmaps generation
  31095. */
  31096. generateMipMaps: boolean;
  31097. /**
  31098. * Gets the number of samples used by the texture (WebGL2+ only)
  31099. */
  31100. samples: number;
  31101. /**
  31102. * Gets the type of the texture (int, float...)
  31103. */
  31104. type: number;
  31105. /**
  31106. * Gets the format of the texture (RGB, RGBA...)
  31107. */
  31108. format: number;
  31109. /**
  31110. * Observable called when the texture is loaded
  31111. */
  31112. onLoadedObservable: Observable<InternalTexture>;
  31113. /**
  31114. * Gets the width of the texture
  31115. */
  31116. width: number;
  31117. /**
  31118. * Gets the height of the texture
  31119. */
  31120. height: number;
  31121. /**
  31122. * Gets the depth of the texture
  31123. */
  31124. depth: number;
  31125. /**
  31126. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31127. */
  31128. baseWidth: number;
  31129. /**
  31130. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31131. */
  31132. baseHeight: number;
  31133. /**
  31134. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31135. */
  31136. baseDepth: number;
  31137. /**
  31138. * Gets a boolean indicating if the texture is inverted on Y axis
  31139. */
  31140. invertY: boolean;
  31141. /** @hidden */
  31142. _invertVScale: boolean;
  31143. /** @hidden */
  31144. _associatedChannel: number;
  31145. /** @hidden */
  31146. _source: InternalTextureSource;
  31147. /** @hidden */
  31148. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31149. /** @hidden */
  31150. _bufferView: Nullable<ArrayBufferView>;
  31151. /** @hidden */
  31152. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31153. /** @hidden */
  31154. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31155. /** @hidden */
  31156. _size: number;
  31157. /** @hidden */
  31158. _extension: string;
  31159. /** @hidden */
  31160. _files: Nullable<string[]>;
  31161. /** @hidden */
  31162. _workingCanvas: Nullable<HTMLCanvasElement>;
  31163. /** @hidden */
  31164. _workingContext: Nullable<CanvasRenderingContext2D>;
  31165. /** @hidden */
  31166. _framebuffer: Nullable<WebGLFramebuffer>;
  31167. /** @hidden */
  31168. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31169. /** @hidden */
  31170. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31171. /** @hidden */
  31172. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31173. /** @hidden */
  31174. _attachments: Nullable<number[]>;
  31175. /** @hidden */
  31176. _cachedCoordinatesMode: Nullable<number>;
  31177. /** @hidden */
  31178. _cachedWrapU: Nullable<number>;
  31179. /** @hidden */
  31180. _cachedWrapV: Nullable<number>;
  31181. /** @hidden */
  31182. _cachedWrapR: Nullable<number>;
  31183. /** @hidden */
  31184. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31185. /** @hidden */
  31186. _isDisabled: boolean;
  31187. /** @hidden */
  31188. _compression: Nullable<string>;
  31189. /** @hidden */
  31190. _generateStencilBuffer: boolean;
  31191. /** @hidden */
  31192. _generateDepthBuffer: boolean;
  31193. /** @hidden */
  31194. _comparisonFunction: number;
  31195. /** @hidden */
  31196. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31197. /** @hidden */
  31198. _lodGenerationScale: number;
  31199. /** @hidden */
  31200. _lodGenerationOffset: number;
  31201. /** @hidden */
  31202. _colorTextureArray: Nullable<WebGLTexture>;
  31203. /** @hidden */
  31204. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31205. /** @hidden */
  31206. _lodTextureHigh: Nullable<BaseTexture>;
  31207. /** @hidden */
  31208. _lodTextureMid: Nullable<BaseTexture>;
  31209. /** @hidden */
  31210. _lodTextureLow: Nullable<BaseTexture>;
  31211. /** @hidden */
  31212. _isRGBD: boolean;
  31213. /** @hidden */
  31214. _linearSpecularLOD: boolean;
  31215. /** @hidden */
  31216. _irradianceTexture: Nullable<BaseTexture>;
  31217. /** @hidden */
  31218. _webGLTexture: Nullable<WebGLTexture>;
  31219. /** @hidden */
  31220. _references: number;
  31221. private _engine;
  31222. /**
  31223. * Gets the Engine the texture belongs to.
  31224. * @returns The babylon engine
  31225. */
  31226. getEngine(): ThinEngine;
  31227. /**
  31228. * Gets the data source type of the texture
  31229. */
  31230. readonly source: InternalTextureSource;
  31231. /**
  31232. * Creates a new InternalTexture
  31233. * @param engine defines the engine to use
  31234. * @param source defines the type of data that will be used
  31235. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31236. */
  31237. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31238. /**
  31239. * Increments the number of references (ie. the number of Texture that point to it)
  31240. */
  31241. incrementReferences(): void;
  31242. /**
  31243. * Change the size of the texture (not the size of the content)
  31244. * @param width defines the new width
  31245. * @param height defines the new height
  31246. * @param depth defines the new depth (1 by default)
  31247. */
  31248. updateSize(width: int, height: int, depth?: int): void;
  31249. /** @hidden */
  31250. _rebuild(): void;
  31251. /** @hidden */
  31252. _swapAndDie(target: InternalTexture): void;
  31253. /**
  31254. * Dispose the current allocated resources
  31255. */
  31256. dispose(): void;
  31257. }
  31258. }
  31259. declare module "babylonjs/Audio/analyser" {
  31260. import { Scene } from "babylonjs/scene";
  31261. /**
  31262. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31264. */
  31265. export class Analyser {
  31266. /**
  31267. * Gets or sets the smoothing
  31268. * @ignorenaming
  31269. */
  31270. SMOOTHING: number;
  31271. /**
  31272. * Gets or sets the FFT table size
  31273. * @ignorenaming
  31274. */
  31275. FFT_SIZE: number;
  31276. /**
  31277. * Gets or sets the bar graph amplitude
  31278. * @ignorenaming
  31279. */
  31280. BARGRAPHAMPLITUDE: number;
  31281. /**
  31282. * Gets or sets the position of the debug canvas
  31283. * @ignorenaming
  31284. */
  31285. DEBUGCANVASPOS: {
  31286. x: number;
  31287. y: number;
  31288. };
  31289. /**
  31290. * Gets or sets the debug canvas size
  31291. * @ignorenaming
  31292. */
  31293. DEBUGCANVASSIZE: {
  31294. width: number;
  31295. height: number;
  31296. };
  31297. private _byteFreqs;
  31298. private _byteTime;
  31299. private _floatFreqs;
  31300. private _webAudioAnalyser;
  31301. private _debugCanvas;
  31302. private _debugCanvasContext;
  31303. private _scene;
  31304. private _registerFunc;
  31305. private _audioEngine;
  31306. /**
  31307. * Creates a new analyser
  31308. * @param scene defines hosting scene
  31309. */
  31310. constructor(scene: Scene);
  31311. /**
  31312. * Get the number of data values you will have to play with for the visualization
  31313. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31314. * @returns a number
  31315. */
  31316. getFrequencyBinCount(): number;
  31317. /**
  31318. * Gets the current frequency data as a byte array
  31319. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31320. * @returns a Uint8Array
  31321. */
  31322. getByteFrequencyData(): Uint8Array;
  31323. /**
  31324. * Gets the current waveform as a byte array
  31325. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31326. * @returns a Uint8Array
  31327. */
  31328. getByteTimeDomainData(): Uint8Array;
  31329. /**
  31330. * Gets the current frequency data as a float array
  31331. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31332. * @returns a Float32Array
  31333. */
  31334. getFloatFrequencyData(): Float32Array;
  31335. /**
  31336. * Renders the debug canvas
  31337. */
  31338. drawDebugCanvas(): void;
  31339. /**
  31340. * Stops rendering the debug canvas and removes it
  31341. */
  31342. stopDebugCanvas(): void;
  31343. /**
  31344. * Connects two audio nodes
  31345. * @param inputAudioNode defines first node to connect
  31346. * @param outputAudioNode defines second node to connect
  31347. */
  31348. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31349. /**
  31350. * Releases all associated resources
  31351. */
  31352. dispose(): void;
  31353. }
  31354. }
  31355. declare module "babylonjs/Audio/audioEngine" {
  31356. import { IDisposable } from "babylonjs/scene";
  31357. import { Analyser } from "babylonjs/Audio/analyser";
  31358. import { Nullable } from "babylonjs/types";
  31359. import { Observable } from "babylonjs/Misc/observable";
  31360. /**
  31361. * This represents an audio engine and it is responsible
  31362. * to play, synchronize and analyse sounds throughout the application.
  31363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31364. */
  31365. export interface IAudioEngine extends IDisposable {
  31366. /**
  31367. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31368. */
  31369. readonly canUseWebAudio: boolean;
  31370. /**
  31371. * Gets the current AudioContext if available.
  31372. */
  31373. readonly audioContext: Nullable<AudioContext>;
  31374. /**
  31375. * The master gain node defines the global audio volume of your audio engine.
  31376. */
  31377. readonly masterGain: GainNode;
  31378. /**
  31379. * Gets whether or not mp3 are supported by your browser.
  31380. */
  31381. readonly isMP3supported: boolean;
  31382. /**
  31383. * Gets whether or not ogg are supported by your browser.
  31384. */
  31385. readonly isOGGsupported: boolean;
  31386. /**
  31387. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31388. * @ignoreNaming
  31389. */
  31390. WarnedWebAudioUnsupported: boolean;
  31391. /**
  31392. * Defines if the audio engine relies on a custom unlocked button.
  31393. * In this case, the embedded button will not be displayed.
  31394. */
  31395. useCustomUnlockedButton: boolean;
  31396. /**
  31397. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31398. */
  31399. readonly unlocked: boolean;
  31400. /**
  31401. * Event raised when audio has been unlocked on the browser.
  31402. */
  31403. onAudioUnlockedObservable: Observable<AudioEngine>;
  31404. /**
  31405. * Event raised when audio has been locked on the browser.
  31406. */
  31407. onAudioLockedObservable: Observable<AudioEngine>;
  31408. /**
  31409. * Flags the audio engine in Locked state.
  31410. * This happens due to new browser policies preventing audio to autoplay.
  31411. */
  31412. lock(): void;
  31413. /**
  31414. * Unlocks the audio engine once a user action has been done on the dom.
  31415. * This is helpful to resume play once browser policies have been satisfied.
  31416. */
  31417. unlock(): void;
  31418. }
  31419. /**
  31420. * This represents the default audio engine used in babylon.
  31421. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31423. */
  31424. export class AudioEngine implements IAudioEngine {
  31425. private _audioContext;
  31426. private _audioContextInitialized;
  31427. private _muteButton;
  31428. private _hostElement;
  31429. /**
  31430. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31431. */
  31432. canUseWebAudio: boolean;
  31433. /**
  31434. * The master gain node defines the global audio volume of your audio engine.
  31435. */
  31436. masterGain: GainNode;
  31437. /**
  31438. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31439. * @ignoreNaming
  31440. */
  31441. WarnedWebAudioUnsupported: boolean;
  31442. /**
  31443. * Gets whether or not mp3 are supported by your browser.
  31444. */
  31445. isMP3supported: boolean;
  31446. /**
  31447. * Gets whether or not ogg are supported by your browser.
  31448. */
  31449. isOGGsupported: boolean;
  31450. /**
  31451. * Gets whether audio has been unlocked on the device.
  31452. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31453. * a user interaction has happened.
  31454. */
  31455. unlocked: boolean;
  31456. /**
  31457. * Defines if the audio engine relies on a custom unlocked button.
  31458. * In this case, the embedded button will not be displayed.
  31459. */
  31460. useCustomUnlockedButton: boolean;
  31461. /**
  31462. * Event raised when audio has been unlocked on the browser.
  31463. */
  31464. onAudioUnlockedObservable: Observable<AudioEngine>;
  31465. /**
  31466. * Event raised when audio has been locked on the browser.
  31467. */
  31468. onAudioLockedObservable: Observable<AudioEngine>;
  31469. /**
  31470. * Gets the current AudioContext if available.
  31471. */
  31472. readonly audioContext: Nullable<AudioContext>;
  31473. private _connectedAnalyser;
  31474. /**
  31475. * Instantiates a new audio engine.
  31476. *
  31477. * There should be only one per page as some browsers restrict the number
  31478. * of audio contexts you can create.
  31479. * @param hostElement defines the host element where to display the mute icon if necessary
  31480. */
  31481. constructor(hostElement?: Nullable<HTMLElement>);
  31482. /**
  31483. * Flags the audio engine in Locked state.
  31484. * This happens due to new browser policies preventing audio to autoplay.
  31485. */
  31486. lock(): void;
  31487. /**
  31488. * Unlocks the audio engine once a user action has been done on the dom.
  31489. * This is helpful to resume play once browser policies have been satisfied.
  31490. */
  31491. unlock(): void;
  31492. private _resumeAudioContext;
  31493. private _initializeAudioContext;
  31494. private _tryToRun;
  31495. private _triggerRunningState;
  31496. private _triggerSuspendedState;
  31497. private _displayMuteButton;
  31498. private _moveButtonToTopLeft;
  31499. private _onResize;
  31500. private _hideMuteButton;
  31501. /**
  31502. * Destroy and release the resources associated with the audio ccontext.
  31503. */
  31504. dispose(): void;
  31505. /**
  31506. * Gets the global volume sets on the master gain.
  31507. * @returns the global volume if set or -1 otherwise
  31508. */
  31509. getGlobalVolume(): number;
  31510. /**
  31511. * Sets the global volume of your experience (sets on the master gain).
  31512. * @param newVolume Defines the new global volume of the application
  31513. */
  31514. setGlobalVolume(newVolume: number): void;
  31515. /**
  31516. * Connect the audio engine to an audio analyser allowing some amazing
  31517. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31519. * @param analyser The analyser to connect to the engine
  31520. */
  31521. connectToAnalyser(analyser: Analyser): void;
  31522. }
  31523. }
  31524. declare module "babylonjs/Loading/loadingScreen" {
  31525. /**
  31526. * Interface used to present a loading screen while loading a scene
  31527. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31528. */
  31529. export interface ILoadingScreen {
  31530. /**
  31531. * Function called to display the loading screen
  31532. */
  31533. displayLoadingUI: () => void;
  31534. /**
  31535. * Function called to hide the loading screen
  31536. */
  31537. hideLoadingUI: () => void;
  31538. /**
  31539. * Gets or sets the color to use for the background
  31540. */
  31541. loadingUIBackgroundColor: string;
  31542. /**
  31543. * Gets or sets the text to display while loading
  31544. */
  31545. loadingUIText: string;
  31546. }
  31547. /**
  31548. * Class used for the default loading screen
  31549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31550. */
  31551. export class DefaultLoadingScreen implements ILoadingScreen {
  31552. private _renderingCanvas;
  31553. private _loadingText;
  31554. private _loadingDivBackgroundColor;
  31555. private _loadingDiv;
  31556. private _loadingTextDiv;
  31557. /** Gets or sets the logo url to use for the default loading screen */
  31558. static DefaultLogoUrl: string;
  31559. /** Gets or sets the spinner url to use for the default loading screen */
  31560. static DefaultSpinnerUrl: string;
  31561. /**
  31562. * Creates a new default loading screen
  31563. * @param _renderingCanvas defines the canvas used to render the scene
  31564. * @param _loadingText defines the default text to display
  31565. * @param _loadingDivBackgroundColor defines the default background color
  31566. */
  31567. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31568. /**
  31569. * Function called to display the loading screen
  31570. */
  31571. displayLoadingUI(): void;
  31572. /**
  31573. * Function called to hide the loading screen
  31574. */
  31575. hideLoadingUI(): void;
  31576. /**
  31577. * Gets or sets the text to display while loading
  31578. */
  31579. loadingUIText: string;
  31580. /**
  31581. * Gets or sets the color to use for the background
  31582. */
  31583. loadingUIBackgroundColor: string;
  31584. private _resizeLoadingUI;
  31585. }
  31586. }
  31587. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31588. /**
  31589. * Interface for any object that can request an animation frame
  31590. */
  31591. export interface ICustomAnimationFrameRequester {
  31592. /**
  31593. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31594. */
  31595. renderFunction?: Function;
  31596. /**
  31597. * Called to request the next frame to render to
  31598. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31599. */
  31600. requestAnimationFrame: Function;
  31601. /**
  31602. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31603. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31604. */
  31605. requestID?: number;
  31606. }
  31607. }
  31608. declare module "babylonjs/Misc/performanceMonitor" {
  31609. /**
  31610. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31611. */
  31612. export class PerformanceMonitor {
  31613. private _enabled;
  31614. private _rollingFrameTime;
  31615. private _lastFrameTimeMs;
  31616. /**
  31617. * constructor
  31618. * @param frameSampleSize The number of samples required to saturate the sliding window
  31619. */
  31620. constructor(frameSampleSize?: number);
  31621. /**
  31622. * Samples current frame
  31623. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31624. */
  31625. sampleFrame(timeMs?: number): void;
  31626. /**
  31627. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31628. */
  31629. readonly averageFrameTime: number;
  31630. /**
  31631. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31632. */
  31633. readonly averageFrameTimeVariance: number;
  31634. /**
  31635. * Returns the frame time of the most recent frame
  31636. */
  31637. readonly instantaneousFrameTime: number;
  31638. /**
  31639. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31640. */
  31641. readonly averageFPS: number;
  31642. /**
  31643. * Returns the average framerate in frames per second using the most recent frame time
  31644. */
  31645. readonly instantaneousFPS: number;
  31646. /**
  31647. * Returns true if enough samples have been taken to completely fill the sliding window
  31648. */
  31649. readonly isSaturated: boolean;
  31650. /**
  31651. * Enables contributions to the sliding window sample set
  31652. */
  31653. enable(): void;
  31654. /**
  31655. * Disables contributions to the sliding window sample set
  31656. * Samples will not be interpolated over the disabled period
  31657. */
  31658. disable(): void;
  31659. /**
  31660. * Returns true if sampling is enabled
  31661. */
  31662. readonly isEnabled: boolean;
  31663. /**
  31664. * Resets performance monitor
  31665. */
  31666. reset(): void;
  31667. }
  31668. /**
  31669. * RollingAverage
  31670. *
  31671. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31672. */
  31673. export class RollingAverage {
  31674. /**
  31675. * Current average
  31676. */
  31677. average: number;
  31678. /**
  31679. * Current variance
  31680. */
  31681. variance: number;
  31682. protected _samples: Array<number>;
  31683. protected _sampleCount: number;
  31684. protected _pos: number;
  31685. protected _m2: number;
  31686. /**
  31687. * constructor
  31688. * @param length The number of samples required to saturate the sliding window
  31689. */
  31690. constructor(length: number);
  31691. /**
  31692. * Adds a sample to the sample set
  31693. * @param v The sample value
  31694. */
  31695. add(v: number): void;
  31696. /**
  31697. * Returns previously added values or null if outside of history or outside the sliding window domain
  31698. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31699. * @return Value previously recorded with add() or null if outside of range
  31700. */
  31701. history(i: number): number;
  31702. /**
  31703. * Returns true if enough samples have been taken to completely fill the sliding window
  31704. * @return true if sample-set saturated
  31705. */
  31706. isSaturated(): boolean;
  31707. /**
  31708. * Resets the rolling average (equivalent to 0 samples taken so far)
  31709. */
  31710. reset(): void;
  31711. /**
  31712. * Wraps a value around the sample range boundaries
  31713. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31714. * @return Wrapped position in sample range
  31715. */
  31716. protected _wrapPosition(i: number): number;
  31717. }
  31718. }
  31719. declare module "babylonjs/Misc/perfCounter" {
  31720. /**
  31721. * This class is used to track a performance counter which is number based.
  31722. * The user has access to many properties which give statistics of different nature.
  31723. *
  31724. * The implementer can track two kinds of Performance Counter: time and count.
  31725. * 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.
  31726. * 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.
  31727. */
  31728. export class PerfCounter {
  31729. /**
  31730. * Gets or sets a global boolean to turn on and off all the counters
  31731. */
  31732. static Enabled: boolean;
  31733. /**
  31734. * Returns the smallest value ever
  31735. */
  31736. readonly min: number;
  31737. /**
  31738. * Returns the biggest value ever
  31739. */
  31740. readonly max: number;
  31741. /**
  31742. * Returns the average value since the performance counter is running
  31743. */
  31744. readonly average: number;
  31745. /**
  31746. * Returns the average value of the last second the counter was monitored
  31747. */
  31748. readonly lastSecAverage: number;
  31749. /**
  31750. * Returns the current value
  31751. */
  31752. readonly current: number;
  31753. /**
  31754. * Gets the accumulated total
  31755. */
  31756. readonly total: number;
  31757. /**
  31758. * Gets the total value count
  31759. */
  31760. readonly count: number;
  31761. /**
  31762. * Creates a new counter
  31763. */
  31764. constructor();
  31765. /**
  31766. * Call this method to start monitoring a new frame.
  31767. * 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.
  31768. */
  31769. fetchNewFrame(): void;
  31770. /**
  31771. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31772. * @param newCount the count value to add to the monitored count
  31773. * @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.
  31774. */
  31775. addCount(newCount: number, fetchResult: boolean): void;
  31776. /**
  31777. * Start monitoring this performance counter
  31778. */
  31779. beginMonitoring(): void;
  31780. /**
  31781. * Compute the time lapsed since the previous beginMonitoring() call.
  31782. * @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
  31783. */
  31784. endMonitoring(newFrame?: boolean): void;
  31785. private _fetchResult;
  31786. private _startMonitoringTime;
  31787. private _min;
  31788. private _max;
  31789. private _average;
  31790. private _current;
  31791. private _totalValueCount;
  31792. private _totalAccumulated;
  31793. private _lastSecAverage;
  31794. private _lastSecAccumulated;
  31795. private _lastSecTime;
  31796. private _lastSecValueCount;
  31797. }
  31798. }
  31799. declare module "babylonjs/Engines/engine" {
  31800. import { Observable } from "babylonjs/Misc/observable";
  31801. import { Nullable, IndicesArray } from "babylonjs/types";
  31802. import { Scene } from "babylonjs/scene";
  31803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31804. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31805. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31806. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31807. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31808. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31809. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31810. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31811. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31813. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31814. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31815. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31816. import { Material } from "babylonjs/Materials/material";
  31817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31818. /**
  31819. * Defines the interface used by display changed events
  31820. */
  31821. export interface IDisplayChangedEventArgs {
  31822. /** Gets the vrDisplay object (if any) */
  31823. vrDisplay: Nullable<any>;
  31824. /** Gets a boolean indicating if webVR is supported */
  31825. vrSupported: boolean;
  31826. }
  31827. /**
  31828. * Defines the interface used by objects containing a viewport (like a camera)
  31829. */
  31830. interface IViewportOwnerLike {
  31831. /**
  31832. * Gets or sets the viewport
  31833. */
  31834. viewport: IViewportLike;
  31835. }
  31836. /**
  31837. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31838. */
  31839. export class Engine extends ThinEngine {
  31840. /** Defines that alpha blending is disabled */
  31841. static readonly ALPHA_DISABLE: number;
  31842. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31843. static readonly ALPHA_ADD: number;
  31844. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31845. static readonly ALPHA_COMBINE: number;
  31846. /** Defines that alpha blending to DEST - SRC * DEST */
  31847. static readonly ALPHA_SUBTRACT: number;
  31848. /** Defines that alpha blending to SRC * DEST */
  31849. static readonly ALPHA_MULTIPLY: number;
  31850. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31851. static readonly ALPHA_MAXIMIZED: number;
  31852. /** Defines that alpha blending to SRC + DEST */
  31853. static readonly ALPHA_ONEONE: number;
  31854. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31855. static readonly ALPHA_PREMULTIPLIED: number;
  31856. /**
  31857. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31858. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31859. */
  31860. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31861. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31862. static readonly ALPHA_INTERPOLATE: number;
  31863. /**
  31864. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31865. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31866. */
  31867. static readonly ALPHA_SCREENMODE: number;
  31868. /** Defines that the ressource is not delayed*/
  31869. static readonly DELAYLOADSTATE_NONE: number;
  31870. /** Defines that the ressource was successfully delay loaded */
  31871. static readonly DELAYLOADSTATE_LOADED: number;
  31872. /** Defines that the ressource is currently delay loading */
  31873. static readonly DELAYLOADSTATE_LOADING: number;
  31874. /** Defines that the ressource is delayed and has not started loading */
  31875. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31876. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31877. static readonly NEVER: number;
  31878. /** 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 */
  31879. static readonly ALWAYS: number;
  31880. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31881. static readonly LESS: number;
  31882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31883. static readonly EQUAL: number;
  31884. /** 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 */
  31885. static readonly LEQUAL: number;
  31886. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31887. static readonly GREATER: number;
  31888. /** 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 */
  31889. static readonly GEQUAL: number;
  31890. /** 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 */
  31891. static readonly NOTEQUAL: number;
  31892. /** Passed to stencilOperation to specify that stencil value must be kept */
  31893. static readonly KEEP: number;
  31894. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31895. static readonly REPLACE: number;
  31896. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31897. static readonly INCR: number;
  31898. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31899. static readonly DECR: number;
  31900. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31901. static readonly INVERT: number;
  31902. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31903. static readonly INCR_WRAP: number;
  31904. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31905. static readonly DECR_WRAP: number;
  31906. /** Texture is not repeating outside of 0..1 UVs */
  31907. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31908. /** Texture is repeating outside of 0..1 UVs */
  31909. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31910. /** Texture is repeating and mirrored */
  31911. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31912. /** ALPHA */
  31913. static readonly TEXTUREFORMAT_ALPHA: number;
  31914. /** LUMINANCE */
  31915. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31916. /** LUMINANCE_ALPHA */
  31917. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31918. /** RGB */
  31919. static readonly TEXTUREFORMAT_RGB: number;
  31920. /** RGBA */
  31921. static readonly TEXTUREFORMAT_RGBA: number;
  31922. /** RED */
  31923. static readonly TEXTUREFORMAT_RED: number;
  31924. /** RED (2nd reference) */
  31925. static readonly TEXTUREFORMAT_R: number;
  31926. /** RG */
  31927. static readonly TEXTUREFORMAT_RG: number;
  31928. /** RED_INTEGER */
  31929. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31930. /** RED_INTEGER (2nd reference) */
  31931. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31932. /** RG_INTEGER */
  31933. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31934. /** RGB_INTEGER */
  31935. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31936. /** RGBA_INTEGER */
  31937. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31938. /** UNSIGNED_BYTE */
  31939. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31940. /** UNSIGNED_BYTE (2nd reference) */
  31941. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31942. /** FLOAT */
  31943. static readonly TEXTURETYPE_FLOAT: number;
  31944. /** HALF_FLOAT */
  31945. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31946. /** BYTE */
  31947. static readonly TEXTURETYPE_BYTE: number;
  31948. /** SHORT */
  31949. static readonly TEXTURETYPE_SHORT: number;
  31950. /** UNSIGNED_SHORT */
  31951. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31952. /** INT */
  31953. static readonly TEXTURETYPE_INT: number;
  31954. /** UNSIGNED_INT */
  31955. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31956. /** UNSIGNED_SHORT_4_4_4_4 */
  31957. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31958. /** UNSIGNED_SHORT_5_5_5_1 */
  31959. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31960. /** UNSIGNED_SHORT_5_6_5 */
  31961. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31962. /** UNSIGNED_INT_2_10_10_10_REV */
  31963. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31964. /** UNSIGNED_INT_24_8 */
  31965. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31966. /** UNSIGNED_INT_10F_11F_11F_REV */
  31967. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31968. /** UNSIGNED_INT_5_9_9_9_REV */
  31969. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31970. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31971. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31972. /** nearest is mag = nearest and min = nearest and mip = linear */
  31973. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31974. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31975. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31976. /** Trilinear is mag = linear and min = linear and mip = linear */
  31977. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31978. /** nearest is mag = nearest and min = nearest and mip = linear */
  31979. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31981. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31982. /** Trilinear is mag = linear and min = linear and mip = linear */
  31983. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31984. /** mag = nearest and min = nearest and mip = nearest */
  31985. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31986. /** mag = nearest and min = linear and mip = nearest */
  31987. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31988. /** mag = nearest and min = linear and mip = linear */
  31989. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31990. /** mag = nearest and min = linear and mip = none */
  31991. static readonly TEXTURE_NEAREST_LINEAR: number;
  31992. /** mag = nearest and min = nearest and mip = none */
  31993. static readonly TEXTURE_NEAREST_NEAREST: number;
  31994. /** mag = linear and min = nearest and mip = nearest */
  31995. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31996. /** mag = linear and min = nearest and mip = linear */
  31997. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31998. /** mag = linear and min = linear and mip = none */
  31999. static readonly TEXTURE_LINEAR_LINEAR: number;
  32000. /** mag = linear and min = nearest and mip = none */
  32001. static readonly TEXTURE_LINEAR_NEAREST: number;
  32002. /** Explicit coordinates mode */
  32003. static readonly TEXTURE_EXPLICIT_MODE: number;
  32004. /** Spherical coordinates mode */
  32005. static readonly TEXTURE_SPHERICAL_MODE: number;
  32006. /** Planar coordinates mode */
  32007. static readonly TEXTURE_PLANAR_MODE: number;
  32008. /** Cubic coordinates mode */
  32009. static readonly TEXTURE_CUBIC_MODE: number;
  32010. /** Projection coordinates mode */
  32011. static readonly TEXTURE_PROJECTION_MODE: number;
  32012. /** Skybox coordinates mode */
  32013. static readonly TEXTURE_SKYBOX_MODE: number;
  32014. /** Inverse Cubic coordinates mode */
  32015. static readonly TEXTURE_INVCUBIC_MODE: number;
  32016. /** Equirectangular coordinates mode */
  32017. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32018. /** Equirectangular Fixed coordinates mode */
  32019. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32020. /** Equirectangular Fixed Mirrored coordinates mode */
  32021. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32022. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32023. static readonly SCALEMODE_FLOOR: number;
  32024. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32025. static readonly SCALEMODE_NEAREST: number;
  32026. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32027. static readonly SCALEMODE_CEILING: number;
  32028. /**
  32029. * Returns the current npm package of the sdk
  32030. */
  32031. static readonly NpmPackage: string;
  32032. /**
  32033. * Returns the current version of the framework
  32034. */
  32035. static readonly Version: string;
  32036. /** Gets the list of created engines */
  32037. static readonly Instances: Engine[];
  32038. /**
  32039. * Gets the latest created engine
  32040. */
  32041. static readonly LastCreatedEngine: Nullable<Engine>;
  32042. /**
  32043. * Gets the latest created scene
  32044. */
  32045. static readonly LastCreatedScene: Nullable<Scene>;
  32046. /**
  32047. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32048. * @param flag defines which part of the materials must be marked as dirty
  32049. * @param predicate defines a predicate used to filter which materials should be affected
  32050. */
  32051. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32052. /**
  32053. * Method called to create the default loading screen.
  32054. * This can be overriden in your own app.
  32055. * @param canvas The rendering canvas element
  32056. * @returns The loading screen
  32057. */
  32058. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32059. /**
  32060. * Method called to create the default rescale post process on each engine.
  32061. */
  32062. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32063. /**
  32064. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32065. **/
  32066. enableOfflineSupport: boolean;
  32067. /**
  32068. * 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)
  32069. **/
  32070. disableManifestCheck: boolean;
  32071. /**
  32072. * Gets the list of created scenes
  32073. */
  32074. scenes: Scene[];
  32075. /**
  32076. * Event raised when a new scene is created
  32077. */
  32078. onNewSceneAddedObservable: Observable<Scene>;
  32079. /**
  32080. * Gets the list of created postprocesses
  32081. */
  32082. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32083. /**
  32084. * Gets a boolean indicating if the pointer is currently locked
  32085. */
  32086. isPointerLock: boolean;
  32087. /**
  32088. * Observable event triggered each time the rendering canvas is resized
  32089. */
  32090. onResizeObservable: Observable<Engine>;
  32091. /**
  32092. * Observable event triggered each time the canvas loses focus
  32093. */
  32094. onCanvasBlurObservable: Observable<Engine>;
  32095. /**
  32096. * Observable event triggered each time the canvas gains focus
  32097. */
  32098. onCanvasFocusObservable: Observable<Engine>;
  32099. /**
  32100. * Observable event triggered each time the canvas receives pointerout event
  32101. */
  32102. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32103. /**
  32104. * Observable raised when the engine begins a new frame
  32105. */
  32106. onBeginFrameObservable: Observable<Engine>;
  32107. /**
  32108. * If set, will be used to request the next animation frame for the render loop
  32109. */
  32110. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32111. /**
  32112. * Observable raised when the engine ends the current frame
  32113. */
  32114. onEndFrameObservable: Observable<Engine>;
  32115. /**
  32116. * Observable raised when the engine is about to compile a shader
  32117. */
  32118. onBeforeShaderCompilationObservable: Observable<Engine>;
  32119. /**
  32120. * Observable raised when the engine has jsut compiled a shader
  32121. */
  32122. onAfterShaderCompilationObservable: Observable<Engine>;
  32123. /**
  32124. * Gets the audio engine
  32125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32126. * @ignorenaming
  32127. */
  32128. static audioEngine: IAudioEngine;
  32129. /**
  32130. * Default AudioEngine factory responsible of creating the Audio Engine.
  32131. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32132. */
  32133. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32134. /**
  32135. * Default offline support factory responsible of creating a tool used to store data locally.
  32136. * By default, this will create a Database object if the workload has been embedded.
  32137. */
  32138. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32139. private _loadingScreen;
  32140. private _pointerLockRequested;
  32141. private _dummyFramebuffer;
  32142. private _rescalePostProcess;
  32143. /** @hidden */
  32144. protected _alphaMode: number;
  32145. /** @hidden */
  32146. protected _alphaEquation: number;
  32147. private _deterministicLockstep;
  32148. private _lockstepMaxSteps;
  32149. protected readonly _supportsHardwareTextureRescaling: boolean;
  32150. private _fps;
  32151. private _deltaTime;
  32152. /** @hidden */
  32153. _drawCalls: PerfCounter;
  32154. /**
  32155. * Turn this value on if you want to pause FPS computation when in background
  32156. */
  32157. disablePerformanceMonitorInBackground: boolean;
  32158. private _performanceMonitor;
  32159. /**
  32160. * Gets the performance monitor attached to this engine
  32161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32162. */
  32163. readonly performanceMonitor: PerformanceMonitor;
  32164. private _onFocus;
  32165. private _onBlur;
  32166. private _onCanvasPointerOut;
  32167. private _onCanvasBlur;
  32168. private _onCanvasFocus;
  32169. private _onFullscreenChange;
  32170. private _onPointerLockChange;
  32171. /**
  32172. * Creates a new engine
  32173. * @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
  32174. * @param antialias defines enable antialiasing (default: false)
  32175. * @param options defines further options to be sent to the getContext() function
  32176. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32177. */
  32178. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32179. /**
  32180. * Gets current aspect ratio
  32181. * @param viewportOwner defines the camera to use to get the aspect ratio
  32182. * @param useScreen defines if screen size must be used (or the current render target if any)
  32183. * @returns a number defining the aspect ratio
  32184. */
  32185. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32186. /**
  32187. * Gets current screen aspect ratio
  32188. * @returns a number defining the aspect ratio
  32189. */
  32190. getScreenAspectRatio(): number;
  32191. /**
  32192. * Gets host document
  32193. * @returns the host document object
  32194. */
  32195. getHostDocument(): Document;
  32196. /**
  32197. * Gets the client rect of the HTML canvas attached with the current webGL context
  32198. * @returns a client rectanglee
  32199. */
  32200. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32201. /**
  32202. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32204. * @returns true if engine is in deterministic lock step mode
  32205. */
  32206. isDeterministicLockStep(): boolean;
  32207. /**
  32208. * Gets the max steps when engine is running in deterministic lock step
  32209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32210. * @returns the max steps
  32211. */
  32212. getLockstepMaxSteps(): number;
  32213. /**
  32214. * Force the mipmap generation for the given render target texture
  32215. * @param texture defines the render target texture to use
  32216. */
  32217. generateMipMapsForCubemap(texture: InternalTexture): void;
  32218. /** States */
  32219. /**
  32220. * Set various states to the webGL context
  32221. * @param culling defines backface culling state
  32222. * @param zOffset defines the value to apply to zOffset (0 by default)
  32223. * @param force defines if states must be applied even if cache is up to date
  32224. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32225. */
  32226. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32227. /**
  32228. * Set the z offset to apply to current rendering
  32229. * @param value defines the offset to apply
  32230. */
  32231. setZOffset(value: number): void;
  32232. /**
  32233. * Gets the current value of the zOffset
  32234. * @returns the current zOffset state
  32235. */
  32236. getZOffset(): number;
  32237. /**
  32238. * Enable or disable depth buffering
  32239. * @param enable defines the state to set
  32240. */
  32241. setDepthBuffer(enable: boolean): void;
  32242. /**
  32243. * Gets a boolean indicating if depth writing is enabled
  32244. * @returns the current depth writing state
  32245. */
  32246. getDepthWrite(): boolean;
  32247. /**
  32248. * Enable or disable depth writing
  32249. * @param enable defines the state to set
  32250. */
  32251. setDepthWrite(enable: boolean): void;
  32252. /**
  32253. * Enable or disable color writing
  32254. * @param enable defines the state to set
  32255. */
  32256. setColorWrite(enable: boolean): void;
  32257. /**
  32258. * Gets a boolean indicating if color writing is enabled
  32259. * @returns the current color writing state
  32260. */
  32261. getColorWrite(): boolean;
  32262. /**
  32263. * Sets alpha constants used by some alpha blending modes
  32264. * @param r defines the red component
  32265. * @param g defines the green component
  32266. * @param b defines the blue component
  32267. * @param a defines the alpha component
  32268. */
  32269. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32270. /**
  32271. * Sets the current alpha mode
  32272. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32273. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32275. */
  32276. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32277. /**
  32278. * Gets the current alpha mode
  32279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32280. * @returns the current alpha mode
  32281. */
  32282. getAlphaMode(): number;
  32283. /**
  32284. * Sets the current alpha equation
  32285. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32286. */
  32287. setAlphaEquation(equation: number): void;
  32288. /**
  32289. * Gets the current alpha equation.
  32290. * @returns the current alpha equation
  32291. */
  32292. getAlphaEquation(): number;
  32293. /**
  32294. * Gets a boolean indicating if stencil buffer is enabled
  32295. * @returns the current stencil buffer state
  32296. */
  32297. getStencilBuffer(): boolean;
  32298. /**
  32299. * Enable or disable the stencil buffer
  32300. * @param enable defines if the stencil buffer must be enabled or disabled
  32301. */
  32302. setStencilBuffer(enable: boolean): void;
  32303. /**
  32304. * Gets the current stencil mask
  32305. * @returns a number defining the new stencil mask to use
  32306. */
  32307. getStencilMask(): number;
  32308. /**
  32309. * Sets the current stencil mask
  32310. * @param mask defines the new stencil mask to use
  32311. */
  32312. setStencilMask(mask: number): void;
  32313. /**
  32314. * Gets the current stencil function
  32315. * @returns a number defining the stencil function to use
  32316. */
  32317. getStencilFunction(): number;
  32318. /**
  32319. * Gets the current stencil reference value
  32320. * @returns a number defining the stencil reference value to use
  32321. */
  32322. getStencilFunctionReference(): number;
  32323. /**
  32324. * Gets the current stencil mask
  32325. * @returns a number defining the stencil mask to use
  32326. */
  32327. getStencilFunctionMask(): number;
  32328. /**
  32329. * Sets the current stencil function
  32330. * @param stencilFunc defines the new stencil function to use
  32331. */
  32332. setStencilFunction(stencilFunc: number): void;
  32333. /**
  32334. * Sets the current stencil reference
  32335. * @param reference defines the new stencil reference to use
  32336. */
  32337. setStencilFunctionReference(reference: number): void;
  32338. /**
  32339. * Sets the current stencil mask
  32340. * @param mask defines the new stencil mask to use
  32341. */
  32342. setStencilFunctionMask(mask: number): void;
  32343. /**
  32344. * Gets the current stencil operation when stencil fails
  32345. * @returns a number defining stencil operation to use when stencil fails
  32346. */
  32347. getStencilOperationFail(): number;
  32348. /**
  32349. * Gets the current stencil operation when depth fails
  32350. * @returns a number defining stencil operation to use when depth fails
  32351. */
  32352. getStencilOperationDepthFail(): number;
  32353. /**
  32354. * Gets the current stencil operation when stencil passes
  32355. * @returns a number defining stencil operation to use when stencil passes
  32356. */
  32357. getStencilOperationPass(): number;
  32358. /**
  32359. * Sets the stencil operation to use when stencil fails
  32360. * @param operation defines the stencil operation to use when stencil fails
  32361. */
  32362. setStencilOperationFail(operation: number): void;
  32363. /**
  32364. * Sets the stencil operation to use when depth fails
  32365. * @param operation defines the stencil operation to use when depth fails
  32366. */
  32367. setStencilOperationDepthFail(operation: number): void;
  32368. /**
  32369. * Sets the stencil operation to use when stencil passes
  32370. * @param operation defines the stencil operation to use when stencil passes
  32371. */
  32372. setStencilOperationPass(operation: number): void;
  32373. /**
  32374. * Sets a boolean indicating if the dithering state is enabled or disabled
  32375. * @param value defines the dithering state
  32376. */
  32377. setDitheringState(value: boolean): void;
  32378. /**
  32379. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32380. * @param value defines the rasterizer state
  32381. */
  32382. setRasterizerState(value: boolean): void;
  32383. /**
  32384. * Gets the current depth function
  32385. * @returns a number defining the depth function
  32386. */
  32387. getDepthFunction(): Nullable<number>;
  32388. /**
  32389. * Sets the current depth function
  32390. * @param depthFunc defines the function to use
  32391. */
  32392. setDepthFunction(depthFunc: number): void;
  32393. /**
  32394. * Sets the current depth function to GREATER
  32395. */
  32396. setDepthFunctionToGreater(): void;
  32397. /**
  32398. * Sets the current depth function to GEQUAL
  32399. */
  32400. setDepthFunctionToGreaterOrEqual(): void;
  32401. /**
  32402. * Sets the current depth function to LESS
  32403. */
  32404. setDepthFunctionToLess(): void;
  32405. /**
  32406. * Sets the current depth function to LEQUAL
  32407. */
  32408. setDepthFunctionToLessOrEqual(): void;
  32409. private _cachedStencilBuffer;
  32410. private _cachedStencilFunction;
  32411. private _cachedStencilMask;
  32412. private _cachedStencilOperationPass;
  32413. private _cachedStencilOperationFail;
  32414. private _cachedStencilOperationDepthFail;
  32415. private _cachedStencilReference;
  32416. /**
  32417. * Caches the the state of the stencil buffer
  32418. */
  32419. cacheStencilState(): void;
  32420. /**
  32421. * Restores the state of the stencil buffer
  32422. */
  32423. restoreStencilState(): void;
  32424. /**
  32425. * Directly set the WebGL Viewport
  32426. * @param x defines the x coordinate of the viewport (in screen space)
  32427. * @param y defines the y coordinate of the viewport (in screen space)
  32428. * @param width defines the width of the viewport (in screen space)
  32429. * @param height defines the height of the viewport (in screen space)
  32430. * @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
  32431. */
  32432. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32433. /**
  32434. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32435. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32436. * @param y defines the y-coordinate of the corner of the clear rectangle
  32437. * @param width defines the width of the clear rectangle
  32438. * @param height defines the height of the clear rectangle
  32439. * @param clearColor defines the clear color
  32440. */
  32441. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32442. /**
  32443. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32444. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32445. * @param y defines the y-coordinate of the corner of the clear rectangle
  32446. * @param width defines the width of the clear rectangle
  32447. * @param height defines the height of the clear rectangle
  32448. */
  32449. enableScissor(x: number, y: number, width: number, height: number): void;
  32450. /**
  32451. * Disable previously set scissor test rectangle
  32452. */
  32453. disableScissor(): void;
  32454. protected _reportDrawCall(): void;
  32455. /**
  32456. * Initializes a webVR display and starts listening to display change events
  32457. * The onVRDisplayChangedObservable will be notified upon these changes
  32458. * @returns The onVRDisplayChangedObservable
  32459. */
  32460. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32461. /** @hidden */
  32462. _prepareVRComponent(): void;
  32463. /** @hidden */
  32464. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32465. /** @hidden */
  32466. _submitVRFrame(): void;
  32467. /**
  32468. * Call this function to leave webVR mode
  32469. * Will do nothing if webVR is not supported or if there is no webVR device
  32470. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32471. */
  32472. disableVR(): void;
  32473. /**
  32474. * Gets a boolean indicating that the system is in VR mode and is presenting
  32475. * @returns true if VR mode is engaged
  32476. */
  32477. isVRPresenting(): boolean;
  32478. /** @hidden */
  32479. _requestVRFrame(): void;
  32480. /** @hidden */
  32481. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32482. /**
  32483. * Gets the source code of the vertex shader associated with a specific webGL program
  32484. * @param program defines the program to use
  32485. * @returns a string containing the source code of the vertex shader associated with the program
  32486. */
  32487. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32488. /**
  32489. * Gets the source code of the fragment shader associated with a specific webGL program
  32490. * @param program defines the program to use
  32491. * @returns a string containing the source code of the fragment shader associated with the program
  32492. */
  32493. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32494. /**
  32495. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32496. * @param x defines the x coordinate of the rectangle where pixels must be read
  32497. * @param y defines the y coordinate of the rectangle where pixels must be read
  32498. * @param width defines the width of the rectangle where pixels must be read
  32499. * @param height defines the height of the rectangle where pixels must be read
  32500. * @returns a Uint8Array containing RGBA colors
  32501. */
  32502. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32503. /**
  32504. * Sets a depth stencil texture from a render target to the according uniform.
  32505. * @param channel The texture channel
  32506. * @param uniform The uniform to set
  32507. * @param texture The render target texture containing the depth stencil texture to apply
  32508. */
  32509. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32510. /**
  32511. * Sets a texture to the webGL context from a postprocess
  32512. * @param channel defines the channel to use
  32513. * @param postProcess defines the source postprocess
  32514. */
  32515. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32516. /**
  32517. * Binds the output of the passed in post process to the texture channel specified
  32518. * @param channel The channel the texture should be bound to
  32519. * @param postProcess The post process which's output should be bound
  32520. */
  32521. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32522. /** @hidden */
  32523. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32524. protected _rebuildBuffers(): void;
  32525. _renderLoop(): void;
  32526. /**
  32527. * Toggle full screen mode
  32528. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32529. */
  32530. switchFullscreen(requestPointerLock: boolean): void;
  32531. /**
  32532. * Enters full screen mode
  32533. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32534. */
  32535. enterFullscreen(requestPointerLock: boolean): void;
  32536. /**
  32537. * Exits full screen mode
  32538. */
  32539. exitFullscreen(): void;
  32540. /**
  32541. * Enters Pointerlock mode
  32542. */
  32543. enterPointerlock(): void;
  32544. /**
  32545. * Exits Pointerlock mode
  32546. */
  32547. exitPointerlock(): void;
  32548. /**
  32549. * Begin a new frame
  32550. */
  32551. beginFrame(): void;
  32552. /**
  32553. * Enf the current frame
  32554. */
  32555. endFrame(): void;
  32556. resize(): void;
  32557. /**
  32558. * Set the compressed texture format to use, based on the formats you have, and the formats
  32559. * supported by the hardware / browser.
  32560. *
  32561. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32562. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32563. * to API arguments needed to compressed textures. This puts the burden on the container
  32564. * generator to house the arcane code for determining these for current & future formats.
  32565. *
  32566. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32567. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32568. *
  32569. * Note: The result of this call is not taken into account when a texture is base64.
  32570. *
  32571. * @param formatsAvailable defines the list of those format families you have created
  32572. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32573. *
  32574. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32575. * @returns The extension selected.
  32576. */
  32577. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32578. /**
  32579. * Force a specific size of the canvas
  32580. * @param width defines the new canvas' width
  32581. * @param height defines the new canvas' height
  32582. */
  32583. setSize(width: number, height: number): void;
  32584. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32585. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32586. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32587. _releaseTexture(texture: InternalTexture): void;
  32588. /**
  32589. * @hidden
  32590. * Rescales a texture
  32591. * @param source input texutre
  32592. * @param destination destination texture
  32593. * @param scene scene to use to render the resize
  32594. * @param internalFormat format to use when resizing
  32595. * @param onComplete callback to be called when resize has completed
  32596. */
  32597. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32598. /**
  32599. * Gets the current framerate
  32600. * @returns a number representing the framerate
  32601. */
  32602. getFps(): number;
  32603. /**
  32604. * Gets the time spent between current and previous frame
  32605. * @returns a number representing the delta time in ms
  32606. */
  32607. getDeltaTime(): number;
  32608. private _measureFps;
  32609. /**
  32610. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32611. * @param renderTarget The render target to set the frame buffer for
  32612. */
  32613. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32614. /**
  32615. * Update a dynamic index buffer
  32616. * @param indexBuffer defines the target index buffer
  32617. * @param indices defines the data to update
  32618. * @param offset defines the offset in the target index buffer where update should start
  32619. */
  32620. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32621. /**
  32622. * Updates the sample count of a render target texture
  32623. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32624. * @param texture defines the texture to update
  32625. * @param samples defines the sample count to set
  32626. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32627. */
  32628. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32629. /** @hidden */
  32630. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32631. dispose(): void;
  32632. private _disableTouchAction;
  32633. /**
  32634. * Display the loading screen
  32635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32636. */
  32637. displayLoadingUI(): void;
  32638. /**
  32639. * Hide the loading screen
  32640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32641. */
  32642. hideLoadingUI(): void;
  32643. /**
  32644. * Gets the current loading screen object
  32645. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32646. */
  32647. /**
  32648. * Sets the current loading screen object
  32649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32650. */
  32651. loadingScreen: ILoadingScreen;
  32652. /**
  32653. * Sets the current loading screen text
  32654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32655. */
  32656. loadingUIText: string;
  32657. /**
  32658. * Sets the current loading screen background color
  32659. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32660. */
  32661. loadingUIBackgroundColor: string;
  32662. /** Pointerlock and fullscreen */
  32663. /**
  32664. * Ask the browser to promote the current element to pointerlock mode
  32665. * @param element defines the DOM element to promote
  32666. */
  32667. static _RequestPointerlock(element: HTMLElement): void;
  32668. /**
  32669. * Asks the browser to exit pointerlock mode
  32670. */
  32671. static _ExitPointerlock(): void;
  32672. /**
  32673. * Ask the browser to promote the current element to fullscreen rendering mode
  32674. * @param element defines the DOM element to promote
  32675. */
  32676. static _RequestFullscreen(element: HTMLElement): void;
  32677. /**
  32678. * Asks the browser to exit fullscreen mode
  32679. */
  32680. static _ExitFullscreen(): void;
  32681. }
  32682. }
  32683. declare module "babylonjs/Engines/engineStore" {
  32684. import { Nullable } from "babylonjs/types";
  32685. import { Engine } from "babylonjs/Engines/engine";
  32686. import { Scene } from "babylonjs/scene";
  32687. /**
  32688. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32689. * during the life time of the application.
  32690. */
  32691. export class EngineStore {
  32692. /** Gets the list of created engines */
  32693. static Instances: import("babylonjs/Engines/engine").Engine[];
  32694. /** @hidden */
  32695. static _LastCreatedScene: Nullable<Scene>;
  32696. /**
  32697. * Gets the latest created engine
  32698. */
  32699. static readonly LastCreatedEngine: Nullable<Engine>;
  32700. /**
  32701. * Gets the latest created scene
  32702. */
  32703. static readonly LastCreatedScene: Nullable<Scene>;
  32704. /**
  32705. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32706. * @ignorenaming
  32707. */
  32708. static UseFallbackTexture: boolean;
  32709. /**
  32710. * Texture content used if a texture cannot loaded
  32711. * @ignorenaming
  32712. */
  32713. static FallbackTexture: string;
  32714. }
  32715. }
  32716. declare module "babylonjs/Misc/promise" {
  32717. /**
  32718. * Helper class that provides a small promise polyfill
  32719. */
  32720. export class PromisePolyfill {
  32721. /**
  32722. * Static function used to check if the polyfill is required
  32723. * If this is the case then the function will inject the polyfill to window.Promise
  32724. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32725. */
  32726. static Apply(force?: boolean): void;
  32727. }
  32728. }
  32729. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32730. /**
  32731. * Interface for screenshot methods with describe argument called `size` as object with options
  32732. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32733. */
  32734. export interface IScreenshotSize {
  32735. /**
  32736. * number in pixels for canvas height
  32737. */
  32738. height?: number;
  32739. /**
  32740. * multiplier allowing render at a higher or lower resolution
  32741. * If value is defined then height and width will be ignored and taken from camera
  32742. */
  32743. precision?: number;
  32744. /**
  32745. * number in pixels for canvas width
  32746. */
  32747. width?: number;
  32748. }
  32749. }
  32750. declare module "babylonjs/Misc/tools" {
  32751. import { Nullable, float } from "babylonjs/types";
  32752. import { DomManagement } from "babylonjs/Misc/domManagement";
  32753. import { WebRequest } from "babylonjs/Misc/webRequest";
  32754. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32756. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32757. import { Camera } from "babylonjs/Cameras/camera";
  32758. import { Engine } from "babylonjs/Engines/engine";
  32759. interface IColor4Like {
  32760. r: float;
  32761. g: float;
  32762. b: float;
  32763. a: float;
  32764. }
  32765. /**
  32766. * Class containing a set of static utilities functions
  32767. */
  32768. export class Tools {
  32769. /**
  32770. * Gets or sets the base URL to use to load assets
  32771. */
  32772. static BaseUrl: string;
  32773. /**
  32774. * Enable/Disable Custom HTTP Request Headers globally.
  32775. * default = false
  32776. * @see CustomRequestHeaders
  32777. */
  32778. static UseCustomRequestHeaders: boolean;
  32779. /**
  32780. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32781. * i.e. when loading files, where the server/service expects an Authorization header
  32782. */
  32783. static CustomRequestHeaders: {
  32784. [key: string]: string;
  32785. };
  32786. /**
  32787. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32788. */
  32789. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32790. /**
  32791. * Default behaviour for cors in the application.
  32792. * It can be a string if the expected behavior is identical in the entire app.
  32793. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32794. */
  32795. static CorsBehavior: string | ((url: string | string[]) => string);
  32796. /**
  32797. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32798. * @ignorenaming
  32799. */
  32800. static UseFallbackTexture: boolean;
  32801. /**
  32802. * Use this object to register external classes like custom textures or material
  32803. * to allow the laoders to instantiate them
  32804. */
  32805. static RegisteredExternalClasses: {
  32806. [key: string]: Object;
  32807. };
  32808. /**
  32809. * Texture content used if a texture cannot loaded
  32810. * @ignorenaming
  32811. */
  32812. static fallbackTexture: string;
  32813. /**
  32814. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32815. * @param u defines the coordinate on X axis
  32816. * @param v defines the coordinate on Y axis
  32817. * @param width defines the width of the source data
  32818. * @param height defines the height of the source data
  32819. * @param pixels defines the source byte array
  32820. * @param color defines the output color
  32821. */
  32822. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32823. /**
  32824. * Interpolates between a and b via alpha
  32825. * @param a The lower value (returned when alpha = 0)
  32826. * @param b The upper value (returned when alpha = 1)
  32827. * @param alpha The interpolation-factor
  32828. * @return The mixed value
  32829. */
  32830. static Mix(a: number, b: number, alpha: number): number;
  32831. /**
  32832. * Tries to instantiate a new object from a given class name
  32833. * @param className defines the class name to instantiate
  32834. * @returns the new object or null if the system was not able to do the instantiation
  32835. */
  32836. static Instantiate(className: string): any;
  32837. /**
  32838. * Provides a slice function that will work even on IE
  32839. * @param data defines the array to slice
  32840. * @param start defines the start of the data (optional)
  32841. * @param end defines the end of the data (optional)
  32842. * @returns the new sliced array
  32843. */
  32844. static Slice<T>(data: T, start?: number, end?: number): T;
  32845. /**
  32846. * Polyfill for setImmediate
  32847. * @param action defines the action to execute after the current execution block
  32848. */
  32849. static SetImmediate(action: () => void): void;
  32850. /**
  32851. * Function indicating if a number is an exponent of 2
  32852. * @param value defines the value to test
  32853. * @returns true if the value is an exponent of 2
  32854. */
  32855. static IsExponentOfTwo(value: number): boolean;
  32856. private static _tmpFloatArray;
  32857. /**
  32858. * Returns the nearest 32-bit single precision float representation of a Number
  32859. * @param value A Number. If the parameter is of a different type, it will get converted
  32860. * to a number or to NaN if it cannot be converted
  32861. * @returns number
  32862. */
  32863. static FloatRound(value: number): number;
  32864. /**
  32865. * Extracts the filename from a path
  32866. * @param path defines the path to use
  32867. * @returns the filename
  32868. */
  32869. static GetFilename(path: string): string;
  32870. /**
  32871. * Extracts the "folder" part of a path (everything before the filename).
  32872. * @param uri The URI to extract the info from
  32873. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32874. * @returns The "folder" part of the path
  32875. */
  32876. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32877. /**
  32878. * Extracts text content from a DOM element hierarchy
  32879. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32880. */
  32881. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32882. /**
  32883. * Convert an angle in radians to degrees
  32884. * @param angle defines the angle to convert
  32885. * @returns the angle in degrees
  32886. */
  32887. static ToDegrees(angle: number): number;
  32888. /**
  32889. * Convert an angle in degrees to radians
  32890. * @param angle defines the angle to convert
  32891. * @returns the angle in radians
  32892. */
  32893. static ToRadians(angle: number): number;
  32894. /**
  32895. * Encode a buffer to a base64 string
  32896. * @param buffer defines the buffer to encode
  32897. * @returns the encoded string
  32898. */
  32899. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32900. /**
  32901. * Returns an array if obj is not an array
  32902. * @param obj defines the object to evaluate as an array
  32903. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32904. * @returns either obj directly if obj is an array or a new array containing obj
  32905. */
  32906. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32907. /**
  32908. * Gets the pointer prefix to use
  32909. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32910. */
  32911. static GetPointerPrefix(): string;
  32912. /**
  32913. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32914. * @param url define the url we are trying
  32915. * @param element define the dom element where to configure the cors policy
  32916. */
  32917. static SetCorsBehavior(url: string | string[], element: {
  32918. crossOrigin: string | null;
  32919. }): void;
  32920. /**
  32921. * Removes unwanted characters from an url
  32922. * @param url defines the url to clean
  32923. * @returns the cleaned url
  32924. */
  32925. static CleanUrl(url: string): string;
  32926. /**
  32927. * Gets or sets a function used to pre-process url before using them to load assets
  32928. */
  32929. static PreprocessUrl: (url: string) => string;
  32930. /**
  32931. * Loads an image as an HTMLImageElement.
  32932. * @param input url string, ArrayBuffer, or Blob to load
  32933. * @param onLoad callback called when the image successfully loads
  32934. * @param onError callback called when the image fails to load
  32935. * @param offlineProvider offline provider for caching
  32936. * @param mimeType optional mime type
  32937. * @returns the HTMLImageElement of the loaded image
  32938. */
  32939. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  32940. /**
  32941. * Loads a file
  32942. * @param url url string, ArrayBuffer, or Blob to load
  32943. * @param onSuccess callback called when the file successfully loads
  32944. * @param onProgress callback called while file is loading (if the server supports this mode)
  32945. * @param offlineProvider defines the offline provider for caching
  32946. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32947. * @param onError callback called when the file fails to load
  32948. * @returns a file request object
  32949. */
  32950. 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;
  32951. /**
  32952. * Loads a file from a url
  32953. * @param url the file url to load
  32954. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32955. */
  32956. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32957. /**
  32958. * Load a script (identified by an url). When the url returns, the
  32959. * content of this file is added into a new script element, attached to the DOM (body element)
  32960. * @param scriptUrl defines the url of the script to laod
  32961. * @param onSuccess defines the callback called when the script is loaded
  32962. * @param onError defines the callback to call if an error occurs
  32963. * @param scriptId defines the id of the script element
  32964. */
  32965. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32966. /**
  32967. * Load an asynchronous script (identified by an url). When the url returns, the
  32968. * content of this file is added into a new script element, attached to the DOM (body element)
  32969. * @param scriptUrl defines the url of the script to laod
  32970. * @param scriptId defines the id of the script element
  32971. * @returns a promise request object
  32972. */
  32973. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32974. /**
  32975. * Loads a file from a blob
  32976. * @param fileToLoad defines the blob to use
  32977. * @param callback defines the callback to call when data is loaded
  32978. * @param progressCallback defines the callback to call during loading process
  32979. * @returns a file request object
  32980. */
  32981. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32982. /**
  32983. * Loads a file
  32984. * @param fileToLoad defines the file to load
  32985. * @param callback defines the callback to call when data is loaded
  32986. * @param progressCallBack defines the callback to call during loading process
  32987. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32988. * @returns a file request object
  32989. */
  32990. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32991. /**
  32992. * Creates a data url from a given string content
  32993. * @param content defines the content to convert
  32994. * @returns the new data url link
  32995. */
  32996. static FileAsURL(content: string): string;
  32997. /**
  32998. * Format the given number to a specific decimal format
  32999. * @param value defines the number to format
  33000. * @param decimals defines the number of decimals to use
  33001. * @returns the formatted string
  33002. */
  33003. static Format(value: number, decimals?: number): string;
  33004. /**
  33005. * Tries to copy an object by duplicating every property
  33006. * @param source defines the source object
  33007. * @param destination defines the target object
  33008. * @param doNotCopyList defines a list of properties to avoid
  33009. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33010. */
  33011. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33012. /**
  33013. * Gets a boolean indicating if the given object has no own property
  33014. * @param obj defines the object to test
  33015. * @returns true if object has no own property
  33016. */
  33017. static IsEmpty(obj: any): boolean;
  33018. /**
  33019. * Function used to register events at window level
  33020. * @param windowElement defines the Window object to use
  33021. * @param events defines the events to register
  33022. */
  33023. static RegisterTopRootEvents(windowElement: Window, events: {
  33024. name: string;
  33025. handler: Nullable<(e: FocusEvent) => any>;
  33026. }[]): void;
  33027. /**
  33028. * Function used to unregister events from window level
  33029. * @param windowElement defines the Window object to use
  33030. * @param events defines the events to unregister
  33031. */
  33032. static UnregisterTopRootEvents(windowElement: Window, events: {
  33033. name: string;
  33034. handler: Nullable<(e: FocusEvent) => any>;
  33035. }[]): void;
  33036. /**
  33037. * @ignore
  33038. */
  33039. static _ScreenshotCanvas: HTMLCanvasElement;
  33040. /**
  33041. * Dumps the current bound framebuffer
  33042. * @param width defines the rendering width
  33043. * @param height defines the rendering height
  33044. * @param engine defines the hosting engine
  33045. * @param successCallback defines the callback triggered once the data are available
  33046. * @param mimeType defines the mime type of the result
  33047. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33048. */
  33049. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33050. /**
  33051. * Converts the canvas data to blob.
  33052. * This acts as a polyfill for browsers not supporting the to blob function.
  33053. * @param canvas Defines the canvas to extract the data from
  33054. * @param successCallback Defines the callback triggered once the data are available
  33055. * @param mimeType Defines the mime type of the result
  33056. */
  33057. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33058. /**
  33059. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33060. * @param successCallback defines the callback triggered once the data are available
  33061. * @param mimeType defines the mime type of the result
  33062. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33063. */
  33064. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33065. /**
  33066. * Downloads a blob in the browser
  33067. * @param blob defines the blob to download
  33068. * @param fileName defines the name of the downloaded file
  33069. */
  33070. static Download(blob: Blob, fileName: string): void;
  33071. /**
  33072. * Captures a screenshot of the current rendering
  33073. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33074. * @param engine defines the rendering engine
  33075. * @param camera defines the source camera
  33076. * @param size This parameter can be set to a single number or to an object with the
  33077. * following (optional) properties: precision, width, height. If a single number is passed,
  33078. * it will be used for both width and height. If an object is passed, the screenshot size
  33079. * will be derived from the parameters. The precision property is a multiplier allowing
  33080. * rendering at a higher or lower resolution
  33081. * @param successCallback defines the callback receives a single parameter which contains the
  33082. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33083. * src parameter of an <img> to display it
  33084. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33085. * Check your browser for supported MIME types
  33086. */
  33087. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33088. /**
  33089. * Captures a screenshot of the current rendering
  33090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33091. * @param engine defines the rendering engine
  33092. * @param camera defines the source camera
  33093. * @param size This parameter can be set to a single number or to an object with the
  33094. * following (optional) properties: precision, width, height. If a single number is passed,
  33095. * it will be used for both width and height. If an object is passed, the screenshot size
  33096. * will be derived from the parameters. The precision property is a multiplier allowing
  33097. * rendering at a higher or lower resolution
  33098. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33099. * Check your browser for supported MIME types
  33100. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33101. * to the src parameter of an <img> to display it
  33102. */
  33103. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33104. /**
  33105. * Generates an image screenshot from the specified camera.
  33106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33107. * @param engine The engine to use for rendering
  33108. * @param camera The camera to use for rendering
  33109. * @param size This parameter can be set to a single number or to an object with the
  33110. * following (optional) properties: precision, width, height. If a single number is passed,
  33111. * it will be used for both width and height. If an object is passed, the screenshot size
  33112. * will be derived from the parameters. The precision property is a multiplier allowing
  33113. * rendering at a higher or lower resolution
  33114. * @param successCallback The callback receives a single parameter which contains the
  33115. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33116. * src parameter of an <img> to display it
  33117. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33118. * Check your browser for supported MIME types
  33119. * @param samples Texture samples (default: 1)
  33120. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33121. * @param fileName A name for for the downloaded file.
  33122. */
  33123. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33124. /**
  33125. * Generates an image screenshot from the specified camera.
  33126. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33127. * @param engine The engine to use for rendering
  33128. * @param camera The camera to use for rendering
  33129. * @param size This parameter can be set to a single number or to an object with the
  33130. * following (optional) properties: precision, width, height. If a single number is passed,
  33131. * it will be used for both width and height. If an object is passed, the screenshot size
  33132. * will be derived from the parameters. The precision property is a multiplier allowing
  33133. * rendering at a higher or lower resolution
  33134. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33135. * Check your browser for supported MIME types
  33136. * @param samples Texture samples (default: 1)
  33137. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33138. * @param fileName A name for for the downloaded file.
  33139. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33140. * to the src parameter of an <img> to display it
  33141. */
  33142. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33143. /**
  33144. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33145. * Be aware Math.random() could cause collisions, but:
  33146. * "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"
  33147. * @returns a pseudo random id
  33148. */
  33149. static RandomId(): string;
  33150. /**
  33151. * Test if the given uri is a base64 string
  33152. * @param uri The uri to test
  33153. * @return True if the uri is a base64 string or false otherwise
  33154. */
  33155. static IsBase64(uri: string): boolean;
  33156. /**
  33157. * Decode the given base64 uri.
  33158. * @param uri The uri to decode
  33159. * @return The decoded base64 data.
  33160. */
  33161. static DecodeBase64(uri: string): ArrayBuffer;
  33162. /**
  33163. * Gets the absolute url.
  33164. * @param url the input url
  33165. * @return the absolute url
  33166. */
  33167. static GetAbsoluteUrl(url: string): string;
  33168. /**
  33169. * No log
  33170. */
  33171. static readonly NoneLogLevel: number;
  33172. /**
  33173. * Only message logs
  33174. */
  33175. static readonly MessageLogLevel: number;
  33176. /**
  33177. * Only warning logs
  33178. */
  33179. static readonly WarningLogLevel: number;
  33180. /**
  33181. * Only error logs
  33182. */
  33183. static readonly ErrorLogLevel: number;
  33184. /**
  33185. * All logs
  33186. */
  33187. static readonly AllLogLevel: number;
  33188. /**
  33189. * Gets a value indicating the number of loading errors
  33190. * @ignorenaming
  33191. */
  33192. static readonly errorsCount: number;
  33193. /**
  33194. * Callback called when a new log is added
  33195. */
  33196. static OnNewCacheEntry: (entry: string) => void;
  33197. /**
  33198. * Log a message to the console
  33199. * @param message defines the message to log
  33200. */
  33201. static Log(message: string): void;
  33202. /**
  33203. * Write a warning message to the console
  33204. * @param message defines the message to log
  33205. */
  33206. static Warn(message: string): void;
  33207. /**
  33208. * Write an error message to the console
  33209. * @param message defines the message to log
  33210. */
  33211. static Error(message: string): void;
  33212. /**
  33213. * Gets current log cache (list of logs)
  33214. */
  33215. static readonly LogCache: string;
  33216. /**
  33217. * Clears the log cache
  33218. */
  33219. static ClearLogCache(): void;
  33220. /**
  33221. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33222. */
  33223. static LogLevels: number;
  33224. /**
  33225. * Checks if the window object exists
  33226. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33227. */
  33228. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33229. /**
  33230. * No performance log
  33231. */
  33232. static readonly PerformanceNoneLogLevel: number;
  33233. /**
  33234. * Use user marks to log performance
  33235. */
  33236. static readonly PerformanceUserMarkLogLevel: number;
  33237. /**
  33238. * Log performance to the console
  33239. */
  33240. static readonly PerformanceConsoleLogLevel: number;
  33241. private static _performance;
  33242. /**
  33243. * Sets the current performance log level
  33244. */
  33245. static PerformanceLogLevel: number;
  33246. private static _StartPerformanceCounterDisabled;
  33247. private static _EndPerformanceCounterDisabled;
  33248. private static _StartUserMark;
  33249. private static _EndUserMark;
  33250. private static _StartPerformanceConsole;
  33251. private static _EndPerformanceConsole;
  33252. /**
  33253. * Starts a performance counter
  33254. */
  33255. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33256. /**
  33257. * Ends a specific performance coutner
  33258. */
  33259. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33260. /**
  33261. * Gets either window.performance.now() if supported or Date.now() else
  33262. */
  33263. static readonly Now: number;
  33264. /**
  33265. * This method will return the name of the class used to create the instance of the given object.
  33266. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33267. * @param object the object to get the class name from
  33268. * @param isType defines if the object is actually a type
  33269. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33270. */
  33271. static GetClassName(object: any, isType?: boolean): string;
  33272. /**
  33273. * Gets the first element of an array satisfying a given predicate
  33274. * @param array defines the array to browse
  33275. * @param predicate defines the predicate to use
  33276. * @returns null if not found or the element
  33277. */
  33278. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33279. /**
  33280. * This method will return the name of the full name of the class, including its owning module (if any).
  33281. * 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).
  33282. * @param object the object to get the class name from
  33283. * @param isType defines if the object is actually a type
  33284. * @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.
  33285. * @ignorenaming
  33286. */
  33287. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33288. /**
  33289. * Returns a promise that resolves after the given amount of time.
  33290. * @param delay Number of milliseconds to delay
  33291. * @returns Promise that resolves after the given amount of time
  33292. */
  33293. static DelayAsync(delay: number): Promise<void>;
  33294. }
  33295. /**
  33296. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33297. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33298. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33299. * @param name The name of the class, case should be preserved
  33300. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33301. */
  33302. export function className(name: string, module?: string): (target: Object) => void;
  33303. /**
  33304. * An implementation of a loop for asynchronous functions.
  33305. */
  33306. export class AsyncLoop {
  33307. /**
  33308. * Defines the number of iterations for the loop
  33309. */
  33310. iterations: number;
  33311. /**
  33312. * Defines the current index of the loop.
  33313. */
  33314. index: number;
  33315. private _done;
  33316. private _fn;
  33317. private _successCallback;
  33318. /**
  33319. * Constructor.
  33320. * @param iterations the number of iterations.
  33321. * @param func the function to run each iteration
  33322. * @param successCallback the callback that will be called upon succesful execution
  33323. * @param offset starting offset.
  33324. */
  33325. constructor(
  33326. /**
  33327. * Defines the number of iterations for the loop
  33328. */
  33329. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33330. /**
  33331. * Execute the next iteration. Must be called after the last iteration was finished.
  33332. */
  33333. executeNext(): void;
  33334. /**
  33335. * Break the loop and run the success callback.
  33336. */
  33337. breakLoop(): void;
  33338. /**
  33339. * Create and run an async loop.
  33340. * @param iterations the number of iterations.
  33341. * @param fn the function to run each iteration
  33342. * @param successCallback the callback that will be called upon succesful execution
  33343. * @param offset starting offset.
  33344. * @returns the created async loop object
  33345. */
  33346. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33347. /**
  33348. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33349. * @param iterations total number of iterations
  33350. * @param syncedIterations number of synchronous iterations in each async iteration.
  33351. * @param fn the function to call each iteration.
  33352. * @param callback a success call back that will be called when iterating stops.
  33353. * @param breakFunction a break condition (optional)
  33354. * @param timeout timeout settings for the setTimeout function. default - 0.
  33355. * @returns the created async loop object
  33356. */
  33357. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33358. }
  33359. }
  33360. declare module "babylonjs/Misc/stringDictionary" {
  33361. import { Nullable } from "babylonjs/types";
  33362. /**
  33363. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33364. * The underlying implementation relies on an associative array to ensure the best performances.
  33365. * The value can be anything including 'null' but except 'undefined'
  33366. */
  33367. export class StringDictionary<T> {
  33368. /**
  33369. * This will clear this dictionary and copy the content from the 'source' one.
  33370. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33371. * @param source the dictionary to take the content from and copy to this dictionary
  33372. */
  33373. copyFrom(source: StringDictionary<T>): void;
  33374. /**
  33375. * Get a value based from its key
  33376. * @param key the given key to get the matching value from
  33377. * @return the value if found, otherwise undefined is returned
  33378. */
  33379. get(key: string): T | undefined;
  33380. /**
  33381. * Get a value from its key or add it if it doesn't exist.
  33382. * This method will ensure you that a given key/data will be present in the dictionary.
  33383. * @param key the given key to get the matching value from
  33384. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33385. * The factory will only be invoked if there's no data for the given key.
  33386. * @return the value corresponding to the key.
  33387. */
  33388. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33389. /**
  33390. * Get a value from its key if present in the dictionary otherwise add it
  33391. * @param key the key to get the value from
  33392. * @param val if there's no such key/value pair in the dictionary add it with this value
  33393. * @return the value corresponding to the key
  33394. */
  33395. getOrAdd(key: string, val: T): T;
  33396. /**
  33397. * Check if there's a given key in the dictionary
  33398. * @param key the key to check for
  33399. * @return true if the key is present, false otherwise
  33400. */
  33401. contains(key: string): boolean;
  33402. /**
  33403. * Add a new key and its corresponding value
  33404. * @param key the key to add
  33405. * @param value the value corresponding to the key
  33406. * @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
  33407. */
  33408. add(key: string, value: T): boolean;
  33409. /**
  33410. * Update a specific value associated to a key
  33411. * @param key defines the key to use
  33412. * @param value defines the value to store
  33413. * @returns true if the value was updated (or false if the key was not found)
  33414. */
  33415. set(key: string, value: T): boolean;
  33416. /**
  33417. * Get the element of the given key and remove it from the dictionary
  33418. * @param key defines the key to search
  33419. * @returns the value associated with the key or null if not found
  33420. */
  33421. getAndRemove(key: string): Nullable<T>;
  33422. /**
  33423. * Remove a key/value from the dictionary.
  33424. * @param key the key to remove
  33425. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33426. */
  33427. remove(key: string): boolean;
  33428. /**
  33429. * Clear the whole content of the dictionary
  33430. */
  33431. clear(): void;
  33432. /**
  33433. * Gets the current count
  33434. */
  33435. readonly count: number;
  33436. /**
  33437. * Execute a callback on each key/val of the dictionary.
  33438. * Note that you can remove any element in this dictionary in the callback implementation
  33439. * @param callback the callback to execute on a given key/value pair
  33440. */
  33441. forEach(callback: (key: string, val: T) => void): void;
  33442. /**
  33443. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33444. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33445. * Note that you can remove any element in this dictionary in the callback implementation
  33446. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33447. * @returns the first item
  33448. */
  33449. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33450. private _count;
  33451. private _data;
  33452. }
  33453. }
  33454. declare module "babylonjs/Collisions/collisionCoordinator" {
  33455. import { Nullable } from "babylonjs/types";
  33456. import { Scene } from "babylonjs/scene";
  33457. import { Vector3 } from "babylonjs/Maths/math.vector";
  33458. import { Collider } from "babylonjs/Collisions/collider";
  33459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33460. /** @hidden */
  33461. export interface ICollisionCoordinator {
  33462. createCollider(): Collider;
  33463. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33464. init(scene: Scene): void;
  33465. }
  33466. /** @hidden */
  33467. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33468. private _scene;
  33469. private _scaledPosition;
  33470. private _scaledVelocity;
  33471. private _finalPosition;
  33472. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33473. createCollider(): Collider;
  33474. init(scene: Scene): void;
  33475. private _collideWithWorld;
  33476. }
  33477. }
  33478. declare module "babylonjs/Inputs/scene.inputManager" {
  33479. import { Nullable } from "babylonjs/types";
  33480. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33481. import { Vector2 } from "babylonjs/Maths/math.vector";
  33482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33483. import { Scene } from "babylonjs/scene";
  33484. /**
  33485. * Class used to manage all inputs for the scene.
  33486. */
  33487. export class InputManager {
  33488. /** The distance in pixel that you have to move to prevent some events */
  33489. static DragMovementThreshold: number;
  33490. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33491. static LongPressDelay: number;
  33492. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33493. static DoubleClickDelay: number;
  33494. /** If you need to check double click without raising a single click at first click, enable this flag */
  33495. static ExclusiveDoubleClickMode: boolean;
  33496. private _wheelEventName;
  33497. private _onPointerMove;
  33498. private _onPointerDown;
  33499. private _onPointerUp;
  33500. private _initClickEvent;
  33501. private _initActionManager;
  33502. private _delayedSimpleClick;
  33503. private _delayedSimpleClickTimeout;
  33504. private _previousDelayedSimpleClickTimeout;
  33505. private _meshPickProceed;
  33506. private _previousButtonPressed;
  33507. private _currentPickResult;
  33508. private _previousPickResult;
  33509. private _totalPointersPressed;
  33510. private _doubleClickOccured;
  33511. private _pointerOverMesh;
  33512. private _pickedDownMesh;
  33513. private _pickedUpMesh;
  33514. private _pointerX;
  33515. private _pointerY;
  33516. private _unTranslatedPointerX;
  33517. private _unTranslatedPointerY;
  33518. private _startingPointerPosition;
  33519. private _previousStartingPointerPosition;
  33520. private _startingPointerTime;
  33521. private _previousStartingPointerTime;
  33522. private _pointerCaptures;
  33523. private _onKeyDown;
  33524. private _onKeyUp;
  33525. private _onCanvasFocusObserver;
  33526. private _onCanvasBlurObserver;
  33527. private _scene;
  33528. /**
  33529. * Creates a new InputManager
  33530. * @param scene defines the hosting scene
  33531. */
  33532. constructor(scene: Scene);
  33533. /**
  33534. * Gets the mesh that is currently under the pointer
  33535. */
  33536. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33537. /**
  33538. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33539. */
  33540. readonly unTranslatedPointer: Vector2;
  33541. /**
  33542. * Gets or sets the current on-screen X position of the pointer
  33543. */
  33544. pointerX: number;
  33545. /**
  33546. * Gets or sets the current on-screen Y position of the pointer
  33547. */
  33548. pointerY: number;
  33549. private _updatePointerPosition;
  33550. private _processPointerMove;
  33551. private _setRayOnPointerInfo;
  33552. private _checkPrePointerObservable;
  33553. /**
  33554. * Use this method to simulate a pointer move on a mesh
  33555. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33556. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33557. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33558. */
  33559. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33560. /**
  33561. * Use this method to simulate a pointer down on a mesh
  33562. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33563. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33564. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33565. */
  33566. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33567. private _processPointerDown;
  33568. /** @hidden */
  33569. _isPointerSwiping(): boolean;
  33570. /**
  33571. * Use this method to simulate a pointer up on a mesh
  33572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33575. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33576. */
  33577. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33578. private _processPointerUp;
  33579. /**
  33580. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33581. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33582. * @returns true if the pointer was captured
  33583. */
  33584. isPointerCaptured(pointerId?: number): boolean;
  33585. /**
  33586. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33587. * @param attachUp defines if you want to attach events to pointerup
  33588. * @param attachDown defines if you want to attach events to pointerdown
  33589. * @param attachMove defines if you want to attach events to pointermove
  33590. */
  33591. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33592. /**
  33593. * Detaches all event handlers
  33594. */
  33595. detachControl(): void;
  33596. /**
  33597. * Force the value of meshUnderPointer
  33598. * @param mesh defines the mesh to use
  33599. */
  33600. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33601. /**
  33602. * Gets the mesh under the pointer
  33603. * @returns a Mesh or null if no mesh is under the pointer
  33604. */
  33605. getPointerOverMesh(): Nullable<AbstractMesh>;
  33606. }
  33607. }
  33608. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33609. /**
  33610. * Helper class used to generate session unique ID
  33611. */
  33612. export class UniqueIdGenerator {
  33613. private static _UniqueIdCounter;
  33614. /**
  33615. * Gets an unique (relatively to the current scene) Id
  33616. */
  33617. static readonly UniqueId: number;
  33618. }
  33619. }
  33620. declare module "babylonjs/Animations/animationGroup" {
  33621. import { Animatable } from "babylonjs/Animations/animatable";
  33622. import { Animation } from "babylonjs/Animations/animation";
  33623. import { Scene, IDisposable } from "babylonjs/scene";
  33624. import { Observable } from "babylonjs/Misc/observable";
  33625. import { Nullable } from "babylonjs/types";
  33626. import "babylonjs/Animations/animatable";
  33627. /**
  33628. * This class defines the direct association between an animation and a target
  33629. */
  33630. export class TargetedAnimation {
  33631. /**
  33632. * Animation to perform
  33633. */
  33634. animation: Animation;
  33635. /**
  33636. * Target to animate
  33637. */
  33638. target: any;
  33639. /**
  33640. * Serialize the object
  33641. * @returns the JSON object representing the current entity
  33642. */
  33643. serialize(): any;
  33644. }
  33645. /**
  33646. * Use this class to create coordinated animations on multiple targets
  33647. */
  33648. export class AnimationGroup implements IDisposable {
  33649. /** The name of the animation group */
  33650. name: string;
  33651. private _scene;
  33652. private _targetedAnimations;
  33653. private _animatables;
  33654. private _from;
  33655. private _to;
  33656. private _isStarted;
  33657. private _isPaused;
  33658. private _speedRatio;
  33659. private _loopAnimation;
  33660. /**
  33661. * Gets or sets the unique id of the node
  33662. */
  33663. uniqueId: number;
  33664. /**
  33665. * This observable will notify when one animation have ended
  33666. */
  33667. onAnimationEndObservable: Observable<TargetedAnimation>;
  33668. /**
  33669. * Observer raised when one animation loops
  33670. */
  33671. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33672. /**
  33673. * This observable will notify when all animations have ended.
  33674. */
  33675. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33676. /**
  33677. * This observable will notify when all animations have paused.
  33678. */
  33679. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33680. /**
  33681. * This observable will notify when all animations are playing.
  33682. */
  33683. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33684. /**
  33685. * Gets the first frame
  33686. */
  33687. readonly from: number;
  33688. /**
  33689. * Gets the last frame
  33690. */
  33691. readonly to: number;
  33692. /**
  33693. * Define if the animations are started
  33694. */
  33695. readonly isStarted: boolean;
  33696. /**
  33697. * Gets a value indicating that the current group is playing
  33698. */
  33699. readonly isPlaying: boolean;
  33700. /**
  33701. * Gets or sets the speed ratio to use for all animations
  33702. */
  33703. /**
  33704. * Gets or sets the speed ratio to use for all animations
  33705. */
  33706. speedRatio: number;
  33707. /**
  33708. * Gets or sets if all animations should loop or not
  33709. */
  33710. loopAnimation: boolean;
  33711. /**
  33712. * Gets the targeted animations for this animation group
  33713. */
  33714. readonly targetedAnimations: Array<TargetedAnimation>;
  33715. /**
  33716. * returning the list of animatables controlled by this animation group.
  33717. */
  33718. readonly animatables: Array<Animatable>;
  33719. /**
  33720. * Instantiates a new Animation Group.
  33721. * This helps managing several animations at once.
  33722. * @see http://doc.babylonjs.com/how_to/group
  33723. * @param name Defines the name of the group
  33724. * @param scene Defines the scene the group belongs to
  33725. */
  33726. constructor(
  33727. /** The name of the animation group */
  33728. name: string, scene?: Nullable<Scene>);
  33729. /**
  33730. * Add an animation (with its target) in the group
  33731. * @param animation defines the animation we want to add
  33732. * @param target defines the target of the animation
  33733. * @returns the TargetedAnimation object
  33734. */
  33735. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33736. /**
  33737. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33738. * It can add constant keys at begin or end
  33739. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33740. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33741. * @returns the animation group
  33742. */
  33743. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33744. /**
  33745. * Start all animations on given targets
  33746. * @param loop defines if animations must loop
  33747. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33748. * @param from defines the from key (optional)
  33749. * @param to defines the to key (optional)
  33750. * @returns the current animation group
  33751. */
  33752. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33753. /**
  33754. * Pause all animations
  33755. * @returns the animation group
  33756. */
  33757. pause(): AnimationGroup;
  33758. /**
  33759. * Play all animations to initial state
  33760. * This function will start() the animations if they were not started or will restart() them if they were paused
  33761. * @param loop defines if animations must loop
  33762. * @returns the animation group
  33763. */
  33764. play(loop?: boolean): AnimationGroup;
  33765. /**
  33766. * Reset all animations to initial state
  33767. * @returns the animation group
  33768. */
  33769. reset(): AnimationGroup;
  33770. /**
  33771. * Restart animations from key 0
  33772. * @returns the animation group
  33773. */
  33774. restart(): AnimationGroup;
  33775. /**
  33776. * Stop all animations
  33777. * @returns the animation group
  33778. */
  33779. stop(): AnimationGroup;
  33780. /**
  33781. * Set animation weight for all animatables
  33782. * @param weight defines the weight to use
  33783. * @return the animationGroup
  33784. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33785. */
  33786. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33787. /**
  33788. * Synchronize and normalize all animatables with a source animatable
  33789. * @param root defines the root animatable to synchronize with
  33790. * @return the animationGroup
  33791. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33792. */
  33793. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33794. /**
  33795. * Goes to a specific frame in this animation group
  33796. * @param frame the frame number to go to
  33797. * @return the animationGroup
  33798. */
  33799. goToFrame(frame: number): AnimationGroup;
  33800. /**
  33801. * Dispose all associated resources
  33802. */
  33803. dispose(): void;
  33804. private _checkAnimationGroupEnded;
  33805. /**
  33806. * Clone the current animation group and returns a copy
  33807. * @param newName defines the name of the new group
  33808. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33809. * @returns the new aniamtion group
  33810. */
  33811. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33812. /**
  33813. * Serializes the animationGroup to an object
  33814. * @returns Serialized object
  33815. */
  33816. serialize(): any;
  33817. /**
  33818. * Returns a new AnimationGroup object parsed from the source provided.
  33819. * @param parsedAnimationGroup defines the source
  33820. * @param scene defines the scene that will receive the animationGroup
  33821. * @returns a new AnimationGroup
  33822. */
  33823. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33824. /**
  33825. * Returns the string "AnimationGroup"
  33826. * @returns "AnimationGroup"
  33827. */
  33828. getClassName(): string;
  33829. /**
  33830. * Creates a detailled string about the object
  33831. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33832. * @returns a string representing the object
  33833. */
  33834. toString(fullDetails?: boolean): string;
  33835. }
  33836. }
  33837. declare module "babylonjs/scene" {
  33838. import { Nullable } from "babylonjs/types";
  33839. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33840. import { Observable } from "babylonjs/Misc/observable";
  33841. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33842. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33843. import { Geometry } from "babylonjs/Meshes/geometry";
  33844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33845. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33847. import { Mesh } from "babylonjs/Meshes/mesh";
  33848. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33849. import { Bone } from "babylonjs/Bones/bone";
  33850. import { Skeleton } from "babylonjs/Bones/skeleton";
  33851. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33852. import { Camera } from "babylonjs/Cameras/camera";
  33853. import { AbstractScene } from "babylonjs/abstractScene";
  33854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33856. import { Material } from "babylonjs/Materials/material";
  33857. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33858. import { Effect } from "babylonjs/Materials/effect";
  33859. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33860. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33861. import { Light } from "babylonjs/Lights/light";
  33862. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33863. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33864. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33865. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33866. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33867. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33868. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33869. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33870. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33871. import { Engine } from "babylonjs/Engines/engine";
  33872. import { Node } from "babylonjs/node";
  33873. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33874. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33875. import { WebRequest } from "babylonjs/Misc/webRequest";
  33876. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33877. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33878. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33879. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33880. import { Plane } from "babylonjs/Maths/math.plane";
  33881. import { Ray } from "babylonjs/Culling/ray";
  33882. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33883. import { Animation } from "babylonjs/Animations/animation";
  33884. import { Animatable } from "babylonjs/Animations/animatable";
  33885. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33886. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33887. import { Collider } from "babylonjs/Collisions/collider";
  33888. /**
  33889. * Define an interface for all classes that will hold resources
  33890. */
  33891. export interface IDisposable {
  33892. /**
  33893. * Releases all held resources
  33894. */
  33895. dispose(): void;
  33896. }
  33897. /** Interface defining initialization parameters for Scene class */
  33898. export interface SceneOptions {
  33899. /**
  33900. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33901. * It will improve performance when the number of geometries becomes important.
  33902. */
  33903. useGeometryUniqueIdsMap?: boolean;
  33904. /**
  33905. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33906. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33907. */
  33908. useMaterialMeshMap?: boolean;
  33909. /**
  33910. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33911. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33912. */
  33913. useClonedMeshhMap?: boolean;
  33914. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33915. virtual?: boolean;
  33916. }
  33917. /**
  33918. * Represents a scene to be rendered by the engine.
  33919. * @see http://doc.babylonjs.com/features/scene
  33920. */
  33921. export class Scene extends AbstractScene implements IAnimatable {
  33922. /** The fog is deactivated */
  33923. static readonly FOGMODE_NONE: number;
  33924. /** The fog density is following an exponential function */
  33925. static readonly FOGMODE_EXP: number;
  33926. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33927. static readonly FOGMODE_EXP2: number;
  33928. /** The fog density is following a linear function. */
  33929. static readonly FOGMODE_LINEAR: number;
  33930. /**
  33931. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33933. */
  33934. static MinDeltaTime: number;
  33935. /**
  33936. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33938. */
  33939. static MaxDeltaTime: number;
  33940. /**
  33941. * Factory used to create the default material.
  33942. * @param name The name of the material to create
  33943. * @param scene The scene to create the material for
  33944. * @returns The default material
  33945. */
  33946. static DefaultMaterialFactory(scene: Scene): Material;
  33947. /**
  33948. * Factory used to create the a collision coordinator.
  33949. * @returns The collision coordinator
  33950. */
  33951. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33952. /** @hidden */
  33953. _inputManager: InputManager;
  33954. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33955. cameraToUseForPointers: Nullable<Camera>;
  33956. /** @hidden */
  33957. readonly _isScene: boolean;
  33958. /**
  33959. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33960. */
  33961. autoClear: boolean;
  33962. /**
  33963. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33964. */
  33965. autoClearDepthAndStencil: boolean;
  33966. /**
  33967. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33968. */
  33969. clearColor: Color4;
  33970. /**
  33971. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33972. */
  33973. ambientColor: Color3;
  33974. /**
  33975. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33976. * It should only be one of the following (if not the default embedded one):
  33977. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33978. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33979. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33980. * The material properties need to be setup according to the type of texture in use.
  33981. */
  33982. environmentBRDFTexture: BaseTexture;
  33983. /** @hidden */
  33984. protected _environmentTexture: Nullable<BaseTexture>;
  33985. /**
  33986. * Texture used in all pbr material as the reflection texture.
  33987. * As in the majority of the scene they are the same (exception for multi room and so on),
  33988. * this is easier to reference from here than from all the materials.
  33989. */
  33990. /**
  33991. * Texture used in all pbr material as the reflection texture.
  33992. * As in the majority of the scene they are the same (exception for multi room and so on),
  33993. * this is easier to set here than in all the materials.
  33994. */
  33995. environmentTexture: Nullable<BaseTexture>;
  33996. /** @hidden */
  33997. protected _environmentIntensity: number;
  33998. /**
  33999. * Intensity of the environment in all pbr material.
  34000. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34001. * As in the majority of the scene they are the same (exception for multi room and so on),
  34002. * this is easier to reference from here than from all the materials.
  34003. */
  34004. /**
  34005. * Intensity of the environment in all pbr material.
  34006. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34007. * As in the majority of the scene they are the same (exception for multi room and so on),
  34008. * this is easier to set here than in all the materials.
  34009. */
  34010. environmentIntensity: number;
  34011. /** @hidden */
  34012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34013. /**
  34014. * Default image processing configuration used either in the rendering
  34015. * Forward main pass or through the imageProcessingPostProcess if present.
  34016. * As in the majority of the scene they are the same (exception for multi camera),
  34017. * this is easier to reference from here than from all the materials and post process.
  34018. *
  34019. * No setter as we it is a shared configuration, you can set the values instead.
  34020. */
  34021. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34022. private _forceWireframe;
  34023. /**
  34024. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34025. */
  34026. forceWireframe: boolean;
  34027. private _forcePointsCloud;
  34028. /**
  34029. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34030. */
  34031. forcePointsCloud: boolean;
  34032. /**
  34033. * Gets or sets the active clipplane 1
  34034. */
  34035. clipPlane: Nullable<Plane>;
  34036. /**
  34037. * Gets or sets the active clipplane 2
  34038. */
  34039. clipPlane2: Nullable<Plane>;
  34040. /**
  34041. * Gets or sets the active clipplane 3
  34042. */
  34043. clipPlane3: Nullable<Plane>;
  34044. /**
  34045. * Gets or sets the active clipplane 4
  34046. */
  34047. clipPlane4: Nullable<Plane>;
  34048. /**
  34049. * Gets or sets a boolean indicating if animations are enabled
  34050. */
  34051. animationsEnabled: boolean;
  34052. private _animationPropertiesOverride;
  34053. /**
  34054. * Gets or sets the animation properties override
  34055. */
  34056. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34057. /**
  34058. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34059. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34060. */
  34061. useConstantAnimationDeltaTime: boolean;
  34062. /**
  34063. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34064. * Please note that it requires to run a ray cast through the scene on every frame
  34065. */
  34066. constantlyUpdateMeshUnderPointer: boolean;
  34067. /**
  34068. * Defines the HTML cursor to use when hovering over interactive elements
  34069. */
  34070. hoverCursor: string;
  34071. /**
  34072. * Defines the HTML default cursor to use (empty by default)
  34073. */
  34074. defaultCursor: string;
  34075. /**
  34076. * This is used to call preventDefault() on pointer down
  34077. * in order to block unwanted artifacts like system double clicks
  34078. */
  34079. preventDefaultOnPointerDown: boolean;
  34080. /**
  34081. * This is used to call preventDefault() on pointer up
  34082. * in order to block unwanted artifacts like system double clicks
  34083. */
  34084. preventDefaultOnPointerUp: boolean;
  34085. /**
  34086. * Gets or sets user defined metadata
  34087. */
  34088. metadata: any;
  34089. /**
  34090. * For internal use only. Please do not use.
  34091. */
  34092. reservedDataStore: any;
  34093. /**
  34094. * Gets the name of the plugin used to load this scene (null by default)
  34095. */
  34096. loadingPluginName: string;
  34097. /**
  34098. * Use this array to add regular expressions used to disable offline support for specific urls
  34099. */
  34100. disableOfflineSupportExceptionRules: RegExp[];
  34101. /**
  34102. * An event triggered when the scene is disposed.
  34103. */
  34104. onDisposeObservable: Observable<Scene>;
  34105. private _onDisposeObserver;
  34106. /** Sets a function to be executed when this scene is disposed. */
  34107. onDispose: () => void;
  34108. /**
  34109. * An event triggered before rendering the scene (right after animations and physics)
  34110. */
  34111. onBeforeRenderObservable: Observable<Scene>;
  34112. private _onBeforeRenderObserver;
  34113. /** Sets a function to be executed before rendering this scene */
  34114. beforeRender: Nullable<() => void>;
  34115. /**
  34116. * An event triggered after rendering the scene
  34117. */
  34118. onAfterRenderObservable: Observable<Scene>;
  34119. /**
  34120. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34121. */
  34122. onAfterRenderCameraObservable: Observable<Camera>;
  34123. private _onAfterRenderObserver;
  34124. /** Sets a function to be executed after rendering this scene */
  34125. afterRender: Nullable<() => void>;
  34126. /**
  34127. * An event triggered before animating the scene
  34128. */
  34129. onBeforeAnimationsObservable: Observable<Scene>;
  34130. /**
  34131. * An event triggered after animations processing
  34132. */
  34133. onAfterAnimationsObservable: Observable<Scene>;
  34134. /**
  34135. * An event triggered before draw calls are ready to be sent
  34136. */
  34137. onBeforeDrawPhaseObservable: Observable<Scene>;
  34138. /**
  34139. * An event triggered after draw calls have been sent
  34140. */
  34141. onAfterDrawPhaseObservable: Observable<Scene>;
  34142. /**
  34143. * An event triggered when the scene is ready
  34144. */
  34145. onReadyObservable: Observable<Scene>;
  34146. /**
  34147. * An event triggered before rendering a camera
  34148. */
  34149. onBeforeCameraRenderObservable: Observable<Camera>;
  34150. private _onBeforeCameraRenderObserver;
  34151. /** Sets a function to be executed before rendering a camera*/
  34152. beforeCameraRender: () => void;
  34153. /**
  34154. * An event triggered after rendering a camera
  34155. */
  34156. onAfterCameraRenderObservable: Observable<Camera>;
  34157. private _onAfterCameraRenderObserver;
  34158. /** Sets a function to be executed after rendering a camera*/
  34159. afterCameraRender: () => void;
  34160. /**
  34161. * An event triggered when active meshes evaluation is about to start
  34162. */
  34163. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34164. /**
  34165. * An event triggered when active meshes evaluation is done
  34166. */
  34167. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34168. /**
  34169. * An event triggered when particles rendering is about to start
  34170. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34171. */
  34172. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34173. /**
  34174. * An event triggered when particles rendering is done
  34175. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34176. */
  34177. onAfterParticlesRenderingObservable: Observable<Scene>;
  34178. /**
  34179. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34180. */
  34181. onDataLoadedObservable: Observable<Scene>;
  34182. /**
  34183. * An event triggered when a camera is created
  34184. */
  34185. onNewCameraAddedObservable: Observable<Camera>;
  34186. /**
  34187. * An event triggered when a camera is removed
  34188. */
  34189. onCameraRemovedObservable: Observable<Camera>;
  34190. /**
  34191. * An event triggered when a light is created
  34192. */
  34193. onNewLightAddedObservable: Observable<Light>;
  34194. /**
  34195. * An event triggered when a light is removed
  34196. */
  34197. onLightRemovedObservable: Observable<Light>;
  34198. /**
  34199. * An event triggered when a geometry is created
  34200. */
  34201. onNewGeometryAddedObservable: Observable<Geometry>;
  34202. /**
  34203. * An event triggered when a geometry is removed
  34204. */
  34205. onGeometryRemovedObservable: Observable<Geometry>;
  34206. /**
  34207. * An event triggered when a transform node is created
  34208. */
  34209. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34210. /**
  34211. * An event triggered when a transform node is removed
  34212. */
  34213. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34214. /**
  34215. * An event triggered when a mesh is created
  34216. */
  34217. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34218. /**
  34219. * An event triggered when a mesh is removed
  34220. */
  34221. onMeshRemovedObservable: Observable<AbstractMesh>;
  34222. /**
  34223. * An event triggered when a skeleton is created
  34224. */
  34225. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34226. /**
  34227. * An event triggered when a skeleton is removed
  34228. */
  34229. onSkeletonRemovedObservable: Observable<Skeleton>;
  34230. /**
  34231. * An event triggered when a material is created
  34232. */
  34233. onNewMaterialAddedObservable: Observable<Material>;
  34234. /**
  34235. * An event triggered when a material is removed
  34236. */
  34237. onMaterialRemovedObservable: Observable<Material>;
  34238. /**
  34239. * An event triggered when a texture is created
  34240. */
  34241. onNewTextureAddedObservable: Observable<BaseTexture>;
  34242. /**
  34243. * An event triggered when a texture is removed
  34244. */
  34245. onTextureRemovedObservable: Observable<BaseTexture>;
  34246. /**
  34247. * An event triggered when render targets are about to be rendered
  34248. * Can happen multiple times per frame.
  34249. */
  34250. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34251. /**
  34252. * An event triggered when render targets were rendered.
  34253. * Can happen multiple times per frame.
  34254. */
  34255. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34256. /**
  34257. * An event triggered before calculating deterministic simulation step
  34258. */
  34259. onBeforeStepObservable: Observable<Scene>;
  34260. /**
  34261. * An event triggered after calculating deterministic simulation step
  34262. */
  34263. onAfterStepObservable: Observable<Scene>;
  34264. /**
  34265. * An event triggered when the activeCamera property is updated
  34266. */
  34267. onActiveCameraChanged: Observable<Scene>;
  34268. /**
  34269. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34270. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34271. * 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)
  34272. */
  34273. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34274. /**
  34275. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34276. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34277. * 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)
  34278. */
  34279. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34280. /**
  34281. * This Observable will when a mesh has been imported into the scene.
  34282. */
  34283. onMeshImportedObservable: Observable<AbstractMesh>;
  34284. /**
  34285. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34286. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34287. */
  34288. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34289. /** @hidden */
  34290. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34291. /**
  34292. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34293. */
  34294. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34295. /**
  34296. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34297. */
  34298. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34299. /**
  34300. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34301. */
  34302. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34303. /** Callback called when a pointer move is detected */
  34304. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34305. /** Callback called when a pointer down is detected */
  34306. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34307. /** Callback called when a pointer up is detected */
  34308. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34309. /** Callback called when a pointer pick is detected */
  34310. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34311. /**
  34312. * 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).
  34313. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34314. */
  34315. onPrePointerObservable: Observable<PointerInfoPre>;
  34316. /**
  34317. * Observable event triggered each time an input event is received from the rendering canvas
  34318. */
  34319. onPointerObservable: Observable<PointerInfo>;
  34320. /**
  34321. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34322. */
  34323. readonly unTranslatedPointer: Vector2;
  34324. /**
  34325. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34326. */
  34327. static DragMovementThreshold: number;
  34328. /**
  34329. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34330. */
  34331. static LongPressDelay: number;
  34332. /**
  34333. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34334. */
  34335. static DoubleClickDelay: number;
  34336. /** If you need to check double click without raising a single click at first click, enable this flag */
  34337. static ExclusiveDoubleClickMode: boolean;
  34338. /** @hidden */
  34339. _mirroredCameraPosition: Nullable<Vector3>;
  34340. /**
  34341. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34342. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34343. */
  34344. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34345. /**
  34346. * Observable event triggered each time an keyboard event is received from the hosting window
  34347. */
  34348. onKeyboardObservable: Observable<KeyboardInfo>;
  34349. private _useRightHandedSystem;
  34350. /**
  34351. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34352. */
  34353. useRightHandedSystem: boolean;
  34354. private _timeAccumulator;
  34355. private _currentStepId;
  34356. private _currentInternalStep;
  34357. /**
  34358. * Sets the step Id used by deterministic lock step
  34359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34360. * @param newStepId defines the step Id
  34361. */
  34362. setStepId(newStepId: number): void;
  34363. /**
  34364. * Gets the step Id used by deterministic lock step
  34365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34366. * @returns the step Id
  34367. */
  34368. getStepId(): number;
  34369. /**
  34370. * Gets the internal step used by deterministic lock step
  34371. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34372. * @returns the internal step
  34373. */
  34374. getInternalStep(): number;
  34375. private _fogEnabled;
  34376. /**
  34377. * Gets or sets a boolean indicating if fog is enabled on this scene
  34378. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34379. * (Default is true)
  34380. */
  34381. fogEnabled: boolean;
  34382. private _fogMode;
  34383. /**
  34384. * Gets or sets the fog mode to use
  34385. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34386. * | mode | value |
  34387. * | --- | --- |
  34388. * | FOGMODE_NONE | 0 |
  34389. * | FOGMODE_EXP | 1 |
  34390. * | FOGMODE_EXP2 | 2 |
  34391. * | FOGMODE_LINEAR | 3 |
  34392. */
  34393. fogMode: number;
  34394. /**
  34395. * Gets or sets the fog color to use
  34396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34397. * (Default is Color3(0.2, 0.2, 0.3))
  34398. */
  34399. fogColor: Color3;
  34400. /**
  34401. * Gets or sets the fog density to use
  34402. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34403. * (Default is 0.1)
  34404. */
  34405. fogDensity: number;
  34406. /**
  34407. * Gets or sets the fog start distance to use
  34408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34409. * (Default is 0)
  34410. */
  34411. fogStart: number;
  34412. /**
  34413. * Gets or sets the fog end distance to use
  34414. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34415. * (Default is 1000)
  34416. */
  34417. fogEnd: number;
  34418. private _shadowsEnabled;
  34419. /**
  34420. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34421. */
  34422. shadowsEnabled: boolean;
  34423. private _lightsEnabled;
  34424. /**
  34425. * Gets or sets a boolean indicating if lights are enabled on this scene
  34426. */
  34427. lightsEnabled: boolean;
  34428. /** All of the active cameras added to this scene. */
  34429. activeCameras: Camera[];
  34430. /** @hidden */
  34431. _activeCamera: Nullable<Camera>;
  34432. /** Gets or sets the current active camera */
  34433. activeCamera: Nullable<Camera>;
  34434. private _defaultMaterial;
  34435. /** The default material used on meshes when no material is affected */
  34436. /** The default material used on meshes when no material is affected */
  34437. defaultMaterial: Material;
  34438. private _texturesEnabled;
  34439. /**
  34440. * Gets or sets a boolean indicating if textures are enabled on this scene
  34441. */
  34442. texturesEnabled: boolean;
  34443. /**
  34444. * Gets or sets a boolean indicating if particles are enabled on this scene
  34445. */
  34446. particlesEnabled: boolean;
  34447. /**
  34448. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34449. */
  34450. spritesEnabled: boolean;
  34451. private _skeletonsEnabled;
  34452. /**
  34453. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34454. */
  34455. skeletonsEnabled: boolean;
  34456. /**
  34457. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34458. */
  34459. lensFlaresEnabled: boolean;
  34460. /**
  34461. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34463. */
  34464. collisionsEnabled: boolean;
  34465. private _collisionCoordinator;
  34466. /** @hidden */
  34467. readonly collisionCoordinator: ICollisionCoordinator;
  34468. /**
  34469. * Defines the gravity applied to this scene (used only for collisions)
  34470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34471. */
  34472. gravity: Vector3;
  34473. /**
  34474. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34475. */
  34476. postProcessesEnabled: boolean;
  34477. /**
  34478. * The list of postprocesses added to the scene
  34479. */
  34480. postProcesses: PostProcess[];
  34481. /**
  34482. * Gets the current postprocess manager
  34483. */
  34484. postProcessManager: PostProcessManager;
  34485. /**
  34486. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34487. */
  34488. renderTargetsEnabled: boolean;
  34489. /**
  34490. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34491. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34492. */
  34493. dumpNextRenderTargets: boolean;
  34494. /**
  34495. * The list of user defined render targets added to the scene
  34496. */
  34497. customRenderTargets: RenderTargetTexture[];
  34498. /**
  34499. * Defines if texture loading must be delayed
  34500. * If true, textures will only be loaded when they need to be rendered
  34501. */
  34502. useDelayedTextureLoading: boolean;
  34503. /**
  34504. * Gets the list of meshes imported to the scene through SceneLoader
  34505. */
  34506. importedMeshesFiles: String[];
  34507. /**
  34508. * Gets or sets a boolean indicating if probes are enabled on this scene
  34509. */
  34510. probesEnabled: boolean;
  34511. /**
  34512. * Gets or sets the current offline provider to use to store scene data
  34513. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34514. */
  34515. offlineProvider: IOfflineProvider;
  34516. /**
  34517. * Gets or sets the action manager associated with the scene
  34518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34519. */
  34520. actionManager: AbstractActionManager;
  34521. private _meshesForIntersections;
  34522. /**
  34523. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34524. */
  34525. proceduralTexturesEnabled: boolean;
  34526. private _engine;
  34527. private _totalVertices;
  34528. /** @hidden */
  34529. _activeIndices: PerfCounter;
  34530. /** @hidden */
  34531. _activeParticles: PerfCounter;
  34532. /** @hidden */
  34533. _activeBones: PerfCounter;
  34534. private _animationRatio;
  34535. /** @hidden */
  34536. _animationTimeLast: number;
  34537. /** @hidden */
  34538. _animationTime: number;
  34539. /**
  34540. * Gets or sets a general scale for animation speed
  34541. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34542. */
  34543. animationTimeScale: number;
  34544. /** @hidden */
  34545. _cachedMaterial: Nullable<Material>;
  34546. /** @hidden */
  34547. _cachedEffect: Nullable<Effect>;
  34548. /** @hidden */
  34549. _cachedVisibility: Nullable<number>;
  34550. private _renderId;
  34551. private _frameId;
  34552. private _executeWhenReadyTimeoutId;
  34553. private _intermediateRendering;
  34554. private _viewUpdateFlag;
  34555. private _projectionUpdateFlag;
  34556. /** @hidden */
  34557. _toBeDisposed: Nullable<IDisposable>[];
  34558. private _activeRequests;
  34559. /** @hidden */
  34560. _pendingData: any[];
  34561. private _isDisposed;
  34562. /**
  34563. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34564. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34565. */
  34566. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34567. private _activeMeshes;
  34568. private _processedMaterials;
  34569. private _renderTargets;
  34570. /** @hidden */
  34571. _activeParticleSystems: SmartArray<IParticleSystem>;
  34572. private _activeSkeletons;
  34573. private _softwareSkinnedMeshes;
  34574. private _renderingManager;
  34575. /** @hidden */
  34576. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34577. private _transformMatrix;
  34578. private _sceneUbo;
  34579. /** @hidden */
  34580. _viewMatrix: Matrix;
  34581. private _projectionMatrix;
  34582. /** @hidden */
  34583. _forcedViewPosition: Nullable<Vector3>;
  34584. /** @hidden */
  34585. _frustumPlanes: Plane[];
  34586. /**
  34587. * Gets the list of frustum planes (built from the active camera)
  34588. */
  34589. readonly frustumPlanes: Plane[];
  34590. /**
  34591. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34592. * This is useful if there are more lights that the maximum simulteanous authorized
  34593. */
  34594. requireLightSorting: boolean;
  34595. /** @hidden */
  34596. readonly useMaterialMeshMap: boolean;
  34597. /** @hidden */
  34598. readonly useClonedMeshhMap: boolean;
  34599. private _externalData;
  34600. private _uid;
  34601. /**
  34602. * @hidden
  34603. * Backing store of defined scene components.
  34604. */
  34605. _components: ISceneComponent[];
  34606. /**
  34607. * @hidden
  34608. * Backing store of defined scene components.
  34609. */
  34610. _serializableComponents: ISceneSerializableComponent[];
  34611. /**
  34612. * List of components to register on the next registration step.
  34613. */
  34614. private _transientComponents;
  34615. /**
  34616. * Registers the transient components if needed.
  34617. */
  34618. private _registerTransientComponents;
  34619. /**
  34620. * @hidden
  34621. * Add a component to the scene.
  34622. * Note that the ccomponent could be registered on th next frame if this is called after
  34623. * the register component stage.
  34624. * @param component Defines the component to add to the scene
  34625. */
  34626. _addComponent(component: ISceneComponent): void;
  34627. /**
  34628. * @hidden
  34629. * Gets a component from the scene.
  34630. * @param name defines the name of the component to retrieve
  34631. * @returns the component or null if not present
  34632. */
  34633. _getComponent(name: string): Nullable<ISceneComponent>;
  34634. /**
  34635. * @hidden
  34636. * Defines the actions happening before camera updates.
  34637. */
  34638. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34639. /**
  34640. * @hidden
  34641. * Defines the actions happening before clear the canvas.
  34642. */
  34643. _beforeClearStage: Stage<SimpleStageAction>;
  34644. /**
  34645. * @hidden
  34646. * Defines the actions when collecting render targets for the frame.
  34647. */
  34648. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34649. /**
  34650. * @hidden
  34651. * Defines the actions happening for one camera in the frame.
  34652. */
  34653. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34654. /**
  34655. * @hidden
  34656. * Defines the actions happening during the per mesh ready checks.
  34657. */
  34658. _isReadyForMeshStage: Stage<MeshStageAction>;
  34659. /**
  34660. * @hidden
  34661. * Defines the actions happening before evaluate active mesh checks.
  34662. */
  34663. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34664. /**
  34665. * @hidden
  34666. * Defines the actions happening during the evaluate sub mesh checks.
  34667. */
  34668. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34669. /**
  34670. * @hidden
  34671. * Defines the actions happening during the active mesh stage.
  34672. */
  34673. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34674. /**
  34675. * @hidden
  34676. * Defines the actions happening during the per camera render target step.
  34677. */
  34678. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34679. /**
  34680. * @hidden
  34681. * Defines the actions happening just before the active camera is drawing.
  34682. */
  34683. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34684. /**
  34685. * @hidden
  34686. * Defines the actions happening just before a render target is drawing.
  34687. */
  34688. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34689. /**
  34690. * @hidden
  34691. * Defines the actions happening just before a rendering group is drawing.
  34692. */
  34693. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34694. /**
  34695. * @hidden
  34696. * Defines the actions happening just before a mesh is drawing.
  34697. */
  34698. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34699. /**
  34700. * @hidden
  34701. * Defines the actions happening just after a mesh has been drawn.
  34702. */
  34703. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34704. /**
  34705. * @hidden
  34706. * Defines the actions happening just after a rendering group has been drawn.
  34707. */
  34708. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34709. /**
  34710. * @hidden
  34711. * Defines the actions happening just after the active camera has been drawn.
  34712. */
  34713. _afterCameraDrawStage: Stage<CameraStageAction>;
  34714. /**
  34715. * @hidden
  34716. * Defines the actions happening just after a render target has been drawn.
  34717. */
  34718. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34719. /**
  34720. * @hidden
  34721. * Defines the actions happening just after rendering all cameras and computing intersections.
  34722. */
  34723. _afterRenderStage: Stage<SimpleStageAction>;
  34724. /**
  34725. * @hidden
  34726. * Defines the actions happening when a pointer move event happens.
  34727. */
  34728. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34729. /**
  34730. * @hidden
  34731. * Defines the actions happening when a pointer down event happens.
  34732. */
  34733. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34734. /**
  34735. * @hidden
  34736. * Defines the actions happening when a pointer up event happens.
  34737. */
  34738. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34739. /**
  34740. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34741. */
  34742. private geometriesByUniqueId;
  34743. /**
  34744. * Creates a new Scene
  34745. * @param engine defines the engine to use to render this scene
  34746. * @param options defines the scene options
  34747. */
  34748. constructor(engine: Engine, options?: SceneOptions);
  34749. /**
  34750. * Gets a string idenfifying the name of the class
  34751. * @returns "Scene" string
  34752. */
  34753. getClassName(): string;
  34754. private _defaultMeshCandidates;
  34755. /**
  34756. * @hidden
  34757. */
  34758. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34759. private _defaultSubMeshCandidates;
  34760. /**
  34761. * @hidden
  34762. */
  34763. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34764. /**
  34765. * Sets the default candidate providers for the scene.
  34766. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34767. * and getCollidingSubMeshCandidates to their default function
  34768. */
  34769. setDefaultCandidateProviders(): void;
  34770. /**
  34771. * Gets the mesh that is currently under the pointer
  34772. */
  34773. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34774. /**
  34775. * Gets or sets the current on-screen X position of the pointer
  34776. */
  34777. pointerX: number;
  34778. /**
  34779. * Gets or sets the current on-screen Y position of the pointer
  34780. */
  34781. pointerY: number;
  34782. /**
  34783. * Gets the cached material (ie. the latest rendered one)
  34784. * @returns the cached material
  34785. */
  34786. getCachedMaterial(): Nullable<Material>;
  34787. /**
  34788. * Gets the cached effect (ie. the latest rendered one)
  34789. * @returns the cached effect
  34790. */
  34791. getCachedEffect(): Nullable<Effect>;
  34792. /**
  34793. * Gets the cached visibility state (ie. the latest rendered one)
  34794. * @returns the cached visibility state
  34795. */
  34796. getCachedVisibility(): Nullable<number>;
  34797. /**
  34798. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34799. * @param material defines the current material
  34800. * @param effect defines the current effect
  34801. * @param visibility defines the current visibility state
  34802. * @returns true if one parameter is not cached
  34803. */
  34804. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34805. /**
  34806. * Gets the engine associated with the scene
  34807. * @returns an Engine
  34808. */
  34809. getEngine(): Engine;
  34810. /**
  34811. * Gets the total number of vertices rendered per frame
  34812. * @returns the total number of vertices rendered per frame
  34813. */
  34814. getTotalVertices(): number;
  34815. /**
  34816. * Gets the performance counter for total vertices
  34817. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34818. */
  34819. readonly totalVerticesPerfCounter: PerfCounter;
  34820. /**
  34821. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34822. * @returns the total number of active indices rendered per frame
  34823. */
  34824. getActiveIndices(): number;
  34825. /**
  34826. * Gets the performance counter for active indices
  34827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34828. */
  34829. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34830. /**
  34831. * Gets the total number of active particles rendered per frame
  34832. * @returns the total number of active particles rendered per frame
  34833. */
  34834. getActiveParticles(): number;
  34835. /**
  34836. * Gets the performance counter for active particles
  34837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34838. */
  34839. readonly activeParticlesPerfCounter: PerfCounter;
  34840. /**
  34841. * Gets the total number of active bones rendered per frame
  34842. * @returns the total number of active bones rendered per frame
  34843. */
  34844. getActiveBones(): number;
  34845. /**
  34846. * Gets the performance counter for active bones
  34847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34848. */
  34849. readonly activeBonesPerfCounter: PerfCounter;
  34850. /**
  34851. * Gets the array of active meshes
  34852. * @returns an array of AbstractMesh
  34853. */
  34854. getActiveMeshes(): SmartArray<AbstractMesh>;
  34855. /**
  34856. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34857. * @returns a number
  34858. */
  34859. getAnimationRatio(): number;
  34860. /**
  34861. * Gets an unique Id for the current render phase
  34862. * @returns a number
  34863. */
  34864. getRenderId(): number;
  34865. /**
  34866. * Gets an unique Id for the current frame
  34867. * @returns a number
  34868. */
  34869. getFrameId(): number;
  34870. /** Call this function if you want to manually increment the render Id*/
  34871. incrementRenderId(): void;
  34872. private _createUbo;
  34873. /**
  34874. * Use this method to simulate a pointer move on a mesh
  34875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34878. * @returns the current scene
  34879. */
  34880. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34881. /**
  34882. * Use this method to simulate a pointer down on a mesh
  34883. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34884. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34885. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34886. * @returns the current scene
  34887. */
  34888. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34889. /**
  34890. * Use this method to simulate a pointer up on a mesh
  34891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34894. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34895. * @returns the current scene
  34896. */
  34897. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34898. /**
  34899. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34900. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34901. * @returns true if the pointer was captured
  34902. */
  34903. isPointerCaptured(pointerId?: number): boolean;
  34904. /**
  34905. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34906. * @param attachUp defines if you want to attach events to pointerup
  34907. * @param attachDown defines if you want to attach events to pointerdown
  34908. * @param attachMove defines if you want to attach events to pointermove
  34909. */
  34910. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34911. /** Detaches all event handlers*/
  34912. detachControl(): void;
  34913. /**
  34914. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34915. * Delay loaded resources are not taking in account
  34916. * @return true if all required resources are ready
  34917. */
  34918. isReady(): boolean;
  34919. /** Resets all cached information relative to material (including effect and visibility) */
  34920. resetCachedMaterial(): void;
  34921. /**
  34922. * Registers a function to be called before every frame render
  34923. * @param func defines the function to register
  34924. */
  34925. registerBeforeRender(func: () => void): void;
  34926. /**
  34927. * Unregisters a function called before every frame render
  34928. * @param func defines the function to unregister
  34929. */
  34930. unregisterBeforeRender(func: () => void): void;
  34931. /**
  34932. * Registers a function to be called after every frame render
  34933. * @param func defines the function to register
  34934. */
  34935. registerAfterRender(func: () => void): void;
  34936. /**
  34937. * Unregisters a function called after every frame render
  34938. * @param func defines the function to unregister
  34939. */
  34940. unregisterAfterRender(func: () => void): void;
  34941. private _executeOnceBeforeRender;
  34942. /**
  34943. * The provided function will run before render once and will be disposed afterwards.
  34944. * A timeout delay can be provided so that the function will be executed in N ms.
  34945. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34946. * @param func The function to be executed.
  34947. * @param timeout optional delay in ms
  34948. */
  34949. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34950. /** @hidden */
  34951. _addPendingData(data: any): void;
  34952. /** @hidden */
  34953. _removePendingData(data: any): void;
  34954. /**
  34955. * Returns the number of items waiting to be loaded
  34956. * @returns the number of items waiting to be loaded
  34957. */
  34958. getWaitingItemsCount(): number;
  34959. /**
  34960. * Returns a boolean indicating if the scene is still loading data
  34961. */
  34962. readonly isLoading: boolean;
  34963. /**
  34964. * Registers a function to be executed when the scene is ready
  34965. * @param {Function} func - the function to be executed
  34966. */
  34967. executeWhenReady(func: () => void): void;
  34968. /**
  34969. * Returns a promise that resolves when the scene is ready
  34970. * @returns A promise that resolves when the scene is ready
  34971. */
  34972. whenReadyAsync(): Promise<void>;
  34973. /** @hidden */
  34974. _checkIsReady(): void;
  34975. /**
  34976. * Gets all animatable attached to the scene
  34977. */
  34978. readonly animatables: Animatable[];
  34979. /**
  34980. * Resets the last animation time frame.
  34981. * Useful to override when animations start running when loading a scene for the first time.
  34982. */
  34983. resetLastAnimationTimeFrame(): void;
  34984. /**
  34985. * Gets the current view matrix
  34986. * @returns a Matrix
  34987. */
  34988. getViewMatrix(): Matrix;
  34989. /**
  34990. * Gets the current projection matrix
  34991. * @returns a Matrix
  34992. */
  34993. getProjectionMatrix(): Matrix;
  34994. /**
  34995. * Gets the current transform matrix
  34996. * @returns a Matrix made of View * Projection
  34997. */
  34998. getTransformMatrix(): Matrix;
  34999. /**
  35000. * Sets the current transform matrix
  35001. * @param viewL defines the View matrix to use
  35002. * @param projectionL defines the Projection matrix to use
  35003. * @param viewR defines the right View matrix to use (if provided)
  35004. * @param projectionR defines the right Projection matrix to use (if provided)
  35005. */
  35006. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35007. /**
  35008. * Gets the uniform buffer used to store scene data
  35009. * @returns a UniformBuffer
  35010. */
  35011. getSceneUniformBuffer(): UniformBuffer;
  35012. /**
  35013. * Gets an unique (relatively to the current scene) Id
  35014. * @returns an unique number for the scene
  35015. */
  35016. getUniqueId(): number;
  35017. /**
  35018. * Add a mesh to the list of scene's meshes
  35019. * @param newMesh defines the mesh to add
  35020. * @param recursive if all child meshes should also be added to the scene
  35021. */
  35022. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35023. /**
  35024. * Remove a mesh for the list of scene's meshes
  35025. * @param toRemove defines the mesh to remove
  35026. * @param recursive if all child meshes should also be removed from the scene
  35027. * @returns the index where the mesh was in the mesh list
  35028. */
  35029. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35030. /**
  35031. * Add a transform node to the list of scene's transform nodes
  35032. * @param newTransformNode defines the transform node to add
  35033. */
  35034. addTransformNode(newTransformNode: TransformNode): void;
  35035. /**
  35036. * Remove a transform node for the list of scene's transform nodes
  35037. * @param toRemove defines the transform node to remove
  35038. * @returns the index where the transform node was in the transform node list
  35039. */
  35040. removeTransformNode(toRemove: TransformNode): number;
  35041. /**
  35042. * Remove a skeleton for the list of scene's skeletons
  35043. * @param toRemove defines the skeleton to remove
  35044. * @returns the index where the skeleton was in the skeleton list
  35045. */
  35046. removeSkeleton(toRemove: Skeleton): number;
  35047. /**
  35048. * Remove a morph target for the list of scene's morph targets
  35049. * @param toRemove defines the morph target to remove
  35050. * @returns the index where the morph target was in the morph target list
  35051. */
  35052. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35053. /**
  35054. * Remove a light for the list of scene's lights
  35055. * @param toRemove defines the light to remove
  35056. * @returns the index where the light was in the light list
  35057. */
  35058. removeLight(toRemove: Light): number;
  35059. /**
  35060. * Remove a camera for the list of scene's cameras
  35061. * @param toRemove defines the camera to remove
  35062. * @returns the index where the camera was in the camera list
  35063. */
  35064. removeCamera(toRemove: Camera): number;
  35065. /**
  35066. * Remove a particle system for the list of scene's particle systems
  35067. * @param toRemove defines the particle system to remove
  35068. * @returns the index where the particle system was in the particle system list
  35069. */
  35070. removeParticleSystem(toRemove: IParticleSystem): number;
  35071. /**
  35072. * Remove a animation for the list of scene's animations
  35073. * @param toRemove defines the animation to remove
  35074. * @returns the index where the animation was in the animation list
  35075. */
  35076. removeAnimation(toRemove: Animation): number;
  35077. /**
  35078. * Will stop the animation of the given target
  35079. * @param target - the target
  35080. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35081. * @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)
  35082. */
  35083. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35084. /**
  35085. * Removes the given animation group from this scene.
  35086. * @param toRemove The animation group to remove
  35087. * @returns The index of the removed animation group
  35088. */
  35089. removeAnimationGroup(toRemove: AnimationGroup): number;
  35090. /**
  35091. * Removes the given multi-material from this scene.
  35092. * @param toRemove The multi-material to remove
  35093. * @returns The index of the removed multi-material
  35094. */
  35095. removeMultiMaterial(toRemove: MultiMaterial): number;
  35096. /**
  35097. * Removes the given material from this scene.
  35098. * @param toRemove The material to remove
  35099. * @returns The index of the removed material
  35100. */
  35101. removeMaterial(toRemove: Material): number;
  35102. /**
  35103. * Removes the given action manager from this scene.
  35104. * @param toRemove The action manager to remove
  35105. * @returns The index of the removed action manager
  35106. */
  35107. removeActionManager(toRemove: AbstractActionManager): number;
  35108. /**
  35109. * Removes the given texture from this scene.
  35110. * @param toRemove The texture to remove
  35111. * @returns The index of the removed texture
  35112. */
  35113. removeTexture(toRemove: BaseTexture): number;
  35114. /**
  35115. * Adds the given light to this scene
  35116. * @param newLight The light to add
  35117. */
  35118. addLight(newLight: Light): void;
  35119. /**
  35120. * Sorts the list list based on light priorities
  35121. */
  35122. sortLightsByPriority(): void;
  35123. /**
  35124. * Adds the given camera to this scene
  35125. * @param newCamera The camera to add
  35126. */
  35127. addCamera(newCamera: Camera): void;
  35128. /**
  35129. * Adds the given skeleton to this scene
  35130. * @param newSkeleton The skeleton to add
  35131. */
  35132. addSkeleton(newSkeleton: Skeleton): void;
  35133. /**
  35134. * Adds the given particle system to this scene
  35135. * @param newParticleSystem The particle system to add
  35136. */
  35137. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35138. /**
  35139. * Adds the given animation to this scene
  35140. * @param newAnimation The animation to add
  35141. */
  35142. addAnimation(newAnimation: Animation): void;
  35143. /**
  35144. * Adds the given animation group to this scene.
  35145. * @param newAnimationGroup The animation group to add
  35146. */
  35147. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35148. /**
  35149. * Adds the given multi-material to this scene
  35150. * @param newMultiMaterial The multi-material to add
  35151. */
  35152. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35153. /**
  35154. * Adds the given material to this scene
  35155. * @param newMaterial The material to add
  35156. */
  35157. addMaterial(newMaterial: Material): void;
  35158. /**
  35159. * Adds the given morph target to this scene
  35160. * @param newMorphTargetManager The morph target to add
  35161. */
  35162. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35163. /**
  35164. * Adds the given geometry to this scene
  35165. * @param newGeometry The geometry to add
  35166. */
  35167. addGeometry(newGeometry: Geometry): void;
  35168. /**
  35169. * Adds the given action manager to this scene
  35170. * @param newActionManager The action manager to add
  35171. */
  35172. addActionManager(newActionManager: AbstractActionManager): void;
  35173. /**
  35174. * Adds the given texture to this scene.
  35175. * @param newTexture The texture to add
  35176. */
  35177. addTexture(newTexture: BaseTexture): void;
  35178. /**
  35179. * Switch active camera
  35180. * @param newCamera defines the new active camera
  35181. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35182. */
  35183. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35184. /**
  35185. * sets the active camera of the scene using its ID
  35186. * @param id defines the camera's ID
  35187. * @return the new active camera or null if none found.
  35188. */
  35189. setActiveCameraByID(id: string): Nullable<Camera>;
  35190. /**
  35191. * sets the active camera of the scene using its name
  35192. * @param name defines the camera's name
  35193. * @returns the new active camera or null if none found.
  35194. */
  35195. setActiveCameraByName(name: string): Nullable<Camera>;
  35196. /**
  35197. * get an animation group using its name
  35198. * @param name defines the material's name
  35199. * @return the animation group or null if none found.
  35200. */
  35201. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35202. /**
  35203. * Get a material using its unique id
  35204. * @param uniqueId defines the material's unique id
  35205. * @return the material or null if none found.
  35206. */
  35207. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35208. /**
  35209. * get a material using its id
  35210. * @param id defines the material's ID
  35211. * @return the material or null if none found.
  35212. */
  35213. getMaterialByID(id: string): Nullable<Material>;
  35214. /**
  35215. * Gets a the last added material using a given id
  35216. * @param id defines the material's ID
  35217. * @return the last material with the given id or null if none found.
  35218. */
  35219. getLastMaterialByID(id: string): Nullable<Material>;
  35220. /**
  35221. * Gets a material using its name
  35222. * @param name defines the material's name
  35223. * @return the material or null if none found.
  35224. */
  35225. getMaterialByName(name: string): Nullable<Material>;
  35226. /**
  35227. * Get a texture using its unique id
  35228. * @param uniqueId defines the texture's unique id
  35229. * @return the texture or null if none found.
  35230. */
  35231. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35232. /**
  35233. * Gets a camera using its id
  35234. * @param id defines the id to look for
  35235. * @returns the camera or null if not found
  35236. */
  35237. getCameraByID(id: string): Nullable<Camera>;
  35238. /**
  35239. * Gets a camera using its unique id
  35240. * @param uniqueId defines the unique id to look for
  35241. * @returns the camera or null if not found
  35242. */
  35243. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35244. /**
  35245. * Gets a camera using its name
  35246. * @param name defines the camera's name
  35247. * @return the camera or null if none found.
  35248. */
  35249. getCameraByName(name: string): Nullable<Camera>;
  35250. /**
  35251. * Gets a bone using its id
  35252. * @param id defines the bone's id
  35253. * @return the bone or null if not found
  35254. */
  35255. getBoneByID(id: string): Nullable<Bone>;
  35256. /**
  35257. * Gets a bone using its id
  35258. * @param name defines the bone's name
  35259. * @return the bone or null if not found
  35260. */
  35261. getBoneByName(name: string): Nullable<Bone>;
  35262. /**
  35263. * Gets a light node using its name
  35264. * @param name defines the the light's name
  35265. * @return the light or null if none found.
  35266. */
  35267. getLightByName(name: string): Nullable<Light>;
  35268. /**
  35269. * Gets a light node using its id
  35270. * @param id defines the light's id
  35271. * @return the light or null if none found.
  35272. */
  35273. getLightByID(id: string): Nullable<Light>;
  35274. /**
  35275. * Gets a light node using its scene-generated unique ID
  35276. * @param uniqueId defines the light's unique id
  35277. * @return the light or null if none found.
  35278. */
  35279. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35280. /**
  35281. * Gets a particle system by id
  35282. * @param id defines the particle system id
  35283. * @return the corresponding system or null if none found
  35284. */
  35285. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35286. /**
  35287. * Gets a geometry using its ID
  35288. * @param id defines the geometry's id
  35289. * @return the geometry or null if none found.
  35290. */
  35291. getGeometryByID(id: string): Nullable<Geometry>;
  35292. private _getGeometryByUniqueID;
  35293. /**
  35294. * Add a new geometry to this scene
  35295. * @param geometry defines the geometry to be added to the scene.
  35296. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35297. * @return a boolean defining if the geometry was added or not
  35298. */
  35299. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35300. /**
  35301. * Removes an existing geometry
  35302. * @param geometry defines the geometry to be removed from the scene
  35303. * @return a boolean defining if the geometry was removed or not
  35304. */
  35305. removeGeometry(geometry: Geometry): boolean;
  35306. /**
  35307. * Gets the list of geometries attached to the scene
  35308. * @returns an array of Geometry
  35309. */
  35310. getGeometries(): Geometry[];
  35311. /**
  35312. * Gets the first added mesh found of a given ID
  35313. * @param id defines the id to search for
  35314. * @return the mesh found or null if not found at all
  35315. */
  35316. getMeshByID(id: string): Nullable<AbstractMesh>;
  35317. /**
  35318. * Gets a list of meshes using their id
  35319. * @param id defines the id to search for
  35320. * @returns a list of meshes
  35321. */
  35322. getMeshesByID(id: string): Array<AbstractMesh>;
  35323. /**
  35324. * Gets the first added transform node found of a given ID
  35325. * @param id defines the id to search for
  35326. * @return the found transform node or null if not found at all.
  35327. */
  35328. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35329. /**
  35330. * Gets a transform node with its auto-generated unique id
  35331. * @param uniqueId efines the unique id to search for
  35332. * @return the found transform node or null if not found at all.
  35333. */
  35334. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35335. /**
  35336. * Gets a list of transform nodes using their id
  35337. * @param id defines the id to search for
  35338. * @returns a list of transform nodes
  35339. */
  35340. getTransformNodesByID(id: string): Array<TransformNode>;
  35341. /**
  35342. * Gets a mesh with its auto-generated unique id
  35343. * @param uniqueId defines the unique id to search for
  35344. * @return the found mesh or null if not found at all.
  35345. */
  35346. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35347. /**
  35348. * Gets a the last added mesh using a given id
  35349. * @param id defines the id to search for
  35350. * @return the found mesh or null if not found at all.
  35351. */
  35352. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35353. /**
  35354. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35355. * @param id defines the id to search for
  35356. * @return the found node or null if not found at all
  35357. */
  35358. getLastEntryByID(id: string): Nullable<Node>;
  35359. /**
  35360. * Gets a node (Mesh, Camera, Light) using a given id
  35361. * @param id defines the id to search for
  35362. * @return the found node or null if not found at all
  35363. */
  35364. getNodeByID(id: string): Nullable<Node>;
  35365. /**
  35366. * Gets a node (Mesh, Camera, Light) using a given name
  35367. * @param name defines the name to search for
  35368. * @return the found node or null if not found at all.
  35369. */
  35370. getNodeByName(name: string): Nullable<Node>;
  35371. /**
  35372. * Gets a mesh using a given name
  35373. * @param name defines the name to search for
  35374. * @return the found mesh or null if not found at all.
  35375. */
  35376. getMeshByName(name: string): Nullable<AbstractMesh>;
  35377. /**
  35378. * Gets a transform node using a given name
  35379. * @param name defines the name to search for
  35380. * @return the found transform node or null if not found at all.
  35381. */
  35382. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35383. /**
  35384. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35385. * @param id defines the id to search for
  35386. * @return the found skeleton or null if not found at all.
  35387. */
  35388. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35389. /**
  35390. * Gets a skeleton using a given auto generated unique id
  35391. * @param uniqueId defines the unique id to search for
  35392. * @return the found skeleton or null if not found at all.
  35393. */
  35394. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35395. /**
  35396. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35397. * @param id defines the id to search for
  35398. * @return the found skeleton or null if not found at all.
  35399. */
  35400. getSkeletonById(id: string): Nullable<Skeleton>;
  35401. /**
  35402. * Gets a skeleton using a given name
  35403. * @param name defines the name to search for
  35404. * @return the found skeleton or null if not found at all.
  35405. */
  35406. getSkeletonByName(name: string): Nullable<Skeleton>;
  35407. /**
  35408. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35409. * @param id defines the id to search for
  35410. * @return the found morph target manager or null if not found at all.
  35411. */
  35412. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35413. /**
  35414. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35415. * @param id defines the id to search for
  35416. * @return the found morph target or null if not found at all.
  35417. */
  35418. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35419. /**
  35420. * Gets a boolean indicating if the given mesh is active
  35421. * @param mesh defines the mesh to look for
  35422. * @returns true if the mesh is in the active list
  35423. */
  35424. isActiveMesh(mesh: AbstractMesh): boolean;
  35425. /**
  35426. * Return a unique id as a string which can serve as an identifier for the scene
  35427. */
  35428. readonly uid: string;
  35429. /**
  35430. * Add an externaly attached data from its key.
  35431. * This method call will fail and return false, if such key already exists.
  35432. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35433. * @param key the unique key that identifies the data
  35434. * @param data the data object to associate to the key for this Engine instance
  35435. * @return true if no such key were already present and the data was added successfully, false otherwise
  35436. */
  35437. addExternalData<T>(key: string, data: T): boolean;
  35438. /**
  35439. * Get an externaly attached data from its key
  35440. * @param key the unique key that identifies the data
  35441. * @return the associated data, if present (can be null), or undefined if not present
  35442. */
  35443. getExternalData<T>(key: string): Nullable<T>;
  35444. /**
  35445. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35446. * @param key the unique key that identifies the data
  35447. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35448. * @return the associated data, can be null if the factory returned null.
  35449. */
  35450. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35451. /**
  35452. * Remove an externaly attached data from the Engine instance
  35453. * @param key the unique key that identifies the data
  35454. * @return true if the data was successfully removed, false if it doesn't exist
  35455. */
  35456. removeExternalData(key: string): boolean;
  35457. private _evaluateSubMesh;
  35458. /**
  35459. * Clear the processed materials smart array preventing retention point in material dispose.
  35460. */
  35461. freeProcessedMaterials(): void;
  35462. private _preventFreeActiveMeshesAndRenderingGroups;
  35463. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35464. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35465. * when disposing several meshes in a row or a hierarchy of meshes.
  35466. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35467. */
  35468. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35469. /**
  35470. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35471. */
  35472. freeActiveMeshes(): void;
  35473. /**
  35474. * Clear the info related to rendering groups preventing retention points during dispose.
  35475. */
  35476. freeRenderingGroups(): void;
  35477. /** @hidden */
  35478. _isInIntermediateRendering(): boolean;
  35479. /**
  35480. * Lambda returning the list of potentially active meshes.
  35481. */
  35482. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35483. /**
  35484. * Lambda returning the list of potentially active sub meshes.
  35485. */
  35486. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35487. /**
  35488. * Lambda returning the list of potentially intersecting sub meshes.
  35489. */
  35490. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35491. /**
  35492. * Lambda returning the list of potentially colliding sub meshes.
  35493. */
  35494. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35495. private _activeMeshesFrozen;
  35496. /**
  35497. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35498. * @returns the current scene
  35499. */
  35500. freezeActiveMeshes(): Scene;
  35501. /**
  35502. * Use this function to restart evaluating active meshes on every frame
  35503. * @returns the current scene
  35504. */
  35505. unfreezeActiveMeshes(): Scene;
  35506. private _evaluateActiveMeshes;
  35507. private _activeMesh;
  35508. /**
  35509. * Update the transform matrix to update from the current active camera
  35510. * @param force defines a boolean used to force the update even if cache is up to date
  35511. */
  35512. updateTransformMatrix(force?: boolean): void;
  35513. private _bindFrameBuffer;
  35514. /** @hidden */
  35515. _allowPostProcessClearColor: boolean;
  35516. /** @hidden */
  35517. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35518. private _processSubCameras;
  35519. private _checkIntersections;
  35520. /** @hidden */
  35521. _advancePhysicsEngineStep(step: number): void;
  35522. /**
  35523. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35524. */
  35525. getDeterministicFrameTime: () => number;
  35526. /** @hidden */
  35527. _animate(): void;
  35528. /** Execute all animations (for a frame) */
  35529. animate(): void;
  35530. /**
  35531. * Render the scene
  35532. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35533. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35534. */
  35535. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35536. /**
  35537. * Freeze all materials
  35538. * A frozen material will not be updatable but should be faster to render
  35539. */
  35540. freezeMaterials(): void;
  35541. /**
  35542. * Unfreeze all materials
  35543. * A frozen material will not be updatable but should be faster to render
  35544. */
  35545. unfreezeMaterials(): void;
  35546. /**
  35547. * Releases all held ressources
  35548. */
  35549. dispose(): void;
  35550. /**
  35551. * Gets if the scene is already disposed
  35552. */
  35553. readonly isDisposed: boolean;
  35554. /**
  35555. * Call this function to reduce memory footprint of the scene.
  35556. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35557. */
  35558. clearCachedVertexData(): void;
  35559. /**
  35560. * This function will remove the local cached buffer data from texture.
  35561. * It will save memory but will prevent the texture from being rebuilt
  35562. */
  35563. cleanCachedTextureBuffer(): void;
  35564. /**
  35565. * Get the world extend vectors with an optional filter
  35566. *
  35567. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35568. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35569. */
  35570. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35571. min: Vector3;
  35572. max: Vector3;
  35573. };
  35574. /**
  35575. * Creates a ray that can be used to pick in the scene
  35576. * @param x defines the x coordinate of the origin (on-screen)
  35577. * @param y defines the y coordinate of the origin (on-screen)
  35578. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35579. * @param camera defines the camera to use for the picking
  35580. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35581. * @returns a Ray
  35582. */
  35583. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35584. /**
  35585. * Creates a ray that can be used to pick in the scene
  35586. * @param x defines the x coordinate of the origin (on-screen)
  35587. * @param y defines the y coordinate of the origin (on-screen)
  35588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35589. * @param result defines the ray where to store the picking ray
  35590. * @param camera defines the camera to use for the picking
  35591. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35592. * @returns the current scene
  35593. */
  35594. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35595. /**
  35596. * Creates a ray that can be used to pick in the scene
  35597. * @param x defines the x coordinate of the origin (on-screen)
  35598. * @param y defines the y coordinate of the origin (on-screen)
  35599. * @param camera defines the camera to use for the picking
  35600. * @returns a Ray
  35601. */
  35602. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35603. /**
  35604. * Creates a ray that can be used to pick in the scene
  35605. * @param x defines the x coordinate of the origin (on-screen)
  35606. * @param y defines the y coordinate of the origin (on-screen)
  35607. * @param result defines the ray where to store the picking ray
  35608. * @param camera defines the camera to use for the picking
  35609. * @returns the current scene
  35610. */
  35611. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35612. /** Launch a ray to try to pick a mesh in the scene
  35613. * @param x position on screen
  35614. * @param y position on screen
  35615. * @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
  35616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35617. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35618. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35619. * @returns a PickingInfo
  35620. */
  35621. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35622. /** Use the given ray to pick a mesh in the scene
  35623. * @param ray The ray to use to pick meshes
  35624. * @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
  35625. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35626. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35627. * @returns a PickingInfo
  35628. */
  35629. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35630. /**
  35631. * Launch a ray to try to pick a mesh in the scene
  35632. * @param x X position on screen
  35633. * @param y Y position on screen
  35634. * @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
  35635. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35637. * @returns an array of PickingInfo
  35638. */
  35639. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35640. /**
  35641. * Launch a ray to try to pick a mesh in the scene
  35642. * @param ray Ray to use
  35643. * @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
  35644. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35645. * @returns an array of PickingInfo
  35646. */
  35647. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35648. /**
  35649. * Force the value of meshUnderPointer
  35650. * @param mesh defines the mesh to use
  35651. */
  35652. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35653. /**
  35654. * Gets the mesh under the pointer
  35655. * @returns a Mesh or null if no mesh is under the pointer
  35656. */
  35657. getPointerOverMesh(): Nullable<AbstractMesh>;
  35658. /** @hidden */
  35659. _rebuildGeometries(): void;
  35660. /** @hidden */
  35661. _rebuildTextures(): void;
  35662. private _getByTags;
  35663. /**
  35664. * Get a list of meshes by tags
  35665. * @param tagsQuery defines the tags query to use
  35666. * @param forEach defines a predicate used to filter results
  35667. * @returns an array of Mesh
  35668. */
  35669. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35670. /**
  35671. * Get a list of cameras by tags
  35672. * @param tagsQuery defines the tags query to use
  35673. * @param forEach defines a predicate used to filter results
  35674. * @returns an array of Camera
  35675. */
  35676. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35677. /**
  35678. * Get a list of lights by tags
  35679. * @param tagsQuery defines the tags query to use
  35680. * @param forEach defines a predicate used to filter results
  35681. * @returns an array of Light
  35682. */
  35683. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35684. /**
  35685. * Get a list of materials by tags
  35686. * @param tagsQuery defines the tags query to use
  35687. * @param forEach defines a predicate used to filter results
  35688. * @returns an array of Material
  35689. */
  35690. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35691. /**
  35692. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35693. * This allowed control for front to back rendering or reversly depending of the special needs.
  35694. *
  35695. * @param renderingGroupId The rendering group id corresponding to its index
  35696. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35697. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35698. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35699. */
  35700. 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;
  35701. /**
  35702. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35703. *
  35704. * @param renderingGroupId The rendering group id corresponding to its index
  35705. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35706. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35707. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35708. */
  35709. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35710. /**
  35711. * Gets the current auto clear configuration for one rendering group of the rendering
  35712. * manager.
  35713. * @param index the rendering group index to get the information for
  35714. * @returns The auto clear setup for the requested rendering group
  35715. */
  35716. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35717. private _blockMaterialDirtyMechanism;
  35718. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35719. blockMaterialDirtyMechanism: boolean;
  35720. /**
  35721. * Will flag all materials as dirty to trigger new shader compilation
  35722. * @param flag defines the flag used to specify which material part must be marked as dirty
  35723. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35724. */
  35725. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35726. /** @hidden */
  35727. _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;
  35728. /** @hidden */
  35729. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35730. }
  35731. }
  35732. declare module "babylonjs/assetContainer" {
  35733. import { AbstractScene } from "babylonjs/abstractScene";
  35734. import { Scene } from "babylonjs/scene";
  35735. import { Mesh } from "babylonjs/Meshes/mesh";
  35736. /**
  35737. * Set of assets to keep when moving a scene into an asset container.
  35738. */
  35739. export class KeepAssets extends AbstractScene {
  35740. }
  35741. /**
  35742. * Container with a set of assets that can be added or removed from a scene.
  35743. */
  35744. export class AssetContainer extends AbstractScene {
  35745. /**
  35746. * The scene the AssetContainer belongs to.
  35747. */
  35748. scene: Scene;
  35749. /**
  35750. * Instantiates an AssetContainer.
  35751. * @param scene The scene the AssetContainer belongs to.
  35752. */
  35753. constructor(scene: Scene);
  35754. /**
  35755. * Adds all the assets from the container to the scene.
  35756. */
  35757. addAllToScene(): void;
  35758. /**
  35759. * Removes all the assets in the container from the scene
  35760. */
  35761. removeAllFromScene(): void;
  35762. /**
  35763. * Disposes all the assets in the container
  35764. */
  35765. dispose(): void;
  35766. private _moveAssets;
  35767. /**
  35768. * Removes all the assets contained in the scene and adds them to the container.
  35769. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35770. */
  35771. moveAllFromScene(keepAssets?: KeepAssets): void;
  35772. /**
  35773. * 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.
  35774. * @returns the root mesh
  35775. */
  35776. createRootMesh(): Mesh;
  35777. }
  35778. }
  35779. declare module "babylonjs/abstractScene" {
  35780. import { Scene } from "babylonjs/scene";
  35781. import { Nullable } from "babylonjs/types";
  35782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35783. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35784. import { Geometry } from "babylonjs/Meshes/geometry";
  35785. import { Skeleton } from "babylonjs/Bones/skeleton";
  35786. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35787. import { AssetContainer } from "babylonjs/assetContainer";
  35788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35789. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35791. import { Material } from "babylonjs/Materials/material";
  35792. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35793. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35794. import { Camera } from "babylonjs/Cameras/camera";
  35795. import { Light } from "babylonjs/Lights/light";
  35796. import { Node } from "babylonjs/node";
  35797. import { Animation } from "babylonjs/Animations/animation";
  35798. /**
  35799. * Defines how the parser contract is defined.
  35800. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35801. */
  35802. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35803. /**
  35804. * Defines how the individual parser contract is defined.
  35805. * These parser can parse an individual asset
  35806. */
  35807. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35808. /**
  35809. * Base class of the scene acting as a container for the different elements composing a scene.
  35810. * This class is dynamically extended by the different components of the scene increasing
  35811. * flexibility and reducing coupling
  35812. */
  35813. export abstract class AbstractScene {
  35814. /**
  35815. * Stores the list of available parsers in the application.
  35816. */
  35817. private static _BabylonFileParsers;
  35818. /**
  35819. * Stores the list of available individual parsers in the application.
  35820. */
  35821. private static _IndividualBabylonFileParsers;
  35822. /**
  35823. * Adds a parser in the list of available ones
  35824. * @param name Defines the name of the parser
  35825. * @param parser Defines the parser to add
  35826. */
  35827. static AddParser(name: string, parser: BabylonFileParser): void;
  35828. /**
  35829. * Gets a general parser from the list of avaialble ones
  35830. * @param name Defines the name of the parser
  35831. * @returns the requested parser or null
  35832. */
  35833. static GetParser(name: string): Nullable<BabylonFileParser>;
  35834. /**
  35835. * Adds n individual parser in the list of available ones
  35836. * @param name Defines the name of the parser
  35837. * @param parser Defines the parser to add
  35838. */
  35839. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35840. /**
  35841. * Gets an individual parser from the list of avaialble ones
  35842. * @param name Defines the name of the parser
  35843. * @returns the requested parser or null
  35844. */
  35845. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35846. /**
  35847. * Parser json data and populate both a scene and its associated container object
  35848. * @param jsonData Defines the data to parse
  35849. * @param scene Defines the scene to parse the data for
  35850. * @param container Defines the container attached to the parsing sequence
  35851. * @param rootUrl Defines the root url of the data
  35852. */
  35853. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35854. /**
  35855. * Gets the list of root nodes (ie. nodes with no parent)
  35856. */
  35857. rootNodes: Node[];
  35858. /** All of the cameras added to this scene
  35859. * @see http://doc.babylonjs.com/babylon101/cameras
  35860. */
  35861. cameras: Camera[];
  35862. /**
  35863. * All of the lights added to this scene
  35864. * @see http://doc.babylonjs.com/babylon101/lights
  35865. */
  35866. lights: Light[];
  35867. /**
  35868. * All of the (abstract) meshes added to this scene
  35869. */
  35870. meshes: AbstractMesh[];
  35871. /**
  35872. * The list of skeletons added to the scene
  35873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35874. */
  35875. skeletons: Skeleton[];
  35876. /**
  35877. * All of the particle systems added to this scene
  35878. * @see http://doc.babylonjs.com/babylon101/particles
  35879. */
  35880. particleSystems: IParticleSystem[];
  35881. /**
  35882. * Gets a list of Animations associated with the scene
  35883. */
  35884. animations: Animation[];
  35885. /**
  35886. * All of the animation groups added to this scene
  35887. * @see http://doc.babylonjs.com/how_to/group
  35888. */
  35889. animationGroups: AnimationGroup[];
  35890. /**
  35891. * All of the multi-materials added to this scene
  35892. * @see http://doc.babylonjs.com/how_to/multi_materials
  35893. */
  35894. multiMaterials: MultiMaterial[];
  35895. /**
  35896. * All of the materials added to this scene
  35897. * In the context of a Scene, it is not supposed to be modified manually.
  35898. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35899. * Note also that the order of the Material wihin the array is not significant and might change.
  35900. * @see http://doc.babylonjs.com/babylon101/materials
  35901. */
  35902. materials: Material[];
  35903. /**
  35904. * The list of morph target managers added to the scene
  35905. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35906. */
  35907. morphTargetManagers: MorphTargetManager[];
  35908. /**
  35909. * The list of geometries used in the scene.
  35910. */
  35911. geometries: Geometry[];
  35912. /**
  35913. * All of the tranform nodes added to this scene
  35914. * In the context of a Scene, it is not supposed to be modified manually.
  35915. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35916. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35917. * @see http://doc.babylonjs.com/how_to/transformnode
  35918. */
  35919. transformNodes: TransformNode[];
  35920. /**
  35921. * ActionManagers available on the scene.
  35922. */
  35923. actionManagers: AbstractActionManager[];
  35924. /**
  35925. * Textures to keep.
  35926. */
  35927. textures: BaseTexture[];
  35928. /**
  35929. * Environment texture for the scene
  35930. */
  35931. environmentTexture: Nullable<BaseTexture>;
  35932. }
  35933. }
  35934. declare module "babylonjs/Audio/sound" {
  35935. import { Observable } from "babylonjs/Misc/observable";
  35936. import { Vector3 } from "babylonjs/Maths/math.vector";
  35937. import { Nullable } from "babylonjs/types";
  35938. import { Scene } from "babylonjs/scene";
  35939. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35940. /**
  35941. * Interface used to define options for Sound class
  35942. */
  35943. export interface ISoundOptions {
  35944. /**
  35945. * Does the sound autoplay once loaded.
  35946. */
  35947. autoplay?: boolean;
  35948. /**
  35949. * Does the sound loop after it finishes playing once.
  35950. */
  35951. loop?: boolean;
  35952. /**
  35953. * Sound's volume
  35954. */
  35955. volume?: number;
  35956. /**
  35957. * Is it a spatial sound?
  35958. */
  35959. spatialSound?: boolean;
  35960. /**
  35961. * Maximum distance to hear that sound
  35962. */
  35963. maxDistance?: number;
  35964. /**
  35965. * Uses user defined attenuation function
  35966. */
  35967. useCustomAttenuation?: boolean;
  35968. /**
  35969. * Define the roll off factor of spatial sounds.
  35970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35971. */
  35972. rolloffFactor?: number;
  35973. /**
  35974. * Define the reference distance the sound should be heard perfectly.
  35975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35976. */
  35977. refDistance?: number;
  35978. /**
  35979. * Define the distance attenuation model the sound will follow.
  35980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35981. */
  35982. distanceModel?: string;
  35983. /**
  35984. * Defines the playback speed (1 by default)
  35985. */
  35986. playbackRate?: number;
  35987. /**
  35988. * Defines if the sound is from a streaming source
  35989. */
  35990. streaming?: boolean;
  35991. /**
  35992. * Defines an optional length (in seconds) inside the sound file
  35993. */
  35994. length?: number;
  35995. /**
  35996. * Defines an optional offset (in seconds) inside the sound file
  35997. */
  35998. offset?: number;
  35999. /**
  36000. * If true, URLs will not be required to state the audio file codec to use.
  36001. */
  36002. skipCodecCheck?: boolean;
  36003. }
  36004. /**
  36005. * Defines a sound that can be played in the application.
  36006. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36008. */
  36009. export class Sound {
  36010. /**
  36011. * The name of the sound in the scene.
  36012. */
  36013. name: string;
  36014. /**
  36015. * Does the sound autoplay once loaded.
  36016. */
  36017. autoplay: boolean;
  36018. /**
  36019. * Does the sound loop after it finishes playing once.
  36020. */
  36021. loop: boolean;
  36022. /**
  36023. * Does the sound use a custom attenuation curve to simulate the falloff
  36024. * happening when the source gets further away from the camera.
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. useCustomAttenuation: boolean;
  36028. /**
  36029. * The sound track id this sound belongs to.
  36030. */
  36031. soundTrackId: number;
  36032. /**
  36033. * Is this sound currently played.
  36034. */
  36035. isPlaying: boolean;
  36036. /**
  36037. * Is this sound currently paused.
  36038. */
  36039. isPaused: boolean;
  36040. /**
  36041. * Does this sound enables spatial sound.
  36042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36043. */
  36044. spatialSound: boolean;
  36045. /**
  36046. * Define the reference distance the sound should be heard perfectly.
  36047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36048. */
  36049. refDistance: number;
  36050. /**
  36051. * Define the roll off factor of spatial sounds.
  36052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36053. */
  36054. rolloffFactor: number;
  36055. /**
  36056. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36058. */
  36059. maxDistance: number;
  36060. /**
  36061. * Define the distance attenuation model the sound will follow.
  36062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36063. */
  36064. distanceModel: string;
  36065. /**
  36066. * @hidden
  36067. * Back Compat
  36068. **/
  36069. onended: () => any;
  36070. /**
  36071. * Observable event when the current playing sound finishes.
  36072. */
  36073. onEndedObservable: Observable<Sound>;
  36074. private _panningModel;
  36075. private _playbackRate;
  36076. private _streaming;
  36077. private _startTime;
  36078. private _startOffset;
  36079. private _position;
  36080. /** @hidden */
  36081. _positionInEmitterSpace: boolean;
  36082. private _localDirection;
  36083. private _volume;
  36084. private _isReadyToPlay;
  36085. private _isDirectional;
  36086. private _readyToPlayCallback;
  36087. private _audioBuffer;
  36088. private _soundSource;
  36089. private _streamingSource;
  36090. private _soundPanner;
  36091. private _soundGain;
  36092. private _inputAudioNode;
  36093. private _outputAudioNode;
  36094. private _coneInnerAngle;
  36095. private _coneOuterAngle;
  36096. private _coneOuterGain;
  36097. private _scene;
  36098. private _connectedTransformNode;
  36099. private _customAttenuationFunction;
  36100. private _registerFunc;
  36101. private _isOutputConnected;
  36102. private _htmlAudioElement;
  36103. private _urlType;
  36104. private _length?;
  36105. private _offset?;
  36106. /** @hidden */
  36107. static _SceneComponentInitialization: (scene: Scene) => void;
  36108. /**
  36109. * Create a sound and attach it to a scene
  36110. * @param name Name of your sound
  36111. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36112. * @param scene defines the scene the sound belongs to
  36113. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36114. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36115. */
  36116. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36117. /**
  36118. * Release the sound and its associated resources
  36119. */
  36120. dispose(): void;
  36121. /**
  36122. * Gets if the sounds is ready to be played or not.
  36123. * @returns true if ready, otherwise false
  36124. */
  36125. isReady(): boolean;
  36126. private _soundLoaded;
  36127. /**
  36128. * Sets the data of the sound from an audiobuffer
  36129. * @param audioBuffer The audioBuffer containing the data
  36130. */
  36131. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36132. /**
  36133. * Updates the current sounds options such as maxdistance, loop...
  36134. * @param options A JSON object containing values named as the object properties
  36135. */
  36136. updateOptions(options: ISoundOptions): void;
  36137. private _createSpatialParameters;
  36138. private _updateSpatialParameters;
  36139. /**
  36140. * Switch the panning model to HRTF:
  36141. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36143. */
  36144. switchPanningModelToHRTF(): void;
  36145. /**
  36146. * Switch the panning model to Equal Power:
  36147. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36149. */
  36150. switchPanningModelToEqualPower(): void;
  36151. private _switchPanningModel;
  36152. /**
  36153. * Connect this sound to a sound track audio node like gain...
  36154. * @param soundTrackAudioNode the sound track audio node to connect to
  36155. */
  36156. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36157. /**
  36158. * Transform this sound into a directional source
  36159. * @param coneInnerAngle Size of the inner cone in degree
  36160. * @param coneOuterAngle Size of the outer cone in degree
  36161. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36162. */
  36163. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36164. /**
  36165. * Gets or sets the inner angle for the directional cone.
  36166. */
  36167. /**
  36168. * Gets or sets the inner angle for the directional cone.
  36169. */
  36170. directionalConeInnerAngle: number;
  36171. /**
  36172. * Gets or sets the outer angle for the directional cone.
  36173. */
  36174. /**
  36175. * Gets or sets the outer angle for the directional cone.
  36176. */
  36177. directionalConeOuterAngle: number;
  36178. /**
  36179. * Sets the position of the emitter if spatial sound is enabled
  36180. * @param newPosition Defines the new posisiton
  36181. */
  36182. setPosition(newPosition: Vector3): void;
  36183. /**
  36184. * Sets the local direction of the emitter if spatial sound is enabled
  36185. * @param newLocalDirection Defines the new local direction
  36186. */
  36187. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36188. private _updateDirection;
  36189. /** @hidden */
  36190. updateDistanceFromListener(): void;
  36191. /**
  36192. * Sets a new custom attenuation function for the sound.
  36193. * @param callback Defines the function used for the attenuation
  36194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36195. */
  36196. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36197. /**
  36198. * Play the sound
  36199. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36200. * @param offset (optional) Start the sound at a specific time in seconds
  36201. * @param length (optional) Sound duration (in seconds)
  36202. */
  36203. play(time?: number, offset?: number, length?: number): void;
  36204. private _onended;
  36205. /**
  36206. * Stop the sound
  36207. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36208. */
  36209. stop(time?: number): void;
  36210. /**
  36211. * Put the sound in pause
  36212. */
  36213. pause(): void;
  36214. /**
  36215. * Sets a dedicated volume for this sounds
  36216. * @param newVolume Define the new volume of the sound
  36217. * @param time Define time for gradual change to new volume
  36218. */
  36219. setVolume(newVolume: number, time?: number): void;
  36220. /**
  36221. * Set the sound play back rate
  36222. * @param newPlaybackRate Define the playback rate the sound should be played at
  36223. */
  36224. setPlaybackRate(newPlaybackRate: number): void;
  36225. /**
  36226. * Gets the volume of the sound.
  36227. * @returns the volume of the sound
  36228. */
  36229. getVolume(): number;
  36230. /**
  36231. * Attach the sound to a dedicated mesh
  36232. * @param transformNode The transform node to connect the sound with
  36233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36234. */
  36235. attachToMesh(transformNode: TransformNode): void;
  36236. /**
  36237. * Detach the sound from the previously attached mesh
  36238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36239. */
  36240. detachFromMesh(): void;
  36241. private _onRegisterAfterWorldMatrixUpdate;
  36242. /**
  36243. * Clone the current sound in the scene.
  36244. * @returns the new sound clone
  36245. */
  36246. clone(): Nullable<Sound>;
  36247. /**
  36248. * Gets the current underlying audio buffer containing the data
  36249. * @returns the audio buffer
  36250. */
  36251. getAudioBuffer(): Nullable<AudioBuffer>;
  36252. /**
  36253. * Serializes the Sound in a JSON representation
  36254. * @returns the JSON representation of the sound
  36255. */
  36256. serialize(): any;
  36257. /**
  36258. * Parse a JSON representation of a sound to innstantiate in a given scene
  36259. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36260. * @param scene Define the scene the new parsed sound should be created in
  36261. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36262. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36263. * @returns the newly parsed sound
  36264. */
  36265. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36266. }
  36267. }
  36268. declare module "babylonjs/Actions/directAudioActions" {
  36269. import { Action } from "babylonjs/Actions/action";
  36270. import { Condition } from "babylonjs/Actions/condition";
  36271. import { Sound } from "babylonjs/Audio/sound";
  36272. /**
  36273. * This defines an action helpful to play a defined sound on a triggered action.
  36274. */
  36275. export class PlaySoundAction extends Action {
  36276. private _sound;
  36277. /**
  36278. * Instantiate the action
  36279. * @param triggerOptions defines the trigger options
  36280. * @param sound defines the sound to play
  36281. * @param condition defines the trigger related conditions
  36282. */
  36283. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36284. /** @hidden */
  36285. _prepare(): void;
  36286. /**
  36287. * Execute the action and play the sound.
  36288. */
  36289. execute(): void;
  36290. /**
  36291. * Serializes the actions and its related information.
  36292. * @param parent defines the object to serialize in
  36293. * @returns the serialized object
  36294. */
  36295. serialize(parent: any): any;
  36296. }
  36297. /**
  36298. * This defines an action helpful to stop a defined sound on a triggered action.
  36299. */
  36300. export class StopSoundAction extends Action {
  36301. private _sound;
  36302. /**
  36303. * Instantiate the action
  36304. * @param triggerOptions defines the trigger options
  36305. * @param sound defines the sound to stop
  36306. * @param condition defines the trigger related conditions
  36307. */
  36308. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36309. /** @hidden */
  36310. _prepare(): void;
  36311. /**
  36312. * Execute the action and stop the sound.
  36313. */
  36314. execute(): void;
  36315. /**
  36316. * Serializes the actions and its related information.
  36317. * @param parent defines the object to serialize in
  36318. * @returns the serialized object
  36319. */
  36320. serialize(parent: any): any;
  36321. }
  36322. }
  36323. declare module "babylonjs/Actions/interpolateValueAction" {
  36324. import { Action } from "babylonjs/Actions/action";
  36325. import { Condition } from "babylonjs/Actions/condition";
  36326. import { Observable } from "babylonjs/Misc/observable";
  36327. /**
  36328. * This defines an action responsible to change the value of a property
  36329. * by interpolating between its current value and the newly set one once triggered.
  36330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36331. */
  36332. export class InterpolateValueAction extends Action {
  36333. /**
  36334. * Defines the path of the property where the value should be interpolated
  36335. */
  36336. propertyPath: string;
  36337. /**
  36338. * Defines the target value at the end of the interpolation.
  36339. */
  36340. value: any;
  36341. /**
  36342. * Defines the time it will take for the property to interpolate to the value.
  36343. */
  36344. duration: number;
  36345. /**
  36346. * Defines if the other scene animations should be stopped when the action has been triggered
  36347. */
  36348. stopOtherAnimations?: boolean;
  36349. /**
  36350. * Defines a callback raised once the interpolation animation has been done.
  36351. */
  36352. onInterpolationDone?: () => void;
  36353. /**
  36354. * Observable triggered once the interpolation animation has been done.
  36355. */
  36356. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36357. private _target;
  36358. private _effectiveTarget;
  36359. private _property;
  36360. /**
  36361. * Instantiate the action
  36362. * @param triggerOptions defines the trigger options
  36363. * @param target defines the object containing the value to interpolate
  36364. * @param propertyPath defines the path to the property in the target object
  36365. * @param value defines the target value at the end of the interpolation
  36366. * @param duration deines the time it will take for the property to interpolate to the value.
  36367. * @param condition defines the trigger related conditions
  36368. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36369. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36370. */
  36371. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36372. /** @hidden */
  36373. _prepare(): void;
  36374. /**
  36375. * Execute the action starts the value interpolation.
  36376. */
  36377. execute(): void;
  36378. /**
  36379. * Serializes the actions and its related information.
  36380. * @param parent defines the object to serialize in
  36381. * @returns the serialized object
  36382. */
  36383. serialize(parent: any): any;
  36384. }
  36385. }
  36386. declare module "babylonjs/Actions/index" {
  36387. export * from "babylonjs/Actions/abstractActionManager";
  36388. export * from "babylonjs/Actions/action";
  36389. export * from "babylonjs/Actions/actionEvent";
  36390. export * from "babylonjs/Actions/actionManager";
  36391. export * from "babylonjs/Actions/condition";
  36392. export * from "babylonjs/Actions/directActions";
  36393. export * from "babylonjs/Actions/directAudioActions";
  36394. export * from "babylonjs/Actions/interpolateValueAction";
  36395. }
  36396. declare module "babylonjs/Animations/index" {
  36397. export * from "babylonjs/Animations/animatable";
  36398. export * from "babylonjs/Animations/animation";
  36399. export * from "babylonjs/Animations/animationGroup";
  36400. export * from "babylonjs/Animations/animationPropertiesOverride";
  36401. export * from "babylonjs/Animations/easing";
  36402. export * from "babylonjs/Animations/runtimeAnimation";
  36403. export * from "babylonjs/Animations/animationEvent";
  36404. export * from "babylonjs/Animations/animationGroup";
  36405. export * from "babylonjs/Animations/animationKey";
  36406. export * from "babylonjs/Animations/animationRange";
  36407. export * from "babylonjs/Animations/animatable.interface";
  36408. }
  36409. declare module "babylonjs/Audio/soundTrack" {
  36410. import { Sound } from "babylonjs/Audio/sound";
  36411. import { Analyser } from "babylonjs/Audio/analyser";
  36412. import { Scene } from "babylonjs/scene";
  36413. /**
  36414. * Options allowed during the creation of a sound track.
  36415. */
  36416. export interface ISoundTrackOptions {
  36417. /**
  36418. * The volume the sound track should take during creation
  36419. */
  36420. volume?: number;
  36421. /**
  36422. * Define if the sound track is the main sound track of the scene
  36423. */
  36424. mainTrack?: boolean;
  36425. }
  36426. /**
  36427. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36428. * It will be also used in a future release to apply effects on a specific track.
  36429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36430. */
  36431. export class SoundTrack {
  36432. /**
  36433. * The unique identifier of the sound track in the scene.
  36434. */
  36435. id: number;
  36436. /**
  36437. * The list of sounds included in the sound track.
  36438. */
  36439. soundCollection: Array<Sound>;
  36440. private _outputAudioNode;
  36441. private _scene;
  36442. private _isMainTrack;
  36443. private _connectedAnalyser;
  36444. private _options;
  36445. private _isInitialized;
  36446. /**
  36447. * Creates a new sound track.
  36448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36449. * @param scene Define the scene the sound track belongs to
  36450. * @param options
  36451. */
  36452. constructor(scene: Scene, options?: ISoundTrackOptions);
  36453. private _initializeSoundTrackAudioGraph;
  36454. /**
  36455. * Release the sound track and its associated resources
  36456. */
  36457. dispose(): void;
  36458. /**
  36459. * Adds a sound to this sound track
  36460. * @param sound define the cound to add
  36461. * @ignoreNaming
  36462. */
  36463. AddSound(sound: Sound): void;
  36464. /**
  36465. * Removes a sound to this sound track
  36466. * @param sound define the cound to remove
  36467. * @ignoreNaming
  36468. */
  36469. RemoveSound(sound: Sound): void;
  36470. /**
  36471. * Set a global volume for the full sound track.
  36472. * @param newVolume Define the new volume of the sound track
  36473. */
  36474. setVolume(newVolume: number): void;
  36475. /**
  36476. * Switch the panning model to HRTF:
  36477. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36479. */
  36480. switchPanningModelToHRTF(): void;
  36481. /**
  36482. * Switch the panning model to Equal Power:
  36483. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36485. */
  36486. switchPanningModelToEqualPower(): void;
  36487. /**
  36488. * Connect the sound track to an audio analyser allowing some amazing
  36489. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36491. * @param analyser The analyser to connect to the engine
  36492. */
  36493. connectToAnalyser(analyser: Analyser): void;
  36494. }
  36495. }
  36496. declare module "babylonjs/Audio/audioSceneComponent" {
  36497. import { Sound } from "babylonjs/Audio/sound";
  36498. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36499. import { Nullable } from "babylonjs/types";
  36500. import { Vector3 } from "babylonjs/Maths/math.vector";
  36501. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36502. import { Scene } from "babylonjs/scene";
  36503. import { AbstractScene } from "babylonjs/abstractScene";
  36504. import "babylonjs/Audio/audioEngine";
  36505. module "babylonjs/abstractScene" {
  36506. interface AbstractScene {
  36507. /**
  36508. * The list of sounds used in the scene.
  36509. */
  36510. sounds: Nullable<Array<Sound>>;
  36511. }
  36512. }
  36513. module "babylonjs/scene" {
  36514. interface Scene {
  36515. /**
  36516. * @hidden
  36517. * Backing field
  36518. */
  36519. _mainSoundTrack: SoundTrack;
  36520. /**
  36521. * The main sound track played by the scene.
  36522. * It cotains your primary collection of sounds.
  36523. */
  36524. mainSoundTrack: SoundTrack;
  36525. /**
  36526. * The list of sound tracks added to the scene
  36527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36528. */
  36529. soundTracks: Nullable<Array<SoundTrack>>;
  36530. /**
  36531. * Gets a sound using a given name
  36532. * @param name defines the name to search for
  36533. * @return the found sound or null if not found at all.
  36534. */
  36535. getSoundByName(name: string): Nullable<Sound>;
  36536. /**
  36537. * Gets or sets if audio support is enabled
  36538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36539. */
  36540. audioEnabled: boolean;
  36541. /**
  36542. * Gets or sets if audio will be output to headphones
  36543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36544. */
  36545. headphone: boolean;
  36546. /**
  36547. * Gets or sets custom audio listener position provider
  36548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36549. */
  36550. audioListenerPositionProvider: Nullable<() => Vector3>;
  36551. }
  36552. }
  36553. /**
  36554. * Defines the sound scene component responsible to manage any sounds
  36555. * in a given scene.
  36556. */
  36557. export class AudioSceneComponent implements ISceneSerializableComponent {
  36558. /**
  36559. * The component name helpfull to identify the component in the list of scene components.
  36560. */
  36561. readonly name: string;
  36562. /**
  36563. * The scene the component belongs to.
  36564. */
  36565. scene: Scene;
  36566. private _audioEnabled;
  36567. /**
  36568. * Gets whether audio is enabled or not.
  36569. * Please use related enable/disable method to switch state.
  36570. */
  36571. readonly audioEnabled: boolean;
  36572. private _headphone;
  36573. /**
  36574. * Gets whether audio is outputing to headphone or not.
  36575. * Please use the according Switch methods to change output.
  36576. */
  36577. readonly headphone: boolean;
  36578. private _audioListenerPositionProvider;
  36579. /**
  36580. * Gets the current audio listener position provider
  36581. */
  36582. /**
  36583. * Sets a custom listener position for all sounds in the scene
  36584. * By default, this is the position of the first active camera
  36585. */
  36586. audioListenerPositionProvider: Nullable<() => Vector3>;
  36587. /**
  36588. * Creates a new instance of the component for the given scene
  36589. * @param scene Defines the scene to register the component in
  36590. */
  36591. constructor(scene: Scene);
  36592. /**
  36593. * Registers the component in a given scene
  36594. */
  36595. register(): void;
  36596. /**
  36597. * Rebuilds the elements related to this component in case of
  36598. * context lost for instance.
  36599. */
  36600. rebuild(): void;
  36601. /**
  36602. * Serializes the component data to the specified json object
  36603. * @param serializationObject The object to serialize to
  36604. */
  36605. serialize(serializationObject: any): void;
  36606. /**
  36607. * Adds all the elements from the container to the scene
  36608. * @param container the container holding the elements
  36609. */
  36610. addFromContainer(container: AbstractScene): void;
  36611. /**
  36612. * Removes all the elements in the container from the scene
  36613. * @param container contains the elements to remove
  36614. * @param dispose if the removed element should be disposed (default: false)
  36615. */
  36616. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36617. /**
  36618. * Disposes the component and the associated ressources.
  36619. */
  36620. dispose(): void;
  36621. /**
  36622. * Disables audio in the associated scene.
  36623. */
  36624. disableAudio(): void;
  36625. /**
  36626. * Enables audio in the associated scene.
  36627. */
  36628. enableAudio(): void;
  36629. /**
  36630. * Switch audio to headphone output.
  36631. */
  36632. switchAudioModeForHeadphones(): void;
  36633. /**
  36634. * Switch audio to normal speakers.
  36635. */
  36636. switchAudioModeForNormalSpeakers(): void;
  36637. private _afterRender;
  36638. }
  36639. }
  36640. declare module "babylonjs/Audio/weightedsound" {
  36641. import { Sound } from "babylonjs/Audio/sound";
  36642. /**
  36643. * Wraps one or more Sound objects and selects one with random weight for playback.
  36644. */
  36645. export class WeightedSound {
  36646. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36647. loop: boolean;
  36648. private _coneInnerAngle;
  36649. private _coneOuterAngle;
  36650. private _volume;
  36651. /** A Sound is currently playing. */
  36652. isPlaying: boolean;
  36653. /** A Sound is currently paused. */
  36654. isPaused: boolean;
  36655. private _sounds;
  36656. private _weights;
  36657. private _currentIndex?;
  36658. /**
  36659. * Creates a new WeightedSound from the list of sounds given.
  36660. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36661. * @param sounds Array of Sounds that will be selected from.
  36662. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36663. */
  36664. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36665. /**
  36666. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36667. */
  36668. /**
  36669. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36670. */
  36671. directionalConeInnerAngle: number;
  36672. /**
  36673. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36674. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36675. */
  36676. /**
  36677. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36678. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36679. */
  36680. directionalConeOuterAngle: number;
  36681. /**
  36682. * Playback volume.
  36683. */
  36684. /**
  36685. * Playback volume.
  36686. */
  36687. volume: number;
  36688. private _onended;
  36689. /**
  36690. * Suspend playback
  36691. */
  36692. pause(): void;
  36693. /**
  36694. * Stop playback
  36695. */
  36696. stop(): void;
  36697. /**
  36698. * Start playback.
  36699. * @param startOffset Position the clip head at a specific time in seconds.
  36700. */
  36701. play(startOffset?: number): void;
  36702. }
  36703. }
  36704. declare module "babylonjs/Audio/index" {
  36705. export * from "babylonjs/Audio/analyser";
  36706. export * from "babylonjs/Audio/audioEngine";
  36707. export * from "babylonjs/Audio/audioSceneComponent";
  36708. export * from "babylonjs/Audio/sound";
  36709. export * from "babylonjs/Audio/soundTrack";
  36710. export * from "babylonjs/Audio/weightedsound";
  36711. }
  36712. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36713. import { Behavior } from "babylonjs/Behaviors/behavior";
  36714. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36715. import { BackEase } from "babylonjs/Animations/easing";
  36716. /**
  36717. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36718. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36719. */
  36720. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36721. /**
  36722. * Gets the name of the behavior.
  36723. */
  36724. readonly name: string;
  36725. /**
  36726. * The easing function used by animations
  36727. */
  36728. static EasingFunction: BackEase;
  36729. /**
  36730. * The easing mode used by animations
  36731. */
  36732. static EasingMode: number;
  36733. /**
  36734. * The duration of the animation, in milliseconds
  36735. */
  36736. transitionDuration: number;
  36737. /**
  36738. * Length of the distance animated by the transition when lower radius is reached
  36739. */
  36740. lowerRadiusTransitionRange: number;
  36741. /**
  36742. * Length of the distance animated by the transition when upper radius is reached
  36743. */
  36744. upperRadiusTransitionRange: number;
  36745. private _autoTransitionRange;
  36746. /**
  36747. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36748. */
  36749. /**
  36750. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36751. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36752. */
  36753. autoTransitionRange: boolean;
  36754. private _attachedCamera;
  36755. private _onAfterCheckInputsObserver;
  36756. private _onMeshTargetChangedObserver;
  36757. /**
  36758. * Initializes the behavior.
  36759. */
  36760. init(): void;
  36761. /**
  36762. * Attaches the behavior to its arc rotate camera.
  36763. * @param camera Defines the camera to attach the behavior to
  36764. */
  36765. attach(camera: ArcRotateCamera): void;
  36766. /**
  36767. * Detaches the behavior from its current arc rotate camera.
  36768. */
  36769. detach(): void;
  36770. private _radiusIsAnimating;
  36771. private _radiusBounceTransition;
  36772. private _animatables;
  36773. private _cachedWheelPrecision;
  36774. /**
  36775. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36776. * @param radiusLimit The limit to check against.
  36777. * @return Bool to indicate if at limit.
  36778. */
  36779. private _isRadiusAtLimit;
  36780. /**
  36781. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36782. * @param radiusDelta The delta by which to animate to. Can be negative.
  36783. */
  36784. private _applyBoundRadiusAnimation;
  36785. /**
  36786. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36787. */
  36788. protected _clearAnimationLocks(): void;
  36789. /**
  36790. * Stops and removes all animations that have been applied to the camera
  36791. */
  36792. stopAllAnimations(): void;
  36793. }
  36794. }
  36795. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36796. import { Behavior } from "babylonjs/Behaviors/behavior";
  36797. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36798. import { ExponentialEase } from "babylonjs/Animations/easing";
  36799. import { Nullable } from "babylonjs/types";
  36800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36801. import { Vector3 } from "babylonjs/Maths/math.vector";
  36802. /**
  36803. * 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.
  36804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36805. */
  36806. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36807. /**
  36808. * Gets the name of the behavior.
  36809. */
  36810. readonly name: string;
  36811. private _mode;
  36812. private _radiusScale;
  36813. private _positionScale;
  36814. private _defaultElevation;
  36815. private _elevationReturnTime;
  36816. private _elevationReturnWaitTime;
  36817. private _zoomStopsAnimation;
  36818. private _framingTime;
  36819. /**
  36820. * The easing function used by animations
  36821. */
  36822. static EasingFunction: ExponentialEase;
  36823. /**
  36824. * The easing mode used by animations
  36825. */
  36826. static EasingMode: number;
  36827. /**
  36828. * Sets the current mode used by the behavior
  36829. */
  36830. /**
  36831. * Gets current mode used by the behavior.
  36832. */
  36833. mode: number;
  36834. /**
  36835. * Sets the scale applied to the radius (1 by default)
  36836. */
  36837. /**
  36838. * Gets the scale applied to the radius
  36839. */
  36840. radiusScale: number;
  36841. /**
  36842. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36843. */
  36844. /**
  36845. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36846. */
  36847. positionScale: number;
  36848. /**
  36849. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36850. * behaviour is triggered, in radians.
  36851. */
  36852. /**
  36853. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36854. * behaviour is triggered, in radians.
  36855. */
  36856. defaultElevation: number;
  36857. /**
  36858. * Sets the time (in milliseconds) taken to return to the default beta position.
  36859. * Negative value indicates camera should not return to default.
  36860. */
  36861. /**
  36862. * Gets the time (in milliseconds) taken to return to the default beta position.
  36863. * Negative value indicates camera should not return to default.
  36864. */
  36865. elevationReturnTime: number;
  36866. /**
  36867. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36868. */
  36869. /**
  36870. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36871. */
  36872. elevationReturnWaitTime: number;
  36873. /**
  36874. * Sets the flag that indicates if user zooming should stop animation.
  36875. */
  36876. /**
  36877. * Gets the flag that indicates if user zooming should stop animation.
  36878. */
  36879. zoomStopsAnimation: boolean;
  36880. /**
  36881. * Sets the transition time when framing the mesh, in milliseconds
  36882. */
  36883. /**
  36884. * Gets the transition time when framing the mesh, in milliseconds
  36885. */
  36886. framingTime: number;
  36887. /**
  36888. * Define if the behavior should automatically change the configured
  36889. * camera limits and sensibilities.
  36890. */
  36891. autoCorrectCameraLimitsAndSensibility: boolean;
  36892. private _onPrePointerObservableObserver;
  36893. private _onAfterCheckInputsObserver;
  36894. private _onMeshTargetChangedObserver;
  36895. private _attachedCamera;
  36896. private _isPointerDown;
  36897. private _lastInteractionTime;
  36898. /**
  36899. * Initializes the behavior.
  36900. */
  36901. init(): void;
  36902. /**
  36903. * Attaches the behavior to its arc rotate camera.
  36904. * @param camera Defines the camera to attach the behavior to
  36905. */
  36906. attach(camera: ArcRotateCamera): void;
  36907. /**
  36908. * Detaches the behavior from its current arc rotate camera.
  36909. */
  36910. detach(): void;
  36911. private _animatables;
  36912. private _betaIsAnimating;
  36913. private _betaTransition;
  36914. private _radiusTransition;
  36915. private _vectorTransition;
  36916. /**
  36917. * Targets the given mesh and updates zoom level accordingly.
  36918. * @param mesh The mesh to target.
  36919. * @param radius Optional. If a cached radius position already exists, overrides default.
  36920. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36921. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36922. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36923. */
  36924. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36925. /**
  36926. * Targets the given mesh with its children and updates zoom level accordingly.
  36927. * @param mesh The mesh to target.
  36928. * @param radius Optional. If a cached radius position already exists, overrides default.
  36929. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36930. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36931. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36932. */
  36933. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36934. /**
  36935. * Targets the given meshes with their children and updates zoom level accordingly.
  36936. * @param meshes The mesh to target.
  36937. * @param radius Optional. If a cached radius position already exists, overrides default.
  36938. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36939. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36940. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36941. */
  36942. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36943. /**
  36944. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36945. * @param minimumWorld Determines the smaller position of the bounding box extend
  36946. * @param maximumWorld Determines the bigger position of the bounding box extend
  36947. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36948. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36949. */
  36950. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36951. /**
  36952. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36953. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36954. * frustum width.
  36955. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36956. * to fully enclose the mesh in the viewing frustum.
  36957. */
  36958. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36959. /**
  36960. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36961. * is automatically returned to its default position (expected to be above ground plane).
  36962. */
  36963. private _maintainCameraAboveGround;
  36964. /**
  36965. * Returns the frustum slope based on the canvas ratio and camera FOV
  36966. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36967. */
  36968. private _getFrustumSlope;
  36969. /**
  36970. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36971. */
  36972. private _clearAnimationLocks;
  36973. /**
  36974. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36975. */
  36976. private _applyUserInteraction;
  36977. /**
  36978. * Stops and removes all animations that have been applied to the camera
  36979. */
  36980. stopAllAnimations(): void;
  36981. /**
  36982. * Gets a value indicating if the user is moving the camera
  36983. */
  36984. readonly isUserIsMoving: boolean;
  36985. /**
  36986. * The camera can move all the way towards the mesh.
  36987. */
  36988. static IgnoreBoundsSizeMode: number;
  36989. /**
  36990. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36991. */
  36992. static FitFrustumSidesMode: number;
  36993. }
  36994. }
  36995. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36996. import { Nullable } from "babylonjs/types";
  36997. import { Camera } from "babylonjs/Cameras/camera";
  36998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36999. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37000. /**
  37001. * Base class for Camera Pointer Inputs.
  37002. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37003. * for example usage.
  37004. */
  37005. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37006. /**
  37007. * Defines the camera the input is attached to.
  37008. */
  37009. abstract camera: Camera;
  37010. /**
  37011. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37012. */
  37013. protected _altKey: boolean;
  37014. protected _ctrlKey: boolean;
  37015. protected _metaKey: boolean;
  37016. protected _shiftKey: boolean;
  37017. /**
  37018. * Which mouse buttons were pressed at time of last mouse event.
  37019. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37020. */
  37021. protected _buttonsPressed: number;
  37022. /**
  37023. * Defines the buttons associated with the input to handle camera move.
  37024. */
  37025. buttons: number[];
  37026. /**
  37027. * Attach the input controls to a specific dom element to get the input from.
  37028. * @param element Defines the element the controls should be listened from
  37029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37030. */
  37031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37032. /**
  37033. * Detach the current controls from the specified dom element.
  37034. * @param element Defines the element to stop listening the inputs from
  37035. */
  37036. detachControl(element: Nullable<HTMLElement>): void;
  37037. /**
  37038. * Gets the class name of the current input.
  37039. * @returns the class name
  37040. */
  37041. getClassName(): string;
  37042. /**
  37043. * Get the friendly name associated with the input class.
  37044. * @returns the input friendly name
  37045. */
  37046. getSimpleName(): string;
  37047. /**
  37048. * Called on pointer POINTERDOUBLETAP event.
  37049. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37050. */
  37051. protected onDoubleTap(type: string): void;
  37052. /**
  37053. * Called on pointer POINTERMOVE event if only a single touch is active.
  37054. * Override this method to provide functionality.
  37055. */
  37056. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37057. /**
  37058. * Called on pointer POINTERMOVE event if multiple touches are active.
  37059. * Override this method to provide functionality.
  37060. */
  37061. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37062. /**
  37063. * Called on JS contextmenu event.
  37064. * Override this method to provide functionality.
  37065. */
  37066. protected onContextMenu(evt: PointerEvent): void;
  37067. /**
  37068. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37069. * press.
  37070. * Override this method to provide functionality.
  37071. */
  37072. protected onButtonDown(evt: PointerEvent): void;
  37073. /**
  37074. * Called each time a new POINTERUP event occurs. Ie, for each button
  37075. * release.
  37076. * Override this method to provide functionality.
  37077. */
  37078. protected onButtonUp(evt: PointerEvent): void;
  37079. /**
  37080. * Called when window becomes inactive.
  37081. * Override this method to provide functionality.
  37082. */
  37083. protected onLostFocus(): void;
  37084. private _pointerInput;
  37085. private _observer;
  37086. private _onLostFocus;
  37087. private pointA;
  37088. private pointB;
  37089. }
  37090. }
  37091. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37092. import { Nullable } from "babylonjs/types";
  37093. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37094. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37095. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37096. /**
  37097. * Manage the pointers inputs to control an arc rotate camera.
  37098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37099. */
  37100. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37101. /**
  37102. * Defines the camera the input is attached to.
  37103. */
  37104. camera: ArcRotateCamera;
  37105. /**
  37106. * Gets the class name of the current input.
  37107. * @returns the class name
  37108. */
  37109. getClassName(): string;
  37110. /**
  37111. * Defines the buttons associated with the input to handle camera move.
  37112. */
  37113. buttons: number[];
  37114. /**
  37115. * Defines the pointer angular sensibility along the X axis or how fast is
  37116. * the camera rotating.
  37117. */
  37118. angularSensibilityX: number;
  37119. /**
  37120. * Defines the pointer angular sensibility along the Y axis or how fast is
  37121. * the camera rotating.
  37122. */
  37123. angularSensibilityY: number;
  37124. /**
  37125. * Defines the pointer pinch precision or how fast is the camera zooming.
  37126. */
  37127. pinchPrecision: number;
  37128. /**
  37129. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37130. * from 0.
  37131. * It defines the percentage of current camera.radius to use as delta when
  37132. * pinch zoom is used.
  37133. */
  37134. pinchDeltaPercentage: number;
  37135. /**
  37136. * Defines the pointer panning sensibility or how fast is the camera moving.
  37137. */
  37138. panningSensibility: number;
  37139. /**
  37140. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37141. */
  37142. multiTouchPanning: boolean;
  37143. /**
  37144. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37145. * zoom (pinch) through multitouch.
  37146. */
  37147. multiTouchPanAndZoom: boolean;
  37148. /**
  37149. * Revers pinch action direction.
  37150. */
  37151. pinchInwards: boolean;
  37152. private _isPanClick;
  37153. private _twoFingerActivityCount;
  37154. private _isPinching;
  37155. /**
  37156. * Called on pointer POINTERMOVE event if only a single touch is active.
  37157. */
  37158. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37159. /**
  37160. * Called on pointer POINTERDOUBLETAP event.
  37161. */
  37162. protected onDoubleTap(type: string): void;
  37163. /**
  37164. * Called on pointer POINTERMOVE event if multiple touches are active.
  37165. */
  37166. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37167. /**
  37168. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37169. * press.
  37170. */
  37171. protected onButtonDown(evt: PointerEvent): void;
  37172. /**
  37173. * Called each time a new POINTERUP event occurs. Ie, for each button
  37174. * release.
  37175. */
  37176. protected onButtonUp(evt: PointerEvent): void;
  37177. /**
  37178. * Called when window becomes inactive.
  37179. */
  37180. protected onLostFocus(): void;
  37181. }
  37182. }
  37183. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37184. import { Nullable } from "babylonjs/types";
  37185. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37187. /**
  37188. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37190. */
  37191. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37192. /**
  37193. * Defines the camera the input is attached to.
  37194. */
  37195. camera: ArcRotateCamera;
  37196. /**
  37197. * Defines the list of key codes associated with the up action (increase alpha)
  37198. */
  37199. keysUp: number[];
  37200. /**
  37201. * Defines the list of key codes associated with the down action (decrease alpha)
  37202. */
  37203. keysDown: number[];
  37204. /**
  37205. * Defines the list of key codes associated with the left action (increase beta)
  37206. */
  37207. keysLeft: number[];
  37208. /**
  37209. * Defines the list of key codes associated with the right action (decrease beta)
  37210. */
  37211. keysRight: number[];
  37212. /**
  37213. * Defines the list of key codes associated with the reset action.
  37214. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37215. */
  37216. keysReset: number[];
  37217. /**
  37218. * Defines the panning sensibility of the inputs.
  37219. * (How fast is the camera paning)
  37220. */
  37221. panningSensibility: number;
  37222. /**
  37223. * Defines the zooming sensibility of the inputs.
  37224. * (How fast is the camera zooming)
  37225. */
  37226. zoomingSensibility: number;
  37227. /**
  37228. * Defines wether maintaining the alt key down switch the movement mode from
  37229. * orientation to zoom.
  37230. */
  37231. useAltToZoom: boolean;
  37232. /**
  37233. * Rotation speed of the camera
  37234. */
  37235. angularSpeed: number;
  37236. private _keys;
  37237. private _ctrlPressed;
  37238. private _altPressed;
  37239. private _onCanvasBlurObserver;
  37240. private _onKeyboardObserver;
  37241. private _engine;
  37242. private _scene;
  37243. /**
  37244. * Attach the input controls to a specific dom element to get the input from.
  37245. * @param element Defines the element the controls should be listened from
  37246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37247. */
  37248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37249. /**
  37250. * Detach the current controls from the specified dom element.
  37251. * @param element Defines the element to stop listening the inputs from
  37252. */
  37253. detachControl(element: Nullable<HTMLElement>): void;
  37254. /**
  37255. * Update the current camera state depending on the inputs that have been used this frame.
  37256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37257. */
  37258. checkInputs(): void;
  37259. /**
  37260. * Gets the class name of the current intput.
  37261. * @returns the class name
  37262. */
  37263. getClassName(): string;
  37264. /**
  37265. * Get the friendly name associated with the input class.
  37266. * @returns the input friendly name
  37267. */
  37268. getSimpleName(): string;
  37269. }
  37270. }
  37271. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37272. import { Nullable } from "babylonjs/types";
  37273. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37275. /**
  37276. * Manage the mouse wheel inputs to control an arc rotate camera.
  37277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37278. */
  37279. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37280. /**
  37281. * Defines the camera the input is attached to.
  37282. */
  37283. camera: ArcRotateCamera;
  37284. /**
  37285. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37286. */
  37287. wheelPrecision: number;
  37288. /**
  37289. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37290. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37291. */
  37292. wheelDeltaPercentage: number;
  37293. private _wheel;
  37294. private _observer;
  37295. private computeDeltaFromMouseWheelLegacyEvent;
  37296. /**
  37297. * Attach the input controls to a specific dom element to get the input from.
  37298. * @param element Defines the element the controls should be listened from
  37299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37300. */
  37301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37302. /**
  37303. * Detach the current controls from the specified dom element.
  37304. * @param element Defines the element to stop listening the inputs from
  37305. */
  37306. detachControl(element: Nullable<HTMLElement>): void;
  37307. /**
  37308. * Gets the class name of the current intput.
  37309. * @returns the class name
  37310. */
  37311. getClassName(): string;
  37312. /**
  37313. * Get the friendly name associated with the input class.
  37314. * @returns the input friendly name
  37315. */
  37316. getSimpleName(): string;
  37317. }
  37318. }
  37319. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37320. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37321. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37322. /**
  37323. * Default Inputs manager for the ArcRotateCamera.
  37324. * It groups all the default supported inputs for ease of use.
  37325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37326. */
  37327. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37328. /**
  37329. * Instantiates a new ArcRotateCameraInputsManager.
  37330. * @param camera Defines the camera the inputs belong to
  37331. */
  37332. constructor(camera: ArcRotateCamera);
  37333. /**
  37334. * Add mouse wheel input support to the input manager.
  37335. * @returns the current input manager
  37336. */
  37337. addMouseWheel(): ArcRotateCameraInputsManager;
  37338. /**
  37339. * Add pointers input support to the input manager.
  37340. * @returns the current input manager
  37341. */
  37342. addPointers(): ArcRotateCameraInputsManager;
  37343. /**
  37344. * Add keyboard input support to the input manager.
  37345. * @returns the current input manager
  37346. */
  37347. addKeyboard(): ArcRotateCameraInputsManager;
  37348. }
  37349. }
  37350. declare module "babylonjs/Cameras/arcRotateCamera" {
  37351. import { Observable } from "babylonjs/Misc/observable";
  37352. import { Nullable } from "babylonjs/types";
  37353. import { Scene } from "babylonjs/scene";
  37354. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37356. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37357. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37358. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37359. import { Camera } from "babylonjs/Cameras/camera";
  37360. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37361. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37362. import { Collider } from "babylonjs/Collisions/collider";
  37363. /**
  37364. * This represents an orbital type of camera.
  37365. *
  37366. * 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.
  37367. * 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.
  37368. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37369. */
  37370. export class ArcRotateCamera extends TargetCamera {
  37371. /**
  37372. * Defines the rotation angle of the camera along the longitudinal axis.
  37373. */
  37374. alpha: number;
  37375. /**
  37376. * Defines the rotation angle of the camera along the latitudinal axis.
  37377. */
  37378. beta: number;
  37379. /**
  37380. * Defines the radius of the camera from it s target point.
  37381. */
  37382. radius: number;
  37383. protected _target: Vector3;
  37384. protected _targetHost: Nullable<AbstractMesh>;
  37385. /**
  37386. * Defines the target point of the camera.
  37387. * The camera looks towards it form the radius distance.
  37388. */
  37389. target: Vector3;
  37390. /**
  37391. * Define the current local position of the camera in the scene
  37392. */
  37393. position: Vector3;
  37394. protected _upVector: Vector3;
  37395. protected _upToYMatrix: Matrix;
  37396. protected _YToUpMatrix: Matrix;
  37397. /**
  37398. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37399. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37400. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37401. */
  37402. upVector: Vector3;
  37403. /**
  37404. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37405. */
  37406. setMatUp(): void;
  37407. /**
  37408. * Current inertia value on the longitudinal axis.
  37409. * The bigger this number the longer it will take for the camera to stop.
  37410. */
  37411. inertialAlphaOffset: number;
  37412. /**
  37413. * Current inertia value on the latitudinal axis.
  37414. * The bigger this number the longer it will take for the camera to stop.
  37415. */
  37416. inertialBetaOffset: number;
  37417. /**
  37418. * Current inertia value on the radius axis.
  37419. * The bigger this number the longer it will take for the camera to stop.
  37420. */
  37421. inertialRadiusOffset: number;
  37422. /**
  37423. * Minimum allowed angle on the longitudinal axis.
  37424. * This can help limiting how the Camera is able to move in the scene.
  37425. */
  37426. lowerAlphaLimit: Nullable<number>;
  37427. /**
  37428. * Maximum allowed angle on the longitudinal axis.
  37429. * This can help limiting how the Camera is able to move in the scene.
  37430. */
  37431. upperAlphaLimit: Nullable<number>;
  37432. /**
  37433. * Minimum allowed angle on the latitudinal axis.
  37434. * This can help limiting how the Camera is able to move in the scene.
  37435. */
  37436. lowerBetaLimit: number;
  37437. /**
  37438. * Maximum allowed angle on the latitudinal axis.
  37439. * This can help limiting how the Camera is able to move in the scene.
  37440. */
  37441. upperBetaLimit: number;
  37442. /**
  37443. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37444. * This can help limiting how the Camera is able to move in the scene.
  37445. */
  37446. lowerRadiusLimit: Nullable<number>;
  37447. /**
  37448. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37449. * This can help limiting how the Camera is able to move in the scene.
  37450. */
  37451. upperRadiusLimit: Nullable<number>;
  37452. /**
  37453. * Defines the current inertia value used during panning of the camera along the X axis.
  37454. */
  37455. inertialPanningX: number;
  37456. /**
  37457. * Defines the current inertia value used during panning of the camera along the Y axis.
  37458. */
  37459. inertialPanningY: number;
  37460. /**
  37461. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37462. * Basically if your fingers moves away from more than this distance you will be considered
  37463. * in pinch mode.
  37464. */
  37465. pinchToPanMaxDistance: number;
  37466. /**
  37467. * Defines the maximum distance the camera can pan.
  37468. * This could help keeping the cammera always in your scene.
  37469. */
  37470. panningDistanceLimit: Nullable<number>;
  37471. /**
  37472. * Defines the target of the camera before paning.
  37473. */
  37474. panningOriginTarget: Vector3;
  37475. /**
  37476. * Defines the value of the inertia used during panning.
  37477. * 0 would mean stop inertia and one would mean no decelleration at all.
  37478. */
  37479. panningInertia: number;
  37480. /**
  37481. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37482. */
  37483. angularSensibilityX: number;
  37484. /**
  37485. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37486. */
  37487. angularSensibilityY: number;
  37488. /**
  37489. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37490. */
  37491. pinchPrecision: number;
  37492. /**
  37493. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37494. * It will be used instead of pinchDeltaPrecision if different from 0.
  37495. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37496. */
  37497. pinchDeltaPercentage: number;
  37498. /**
  37499. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37500. */
  37501. panningSensibility: number;
  37502. /**
  37503. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37504. */
  37505. keysUp: number[];
  37506. /**
  37507. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37508. */
  37509. keysDown: number[];
  37510. /**
  37511. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37512. */
  37513. keysLeft: number[];
  37514. /**
  37515. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37516. */
  37517. keysRight: number[];
  37518. /**
  37519. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37520. */
  37521. wheelPrecision: number;
  37522. /**
  37523. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37524. * It will be used instead of pinchDeltaPrecision if different from 0.
  37525. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37526. */
  37527. wheelDeltaPercentage: number;
  37528. /**
  37529. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37530. */
  37531. zoomOnFactor: number;
  37532. /**
  37533. * Defines a screen offset for the camera position.
  37534. */
  37535. targetScreenOffset: Vector2;
  37536. /**
  37537. * Allows the camera to be completely reversed.
  37538. * If false the camera can not arrive upside down.
  37539. */
  37540. allowUpsideDown: boolean;
  37541. /**
  37542. * Define if double tap/click is used to restore the previously saved state of the camera.
  37543. */
  37544. useInputToRestoreState: boolean;
  37545. /** @hidden */
  37546. _viewMatrix: Matrix;
  37547. /** @hidden */
  37548. _useCtrlForPanning: boolean;
  37549. /** @hidden */
  37550. _panningMouseButton: number;
  37551. /**
  37552. * Defines the input associated to the camera.
  37553. */
  37554. inputs: ArcRotateCameraInputsManager;
  37555. /** @hidden */
  37556. _reset: () => void;
  37557. /**
  37558. * Defines the allowed panning axis.
  37559. */
  37560. panningAxis: Vector3;
  37561. protected _localDirection: Vector3;
  37562. protected _transformedDirection: Vector3;
  37563. private _bouncingBehavior;
  37564. /**
  37565. * Gets the bouncing behavior of the camera if it has been enabled.
  37566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37567. */
  37568. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37569. /**
  37570. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37572. */
  37573. useBouncingBehavior: boolean;
  37574. private _framingBehavior;
  37575. /**
  37576. * Gets the framing behavior of the camera if it has been enabled.
  37577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37578. */
  37579. readonly framingBehavior: Nullable<FramingBehavior>;
  37580. /**
  37581. * Defines if the framing behavior of the camera is enabled on the camera.
  37582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37583. */
  37584. useFramingBehavior: boolean;
  37585. private _autoRotationBehavior;
  37586. /**
  37587. * Gets the auto rotation behavior of the camera if it has been enabled.
  37588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37589. */
  37590. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37591. /**
  37592. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37594. */
  37595. useAutoRotationBehavior: boolean;
  37596. /**
  37597. * Observable triggered when the mesh target has been changed on the camera.
  37598. */
  37599. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37600. /**
  37601. * Event raised when the camera is colliding with a mesh.
  37602. */
  37603. onCollide: (collidedMesh: AbstractMesh) => void;
  37604. /**
  37605. * Defines whether the camera should check collision with the objects oh the scene.
  37606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37607. */
  37608. checkCollisions: boolean;
  37609. /**
  37610. * Defines the collision radius of the camera.
  37611. * This simulates a sphere around the camera.
  37612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37613. */
  37614. collisionRadius: Vector3;
  37615. protected _collider: Collider;
  37616. protected _previousPosition: Vector3;
  37617. protected _collisionVelocity: Vector3;
  37618. protected _newPosition: Vector3;
  37619. protected _previousAlpha: number;
  37620. protected _previousBeta: number;
  37621. protected _previousRadius: number;
  37622. protected _collisionTriggered: boolean;
  37623. protected _targetBoundingCenter: Nullable<Vector3>;
  37624. private _computationVector;
  37625. /**
  37626. * Instantiates a new ArcRotateCamera in a given scene
  37627. * @param name Defines the name of the camera
  37628. * @param alpha Defines the camera rotation along the logitudinal axis
  37629. * @param beta Defines the camera rotation along the latitudinal axis
  37630. * @param radius Defines the camera distance from its target
  37631. * @param target Defines the camera target
  37632. * @param scene Defines the scene the camera belongs to
  37633. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37634. */
  37635. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37636. /** @hidden */
  37637. _initCache(): void;
  37638. /** @hidden */
  37639. _updateCache(ignoreParentClass?: boolean): void;
  37640. protected _getTargetPosition(): Vector3;
  37641. private _storedAlpha;
  37642. private _storedBeta;
  37643. private _storedRadius;
  37644. private _storedTarget;
  37645. private _storedTargetScreenOffset;
  37646. /**
  37647. * Stores the current state of the camera (alpha, beta, radius and target)
  37648. * @returns the camera itself
  37649. */
  37650. storeState(): Camera;
  37651. /**
  37652. * @hidden
  37653. * Restored camera state. You must call storeState() first
  37654. */
  37655. _restoreStateValues(): boolean;
  37656. /** @hidden */
  37657. _isSynchronizedViewMatrix(): boolean;
  37658. /**
  37659. * Attached controls to the current camera.
  37660. * @param element Defines the element the controls should be listened from
  37661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37662. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37663. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37664. */
  37665. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37666. /**
  37667. * Detach the current controls from the camera.
  37668. * The camera will stop reacting to inputs.
  37669. * @param element Defines the element to stop listening the inputs from
  37670. */
  37671. detachControl(element: HTMLElement): void;
  37672. /** @hidden */
  37673. _checkInputs(): void;
  37674. protected _checkLimits(): void;
  37675. /**
  37676. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37677. */
  37678. rebuildAnglesAndRadius(): void;
  37679. /**
  37680. * Use a position to define the current camera related information like alpha, beta and radius
  37681. * @param position Defines the position to set the camera at
  37682. */
  37683. setPosition(position: Vector3): void;
  37684. /**
  37685. * Defines the target the camera should look at.
  37686. * This will automatically adapt alpha beta and radius to fit within the new target.
  37687. * @param target Defines the new target as a Vector or a mesh
  37688. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37689. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37690. */
  37691. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37692. /** @hidden */
  37693. _getViewMatrix(): Matrix;
  37694. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37695. /**
  37696. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37697. * @param meshes Defines the mesh to zoom on
  37698. * @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)
  37699. */
  37700. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37701. /**
  37702. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37703. * The target will be changed but the radius
  37704. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37705. * @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)
  37706. */
  37707. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37708. min: Vector3;
  37709. max: Vector3;
  37710. distance: number;
  37711. }, doNotUpdateMaxZ?: boolean): void;
  37712. /**
  37713. * @override
  37714. * Override Camera.createRigCamera
  37715. */
  37716. createRigCamera(name: string, cameraIndex: number): Camera;
  37717. /**
  37718. * @hidden
  37719. * @override
  37720. * Override Camera._updateRigCameras
  37721. */
  37722. _updateRigCameras(): void;
  37723. /**
  37724. * Destroy the camera and release the current resources hold by it.
  37725. */
  37726. dispose(): void;
  37727. /**
  37728. * Gets the current object class name.
  37729. * @return the class name
  37730. */
  37731. getClassName(): string;
  37732. }
  37733. }
  37734. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37735. import { Behavior } from "babylonjs/Behaviors/behavior";
  37736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37737. /**
  37738. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37740. */
  37741. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37742. /**
  37743. * Gets the name of the behavior.
  37744. */
  37745. readonly name: string;
  37746. private _zoomStopsAnimation;
  37747. private _idleRotationSpeed;
  37748. private _idleRotationWaitTime;
  37749. private _idleRotationSpinupTime;
  37750. /**
  37751. * Sets the flag that indicates if user zooming should stop animation.
  37752. */
  37753. /**
  37754. * Gets the flag that indicates if user zooming should stop animation.
  37755. */
  37756. zoomStopsAnimation: boolean;
  37757. /**
  37758. * Sets the default speed at which the camera rotates around the model.
  37759. */
  37760. /**
  37761. * Gets the default speed at which the camera rotates around the model.
  37762. */
  37763. idleRotationSpeed: number;
  37764. /**
  37765. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37766. */
  37767. /**
  37768. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37769. */
  37770. idleRotationWaitTime: number;
  37771. /**
  37772. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37773. */
  37774. /**
  37775. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37776. */
  37777. idleRotationSpinupTime: number;
  37778. /**
  37779. * Gets a value indicating if the camera is currently rotating because of this behavior
  37780. */
  37781. readonly rotationInProgress: boolean;
  37782. private _onPrePointerObservableObserver;
  37783. private _onAfterCheckInputsObserver;
  37784. private _attachedCamera;
  37785. private _isPointerDown;
  37786. private _lastFrameTime;
  37787. private _lastInteractionTime;
  37788. private _cameraRotationSpeed;
  37789. /**
  37790. * Initializes the behavior.
  37791. */
  37792. init(): void;
  37793. /**
  37794. * Attaches the behavior to its arc rotate camera.
  37795. * @param camera Defines the camera to attach the behavior to
  37796. */
  37797. attach(camera: ArcRotateCamera): void;
  37798. /**
  37799. * Detaches the behavior from its current arc rotate camera.
  37800. */
  37801. detach(): void;
  37802. /**
  37803. * Returns true if user is scrolling.
  37804. * @return true if user is scrolling.
  37805. */
  37806. private _userIsZooming;
  37807. private _lastFrameRadius;
  37808. private _shouldAnimationStopForInteraction;
  37809. /**
  37810. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37811. */
  37812. private _applyUserInteraction;
  37813. private _userIsMoving;
  37814. }
  37815. }
  37816. declare module "babylonjs/Behaviors/Cameras/index" {
  37817. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37818. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37819. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37820. }
  37821. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37822. import { Mesh } from "babylonjs/Meshes/mesh";
  37823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37824. import { Behavior } from "babylonjs/Behaviors/behavior";
  37825. /**
  37826. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37827. */
  37828. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37829. private ui;
  37830. /**
  37831. * The name of the behavior
  37832. */
  37833. name: string;
  37834. /**
  37835. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37836. */
  37837. distanceAwayFromFace: number;
  37838. /**
  37839. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37840. */
  37841. distanceAwayFromBottomOfFace: number;
  37842. private _faceVectors;
  37843. private _target;
  37844. private _scene;
  37845. private _onRenderObserver;
  37846. private _tmpMatrix;
  37847. private _tmpVector;
  37848. /**
  37849. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37850. * @param ui The transform node that should be attched to the mesh
  37851. */
  37852. constructor(ui: TransformNode);
  37853. /**
  37854. * Initializes the behavior
  37855. */
  37856. init(): void;
  37857. private _closestFace;
  37858. private _zeroVector;
  37859. private _lookAtTmpMatrix;
  37860. private _lookAtToRef;
  37861. /**
  37862. * Attaches the AttachToBoxBehavior to the passed in mesh
  37863. * @param target The mesh that the specified node will be attached to
  37864. */
  37865. attach(target: Mesh): void;
  37866. /**
  37867. * Detaches the behavior from the mesh
  37868. */
  37869. detach(): void;
  37870. }
  37871. }
  37872. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37873. import { Behavior } from "babylonjs/Behaviors/behavior";
  37874. import { Mesh } from "babylonjs/Meshes/mesh";
  37875. /**
  37876. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37877. */
  37878. export class FadeInOutBehavior implements Behavior<Mesh> {
  37879. /**
  37880. * Time in milliseconds to delay before fading in (Default: 0)
  37881. */
  37882. delay: number;
  37883. /**
  37884. * Time in milliseconds for the mesh to fade in (Default: 300)
  37885. */
  37886. fadeInTime: number;
  37887. private _millisecondsPerFrame;
  37888. private _hovered;
  37889. private _hoverValue;
  37890. private _ownerNode;
  37891. /**
  37892. * Instatiates the FadeInOutBehavior
  37893. */
  37894. constructor();
  37895. /**
  37896. * The name of the behavior
  37897. */
  37898. readonly name: string;
  37899. /**
  37900. * Initializes the behavior
  37901. */
  37902. init(): void;
  37903. /**
  37904. * Attaches the fade behavior on the passed in mesh
  37905. * @param ownerNode The mesh that will be faded in/out once attached
  37906. */
  37907. attach(ownerNode: Mesh): void;
  37908. /**
  37909. * Detaches the behavior from the mesh
  37910. */
  37911. detach(): void;
  37912. /**
  37913. * Triggers the mesh to begin fading in or out
  37914. * @param value if the object should fade in or out (true to fade in)
  37915. */
  37916. fadeIn(value: boolean): void;
  37917. private _update;
  37918. private _setAllVisibility;
  37919. }
  37920. }
  37921. declare module "babylonjs/Misc/pivotTools" {
  37922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37923. /**
  37924. * Class containing a set of static utilities functions for managing Pivots
  37925. * @hidden
  37926. */
  37927. export class PivotTools {
  37928. private static _PivotCached;
  37929. private static _OldPivotPoint;
  37930. private static _PivotTranslation;
  37931. private static _PivotTmpVector;
  37932. /** @hidden */
  37933. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37934. /** @hidden */
  37935. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37936. }
  37937. }
  37938. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37939. import { Scene } from "babylonjs/scene";
  37940. import { Vector4 } from "babylonjs/Maths/math.vector";
  37941. import { Mesh } from "babylonjs/Meshes/mesh";
  37942. import { Nullable } from "babylonjs/types";
  37943. import { Plane } from "babylonjs/Maths/math.plane";
  37944. /**
  37945. * Class containing static functions to help procedurally build meshes
  37946. */
  37947. export class PlaneBuilder {
  37948. /**
  37949. * Creates a plane mesh
  37950. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37951. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37952. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37956. * @param name defines the name of the mesh
  37957. * @param options defines the options used to create the mesh
  37958. * @param scene defines the hosting scene
  37959. * @returns the plane mesh
  37960. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37961. */
  37962. static CreatePlane(name: string, options: {
  37963. size?: number;
  37964. width?: number;
  37965. height?: number;
  37966. sideOrientation?: number;
  37967. frontUVs?: Vector4;
  37968. backUVs?: Vector4;
  37969. updatable?: boolean;
  37970. sourcePlane?: Plane;
  37971. }, scene?: Nullable<Scene>): Mesh;
  37972. }
  37973. }
  37974. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37975. import { Behavior } from "babylonjs/Behaviors/behavior";
  37976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37977. import { Observable } from "babylonjs/Misc/observable";
  37978. import { Vector3 } from "babylonjs/Maths/math.vector";
  37979. import { Ray } from "babylonjs/Culling/ray";
  37980. import "babylonjs/Meshes/Builders/planeBuilder";
  37981. /**
  37982. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37983. */
  37984. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37985. private static _AnyMouseID;
  37986. /**
  37987. * Abstract mesh the behavior is set on
  37988. */
  37989. attachedNode: AbstractMesh;
  37990. private _dragPlane;
  37991. private _scene;
  37992. private _pointerObserver;
  37993. private _beforeRenderObserver;
  37994. private static _planeScene;
  37995. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37996. /**
  37997. * 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)
  37998. */
  37999. maxDragAngle: number;
  38000. /**
  38001. * @hidden
  38002. */
  38003. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38004. /**
  38005. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38006. */
  38007. currentDraggingPointerID: number;
  38008. /**
  38009. * The last position where the pointer hit the drag plane in world space
  38010. */
  38011. lastDragPosition: Vector3;
  38012. /**
  38013. * If the behavior is currently in a dragging state
  38014. */
  38015. dragging: boolean;
  38016. /**
  38017. * 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)
  38018. */
  38019. dragDeltaRatio: number;
  38020. /**
  38021. * If the drag plane orientation should be updated during the dragging (Default: true)
  38022. */
  38023. updateDragPlane: boolean;
  38024. private _debugMode;
  38025. private _moving;
  38026. /**
  38027. * Fires each time the attached mesh is dragged with the pointer
  38028. * * delta between last drag position and current drag position in world space
  38029. * * dragDistance along the drag axis
  38030. * * dragPlaneNormal normal of the current drag plane used during the drag
  38031. * * dragPlanePoint in world space where the drag intersects the drag plane
  38032. */
  38033. onDragObservable: Observable<{
  38034. delta: Vector3;
  38035. dragPlanePoint: Vector3;
  38036. dragPlaneNormal: Vector3;
  38037. dragDistance: number;
  38038. pointerId: number;
  38039. }>;
  38040. /**
  38041. * Fires each time a drag begins (eg. mouse down on mesh)
  38042. */
  38043. onDragStartObservable: Observable<{
  38044. dragPlanePoint: Vector3;
  38045. pointerId: number;
  38046. }>;
  38047. /**
  38048. * Fires each time a drag ends (eg. mouse release after drag)
  38049. */
  38050. onDragEndObservable: Observable<{
  38051. dragPlanePoint: Vector3;
  38052. pointerId: number;
  38053. }>;
  38054. /**
  38055. * If the attached mesh should be moved when dragged
  38056. */
  38057. moveAttached: boolean;
  38058. /**
  38059. * If the drag behavior will react to drag events (Default: true)
  38060. */
  38061. enabled: boolean;
  38062. /**
  38063. * If pointer events should start and release the drag (Default: true)
  38064. */
  38065. startAndReleaseDragOnPointerEvents: boolean;
  38066. /**
  38067. * If camera controls should be detached during the drag
  38068. */
  38069. detachCameraControls: boolean;
  38070. /**
  38071. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38072. */
  38073. useObjectOrienationForDragging: boolean;
  38074. private _options;
  38075. /**
  38076. * Creates a pointer drag behavior that can be attached to a mesh
  38077. * @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)
  38078. */
  38079. constructor(options?: {
  38080. dragAxis?: Vector3;
  38081. dragPlaneNormal?: Vector3;
  38082. });
  38083. /**
  38084. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38085. */
  38086. validateDrag: (targetPosition: Vector3) => boolean;
  38087. /**
  38088. * The name of the behavior
  38089. */
  38090. readonly name: string;
  38091. /**
  38092. * Initializes the behavior
  38093. */
  38094. init(): void;
  38095. private _tmpVector;
  38096. private _alternatePickedPoint;
  38097. private _worldDragAxis;
  38098. private _targetPosition;
  38099. private _attachedElement;
  38100. /**
  38101. * Attaches the drag behavior the passed in mesh
  38102. * @param ownerNode The mesh that will be dragged around once attached
  38103. * @param predicate Predicate to use for pick filtering
  38104. */
  38105. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38106. /**
  38107. * Force relase the drag action by code.
  38108. */
  38109. releaseDrag(): void;
  38110. private _startDragRay;
  38111. private _lastPointerRay;
  38112. /**
  38113. * Simulates the start of a pointer drag event on the behavior
  38114. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38115. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38116. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38117. */
  38118. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38119. private _startDrag;
  38120. private _dragDelta;
  38121. private _moveDrag;
  38122. private _pickWithRayOnDragPlane;
  38123. private _pointA;
  38124. private _pointB;
  38125. private _pointC;
  38126. private _lineA;
  38127. private _lineB;
  38128. private _localAxis;
  38129. private _lookAt;
  38130. private _updateDragPlanePosition;
  38131. /**
  38132. * Detaches the behavior from the mesh
  38133. */
  38134. detach(): void;
  38135. }
  38136. }
  38137. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38138. import { Mesh } from "babylonjs/Meshes/mesh";
  38139. import { Behavior } from "babylonjs/Behaviors/behavior";
  38140. /**
  38141. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38142. */
  38143. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38144. private _dragBehaviorA;
  38145. private _dragBehaviorB;
  38146. private _startDistance;
  38147. private _initialScale;
  38148. private _targetScale;
  38149. private _ownerNode;
  38150. private _sceneRenderObserver;
  38151. /**
  38152. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38153. */
  38154. constructor();
  38155. /**
  38156. * The name of the behavior
  38157. */
  38158. readonly name: string;
  38159. /**
  38160. * Initializes the behavior
  38161. */
  38162. init(): void;
  38163. private _getCurrentDistance;
  38164. /**
  38165. * Attaches the scale behavior the passed in mesh
  38166. * @param ownerNode The mesh that will be scaled around once attached
  38167. */
  38168. attach(ownerNode: Mesh): void;
  38169. /**
  38170. * Detaches the behavior from the mesh
  38171. */
  38172. detach(): void;
  38173. }
  38174. }
  38175. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38176. import { Behavior } from "babylonjs/Behaviors/behavior";
  38177. import { Mesh } from "babylonjs/Meshes/mesh";
  38178. import { Observable } from "babylonjs/Misc/observable";
  38179. /**
  38180. * 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
  38181. */
  38182. export class SixDofDragBehavior implements Behavior<Mesh> {
  38183. private static _virtualScene;
  38184. private _ownerNode;
  38185. private _sceneRenderObserver;
  38186. private _scene;
  38187. private _targetPosition;
  38188. private _virtualOriginMesh;
  38189. private _virtualDragMesh;
  38190. private _pointerObserver;
  38191. private _moving;
  38192. private _startingOrientation;
  38193. /**
  38194. * 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)
  38195. */
  38196. private zDragFactor;
  38197. /**
  38198. * If the object should rotate to face the drag origin
  38199. */
  38200. rotateDraggedObject: boolean;
  38201. /**
  38202. * If the behavior is currently in a dragging state
  38203. */
  38204. dragging: boolean;
  38205. /**
  38206. * 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)
  38207. */
  38208. dragDeltaRatio: number;
  38209. /**
  38210. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38211. */
  38212. currentDraggingPointerID: number;
  38213. /**
  38214. * If camera controls should be detached during the drag
  38215. */
  38216. detachCameraControls: boolean;
  38217. /**
  38218. * Fires each time a drag starts
  38219. */
  38220. onDragStartObservable: Observable<{}>;
  38221. /**
  38222. * Fires each time a drag ends (eg. mouse release after drag)
  38223. */
  38224. onDragEndObservable: Observable<{}>;
  38225. /**
  38226. * 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
  38227. */
  38228. constructor();
  38229. /**
  38230. * The name of the behavior
  38231. */
  38232. readonly name: string;
  38233. /**
  38234. * Initializes the behavior
  38235. */
  38236. init(): void;
  38237. /**
  38238. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38239. */
  38240. private readonly _pointerCamera;
  38241. /**
  38242. * Attaches the scale behavior the passed in mesh
  38243. * @param ownerNode The mesh that will be scaled around once attached
  38244. */
  38245. attach(ownerNode: Mesh): void;
  38246. /**
  38247. * Detaches the behavior from the mesh
  38248. */
  38249. detach(): void;
  38250. }
  38251. }
  38252. declare module "babylonjs/Behaviors/Meshes/index" {
  38253. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38254. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38255. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38256. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38257. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38258. }
  38259. declare module "babylonjs/Behaviors/index" {
  38260. export * from "babylonjs/Behaviors/behavior";
  38261. export * from "babylonjs/Behaviors/Cameras/index";
  38262. export * from "babylonjs/Behaviors/Meshes/index";
  38263. }
  38264. declare module "babylonjs/Bones/boneIKController" {
  38265. import { Bone } from "babylonjs/Bones/bone";
  38266. import { Vector3 } from "babylonjs/Maths/math.vector";
  38267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38268. import { Nullable } from "babylonjs/types";
  38269. /**
  38270. * Class used to apply inverse kinematics to bones
  38271. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38272. */
  38273. export class BoneIKController {
  38274. private static _tmpVecs;
  38275. private static _tmpQuat;
  38276. private static _tmpMats;
  38277. /**
  38278. * Gets or sets the target mesh
  38279. */
  38280. targetMesh: AbstractMesh;
  38281. /** Gets or sets the mesh used as pole */
  38282. poleTargetMesh: AbstractMesh;
  38283. /**
  38284. * Gets or sets the bone used as pole
  38285. */
  38286. poleTargetBone: Nullable<Bone>;
  38287. /**
  38288. * Gets or sets the target position
  38289. */
  38290. targetPosition: Vector3;
  38291. /**
  38292. * Gets or sets the pole target position
  38293. */
  38294. poleTargetPosition: Vector3;
  38295. /**
  38296. * Gets or sets the pole target local offset
  38297. */
  38298. poleTargetLocalOffset: Vector3;
  38299. /**
  38300. * Gets or sets the pole angle
  38301. */
  38302. poleAngle: number;
  38303. /**
  38304. * Gets or sets the mesh associated with the controller
  38305. */
  38306. mesh: AbstractMesh;
  38307. /**
  38308. * 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)
  38309. */
  38310. slerpAmount: number;
  38311. private _bone1Quat;
  38312. private _bone1Mat;
  38313. private _bone2Ang;
  38314. private _bone1;
  38315. private _bone2;
  38316. private _bone1Length;
  38317. private _bone2Length;
  38318. private _maxAngle;
  38319. private _maxReach;
  38320. private _rightHandedSystem;
  38321. private _bendAxis;
  38322. private _slerping;
  38323. private _adjustRoll;
  38324. /**
  38325. * Gets or sets maximum allowed angle
  38326. */
  38327. maxAngle: number;
  38328. /**
  38329. * Creates a new BoneIKController
  38330. * @param mesh defines the mesh to control
  38331. * @param bone defines the bone to control
  38332. * @param options defines options to set up the controller
  38333. */
  38334. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38335. targetMesh?: AbstractMesh;
  38336. poleTargetMesh?: AbstractMesh;
  38337. poleTargetBone?: Bone;
  38338. poleTargetLocalOffset?: Vector3;
  38339. poleAngle?: number;
  38340. bendAxis?: Vector3;
  38341. maxAngle?: number;
  38342. slerpAmount?: number;
  38343. });
  38344. private _setMaxAngle;
  38345. /**
  38346. * Force the controller to update the bones
  38347. */
  38348. update(): void;
  38349. }
  38350. }
  38351. declare module "babylonjs/Bones/boneLookController" {
  38352. import { Vector3 } from "babylonjs/Maths/math.vector";
  38353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38354. import { Bone } from "babylonjs/Bones/bone";
  38355. import { Space } from "babylonjs/Maths/math.axis";
  38356. /**
  38357. * Class used to make a bone look toward a point in space
  38358. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38359. */
  38360. export class BoneLookController {
  38361. private static _tmpVecs;
  38362. private static _tmpQuat;
  38363. private static _tmpMats;
  38364. /**
  38365. * The target Vector3 that the bone will look at
  38366. */
  38367. target: Vector3;
  38368. /**
  38369. * The mesh that the bone is attached to
  38370. */
  38371. mesh: AbstractMesh;
  38372. /**
  38373. * The bone that will be looking to the target
  38374. */
  38375. bone: Bone;
  38376. /**
  38377. * The up axis of the coordinate system that is used when the bone is rotated
  38378. */
  38379. upAxis: Vector3;
  38380. /**
  38381. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38382. */
  38383. upAxisSpace: Space;
  38384. /**
  38385. * Used to make an adjustment to the yaw of the bone
  38386. */
  38387. adjustYaw: number;
  38388. /**
  38389. * Used to make an adjustment to the pitch of the bone
  38390. */
  38391. adjustPitch: number;
  38392. /**
  38393. * Used to make an adjustment to the roll of the bone
  38394. */
  38395. adjustRoll: number;
  38396. /**
  38397. * 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)
  38398. */
  38399. slerpAmount: number;
  38400. private _minYaw;
  38401. private _maxYaw;
  38402. private _minPitch;
  38403. private _maxPitch;
  38404. private _minYawSin;
  38405. private _minYawCos;
  38406. private _maxYawSin;
  38407. private _maxYawCos;
  38408. private _midYawConstraint;
  38409. private _minPitchTan;
  38410. private _maxPitchTan;
  38411. private _boneQuat;
  38412. private _slerping;
  38413. private _transformYawPitch;
  38414. private _transformYawPitchInv;
  38415. private _firstFrameSkipped;
  38416. private _yawRange;
  38417. private _fowardAxis;
  38418. /**
  38419. * Gets or sets the minimum yaw angle that the bone can look to
  38420. */
  38421. minYaw: number;
  38422. /**
  38423. * Gets or sets the maximum yaw angle that the bone can look to
  38424. */
  38425. maxYaw: number;
  38426. /**
  38427. * Gets or sets the minimum pitch angle that the bone can look to
  38428. */
  38429. minPitch: number;
  38430. /**
  38431. * Gets or sets the maximum pitch angle that the bone can look to
  38432. */
  38433. maxPitch: number;
  38434. /**
  38435. * Create a BoneLookController
  38436. * @param mesh the mesh that the bone belongs to
  38437. * @param bone the bone that will be looking to the target
  38438. * @param target the target Vector3 to look at
  38439. * @param options optional settings:
  38440. * * maxYaw: the maximum angle the bone will yaw to
  38441. * * minYaw: the minimum angle the bone will yaw to
  38442. * * maxPitch: the maximum angle the bone will pitch to
  38443. * * minPitch: the minimum angle the bone will yaw to
  38444. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38445. * * upAxis: the up axis of the coordinate system
  38446. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38447. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38448. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38449. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38450. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38451. * * adjustRoll: used to make an adjustment to the roll of the bone
  38452. **/
  38453. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38454. maxYaw?: number;
  38455. minYaw?: number;
  38456. maxPitch?: number;
  38457. minPitch?: number;
  38458. slerpAmount?: number;
  38459. upAxis?: Vector3;
  38460. upAxisSpace?: Space;
  38461. yawAxis?: Vector3;
  38462. pitchAxis?: Vector3;
  38463. adjustYaw?: number;
  38464. adjustPitch?: number;
  38465. adjustRoll?: number;
  38466. });
  38467. /**
  38468. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38469. */
  38470. update(): void;
  38471. private _getAngleDiff;
  38472. private _getAngleBetween;
  38473. private _isAngleBetween;
  38474. }
  38475. }
  38476. declare module "babylonjs/Bones/index" {
  38477. export * from "babylonjs/Bones/bone";
  38478. export * from "babylonjs/Bones/boneIKController";
  38479. export * from "babylonjs/Bones/boneLookController";
  38480. export * from "babylonjs/Bones/skeleton";
  38481. }
  38482. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38483. import { Nullable } from "babylonjs/types";
  38484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38486. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38487. /**
  38488. * Manage the gamepad inputs to control an arc rotate camera.
  38489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38490. */
  38491. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38492. /**
  38493. * Defines the camera the input is attached to.
  38494. */
  38495. camera: ArcRotateCamera;
  38496. /**
  38497. * Defines the gamepad the input is gathering event from.
  38498. */
  38499. gamepad: Nullable<Gamepad>;
  38500. /**
  38501. * Defines the gamepad rotation sensiblity.
  38502. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38503. */
  38504. gamepadRotationSensibility: number;
  38505. /**
  38506. * Defines the gamepad move sensiblity.
  38507. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38508. */
  38509. gamepadMoveSensibility: number;
  38510. private _yAxisScale;
  38511. /**
  38512. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38513. */
  38514. invertYAxis: boolean;
  38515. private _onGamepadConnectedObserver;
  38516. private _onGamepadDisconnectedObserver;
  38517. /**
  38518. * Attach the input controls to a specific dom element to get the input from.
  38519. * @param element Defines the element the controls should be listened from
  38520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38521. */
  38522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38523. /**
  38524. * Detach the current controls from the specified dom element.
  38525. * @param element Defines the element to stop listening the inputs from
  38526. */
  38527. detachControl(element: Nullable<HTMLElement>): void;
  38528. /**
  38529. * Update the current camera state depending on the inputs that have been used this frame.
  38530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38531. */
  38532. checkInputs(): void;
  38533. /**
  38534. * Gets the class name of the current intput.
  38535. * @returns the class name
  38536. */
  38537. getClassName(): string;
  38538. /**
  38539. * Get the friendly name associated with the input class.
  38540. * @returns the input friendly name
  38541. */
  38542. getSimpleName(): string;
  38543. }
  38544. }
  38545. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38546. import { Nullable } from "babylonjs/types";
  38547. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38549. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38550. interface ArcRotateCameraInputsManager {
  38551. /**
  38552. * Add orientation input support to the input manager.
  38553. * @returns the current input manager
  38554. */
  38555. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38556. }
  38557. }
  38558. /**
  38559. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38561. */
  38562. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38563. /**
  38564. * Defines the camera the input is attached to.
  38565. */
  38566. camera: ArcRotateCamera;
  38567. /**
  38568. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38569. */
  38570. alphaCorrection: number;
  38571. /**
  38572. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38573. */
  38574. gammaCorrection: number;
  38575. private _alpha;
  38576. private _gamma;
  38577. private _dirty;
  38578. private _deviceOrientationHandler;
  38579. /**
  38580. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38581. */
  38582. constructor();
  38583. /**
  38584. * Attach the input controls to a specific dom element to get the input from.
  38585. * @param element Defines the element the controls should be listened from
  38586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38587. */
  38588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38589. /** @hidden */
  38590. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38591. /**
  38592. * Update the current camera state depending on the inputs that have been used this frame.
  38593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38594. */
  38595. checkInputs(): void;
  38596. /**
  38597. * Detach the current controls from the specified dom element.
  38598. * @param element Defines the element to stop listening the inputs from
  38599. */
  38600. detachControl(element: Nullable<HTMLElement>): void;
  38601. /**
  38602. * Gets the class name of the current intput.
  38603. * @returns the class name
  38604. */
  38605. getClassName(): string;
  38606. /**
  38607. * Get the friendly name associated with the input class.
  38608. * @returns the input friendly name
  38609. */
  38610. getSimpleName(): string;
  38611. }
  38612. }
  38613. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38614. import { Nullable } from "babylonjs/types";
  38615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38616. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38617. /**
  38618. * Listen to mouse events to control the camera.
  38619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38620. */
  38621. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38622. /**
  38623. * Defines the camera the input is attached to.
  38624. */
  38625. camera: FlyCamera;
  38626. /**
  38627. * Defines if touch is enabled. (Default is true.)
  38628. */
  38629. touchEnabled: boolean;
  38630. /**
  38631. * Defines the buttons associated with the input to handle camera rotation.
  38632. */
  38633. buttons: number[];
  38634. /**
  38635. * Assign buttons for Yaw control.
  38636. */
  38637. buttonsYaw: number[];
  38638. /**
  38639. * Assign buttons for Pitch control.
  38640. */
  38641. buttonsPitch: number[];
  38642. /**
  38643. * Assign buttons for Roll control.
  38644. */
  38645. buttonsRoll: number[];
  38646. /**
  38647. * Detect if any button is being pressed while mouse is moved.
  38648. * -1 = Mouse locked.
  38649. * 0 = Left button.
  38650. * 1 = Middle Button.
  38651. * 2 = Right Button.
  38652. */
  38653. activeButton: number;
  38654. /**
  38655. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38656. * Higher values reduce its sensitivity.
  38657. */
  38658. angularSensibility: number;
  38659. private _mousemoveCallback;
  38660. private _observer;
  38661. private _rollObserver;
  38662. private previousPosition;
  38663. private noPreventDefault;
  38664. private element;
  38665. /**
  38666. * Listen to mouse events to control the camera.
  38667. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38669. */
  38670. constructor(touchEnabled?: boolean);
  38671. /**
  38672. * Attach the mouse control to the HTML DOM element.
  38673. * @param element Defines the element that listens to the input events.
  38674. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38675. */
  38676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38677. /**
  38678. * Detach the current controls from the specified dom element.
  38679. * @param element Defines the element to stop listening the inputs from
  38680. */
  38681. detachControl(element: Nullable<HTMLElement>): void;
  38682. /**
  38683. * Gets the class name of the current input.
  38684. * @returns the class name.
  38685. */
  38686. getClassName(): string;
  38687. /**
  38688. * Get the friendly name associated with the input class.
  38689. * @returns the input's friendly name.
  38690. */
  38691. getSimpleName(): string;
  38692. private _pointerInput;
  38693. private _onMouseMove;
  38694. /**
  38695. * Rotate camera by mouse offset.
  38696. */
  38697. private rotateCamera;
  38698. }
  38699. }
  38700. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38701. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38702. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38703. /**
  38704. * Default Inputs manager for the FlyCamera.
  38705. * It groups all the default supported inputs for ease of use.
  38706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38707. */
  38708. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38709. /**
  38710. * Instantiates a new FlyCameraInputsManager.
  38711. * @param camera Defines the camera the inputs belong to.
  38712. */
  38713. constructor(camera: FlyCamera);
  38714. /**
  38715. * Add keyboard input support to the input manager.
  38716. * @returns the new FlyCameraKeyboardMoveInput().
  38717. */
  38718. addKeyboard(): FlyCameraInputsManager;
  38719. /**
  38720. * Add mouse input support to the input manager.
  38721. * @param touchEnabled Enable touch screen support.
  38722. * @returns the new FlyCameraMouseInput().
  38723. */
  38724. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38725. }
  38726. }
  38727. declare module "babylonjs/Cameras/flyCamera" {
  38728. import { Scene } from "babylonjs/scene";
  38729. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38731. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38732. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38733. /**
  38734. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38735. * such as in a 3D Space Shooter or a Flight Simulator.
  38736. */
  38737. export class FlyCamera extends TargetCamera {
  38738. /**
  38739. * Define the collision ellipsoid of the camera.
  38740. * This is helpful for simulating a camera body, like a player's body.
  38741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38742. */
  38743. ellipsoid: Vector3;
  38744. /**
  38745. * Define an offset for the position of the ellipsoid around the camera.
  38746. * This can be helpful if the camera is attached away from the player's body center,
  38747. * such as at its head.
  38748. */
  38749. ellipsoidOffset: Vector3;
  38750. /**
  38751. * Enable or disable collisions of the camera with the rest of the scene objects.
  38752. */
  38753. checkCollisions: boolean;
  38754. /**
  38755. * Enable or disable gravity on the camera.
  38756. */
  38757. applyGravity: boolean;
  38758. /**
  38759. * Define the current direction the camera is moving to.
  38760. */
  38761. cameraDirection: Vector3;
  38762. /**
  38763. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38764. * This overrides and empties cameraRotation.
  38765. */
  38766. rotationQuaternion: Quaternion;
  38767. /**
  38768. * Track Roll to maintain the wanted Rolling when looking around.
  38769. */
  38770. _trackRoll: number;
  38771. /**
  38772. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38773. */
  38774. rollCorrect: number;
  38775. /**
  38776. * Mimic a banked turn, Rolling the camera when Yawing.
  38777. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38778. */
  38779. bankedTurn: boolean;
  38780. /**
  38781. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38782. */
  38783. bankedTurnLimit: number;
  38784. /**
  38785. * Value of 0 disables the banked Roll.
  38786. * Value of 1 is equal to the Yaw angle in radians.
  38787. */
  38788. bankedTurnMultiplier: number;
  38789. /**
  38790. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38791. */
  38792. inputs: FlyCameraInputsManager;
  38793. /**
  38794. * Gets the input sensibility for mouse input.
  38795. * Higher values reduce sensitivity.
  38796. */
  38797. /**
  38798. * Sets the input sensibility for a mouse input.
  38799. * Higher values reduce sensitivity.
  38800. */
  38801. angularSensibility: number;
  38802. /**
  38803. * Get the keys for camera movement forward.
  38804. */
  38805. /**
  38806. * Set the keys for camera movement forward.
  38807. */
  38808. keysForward: number[];
  38809. /**
  38810. * Get the keys for camera movement backward.
  38811. */
  38812. keysBackward: number[];
  38813. /**
  38814. * Get the keys for camera movement up.
  38815. */
  38816. /**
  38817. * Set the keys for camera movement up.
  38818. */
  38819. keysUp: number[];
  38820. /**
  38821. * Get the keys for camera movement down.
  38822. */
  38823. /**
  38824. * Set the keys for camera movement down.
  38825. */
  38826. keysDown: number[];
  38827. /**
  38828. * Get the keys for camera movement left.
  38829. */
  38830. /**
  38831. * Set the keys for camera movement left.
  38832. */
  38833. keysLeft: number[];
  38834. /**
  38835. * Set the keys for camera movement right.
  38836. */
  38837. /**
  38838. * Set the keys for camera movement right.
  38839. */
  38840. keysRight: number[];
  38841. /**
  38842. * Event raised when the camera collides with a mesh in the scene.
  38843. */
  38844. onCollide: (collidedMesh: AbstractMesh) => void;
  38845. private _collider;
  38846. private _needMoveForGravity;
  38847. private _oldPosition;
  38848. private _diffPosition;
  38849. private _newPosition;
  38850. /** @hidden */
  38851. _localDirection: Vector3;
  38852. /** @hidden */
  38853. _transformedDirection: Vector3;
  38854. /**
  38855. * Instantiates a FlyCamera.
  38856. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38857. * such as in a 3D Space Shooter or a Flight Simulator.
  38858. * @param name Define the name of the camera in the scene.
  38859. * @param position Define the starting position of the camera in the scene.
  38860. * @param scene Define the scene the camera belongs to.
  38861. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38862. */
  38863. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38864. /**
  38865. * Attach a control to the HTML DOM element.
  38866. * @param element Defines the element that listens to the input events.
  38867. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38868. */
  38869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38870. /**
  38871. * Detach a control from the HTML DOM element.
  38872. * The camera will stop reacting to that input.
  38873. * @param element Defines the element that listens to the input events.
  38874. */
  38875. detachControl(element: HTMLElement): void;
  38876. private _collisionMask;
  38877. /**
  38878. * Get the mask that the camera ignores in collision events.
  38879. */
  38880. /**
  38881. * Set the mask that the camera ignores in collision events.
  38882. */
  38883. collisionMask: number;
  38884. /** @hidden */
  38885. _collideWithWorld(displacement: Vector3): void;
  38886. /** @hidden */
  38887. private _onCollisionPositionChange;
  38888. /** @hidden */
  38889. _checkInputs(): void;
  38890. /** @hidden */
  38891. _decideIfNeedsToMove(): boolean;
  38892. /** @hidden */
  38893. _updatePosition(): void;
  38894. /**
  38895. * Restore the Roll to its target value at the rate specified.
  38896. * @param rate - Higher means slower restoring.
  38897. * @hidden
  38898. */
  38899. restoreRoll(rate: number): void;
  38900. /**
  38901. * Destroy the camera and release the current resources held by it.
  38902. */
  38903. dispose(): void;
  38904. /**
  38905. * Get the current object class name.
  38906. * @returns the class name.
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38912. import { Nullable } from "babylonjs/types";
  38913. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38914. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38915. /**
  38916. * Listen to keyboard events to control the camera.
  38917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38918. */
  38919. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38920. /**
  38921. * Defines the camera the input is attached to.
  38922. */
  38923. camera: FlyCamera;
  38924. /**
  38925. * The list of keyboard keys used to control the forward move of the camera.
  38926. */
  38927. keysForward: number[];
  38928. /**
  38929. * The list of keyboard keys used to control the backward move of the camera.
  38930. */
  38931. keysBackward: number[];
  38932. /**
  38933. * The list of keyboard keys used to control the forward move of the camera.
  38934. */
  38935. keysUp: number[];
  38936. /**
  38937. * The list of keyboard keys used to control the backward move of the camera.
  38938. */
  38939. keysDown: number[];
  38940. /**
  38941. * The list of keyboard keys used to control the right strafe move of the camera.
  38942. */
  38943. keysRight: number[];
  38944. /**
  38945. * The list of keyboard keys used to control the left strafe move of the camera.
  38946. */
  38947. keysLeft: number[];
  38948. private _keys;
  38949. private _onCanvasBlurObserver;
  38950. private _onKeyboardObserver;
  38951. private _engine;
  38952. private _scene;
  38953. /**
  38954. * Attach the input controls to a specific dom element to get the input from.
  38955. * @param element Defines the element the controls should be listened from
  38956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38957. */
  38958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38959. /**
  38960. * Detach the current controls from the specified dom element.
  38961. * @param element Defines the element to stop listening the inputs from
  38962. */
  38963. detachControl(element: Nullable<HTMLElement>): void;
  38964. /**
  38965. * Gets the class name of the current intput.
  38966. * @returns the class name
  38967. */
  38968. getClassName(): string;
  38969. /** @hidden */
  38970. _onLostFocus(e: FocusEvent): void;
  38971. /**
  38972. * Get the friendly name associated with the input class.
  38973. * @returns the input friendly name
  38974. */
  38975. getSimpleName(): string;
  38976. /**
  38977. * Update the current camera state depending on the inputs that have been used this frame.
  38978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38979. */
  38980. checkInputs(): void;
  38981. }
  38982. }
  38983. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38984. import { Nullable } from "babylonjs/types";
  38985. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38986. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38987. /**
  38988. * Manage the mouse wheel inputs to control a follow camera.
  38989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38990. */
  38991. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38992. /**
  38993. * Defines the camera the input is attached to.
  38994. */
  38995. camera: FollowCamera;
  38996. /**
  38997. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38998. */
  38999. axisControlRadius: boolean;
  39000. /**
  39001. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39002. */
  39003. axisControlHeight: boolean;
  39004. /**
  39005. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39006. */
  39007. axisControlRotation: boolean;
  39008. /**
  39009. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39010. * relation to mouseWheel events.
  39011. */
  39012. wheelPrecision: number;
  39013. /**
  39014. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39015. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39016. */
  39017. wheelDeltaPercentage: number;
  39018. private _wheel;
  39019. private _observer;
  39020. /**
  39021. * Attach the input controls to a specific dom element to get the input from.
  39022. * @param element Defines the element the controls should be listened from
  39023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39024. */
  39025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39026. /**
  39027. * Detach the current controls from the specified dom element.
  39028. * @param element Defines the element to stop listening the inputs from
  39029. */
  39030. detachControl(element: Nullable<HTMLElement>): void;
  39031. /**
  39032. * Gets the class name of the current intput.
  39033. * @returns the class name
  39034. */
  39035. getClassName(): string;
  39036. /**
  39037. * Get the friendly name associated with the input class.
  39038. * @returns the input friendly name
  39039. */
  39040. getSimpleName(): string;
  39041. }
  39042. }
  39043. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39044. import { Nullable } from "babylonjs/types";
  39045. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39046. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39047. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39048. /**
  39049. * Manage the pointers inputs to control an follow camera.
  39050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39051. */
  39052. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39053. /**
  39054. * Defines the camera the input is attached to.
  39055. */
  39056. camera: FollowCamera;
  39057. /**
  39058. * Gets the class name of the current input.
  39059. * @returns the class name
  39060. */
  39061. getClassName(): string;
  39062. /**
  39063. * Defines the pointer angular sensibility along the X axis or how fast is
  39064. * the camera rotating.
  39065. * A negative number will reverse the axis direction.
  39066. */
  39067. angularSensibilityX: number;
  39068. /**
  39069. * Defines the pointer angular sensibility along the Y axis or how fast is
  39070. * the camera rotating.
  39071. * A negative number will reverse the axis direction.
  39072. */
  39073. angularSensibilityY: number;
  39074. /**
  39075. * Defines the pointer pinch precision or how fast is the camera zooming.
  39076. * A negative number will reverse the axis direction.
  39077. */
  39078. pinchPrecision: number;
  39079. /**
  39080. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39081. * from 0.
  39082. * It defines the percentage of current camera.radius to use as delta when
  39083. * pinch zoom is used.
  39084. */
  39085. pinchDeltaPercentage: number;
  39086. /**
  39087. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39088. */
  39089. axisXControlRadius: boolean;
  39090. /**
  39091. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39092. */
  39093. axisXControlHeight: boolean;
  39094. /**
  39095. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39096. */
  39097. axisXControlRotation: boolean;
  39098. /**
  39099. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39100. */
  39101. axisYControlRadius: boolean;
  39102. /**
  39103. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39104. */
  39105. axisYControlHeight: boolean;
  39106. /**
  39107. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39108. */
  39109. axisYControlRotation: boolean;
  39110. /**
  39111. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39112. */
  39113. axisPinchControlRadius: boolean;
  39114. /**
  39115. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39116. */
  39117. axisPinchControlHeight: boolean;
  39118. /**
  39119. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39120. */
  39121. axisPinchControlRotation: boolean;
  39122. /**
  39123. * Log error messages if basic misconfiguration has occurred.
  39124. */
  39125. warningEnable: boolean;
  39126. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39127. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39128. private _warningCounter;
  39129. private _warning;
  39130. }
  39131. }
  39132. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39133. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39134. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39135. /**
  39136. * Default Inputs manager for the FollowCamera.
  39137. * It groups all the default supported inputs for ease of use.
  39138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39139. */
  39140. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39141. /**
  39142. * Instantiates a new FollowCameraInputsManager.
  39143. * @param camera Defines the camera the inputs belong to
  39144. */
  39145. constructor(camera: FollowCamera);
  39146. /**
  39147. * Add keyboard input support to the input manager.
  39148. * @returns the current input manager
  39149. */
  39150. addKeyboard(): FollowCameraInputsManager;
  39151. /**
  39152. * Add mouse wheel input support to the input manager.
  39153. * @returns the current input manager
  39154. */
  39155. addMouseWheel(): FollowCameraInputsManager;
  39156. /**
  39157. * Add pointers input support to the input manager.
  39158. * @returns the current input manager
  39159. */
  39160. addPointers(): FollowCameraInputsManager;
  39161. /**
  39162. * Add orientation input support to the input manager.
  39163. * @returns the current input manager
  39164. */
  39165. addVRDeviceOrientation(): FollowCameraInputsManager;
  39166. }
  39167. }
  39168. declare module "babylonjs/Cameras/followCamera" {
  39169. import { Nullable } from "babylonjs/types";
  39170. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39171. import { Scene } from "babylonjs/scene";
  39172. import { Vector3 } from "babylonjs/Maths/math.vector";
  39173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39174. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39175. /**
  39176. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39177. * an arc rotate version arcFollowCamera are available.
  39178. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39179. */
  39180. export class FollowCamera extends TargetCamera {
  39181. /**
  39182. * Distance the follow camera should follow an object at
  39183. */
  39184. radius: number;
  39185. /**
  39186. * Minimum allowed distance of the camera to the axis of rotation
  39187. * (The camera can not get closer).
  39188. * This can help limiting how the Camera is able to move in the scene.
  39189. */
  39190. lowerRadiusLimit: Nullable<number>;
  39191. /**
  39192. * Maximum allowed distance of the camera to the axis of rotation
  39193. * (The camera can not get further).
  39194. * This can help limiting how the Camera is able to move in the scene.
  39195. */
  39196. upperRadiusLimit: Nullable<number>;
  39197. /**
  39198. * Define a rotation offset between the camera and the object it follows
  39199. */
  39200. rotationOffset: number;
  39201. /**
  39202. * Minimum allowed angle to camera position relative to target object.
  39203. * This can help limiting how the Camera is able to move in the scene.
  39204. */
  39205. lowerRotationOffsetLimit: Nullable<number>;
  39206. /**
  39207. * Maximum allowed angle to camera position relative to target object.
  39208. * This can help limiting how the Camera is able to move in the scene.
  39209. */
  39210. upperRotationOffsetLimit: Nullable<number>;
  39211. /**
  39212. * Define a height offset between the camera and the object it follows.
  39213. * It can help following an object from the top (like a car chaing a plane)
  39214. */
  39215. heightOffset: number;
  39216. /**
  39217. * Minimum allowed height of camera position relative to target object.
  39218. * This can help limiting how the Camera is able to move in the scene.
  39219. */
  39220. lowerHeightOffsetLimit: Nullable<number>;
  39221. /**
  39222. * Maximum allowed height of camera position relative to target object.
  39223. * This can help limiting how the Camera is able to move in the scene.
  39224. */
  39225. upperHeightOffsetLimit: Nullable<number>;
  39226. /**
  39227. * Define how fast the camera can accelerate to follow it s target.
  39228. */
  39229. cameraAcceleration: number;
  39230. /**
  39231. * Define the speed limit of the camera following an object.
  39232. */
  39233. maxCameraSpeed: number;
  39234. /**
  39235. * Define the target of the camera.
  39236. */
  39237. lockedTarget: Nullable<AbstractMesh>;
  39238. /**
  39239. * Defines the input associated with the camera.
  39240. */
  39241. inputs: FollowCameraInputsManager;
  39242. /**
  39243. * Instantiates the follow camera.
  39244. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39245. * @param name Define the name of the camera in the scene
  39246. * @param position Define the position of the camera
  39247. * @param scene Define the scene the camera belong to
  39248. * @param lockedTarget Define the target of the camera
  39249. */
  39250. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39251. private _follow;
  39252. /**
  39253. * Attached controls to the current camera.
  39254. * @param element Defines the element the controls should be listened from
  39255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39256. */
  39257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39258. /**
  39259. * Detach the current controls from the camera.
  39260. * The camera will stop reacting to inputs.
  39261. * @param element Defines the element to stop listening the inputs from
  39262. */
  39263. detachControl(element: HTMLElement): void;
  39264. /** @hidden */
  39265. _checkInputs(): void;
  39266. private _checkLimits;
  39267. /**
  39268. * Gets the camera class name.
  39269. * @returns the class name
  39270. */
  39271. getClassName(): string;
  39272. }
  39273. /**
  39274. * Arc Rotate version of the follow camera.
  39275. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39276. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39277. */
  39278. export class ArcFollowCamera extends TargetCamera {
  39279. /** The longitudinal angle of the camera */
  39280. alpha: number;
  39281. /** The latitudinal angle of the camera */
  39282. beta: number;
  39283. /** The radius of the camera from its target */
  39284. radius: number;
  39285. /** Define the camera target (the messh it should follow) */
  39286. target: Nullable<AbstractMesh>;
  39287. private _cartesianCoordinates;
  39288. /**
  39289. * Instantiates a new ArcFollowCamera
  39290. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39291. * @param name Define the name of the camera
  39292. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39293. * @param beta Define the rotation angle of the camera around the elevation axis
  39294. * @param radius Define the radius of the camera from its target point
  39295. * @param target Define the target of the camera
  39296. * @param scene Define the scene the camera belongs to
  39297. */
  39298. constructor(name: string,
  39299. /** The longitudinal angle of the camera */
  39300. alpha: number,
  39301. /** The latitudinal angle of the camera */
  39302. beta: number,
  39303. /** The radius of the camera from its target */
  39304. radius: number,
  39305. /** Define the camera target (the messh it should follow) */
  39306. target: Nullable<AbstractMesh>, scene: Scene);
  39307. private _follow;
  39308. /** @hidden */
  39309. _checkInputs(): void;
  39310. /**
  39311. * Returns the class name of the object.
  39312. * It is mostly used internally for serialization purposes.
  39313. */
  39314. getClassName(): string;
  39315. }
  39316. }
  39317. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39318. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39319. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39320. import { Nullable } from "babylonjs/types";
  39321. /**
  39322. * Manage the keyboard inputs to control the movement of a follow camera.
  39323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39324. */
  39325. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39326. /**
  39327. * Defines the camera the input is attached to.
  39328. */
  39329. camera: FollowCamera;
  39330. /**
  39331. * Defines the list of key codes associated with the up action (increase heightOffset)
  39332. */
  39333. keysHeightOffsetIncr: number[];
  39334. /**
  39335. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39336. */
  39337. keysHeightOffsetDecr: number[];
  39338. /**
  39339. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39340. */
  39341. keysHeightOffsetModifierAlt: boolean;
  39342. /**
  39343. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39344. */
  39345. keysHeightOffsetModifierCtrl: boolean;
  39346. /**
  39347. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39348. */
  39349. keysHeightOffsetModifierShift: boolean;
  39350. /**
  39351. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39352. */
  39353. keysRotationOffsetIncr: number[];
  39354. /**
  39355. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39356. */
  39357. keysRotationOffsetDecr: number[];
  39358. /**
  39359. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39360. */
  39361. keysRotationOffsetModifierAlt: boolean;
  39362. /**
  39363. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39364. */
  39365. keysRotationOffsetModifierCtrl: boolean;
  39366. /**
  39367. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39368. */
  39369. keysRotationOffsetModifierShift: boolean;
  39370. /**
  39371. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39372. */
  39373. keysRadiusIncr: number[];
  39374. /**
  39375. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39376. */
  39377. keysRadiusDecr: number[];
  39378. /**
  39379. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39380. */
  39381. keysRadiusModifierAlt: boolean;
  39382. /**
  39383. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39384. */
  39385. keysRadiusModifierCtrl: boolean;
  39386. /**
  39387. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39388. */
  39389. keysRadiusModifierShift: boolean;
  39390. /**
  39391. * Defines the rate of change of heightOffset.
  39392. */
  39393. heightSensibility: number;
  39394. /**
  39395. * Defines the rate of change of rotationOffset.
  39396. */
  39397. rotationSensibility: number;
  39398. /**
  39399. * Defines the rate of change of radius.
  39400. */
  39401. radiusSensibility: number;
  39402. private _keys;
  39403. private _ctrlPressed;
  39404. private _altPressed;
  39405. private _shiftPressed;
  39406. private _onCanvasBlurObserver;
  39407. private _onKeyboardObserver;
  39408. private _engine;
  39409. private _scene;
  39410. /**
  39411. * Attach the input controls to a specific dom element to get the input from.
  39412. * @param element Defines the element the controls should be listened from
  39413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39414. */
  39415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39416. /**
  39417. * Detach the current controls from the specified dom element.
  39418. * @param element Defines the element to stop listening the inputs from
  39419. */
  39420. detachControl(element: Nullable<HTMLElement>): void;
  39421. /**
  39422. * Update the current camera state depending on the inputs that have been used this frame.
  39423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39424. */
  39425. checkInputs(): void;
  39426. /**
  39427. * Gets the class name of the current input.
  39428. * @returns the class name
  39429. */
  39430. getClassName(): string;
  39431. /**
  39432. * Get the friendly name associated with the input class.
  39433. * @returns the input friendly name
  39434. */
  39435. getSimpleName(): string;
  39436. /**
  39437. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39438. * allow modification of the heightOffset value.
  39439. */
  39440. private _modifierHeightOffset;
  39441. /**
  39442. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39443. * allow modification of the rotationOffset value.
  39444. */
  39445. private _modifierRotationOffset;
  39446. /**
  39447. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39448. * allow modification of the radius value.
  39449. */
  39450. private _modifierRadius;
  39451. }
  39452. }
  39453. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39454. import { Nullable } from "babylonjs/types";
  39455. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39456. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39457. import { Observable } from "babylonjs/Misc/observable";
  39458. module "babylonjs/Cameras/freeCameraInputsManager" {
  39459. interface FreeCameraInputsManager {
  39460. /**
  39461. * @hidden
  39462. */
  39463. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39464. /**
  39465. * Add orientation input support to the input manager.
  39466. * @returns the current input manager
  39467. */
  39468. addDeviceOrientation(): FreeCameraInputsManager;
  39469. }
  39470. }
  39471. /**
  39472. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39473. * Screen rotation is taken into account.
  39474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39475. */
  39476. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39477. private _camera;
  39478. private _screenOrientationAngle;
  39479. private _constantTranform;
  39480. private _screenQuaternion;
  39481. private _alpha;
  39482. private _beta;
  39483. private _gamma;
  39484. /**
  39485. * Can be used to detect if a device orientation sensor is availible on a device
  39486. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39487. * @returns a promise that will resolve on orientation change
  39488. */
  39489. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39490. /**
  39491. * @hidden
  39492. */
  39493. _onDeviceOrientationChangedObservable: Observable<void>;
  39494. /**
  39495. * Instantiates a new input
  39496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39497. */
  39498. constructor();
  39499. /**
  39500. * Define the camera controlled by the input.
  39501. */
  39502. camera: FreeCamera;
  39503. /**
  39504. * Attach the input controls to a specific dom element to get the input from.
  39505. * @param element Defines the element the controls should be listened from
  39506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39507. */
  39508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39509. private _orientationChanged;
  39510. private _deviceOrientation;
  39511. /**
  39512. * Detach the current controls from the specified dom element.
  39513. * @param element Defines the element to stop listening the inputs from
  39514. */
  39515. detachControl(element: Nullable<HTMLElement>): void;
  39516. /**
  39517. * Update the current camera state depending on the inputs that have been used this frame.
  39518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39519. */
  39520. checkInputs(): void;
  39521. /**
  39522. * Gets the class name of the current intput.
  39523. * @returns the class name
  39524. */
  39525. getClassName(): string;
  39526. /**
  39527. * Get the friendly name associated with the input class.
  39528. * @returns the input friendly name
  39529. */
  39530. getSimpleName(): string;
  39531. }
  39532. }
  39533. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39534. import { Nullable } from "babylonjs/types";
  39535. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39537. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39538. /**
  39539. * Manage the gamepad inputs to control a free camera.
  39540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39541. */
  39542. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39543. /**
  39544. * Define the camera the input is attached to.
  39545. */
  39546. camera: FreeCamera;
  39547. /**
  39548. * Define the Gamepad controlling the input
  39549. */
  39550. gamepad: Nullable<Gamepad>;
  39551. /**
  39552. * Defines the gamepad rotation sensiblity.
  39553. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39554. */
  39555. gamepadAngularSensibility: number;
  39556. /**
  39557. * Defines the gamepad move sensiblity.
  39558. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39559. */
  39560. gamepadMoveSensibility: number;
  39561. private _yAxisScale;
  39562. /**
  39563. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39564. */
  39565. invertYAxis: boolean;
  39566. private _onGamepadConnectedObserver;
  39567. private _onGamepadDisconnectedObserver;
  39568. private _cameraTransform;
  39569. private _deltaTransform;
  39570. private _vector3;
  39571. private _vector2;
  39572. /**
  39573. * Attach the input controls to a specific dom element to get the input from.
  39574. * @param element Defines the element the controls should be listened from
  39575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39576. */
  39577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39578. /**
  39579. * Detach the current controls from the specified dom element.
  39580. * @param element Defines the element to stop listening the inputs from
  39581. */
  39582. detachControl(element: Nullable<HTMLElement>): void;
  39583. /**
  39584. * Update the current camera state depending on the inputs that have been used this frame.
  39585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39586. */
  39587. checkInputs(): void;
  39588. /**
  39589. * Gets the class name of the current intput.
  39590. * @returns the class name
  39591. */
  39592. getClassName(): string;
  39593. /**
  39594. * Get the friendly name associated with the input class.
  39595. * @returns the input friendly name
  39596. */
  39597. getSimpleName(): string;
  39598. }
  39599. }
  39600. declare module "babylonjs/Misc/virtualJoystick" {
  39601. import { Nullable } from "babylonjs/types";
  39602. import { Vector3 } from "babylonjs/Maths/math.vector";
  39603. /**
  39604. * Defines the potential axis of a Joystick
  39605. */
  39606. export enum JoystickAxis {
  39607. /** X axis */
  39608. X = 0,
  39609. /** Y axis */
  39610. Y = 1,
  39611. /** Z axis */
  39612. Z = 2
  39613. }
  39614. /**
  39615. * Class used to define virtual joystick (used in touch mode)
  39616. */
  39617. export class VirtualJoystick {
  39618. /**
  39619. * Gets or sets a boolean indicating that left and right values must be inverted
  39620. */
  39621. reverseLeftRight: boolean;
  39622. /**
  39623. * Gets or sets a boolean indicating that up and down values must be inverted
  39624. */
  39625. reverseUpDown: boolean;
  39626. /**
  39627. * Gets the offset value for the position (ie. the change of the position value)
  39628. */
  39629. deltaPosition: Vector3;
  39630. /**
  39631. * Gets a boolean indicating if the virtual joystick was pressed
  39632. */
  39633. pressed: boolean;
  39634. /**
  39635. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39636. */
  39637. static Canvas: Nullable<HTMLCanvasElement>;
  39638. private static _globalJoystickIndex;
  39639. private static vjCanvasContext;
  39640. private static vjCanvasWidth;
  39641. private static vjCanvasHeight;
  39642. private static halfWidth;
  39643. private _action;
  39644. private _axisTargetedByLeftAndRight;
  39645. private _axisTargetedByUpAndDown;
  39646. private _joystickSensibility;
  39647. private _inversedSensibility;
  39648. private _joystickPointerID;
  39649. private _joystickColor;
  39650. private _joystickPointerPos;
  39651. private _joystickPreviousPointerPos;
  39652. private _joystickPointerStartPos;
  39653. private _deltaJoystickVector;
  39654. private _leftJoystick;
  39655. private _touches;
  39656. private _onPointerDownHandlerRef;
  39657. private _onPointerMoveHandlerRef;
  39658. private _onPointerUpHandlerRef;
  39659. private _onResize;
  39660. /**
  39661. * Creates a new virtual joystick
  39662. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39663. */
  39664. constructor(leftJoystick?: boolean);
  39665. /**
  39666. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39667. * @param newJoystickSensibility defines the new sensibility
  39668. */
  39669. setJoystickSensibility(newJoystickSensibility: number): void;
  39670. private _onPointerDown;
  39671. private _onPointerMove;
  39672. private _onPointerUp;
  39673. /**
  39674. * Change the color of the virtual joystick
  39675. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39676. */
  39677. setJoystickColor(newColor: string): void;
  39678. /**
  39679. * Defines a callback to call when the joystick is touched
  39680. * @param action defines the callback
  39681. */
  39682. setActionOnTouch(action: () => any): void;
  39683. /**
  39684. * Defines which axis you'd like to control for left & right
  39685. * @param axis defines the axis to use
  39686. */
  39687. setAxisForLeftRight(axis: JoystickAxis): void;
  39688. /**
  39689. * Defines which axis you'd like to control for up & down
  39690. * @param axis defines the axis to use
  39691. */
  39692. setAxisForUpDown(axis: JoystickAxis): void;
  39693. private _drawVirtualJoystick;
  39694. /**
  39695. * Release internal HTML canvas
  39696. */
  39697. releaseCanvas(): void;
  39698. }
  39699. }
  39700. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39701. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39702. import { Nullable } from "babylonjs/types";
  39703. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39704. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39705. module "babylonjs/Cameras/freeCameraInputsManager" {
  39706. interface FreeCameraInputsManager {
  39707. /**
  39708. * Add virtual joystick input support to the input manager.
  39709. * @returns the current input manager
  39710. */
  39711. addVirtualJoystick(): FreeCameraInputsManager;
  39712. }
  39713. }
  39714. /**
  39715. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39717. */
  39718. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39719. /**
  39720. * Defines the camera the input is attached to.
  39721. */
  39722. camera: FreeCamera;
  39723. private _leftjoystick;
  39724. private _rightjoystick;
  39725. /**
  39726. * Gets the left stick of the virtual joystick.
  39727. * @returns The virtual Joystick
  39728. */
  39729. getLeftJoystick(): VirtualJoystick;
  39730. /**
  39731. * Gets the right stick of the virtual joystick.
  39732. * @returns The virtual Joystick
  39733. */
  39734. getRightJoystick(): VirtualJoystick;
  39735. /**
  39736. * Update the current camera state depending on the inputs that have been used this frame.
  39737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39738. */
  39739. checkInputs(): void;
  39740. /**
  39741. * Attach the input controls to a specific dom element to get the input from.
  39742. * @param element Defines the element the controls should be listened from
  39743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39744. */
  39745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39746. /**
  39747. * Detach the current controls from the specified dom element.
  39748. * @param element Defines the element to stop listening the inputs from
  39749. */
  39750. detachControl(element: Nullable<HTMLElement>): void;
  39751. /**
  39752. * Gets the class name of the current intput.
  39753. * @returns the class name
  39754. */
  39755. getClassName(): string;
  39756. /**
  39757. * Get the friendly name associated with the input class.
  39758. * @returns the input friendly name
  39759. */
  39760. getSimpleName(): string;
  39761. }
  39762. }
  39763. declare module "babylonjs/Cameras/Inputs/index" {
  39764. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39765. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39766. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39767. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39768. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39769. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39770. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39771. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39772. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39773. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39774. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39775. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39776. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39777. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39778. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39779. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39780. }
  39781. declare module "babylonjs/Cameras/touchCamera" {
  39782. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39783. import { Scene } from "babylonjs/scene";
  39784. import { Vector3 } from "babylonjs/Maths/math.vector";
  39785. /**
  39786. * This represents a FPS type of camera controlled by touch.
  39787. * This is like a universal camera minus the Gamepad controls.
  39788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39789. */
  39790. export class TouchCamera extends FreeCamera {
  39791. /**
  39792. * Defines the touch sensibility for rotation.
  39793. * The higher the faster.
  39794. */
  39795. touchAngularSensibility: number;
  39796. /**
  39797. * Defines the touch sensibility for move.
  39798. * The higher the faster.
  39799. */
  39800. touchMoveSensibility: number;
  39801. /**
  39802. * Instantiates a new touch camera.
  39803. * This represents a FPS type of camera controlled by touch.
  39804. * This is like a universal camera minus the Gamepad controls.
  39805. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39806. * @param name Define the name of the camera in the scene
  39807. * @param position Define the start position of the camera in the scene
  39808. * @param scene Define the scene the camera belongs to
  39809. */
  39810. constructor(name: string, position: Vector3, scene: Scene);
  39811. /**
  39812. * Gets the current object class name.
  39813. * @return the class name
  39814. */
  39815. getClassName(): string;
  39816. /** @hidden */
  39817. _setupInputs(): void;
  39818. }
  39819. }
  39820. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39821. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39822. import { Scene } from "babylonjs/scene";
  39823. import { Vector3 } from "babylonjs/Maths/math.vector";
  39824. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39825. import { Axis } from "babylonjs/Maths/math.axis";
  39826. /**
  39827. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39828. * being tilted forward or back and left or right.
  39829. */
  39830. export class DeviceOrientationCamera extends FreeCamera {
  39831. private _initialQuaternion;
  39832. private _quaternionCache;
  39833. private _tmpDragQuaternion;
  39834. private _disablePointerInputWhenUsingDeviceOrientation;
  39835. /**
  39836. * Creates a new device orientation camera
  39837. * @param name The name of the camera
  39838. * @param position The start position camera
  39839. * @param scene The scene the camera belongs to
  39840. */
  39841. constructor(name: string, position: Vector3, scene: Scene);
  39842. /**
  39843. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39844. */
  39845. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39846. private _dragFactor;
  39847. /**
  39848. * Enabled turning on the y axis when the orientation sensor is active
  39849. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39850. */
  39851. enableHorizontalDragging(dragFactor?: number): void;
  39852. /**
  39853. * Gets the current instance class name ("DeviceOrientationCamera").
  39854. * This helps avoiding instanceof at run time.
  39855. * @returns the class name
  39856. */
  39857. getClassName(): string;
  39858. /**
  39859. * @hidden
  39860. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39861. */
  39862. _checkInputs(): void;
  39863. /**
  39864. * Reset the camera to its default orientation on the specified axis only.
  39865. * @param axis The axis to reset
  39866. */
  39867. resetToCurrentRotation(axis?: Axis): void;
  39868. }
  39869. }
  39870. declare module "babylonjs/Gamepads/xboxGamepad" {
  39871. import { Observable } from "babylonjs/Misc/observable";
  39872. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39873. /**
  39874. * Defines supported buttons for XBox360 compatible gamepads
  39875. */
  39876. export enum Xbox360Button {
  39877. /** A */
  39878. A = 0,
  39879. /** B */
  39880. B = 1,
  39881. /** X */
  39882. X = 2,
  39883. /** Y */
  39884. Y = 3,
  39885. /** Start */
  39886. Start = 4,
  39887. /** Back */
  39888. Back = 5,
  39889. /** Left button */
  39890. LB = 6,
  39891. /** Right button */
  39892. RB = 7,
  39893. /** Left stick */
  39894. LeftStick = 8,
  39895. /** Right stick */
  39896. RightStick = 9
  39897. }
  39898. /** Defines values for XBox360 DPad */
  39899. export enum Xbox360Dpad {
  39900. /** Up */
  39901. Up = 0,
  39902. /** Down */
  39903. Down = 1,
  39904. /** Left */
  39905. Left = 2,
  39906. /** Right */
  39907. Right = 3
  39908. }
  39909. /**
  39910. * Defines a XBox360 gamepad
  39911. */
  39912. export class Xbox360Pad extends Gamepad {
  39913. private _leftTrigger;
  39914. private _rightTrigger;
  39915. private _onlefttriggerchanged;
  39916. private _onrighttriggerchanged;
  39917. private _onbuttondown;
  39918. private _onbuttonup;
  39919. private _ondpaddown;
  39920. private _ondpadup;
  39921. /** Observable raised when a button is pressed */
  39922. onButtonDownObservable: Observable<Xbox360Button>;
  39923. /** Observable raised when a button is released */
  39924. onButtonUpObservable: Observable<Xbox360Button>;
  39925. /** Observable raised when a pad is pressed */
  39926. onPadDownObservable: Observable<Xbox360Dpad>;
  39927. /** Observable raised when a pad is released */
  39928. onPadUpObservable: Observable<Xbox360Dpad>;
  39929. private _buttonA;
  39930. private _buttonB;
  39931. private _buttonX;
  39932. private _buttonY;
  39933. private _buttonBack;
  39934. private _buttonStart;
  39935. private _buttonLB;
  39936. private _buttonRB;
  39937. private _buttonLeftStick;
  39938. private _buttonRightStick;
  39939. private _dPadUp;
  39940. private _dPadDown;
  39941. private _dPadLeft;
  39942. private _dPadRight;
  39943. private _isXboxOnePad;
  39944. /**
  39945. * Creates a new XBox360 gamepad object
  39946. * @param id defines the id of this gamepad
  39947. * @param index defines its index
  39948. * @param gamepad defines the internal HTML gamepad object
  39949. * @param xboxOne defines if it is a XBox One gamepad
  39950. */
  39951. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39952. /**
  39953. * Defines the callback to call when left trigger is pressed
  39954. * @param callback defines the callback to use
  39955. */
  39956. onlefttriggerchanged(callback: (value: number) => void): void;
  39957. /**
  39958. * Defines the callback to call when right trigger is pressed
  39959. * @param callback defines the callback to use
  39960. */
  39961. onrighttriggerchanged(callback: (value: number) => void): void;
  39962. /**
  39963. * Gets the left trigger value
  39964. */
  39965. /**
  39966. * Sets the left trigger value
  39967. */
  39968. leftTrigger: number;
  39969. /**
  39970. * Gets the right trigger value
  39971. */
  39972. /**
  39973. * Sets the right trigger value
  39974. */
  39975. rightTrigger: number;
  39976. /**
  39977. * Defines the callback to call when a button is pressed
  39978. * @param callback defines the callback to use
  39979. */
  39980. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39981. /**
  39982. * Defines the callback to call when a button is released
  39983. * @param callback defines the callback to use
  39984. */
  39985. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39986. /**
  39987. * Defines the callback to call when a pad is pressed
  39988. * @param callback defines the callback to use
  39989. */
  39990. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39991. /**
  39992. * Defines the callback to call when a pad is released
  39993. * @param callback defines the callback to use
  39994. */
  39995. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39996. private _setButtonValue;
  39997. private _setDPadValue;
  39998. /**
  39999. * Gets the value of the `A` button
  40000. */
  40001. /**
  40002. * Sets the value of the `A` button
  40003. */
  40004. buttonA: number;
  40005. /**
  40006. * Gets the value of the `B` button
  40007. */
  40008. /**
  40009. * Sets the value of the `B` button
  40010. */
  40011. buttonB: number;
  40012. /**
  40013. * Gets the value of the `X` button
  40014. */
  40015. /**
  40016. * Sets the value of the `X` button
  40017. */
  40018. buttonX: number;
  40019. /**
  40020. * Gets the value of the `Y` button
  40021. */
  40022. /**
  40023. * Sets the value of the `Y` button
  40024. */
  40025. buttonY: number;
  40026. /**
  40027. * Gets the value of the `Start` button
  40028. */
  40029. /**
  40030. * Sets the value of the `Start` button
  40031. */
  40032. buttonStart: number;
  40033. /**
  40034. * Gets the value of the `Back` button
  40035. */
  40036. /**
  40037. * Sets the value of the `Back` button
  40038. */
  40039. buttonBack: number;
  40040. /**
  40041. * Gets the value of the `Left` button
  40042. */
  40043. /**
  40044. * Sets the value of the `Left` button
  40045. */
  40046. buttonLB: number;
  40047. /**
  40048. * Gets the value of the `Right` button
  40049. */
  40050. /**
  40051. * Sets the value of the `Right` button
  40052. */
  40053. buttonRB: number;
  40054. /**
  40055. * Gets the value of the Left joystick
  40056. */
  40057. /**
  40058. * Sets the value of the Left joystick
  40059. */
  40060. buttonLeftStick: number;
  40061. /**
  40062. * Gets the value of the Right joystick
  40063. */
  40064. /**
  40065. * Sets the value of the Right joystick
  40066. */
  40067. buttonRightStick: number;
  40068. /**
  40069. * Gets the value of D-pad up
  40070. */
  40071. /**
  40072. * Sets the value of D-pad up
  40073. */
  40074. dPadUp: number;
  40075. /**
  40076. * Gets the value of D-pad down
  40077. */
  40078. /**
  40079. * Sets the value of D-pad down
  40080. */
  40081. dPadDown: number;
  40082. /**
  40083. * Gets the value of D-pad left
  40084. */
  40085. /**
  40086. * Sets the value of D-pad left
  40087. */
  40088. dPadLeft: number;
  40089. /**
  40090. * Gets the value of D-pad right
  40091. */
  40092. /**
  40093. * Sets the value of D-pad right
  40094. */
  40095. dPadRight: number;
  40096. /**
  40097. * Force the gamepad to synchronize with device values
  40098. */
  40099. update(): void;
  40100. /**
  40101. * Disposes the gamepad
  40102. */
  40103. dispose(): void;
  40104. }
  40105. }
  40106. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40107. import { Observable } from "babylonjs/Misc/observable";
  40108. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40109. /**
  40110. * Defines supported buttons for DualShock compatible gamepads
  40111. */
  40112. export enum DualShockButton {
  40113. /** Cross */
  40114. Cross = 0,
  40115. /** Circle */
  40116. Circle = 1,
  40117. /** Square */
  40118. Square = 2,
  40119. /** Triangle */
  40120. Triangle = 3,
  40121. /** Options */
  40122. Options = 4,
  40123. /** Share */
  40124. Share = 5,
  40125. /** L1 */
  40126. L1 = 6,
  40127. /** R1 */
  40128. R1 = 7,
  40129. /** Left stick */
  40130. LeftStick = 8,
  40131. /** Right stick */
  40132. RightStick = 9
  40133. }
  40134. /** Defines values for DualShock DPad */
  40135. export enum DualShockDpad {
  40136. /** Up */
  40137. Up = 0,
  40138. /** Down */
  40139. Down = 1,
  40140. /** Left */
  40141. Left = 2,
  40142. /** Right */
  40143. Right = 3
  40144. }
  40145. /**
  40146. * Defines a DualShock gamepad
  40147. */
  40148. export class DualShockPad extends Gamepad {
  40149. private _leftTrigger;
  40150. private _rightTrigger;
  40151. private _onlefttriggerchanged;
  40152. private _onrighttriggerchanged;
  40153. private _onbuttondown;
  40154. private _onbuttonup;
  40155. private _ondpaddown;
  40156. private _ondpadup;
  40157. /** Observable raised when a button is pressed */
  40158. onButtonDownObservable: Observable<DualShockButton>;
  40159. /** Observable raised when a button is released */
  40160. onButtonUpObservable: Observable<DualShockButton>;
  40161. /** Observable raised when a pad is pressed */
  40162. onPadDownObservable: Observable<DualShockDpad>;
  40163. /** Observable raised when a pad is released */
  40164. onPadUpObservable: Observable<DualShockDpad>;
  40165. private _buttonCross;
  40166. private _buttonCircle;
  40167. private _buttonSquare;
  40168. private _buttonTriangle;
  40169. private _buttonShare;
  40170. private _buttonOptions;
  40171. private _buttonL1;
  40172. private _buttonR1;
  40173. private _buttonLeftStick;
  40174. private _buttonRightStick;
  40175. private _dPadUp;
  40176. private _dPadDown;
  40177. private _dPadLeft;
  40178. private _dPadRight;
  40179. /**
  40180. * Creates a new DualShock gamepad object
  40181. * @param id defines the id of this gamepad
  40182. * @param index defines its index
  40183. * @param gamepad defines the internal HTML gamepad object
  40184. */
  40185. constructor(id: string, index: number, gamepad: any);
  40186. /**
  40187. * Defines the callback to call when left trigger is pressed
  40188. * @param callback defines the callback to use
  40189. */
  40190. onlefttriggerchanged(callback: (value: number) => void): void;
  40191. /**
  40192. * Defines the callback to call when right trigger is pressed
  40193. * @param callback defines the callback to use
  40194. */
  40195. onrighttriggerchanged(callback: (value: number) => void): void;
  40196. /**
  40197. * Gets the left trigger value
  40198. */
  40199. /**
  40200. * Sets the left trigger value
  40201. */
  40202. leftTrigger: number;
  40203. /**
  40204. * Gets the right trigger value
  40205. */
  40206. /**
  40207. * Sets the right trigger value
  40208. */
  40209. rightTrigger: number;
  40210. /**
  40211. * Defines the callback to call when a button is pressed
  40212. * @param callback defines the callback to use
  40213. */
  40214. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40215. /**
  40216. * Defines the callback to call when a button is released
  40217. * @param callback defines the callback to use
  40218. */
  40219. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40220. /**
  40221. * Defines the callback to call when a pad is pressed
  40222. * @param callback defines the callback to use
  40223. */
  40224. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40225. /**
  40226. * Defines the callback to call when a pad is released
  40227. * @param callback defines the callback to use
  40228. */
  40229. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40230. private _setButtonValue;
  40231. private _setDPadValue;
  40232. /**
  40233. * Gets the value of the `Cross` button
  40234. */
  40235. /**
  40236. * Sets the value of the `Cross` button
  40237. */
  40238. buttonCross: number;
  40239. /**
  40240. * Gets the value of the `Circle` button
  40241. */
  40242. /**
  40243. * Sets the value of the `Circle` button
  40244. */
  40245. buttonCircle: number;
  40246. /**
  40247. * Gets the value of the `Square` button
  40248. */
  40249. /**
  40250. * Sets the value of the `Square` button
  40251. */
  40252. buttonSquare: number;
  40253. /**
  40254. * Gets the value of the `Triangle` button
  40255. */
  40256. /**
  40257. * Sets the value of the `Triangle` button
  40258. */
  40259. buttonTriangle: number;
  40260. /**
  40261. * Gets the value of the `Options` button
  40262. */
  40263. /**
  40264. * Sets the value of the `Options` button
  40265. */
  40266. buttonOptions: number;
  40267. /**
  40268. * Gets the value of the `Share` button
  40269. */
  40270. /**
  40271. * Sets the value of the `Share` button
  40272. */
  40273. buttonShare: number;
  40274. /**
  40275. * Gets the value of the `L1` button
  40276. */
  40277. /**
  40278. * Sets the value of the `L1` button
  40279. */
  40280. buttonL1: number;
  40281. /**
  40282. * Gets the value of the `R1` button
  40283. */
  40284. /**
  40285. * Sets the value of the `R1` button
  40286. */
  40287. buttonR1: number;
  40288. /**
  40289. * Gets the value of the Left joystick
  40290. */
  40291. /**
  40292. * Sets the value of the Left joystick
  40293. */
  40294. buttonLeftStick: number;
  40295. /**
  40296. * Gets the value of the Right joystick
  40297. */
  40298. /**
  40299. * Sets the value of the Right joystick
  40300. */
  40301. buttonRightStick: number;
  40302. /**
  40303. * Gets the value of D-pad up
  40304. */
  40305. /**
  40306. * Sets the value of D-pad up
  40307. */
  40308. dPadUp: number;
  40309. /**
  40310. * Gets the value of D-pad down
  40311. */
  40312. /**
  40313. * Sets the value of D-pad down
  40314. */
  40315. dPadDown: number;
  40316. /**
  40317. * Gets the value of D-pad left
  40318. */
  40319. /**
  40320. * Sets the value of D-pad left
  40321. */
  40322. dPadLeft: number;
  40323. /**
  40324. * Gets the value of D-pad right
  40325. */
  40326. /**
  40327. * Sets the value of D-pad right
  40328. */
  40329. dPadRight: number;
  40330. /**
  40331. * Force the gamepad to synchronize with device values
  40332. */
  40333. update(): void;
  40334. /**
  40335. * Disposes the gamepad
  40336. */
  40337. dispose(): void;
  40338. }
  40339. }
  40340. declare module "babylonjs/Gamepads/gamepadManager" {
  40341. import { Observable } from "babylonjs/Misc/observable";
  40342. import { Nullable } from "babylonjs/types";
  40343. import { Scene } from "babylonjs/scene";
  40344. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40345. /**
  40346. * Manager for handling gamepads
  40347. */
  40348. export class GamepadManager {
  40349. private _scene?;
  40350. private _babylonGamepads;
  40351. private _oneGamepadConnected;
  40352. /** @hidden */
  40353. _isMonitoring: boolean;
  40354. private _gamepadEventSupported;
  40355. private _gamepadSupport;
  40356. /**
  40357. * observable to be triggered when the gamepad controller has been connected
  40358. */
  40359. onGamepadConnectedObservable: Observable<Gamepad>;
  40360. /**
  40361. * observable to be triggered when the gamepad controller has been disconnected
  40362. */
  40363. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40364. private _onGamepadConnectedEvent;
  40365. private _onGamepadDisconnectedEvent;
  40366. /**
  40367. * Initializes the gamepad manager
  40368. * @param _scene BabylonJS scene
  40369. */
  40370. constructor(_scene?: Scene | undefined);
  40371. /**
  40372. * The gamepads in the game pad manager
  40373. */
  40374. readonly gamepads: Gamepad[];
  40375. /**
  40376. * Get the gamepad controllers based on type
  40377. * @param type The type of gamepad controller
  40378. * @returns Nullable gamepad
  40379. */
  40380. getGamepadByType(type?: number): Nullable<Gamepad>;
  40381. /**
  40382. * Disposes the gamepad manager
  40383. */
  40384. dispose(): void;
  40385. private _addNewGamepad;
  40386. private _startMonitoringGamepads;
  40387. private _stopMonitoringGamepads;
  40388. /** @hidden */
  40389. _checkGamepadsStatus(): void;
  40390. private _updateGamepadObjects;
  40391. }
  40392. }
  40393. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40394. import { Nullable } from "babylonjs/types";
  40395. import { Scene } from "babylonjs/scene";
  40396. import { ISceneComponent } from "babylonjs/sceneComponent";
  40397. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40398. module "babylonjs/scene" {
  40399. interface Scene {
  40400. /** @hidden */
  40401. _gamepadManager: Nullable<GamepadManager>;
  40402. /**
  40403. * Gets the gamepad manager associated with the scene
  40404. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40405. */
  40406. gamepadManager: GamepadManager;
  40407. }
  40408. }
  40409. module "babylonjs/Cameras/freeCameraInputsManager" {
  40410. /**
  40411. * Interface representing a free camera inputs manager
  40412. */
  40413. interface FreeCameraInputsManager {
  40414. /**
  40415. * Adds gamepad input support to the FreeCameraInputsManager.
  40416. * @returns the FreeCameraInputsManager
  40417. */
  40418. addGamepad(): FreeCameraInputsManager;
  40419. }
  40420. }
  40421. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40422. /**
  40423. * Interface representing an arc rotate camera inputs manager
  40424. */
  40425. interface ArcRotateCameraInputsManager {
  40426. /**
  40427. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40428. * @returns the camera inputs manager
  40429. */
  40430. addGamepad(): ArcRotateCameraInputsManager;
  40431. }
  40432. }
  40433. /**
  40434. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40435. */
  40436. export class GamepadSystemSceneComponent implements ISceneComponent {
  40437. /**
  40438. * The component name helpfull to identify the component in the list of scene components.
  40439. */
  40440. readonly name: string;
  40441. /**
  40442. * The scene the component belongs to.
  40443. */
  40444. scene: Scene;
  40445. /**
  40446. * Creates a new instance of the component for the given scene
  40447. * @param scene Defines the scene to register the component in
  40448. */
  40449. constructor(scene: Scene);
  40450. /**
  40451. * Registers the component in a given scene
  40452. */
  40453. register(): void;
  40454. /**
  40455. * Rebuilds the elements related to this component in case of
  40456. * context lost for instance.
  40457. */
  40458. rebuild(): void;
  40459. /**
  40460. * Disposes the component and the associated ressources
  40461. */
  40462. dispose(): void;
  40463. private _beforeCameraUpdate;
  40464. }
  40465. }
  40466. declare module "babylonjs/Cameras/universalCamera" {
  40467. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40468. import { Scene } from "babylonjs/scene";
  40469. import { Vector3 } from "babylonjs/Maths/math.vector";
  40470. import "babylonjs/Gamepads/gamepadSceneComponent";
  40471. /**
  40472. * 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,
  40473. * which still works and will still be found in many Playgrounds.
  40474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40475. */
  40476. export class UniversalCamera extends TouchCamera {
  40477. /**
  40478. * Defines the gamepad rotation sensiblity.
  40479. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40480. */
  40481. gamepadAngularSensibility: number;
  40482. /**
  40483. * Defines the gamepad move sensiblity.
  40484. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40485. */
  40486. gamepadMoveSensibility: number;
  40487. /**
  40488. * 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,
  40489. * which still works and will still be found in many Playgrounds.
  40490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40491. * @param name Define the name of the camera in the scene
  40492. * @param position Define the start position of the camera in the scene
  40493. * @param scene Define the scene the camera belongs to
  40494. */
  40495. constructor(name: string, position: Vector3, scene: Scene);
  40496. /**
  40497. * Gets the current object class name.
  40498. * @return the class name
  40499. */
  40500. getClassName(): string;
  40501. }
  40502. }
  40503. declare module "babylonjs/Cameras/gamepadCamera" {
  40504. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40505. import { Scene } from "babylonjs/scene";
  40506. import { Vector3 } from "babylonjs/Maths/math.vector";
  40507. /**
  40508. * This represents a FPS type of camera. This is only here for back compat purpose.
  40509. * Please use the UniversalCamera instead as both are identical.
  40510. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40511. */
  40512. export class GamepadCamera extends UniversalCamera {
  40513. /**
  40514. * Instantiates a new Gamepad Camera
  40515. * This represents a FPS type of camera. This is only here for back compat purpose.
  40516. * Please use the UniversalCamera instead as both are identical.
  40517. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40518. * @param name Define the name of the camera in the scene
  40519. * @param position Define the start position of the camera in the scene
  40520. * @param scene Define the scene the camera belongs to
  40521. */
  40522. constructor(name: string, position: Vector3, scene: Scene);
  40523. /**
  40524. * Gets the current object class name.
  40525. * @return the class name
  40526. */
  40527. getClassName(): string;
  40528. }
  40529. }
  40530. declare module "babylonjs/Shaders/pass.fragment" {
  40531. /** @hidden */
  40532. export var passPixelShader: {
  40533. name: string;
  40534. shader: string;
  40535. };
  40536. }
  40537. declare module "babylonjs/Shaders/passCube.fragment" {
  40538. /** @hidden */
  40539. export var passCubePixelShader: {
  40540. name: string;
  40541. shader: string;
  40542. };
  40543. }
  40544. declare module "babylonjs/PostProcesses/passPostProcess" {
  40545. import { Nullable } from "babylonjs/types";
  40546. import { Camera } from "babylonjs/Cameras/camera";
  40547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40548. import { Engine } from "babylonjs/Engines/engine";
  40549. import "babylonjs/Shaders/pass.fragment";
  40550. import "babylonjs/Shaders/passCube.fragment";
  40551. /**
  40552. * PassPostProcess which produces an output the same as it's input
  40553. */
  40554. export class PassPostProcess extends PostProcess {
  40555. /**
  40556. * Creates the PassPostProcess
  40557. * @param name The name of the effect.
  40558. * @param options The required width/height ratio to downsize to before computing the render pass.
  40559. * @param camera The camera to apply the render pass to.
  40560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40561. * @param engine The engine which the post process will be applied. (default: current engine)
  40562. * @param reusable If the post process can be reused on the same frame. (default: false)
  40563. * @param textureType The type of texture to be used when performing the post processing.
  40564. * @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)
  40565. */
  40566. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40567. }
  40568. /**
  40569. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40570. */
  40571. export class PassCubePostProcess extends PostProcess {
  40572. private _face;
  40573. /**
  40574. * Gets or sets the cube face to display.
  40575. * * 0 is +X
  40576. * * 1 is -X
  40577. * * 2 is +Y
  40578. * * 3 is -Y
  40579. * * 4 is +Z
  40580. * * 5 is -Z
  40581. */
  40582. face: number;
  40583. /**
  40584. * Creates the PassCubePostProcess
  40585. * @param name The name of the effect.
  40586. * @param options The required width/height ratio to downsize to before computing the render pass.
  40587. * @param camera The camera to apply the render pass to.
  40588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40589. * @param engine The engine which the post process will be applied. (default: current engine)
  40590. * @param reusable If the post process can be reused on the same frame. (default: false)
  40591. * @param textureType The type of texture to be used when performing the post processing.
  40592. * @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)
  40593. */
  40594. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40595. }
  40596. }
  40597. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40598. /** @hidden */
  40599. export var anaglyphPixelShader: {
  40600. name: string;
  40601. shader: string;
  40602. };
  40603. }
  40604. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40605. import { Engine } from "babylonjs/Engines/engine";
  40606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40607. import { Camera } from "babylonjs/Cameras/camera";
  40608. import "babylonjs/Shaders/anaglyph.fragment";
  40609. /**
  40610. * Postprocess used to generate anaglyphic rendering
  40611. */
  40612. export class AnaglyphPostProcess extends PostProcess {
  40613. private _passedProcess;
  40614. /**
  40615. * Creates a new AnaglyphPostProcess
  40616. * @param name defines postprocess name
  40617. * @param options defines creation options or target ratio scale
  40618. * @param rigCameras defines cameras using this postprocess
  40619. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40620. * @param engine defines hosting engine
  40621. * @param reusable defines if the postprocess will be reused multiple times per frame
  40622. */
  40623. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40624. }
  40625. }
  40626. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40627. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40629. import { Scene } from "babylonjs/scene";
  40630. import { Vector3 } from "babylonjs/Maths/math.vector";
  40631. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40632. /**
  40633. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40634. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40635. */
  40636. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40637. /**
  40638. * Creates a new AnaglyphArcRotateCamera
  40639. * @param name defines camera name
  40640. * @param alpha defines alpha angle (in radians)
  40641. * @param beta defines beta angle (in radians)
  40642. * @param radius defines radius
  40643. * @param target defines camera target
  40644. * @param interaxialDistance defines distance between each color axis
  40645. * @param scene defines the hosting scene
  40646. */
  40647. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40648. /**
  40649. * Gets camera class name
  40650. * @returns AnaglyphArcRotateCamera
  40651. */
  40652. getClassName(): string;
  40653. }
  40654. }
  40655. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40657. import { Scene } from "babylonjs/scene";
  40658. import { Vector3 } from "babylonjs/Maths/math.vector";
  40659. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40660. /**
  40661. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40662. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40663. */
  40664. export class AnaglyphFreeCamera extends FreeCamera {
  40665. /**
  40666. * Creates a new AnaglyphFreeCamera
  40667. * @param name defines camera name
  40668. * @param position defines initial position
  40669. * @param interaxialDistance defines distance between each color axis
  40670. * @param scene defines the hosting scene
  40671. */
  40672. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40673. /**
  40674. * Gets camera class name
  40675. * @returns AnaglyphFreeCamera
  40676. */
  40677. getClassName(): string;
  40678. }
  40679. }
  40680. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40681. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40682. import { Scene } from "babylonjs/scene";
  40683. import { Vector3 } from "babylonjs/Maths/math.vector";
  40684. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40685. /**
  40686. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40687. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40688. */
  40689. export class AnaglyphGamepadCamera extends GamepadCamera {
  40690. /**
  40691. * Creates a new AnaglyphGamepadCamera
  40692. * @param name defines camera name
  40693. * @param position defines initial position
  40694. * @param interaxialDistance defines distance between each color axis
  40695. * @param scene defines the hosting scene
  40696. */
  40697. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40698. /**
  40699. * Gets camera class name
  40700. * @returns AnaglyphGamepadCamera
  40701. */
  40702. getClassName(): string;
  40703. }
  40704. }
  40705. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40706. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40707. import { Scene } from "babylonjs/scene";
  40708. import { Vector3 } from "babylonjs/Maths/math.vector";
  40709. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40710. /**
  40711. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40712. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40713. */
  40714. export class AnaglyphUniversalCamera extends UniversalCamera {
  40715. /**
  40716. * Creates a new AnaglyphUniversalCamera
  40717. * @param name defines camera name
  40718. * @param position defines initial position
  40719. * @param interaxialDistance defines distance between each color axis
  40720. * @param scene defines the hosting scene
  40721. */
  40722. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40723. /**
  40724. * Gets camera class name
  40725. * @returns AnaglyphUniversalCamera
  40726. */
  40727. getClassName(): string;
  40728. }
  40729. }
  40730. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40731. /** @hidden */
  40732. export var stereoscopicInterlacePixelShader: {
  40733. name: string;
  40734. shader: string;
  40735. };
  40736. }
  40737. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40738. import { Camera } from "babylonjs/Cameras/camera";
  40739. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40740. import { Engine } from "babylonjs/Engines/engine";
  40741. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40742. /**
  40743. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40744. */
  40745. export class StereoscopicInterlacePostProcess extends PostProcess {
  40746. private _stepSize;
  40747. private _passedProcess;
  40748. /**
  40749. * Initializes a StereoscopicInterlacePostProcess
  40750. * @param name The name of the effect.
  40751. * @param rigCameras The rig cameras to be appled to the post process
  40752. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40754. * @param engine The engine which the post process will be applied. (default: current engine)
  40755. * @param reusable If the post process can be reused on the same frame. (default: false)
  40756. */
  40757. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40758. }
  40759. }
  40760. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40761. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40763. import { Scene } from "babylonjs/scene";
  40764. import { Vector3 } from "babylonjs/Maths/math.vector";
  40765. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40766. /**
  40767. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40768. * @see http://doc.babylonjs.com/features/cameras
  40769. */
  40770. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40771. /**
  40772. * Creates a new StereoscopicArcRotateCamera
  40773. * @param name defines camera name
  40774. * @param alpha defines alpha angle (in radians)
  40775. * @param beta defines beta angle (in radians)
  40776. * @param radius defines radius
  40777. * @param target defines camera target
  40778. * @param interaxialDistance defines distance between each color axis
  40779. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40780. * @param scene defines the hosting scene
  40781. */
  40782. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40783. /**
  40784. * Gets camera class name
  40785. * @returns StereoscopicArcRotateCamera
  40786. */
  40787. getClassName(): string;
  40788. }
  40789. }
  40790. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40791. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40792. import { Scene } from "babylonjs/scene";
  40793. import { Vector3 } from "babylonjs/Maths/math.vector";
  40794. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40795. /**
  40796. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40797. * @see http://doc.babylonjs.com/features/cameras
  40798. */
  40799. export class StereoscopicFreeCamera extends FreeCamera {
  40800. /**
  40801. * Creates a new StereoscopicFreeCamera
  40802. * @param name defines camera name
  40803. * @param position defines initial position
  40804. * @param interaxialDistance defines distance between each color axis
  40805. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40806. * @param scene defines the hosting scene
  40807. */
  40808. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40809. /**
  40810. * Gets camera class name
  40811. * @returns StereoscopicFreeCamera
  40812. */
  40813. getClassName(): string;
  40814. }
  40815. }
  40816. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40817. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40818. import { Scene } from "babylonjs/scene";
  40819. import { Vector3 } from "babylonjs/Maths/math.vector";
  40820. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40821. /**
  40822. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40823. * @see http://doc.babylonjs.com/features/cameras
  40824. */
  40825. export class StereoscopicGamepadCamera extends GamepadCamera {
  40826. /**
  40827. * Creates a new StereoscopicGamepadCamera
  40828. * @param name defines camera name
  40829. * @param position defines initial position
  40830. * @param interaxialDistance defines distance between each color axis
  40831. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40832. * @param scene defines the hosting scene
  40833. */
  40834. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40835. /**
  40836. * Gets camera class name
  40837. * @returns StereoscopicGamepadCamera
  40838. */
  40839. getClassName(): string;
  40840. }
  40841. }
  40842. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40843. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40844. import { Scene } from "babylonjs/scene";
  40845. import { Vector3 } from "babylonjs/Maths/math.vector";
  40846. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40847. /**
  40848. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40849. * @see http://doc.babylonjs.com/features/cameras
  40850. */
  40851. export class StereoscopicUniversalCamera extends UniversalCamera {
  40852. /**
  40853. * Creates a new StereoscopicUniversalCamera
  40854. * @param name defines camera name
  40855. * @param position defines initial position
  40856. * @param interaxialDistance defines distance between each color axis
  40857. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40858. * @param scene defines the hosting scene
  40859. */
  40860. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40861. /**
  40862. * Gets camera class name
  40863. * @returns StereoscopicUniversalCamera
  40864. */
  40865. getClassName(): string;
  40866. }
  40867. }
  40868. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40869. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40870. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40871. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40872. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40873. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40874. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40875. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40876. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40877. }
  40878. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40879. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40880. import { Scene } from "babylonjs/scene";
  40881. import { Vector3 } from "babylonjs/Maths/math.vector";
  40882. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40883. /**
  40884. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40885. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40886. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40887. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40888. */
  40889. export class VirtualJoysticksCamera extends FreeCamera {
  40890. /**
  40891. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40892. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40893. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40894. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40895. * @param name Define the name of the camera in the scene
  40896. * @param position Define the start position of the camera in the scene
  40897. * @param scene Define the scene the camera belongs to
  40898. */
  40899. constructor(name: string, position: Vector3, scene: Scene);
  40900. /**
  40901. * Gets the current object class name.
  40902. * @return the class name
  40903. */
  40904. getClassName(): string;
  40905. }
  40906. }
  40907. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40908. import { Matrix } from "babylonjs/Maths/math.vector";
  40909. /**
  40910. * This represents all the required metrics to create a VR camera.
  40911. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40912. */
  40913. export class VRCameraMetrics {
  40914. /**
  40915. * Define the horizontal resolution off the screen.
  40916. */
  40917. hResolution: number;
  40918. /**
  40919. * Define the vertical resolution off the screen.
  40920. */
  40921. vResolution: number;
  40922. /**
  40923. * Define the horizontal screen size.
  40924. */
  40925. hScreenSize: number;
  40926. /**
  40927. * Define the vertical screen size.
  40928. */
  40929. vScreenSize: number;
  40930. /**
  40931. * Define the vertical screen center position.
  40932. */
  40933. vScreenCenter: number;
  40934. /**
  40935. * Define the distance of the eyes to the screen.
  40936. */
  40937. eyeToScreenDistance: number;
  40938. /**
  40939. * Define the distance between both lenses
  40940. */
  40941. lensSeparationDistance: number;
  40942. /**
  40943. * Define the distance between both viewer's eyes.
  40944. */
  40945. interpupillaryDistance: number;
  40946. /**
  40947. * Define the distortion factor of the VR postprocess.
  40948. * Please, touch with care.
  40949. */
  40950. distortionK: number[];
  40951. /**
  40952. * Define the chromatic aberration correction factors for the VR post process.
  40953. */
  40954. chromaAbCorrection: number[];
  40955. /**
  40956. * Define the scale factor of the post process.
  40957. * The smaller the better but the slower.
  40958. */
  40959. postProcessScaleFactor: number;
  40960. /**
  40961. * Define an offset for the lens center.
  40962. */
  40963. lensCenterOffset: number;
  40964. /**
  40965. * Define if the current vr camera should compensate the distortion of the lense or not.
  40966. */
  40967. compensateDistortion: boolean;
  40968. /**
  40969. * Defines if multiview should be enabled when rendering (Default: false)
  40970. */
  40971. multiviewEnabled: boolean;
  40972. /**
  40973. * Gets the rendering aspect ratio based on the provided resolutions.
  40974. */
  40975. readonly aspectRatio: number;
  40976. /**
  40977. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40978. */
  40979. readonly aspectRatioFov: number;
  40980. /**
  40981. * @hidden
  40982. */
  40983. readonly leftHMatrix: Matrix;
  40984. /**
  40985. * @hidden
  40986. */
  40987. readonly rightHMatrix: Matrix;
  40988. /**
  40989. * @hidden
  40990. */
  40991. readonly leftPreViewMatrix: Matrix;
  40992. /**
  40993. * @hidden
  40994. */
  40995. readonly rightPreViewMatrix: Matrix;
  40996. /**
  40997. * Get the default VRMetrics based on the most generic setup.
  40998. * @returns the default vr metrics
  40999. */
  41000. static GetDefault(): VRCameraMetrics;
  41001. }
  41002. }
  41003. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41004. /** @hidden */
  41005. export var vrDistortionCorrectionPixelShader: {
  41006. name: string;
  41007. shader: string;
  41008. };
  41009. }
  41010. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41011. import { Camera } from "babylonjs/Cameras/camera";
  41012. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41013. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41014. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41015. /**
  41016. * VRDistortionCorrectionPostProcess used for mobile VR
  41017. */
  41018. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41019. private _isRightEye;
  41020. private _distortionFactors;
  41021. private _postProcessScaleFactor;
  41022. private _lensCenterOffset;
  41023. private _scaleIn;
  41024. private _scaleFactor;
  41025. private _lensCenter;
  41026. /**
  41027. * Initializes the VRDistortionCorrectionPostProcess
  41028. * @param name The name of the effect.
  41029. * @param camera The camera to apply the render pass to.
  41030. * @param isRightEye If this is for the right eye distortion
  41031. * @param vrMetrics All the required metrics for the VR camera
  41032. */
  41033. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41034. }
  41035. }
  41036. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41037. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41038. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41039. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41040. import { Scene } from "babylonjs/scene";
  41041. import { Vector3 } from "babylonjs/Maths/math.vector";
  41042. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41043. import "babylonjs/Cameras/RigModes/vrRigMode";
  41044. /**
  41045. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41046. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41047. */
  41048. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41049. /**
  41050. * Creates a new VRDeviceOrientationArcRotateCamera
  41051. * @param name defines camera name
  41052. * @param alpha defines the camera rotation along the logitudinal axis
  41053. * @param beta defines the camera rotation along the latitudinal axis
  41054. * @param radius defines the camera distance from its target
  41055. * @param target defines the camera target
  41056. * @param scene defines the scene the camera belongs to
  41057. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41058. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41059. */
  41060. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41061. /**
  41062. * Gets camera class name
  41063. * @returns VRDeviceOrientationArcRotateCamera
  41064. */
  41065. getClassName(): string;
  41066. }
  41067. }
  41068. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41069. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41070. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41071. import { Scene } from "babylonjs/scene";
  41072. import { Vector3 } from "babylonjs/Maths/math.vector";
  41073. import "babylonjs/Cameras/RigModes/vrRigMode";
  41074. /**
  41075. * Camera used to simulate VR rendering (based on FreeCamera)
  41076. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41077. */
  41078. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41079. /**
  41080. * Creates a new VRDeviceOrientationFreeCamera
  41081. * @param name defines camera name
  41082. * @param position defines the start position of the camera
  41083. * @param scene defines the scene the camera belongs to
  41084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41086. */
  41087. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41088. /**
  41089. * Gets camera class name
  41090. * @returns VRDeviceOrientationFreeCamera
  41091. */
  41092. getClassName(): string;
  41093. }
  41094. }
  41095. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41096. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41097. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41098. import { Scene } from "babylonjs/scene";
  41099. import { Vector3 } from "babylonjs/Maths/math.vector";
  41100. import "babylonjs/Gamepads/gamepadSceneComponent";
  41101. /**
  41102. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41103. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41104. */
  41105. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41106. /**
  41107. * Creates a new VRDeviceOrientationGamepadCamera
  41108. * @param name defines camera name
  41109. * @param position defines the start position of the camera
  41110. * @param scene defines the scene the camera belongs to
  41111. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41112. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41113. */
  41114. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41115. /**
  41116. * Gets camera class name
  41117. * @returns VRDeviceOrientationGamepadCamera
  41118. */
  41119. getClassName(): string;
  41120. }
  41121. }
  41122. declare module "babylonjs/Materials/pushMaterial" {
  41123. import { Nullable } from "babylonjs/types";
  41124. import { Scene } from "babylonjs/scene";
  41125. import { Matrix } from "babylonjs/Maths/math.vector";
  41126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41127. import { Mesh } from "babylonjs/Meshes/mesh";
  41128. import { Material } from "babylonjs/Materials/material";
  41129. import { Effect } from "babylonjs/Materials/effect";
  41130. /**
  41131. * Base class of materials working in push mode in babylon JS
  41132. * @hidden
  41133. */
  41134. export class PushMaterial extends Material {
  41135. protected _activeEffect: Effect;
  41136. protected _normalMatrix: Matrix;
  41137. /**
  41138. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41139. * This means that the material can keep using a previous shader while a new one is being compiled.
  41140. * This is mostly used when shader parallel compilation is supported (true by default)
  41141. */
  41142. allowShaderHotSwapping: boolean;
  41143. constructor(name: string, scene: Scene);
  41144. getEffect(): Effect;
  41145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41146. /**
  41147. * Binds the given world matrix to the active effect
  41148. *
  41149. * @param world the matrix to bind
  41150. */
  41151. bindOnlyWorldMatrix(world: Matrix): void;
  41152. /**
  41153. * Binds the given normal matrix to the active effect
  41154. *
  41155. * @param normalMatrix the matrix to bind
  41156. */
  41157. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41158. bind(world: Matrix, mesh?: Mesh): void;
  41159. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41160. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41161. }
  41162. }
  41163. declare module "babylonjs/Materials/materialFlags" {
  41164. /**
  41165. * This groups all the flags used to control the materials channel.
  41166. */
  41167. export class MaterialFlags {
  41168. private static _DiffuseTextureEnabled;
  41169. /**
  41170. * Are diffuse textures enabled in the application.
  41171. */
  41172. static DiffuseTextureEnabled: boolean;
  41173. private static _AmbientTextureEnabled;
  41174. /**
  41175. * Are ambient textures enabled in the application.
  41176. */
  41177. static AmbientTextureEnabled: boolean;
  41178. private static _OpacityTextureEnabled;
  41179. /**
  41180. * Are opacity textures enabled in the application.
  41181. */
  41182. static OpacityTextureEnabled: boolean;
  41183. private static _ReflectionTextureEnabled;
  41184. /**
  41185. * Are reflection textures enabled in the application.
  41186. */
  41187. static ReflectionTextureEnabled: boolean;
  41188. private static _EmissiveTextureEnabled;
  41189. /**
  41190. * Are emissive textures enabled in the application.
  41191. */
  41192. static EmissiveTextureEnabled: boolean;
  41193. private static _SpecularTextureEnabled;
  41194. /**
  41195. * Are specular textures enabled in the application.
  41196. */
  41197. static SpecularTextureEnabled: boolean;
  41198. private static _BumpTextureEnabled;
  41199. /**
  41200. * Are bump textures enabled in the application.
  41201. */
  41202. static BumpTextureEnabled: boolean;
  41203. private static _LightmapTextureEnabled;
  41204. /**
  41205. * Are lightmap textures enabled in the application.
  41206. */
  41207. static LightmapTextureEnabled: boolean;
  41208. private static _RefractionTextureEnabled;
  41209. /**
  41210. * Are refraction textures enabled in the application.
  41211. */
  41212. static RefractionTextureEnabled: boolean;
  41213. private static _ColorGradingTextureEnabled;
  41214. /**
  41215. * Are color grading textures enabled in the application.
  41216. */
  41217. static ColorGradingTextureEnabled: boolean;
  41218. private static _FresnelEnabled;
  41219. /**
  41220. * Are fresnels enabled in the application.
  41221. */
  41222. static FresnelEnabled: boolean;
  41223. private static _ClearCoatTextureEnabled;
  41224. /**
  41225. * Are clear coat textures enabled in the application.
  41226. */
  41227. static ClearCoatTextureEnabled: boolean;
  41228. private static _ClearCoatBumpTextureEnabled;
  41229. /**
  41230. * Are clear coat bump textures enabled in the application.
  41231. */
  41232. static ClearCoatBumpTextureEnabled: boolean;
  41233. private static _ClearCoatTintTextureEnabled;
  41234. /**
  41235. * Are clear coat tint textures enabled in the application.
  41236. */
  41237. static ClearCoatTintTextureEnabled: boolean;
  41238. private static _SheenTextureEnabled;
  41239. /**
  41240. * Are sheen textures enabled in the application.
  41241. */
  41242. static SheenTextureEnabled: boolean;
  41243. private static _AnisotropicTextureEnabled;
  41244. /**
  41245. * Are anisotropic textures enabled in the application.
  41246. */
  41247. static AnisotropicTextureEnabled: boolean;
  41248. private static _ThicknessTextureEnabled;
  41249. /**
  41250. * Are thickness textures enabled in the application.
  41251. */
  41252. static ThicknessTextureEnabled: boolean;
  41253. }
  41254. }
  41255. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41256. /** @hidden */
  41257. export var defaultFragmentDeclaration: {
  41258. name: string;
  41259. shader: string;
  41260. };
  41261. }
  41262. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41263. /** @hidden */
  41264. export var defaultUboDeclaration: {
  41265. name: string;
  41266. shader: string;
  41267. };
  41268. }
  41269. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41270. /** @hidden */
  41271. export var lightFragmentDeclaration: {
  41272. name: string;
  41273. shader: string;
  41274. };
  41275. }
  41276. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41277. /** @hidden */
  41278. export var lightUboDeclaration: {
  41279. name: string;
  41280. shader: string;
  41281. };
  41282. }
  41283. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41284. /** @hidden */
  41285. export var lightsFragmentFunctions: {
  41286. name: string;
  41287. shader: string;
  41288. };
  41289. }
  41290. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41291. /** @hidden */
  41292. export var shadowsFragmentFunctions: {
  41293. name: string;
  41294. shader: string;
  41295. };
  41296. }
  41297. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41298. /** @hidden */
  41299. export var fresnelFunction: {
  41300. name: string;
  41301. shader: string;
  41302. };
  41303. }
  41304. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41305. /** @hidden */
  41306. export var reflectionFunction: {
  41307. name: string;
  41308. shader: string;
  41309. };
  41310. }
  41311. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41312. /** @hidden */
  41313. export var bumpFragmentFunctions: {
  41314. name: string;
  41315. shader: string;
  41316. };
  41317. }
  41318. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41319. /** @hidden */
  41320. export var logDepthDeclaration: {
  41321. name: string;
  41322. shader: string;
  41323. };
  41324. }
  41325. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41326. /** @hidden */
  41327. export var bumpFragment: {
  41328. name: string;
  41329. shader: string;
  41330. };
  41331. }
  41332. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41333. /** @hidden */
  41334. export var depthPrePass: {
  41335. name: string;
  41336. shader: string;
  41337. };
  41338. }
  41339. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41340. /** @hidden */
  41341. export var lightFragment: {
  41342. name: string;
  41343. shader: string;
  41344. };
  41345. }
  41346. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41347. /** @hidden */
  41348. export var logDepthFragment: {
  41349. name: string;
  41350. shader: string;
  41351. };
  41352. }
  41353. declare module "babylonjs/Shaders/default.fragment" {
  41354. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41355. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41357. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41358. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41359. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41360. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41361. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41362. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41363. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41364. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41365. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41366. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41367. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41368. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41369. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41370. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41371. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41372. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41373. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41374. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41375. /** @hidden */
  41376. export var defaultPixelShader: {
  41377. name: string;
  41378. shader: string;
  41379. };
  41380. }
  41381. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41382. /** @hidden */
  41383. export var defaultVertexDeclaration: {
  41384. name: string;
  41385. shader: string;
  41386. };
  41387. }
  41388. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41389. /** @hidden */
  41390. export var bumpVertexDeclaration: {
  41391. name: string;
  41392. shader: string;
  41393. };
  41394. }
  41395. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41396. /** @hidden */
  41397. export var bumpVertex: {
  41398. name: string;
  41399. shader: string;
  41400. };
  41401. }
  41402. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41403. /** @hidden */
  41404. export var fogVertex: {
  41405. name: string;
  41406. shader: string;
  41407. };
  41408. }
  41409. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41410. /** @hidden */
  41411. export var shadowsVertex: {
  41412. name: string;
  41413. shader: string;
  41414. };
  41415. }
  41416. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41417. /** @hidden */
  41418. export var pointCloudVertex: {
  41419. name: string;
  41420. shader: string;
  41421. };
  41422. }
  41423. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41424. /** @hidden */
  41425. export var logDepthVertex: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module "babylonjs/Shaders/default.vertex" {
  41431. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41432. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41434. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41435. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41437. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41438. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41439. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41440. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41441. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41443. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41444. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41445. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41446. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41447. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41448. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41449. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41450. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41451. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41452. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41453. /** @hidden */
  41454. export var defaultVertexShader: {
  41455. name: string;
  41456. shader: string;
  41457. };
  41458. }
  41459. declare module "babylonjs/Materials/standardMaterial" {
  41460. import { SmartArray } from "babylonjs/Misc/smartArray";
  41461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41462. import { Nullable } from "babylonjs/types";
  41463. import { Scene } from "babylonjs/scene";
  41464. import { Matrix } from "babylonjs/Maths/math.vector";
  41465. import { Color3 } from "babylonjs/Maths/math.color";
  41466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41468. import { Mesh } from "babylonjs/Meshes/mesh";
  41469. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41470. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41471. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41472. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41473. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41476. import "babylonjs/Shaders/default.fragment";
  41477. import "babylonjs/Shaders/default.vertex";
  41478. /** @hidden */
  41479. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41480. MAINUV1: boolean;
  41481. MAINUV2: boolean;
  41482. DIFFUSE: boolean;
  41483. DIFFUSEDIRECTUV: number;
  41484. AMBIENT: boolean;
  41485. AMBIENTDIRECTUV: number;
  41486. OPACITY: boolean;
  41487. OPACITYDIRECTUV: number;
  41488. OPACITYRGB: boolean;
  41489. REFLECTION: boolean;
  41490. EMISSIVE: boolean;
  41491. EMISSIVEDIRECTUV: number;
  41492. SPECULAR: boolean;
  41493. SPECULARDIRECTUV: number;
  41494. BUMP: boolean;
  41495. BUMPDIRECTUV: number;
  41496. PARALLAX: boolean;
  41497. PARALLAXOCCLUSION: boolean;
  41498. SPECULAROVERALPHA: boolean;
  41499. CLIPPLANE: boolean;
  41500. CLIPPLANE2: boolean;
  41501. CLIPPLANE3: boolean;
  41502. CLIPPLANE4: boolean;
  41503. ALPHATEST: boolean;
  41504. DEPTHPREPASS: boolean;
  41505. ALPHAFROMDIFFUSE: boolean;
  41506. POINTSIZE: boolean;
  41507. FOG: boolean;
  41508. SPECULARTERM: boolean;
  41509. DIFFUSEFRESNEL: boolean;
  41510. OPACITYFRESNEL: boolean;
  41511. REFLECTIONFRESNEL: boolean;
  41512. REFRACTIONFRESNEL: boolean;
  41513. EMISSIVEFRESNEL: boolean;
  41514. FRESNEL: boolean;
  41515. NORMAL: boolean;
  41516. UV1: boolean;
  41517. UV2: boolean;
  41518. VERTEXCOLOR: boolean;
  41519. VERTEXALPHA: boolean;
  41520. NUM_BONE_INFLUENCERS: number;
  41521. BonesPerMesh: number;
  41522. BONETEXTURE: boolean;
  41523. INSTANCES: boolean;
  41524. GLOSSINESS: boolean;
  41525. ROUGHNESS: boolean;
  41526. EMISSIVEASILLUMINATION: boolean;
  41527. LINKEMISSIVEWITHDIFFUSE: boolean;
  41528. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41529. LIGHTMAP: boolean;
  41530. LIGHTMAPDIRECTUV: number;
  41531. OBJECTSPACE_NORMALMAP: boolean;
  41532. USELIGHTMAPASSHADOWMAP: boolean;
  41533. REFLECTIONMAP_3D: boolean;
  41534. REFLECTIONMAP_SPHERICAL: boolean;
  41535. REFLECTIONMAP_PLANAR: boolean;
  41536. REFLECTIONMAP_CUBIC: boolean;
  41537. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41538. REFLECTIONMAP_PROJECTION: boolean;
  41539. REFLECTIONMAP_SKYBOX: boolean;
  41540. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41541. REFLECTIONMAP_EXPLICIT: boolean;
  41542. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41543. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41544. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41545. INVERTCUBICMAP: boolean;
  41546. LOGARITHMICDEPTH: boolean;
  41547. REFRACTION: boolean;
  41548. REFRACTIONMAP_3D: boolean;
  41549. REFLECTIONOVERALPHA: boolean;
  41550. TWOSIDEDLIGHTING: boolean;
  41551. SHADOWFLOAT: boolean;
  41552. MORPHTARGETS: boolean;
  41553. MORPHTARGETS_NORMAL: boolean;
  41554. MORPHTARGETS_TANGENT: boolean;
  41555. MORPHTARGETS_UV: boolean;
  41556. NUM_MORPH_INFLUENCERS: number;
  41557. NONUNIFORMSCALING: boolean;
  41558. PREMULTIPLYALPHA: boolean;
  41559. IMAGEPROCESSING: boolean;
  41560. VIGNETTE: boolean;
  41561. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41562. VIGNETTEBLENDMODEOPAQUE: boolean;
  41563. TONEMAPPING: boolean;
  41564. TONEMAPPING_ACES: boolean;
  41565. CONTRAST: boolean;
  41566. COLORCURVES: boolean;
  41567. COLORGRADING: boolean;
  41568. COLORGRADING3D: boolean;
  41569. SAMPLER3DGREENDEPTH: boolean;
  41570. SAMPLER3DBGRMAP: boolean;
  41571. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41572. MULTIVIEW: boolean;
  41573. /**
  41574. * If the reflection texture on this material is in linear color space
  41575. * @hidden
  41576. */
  41577. IS_REFLECTION_LINEAR: boolean;
  41578. /**
  41579. * If the refraction texture on this material is in linear color space
  41580. * @hidden
  41581. */
  41582. IS_REFRACTION_LINEAR: boolean;
  41583. EXPOSURE: boolean;
  41584. constructor();
  41585. setReflectionMode(modeToEnable: string): void;
  41586. }
  41587. /**
  41588. * This is the default material used in Babylon. It is the best trade off between quality
  41589. * and performances.
  41590. * @see http://doc.babylonjs.com/babylon101/materials
  41591. */
  41592. export class StandardMaterial extends PushMaterial {
  41593. private _diffuseTexture;
  41594. /**
  41595. * The basic texture of the material as viewed under a light.
  41596. */
  41597. diffuseTexture: Nullable<BaseTexture>;
  41598. private _ambientTexture;
  41599. /**
  41600. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41601. */
  41602. ambientTexture: Nullable<BaseTexture>;
  41603. private _opacityTexture;
  41604. /**
  41605. * Define the transparency of the material from a texture.
  41606. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41607. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41608. */
  41609. opacityTexture: Nullable<BaseTexture>;
  41610. private _reflectionTexture;
  41611. /**
  41612. * Define the texture used to display the reflection.
  41613. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41614. */
  41615. reflectionTexture: Nullable<BaseTexture>;
  41616. private _emissiveTexture;
  41617. /**
  41618. * Define texture of the material as if self lit.
  41619. * This will be mixed in the final result even in the absence of light.
  41620. */
  41621. emissiveTexture: Nullable<BaseTexture>;
  41622. private _specularTexture;
  41623. /**
  41624. * Define how the color and intensity of the highlight given by the light in the material.
  41625. */
  41626. specularTexture: Nullable<BaseTexture>;
  41627. private _bumpTexture;
  41628. /**
  41629. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41630. * 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.
  41631. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41632. */
  41633. bumpTexture: Nullable<BaseTexture>;
  41634. private _lightmapTexture;
  41635. /**
  41636. * Complex lighting can be computationally expensive to compute at runtime.
  41637. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41638. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41639. */
  41640. lightmapTexture: Nullable<BaseTexture>;
  41641. private _refractionTexture;
  41642. /**
  41643. * Define the texture used to display the refraction.
  41644. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41645. */
  41646. refractionTexture: Nullable<BaseTexture>;
  41647. /**
  41648. * The color of the material lit by the environmental background lighting.
  41649. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41650. */
  41651. ambientColor: Color3;
  41652. /**
  41653. * The basic color of the material as viewed under a light.
  41654. */
  41655. diffuseColor: Color3;
  41656. /**
  41657. * Define how the color and intensity of the highlight given by the light in the material.
  41658. */
  41659. specularColor: Color3;
  41660. /**
  41661. * Define the color of the material as if self lit.
  41662. * This will be mixed in the final result even in the absence of light.
  41663. */
  41664. emissiveColor: Color3;
  41665. /**
  41666. * Defines how sharp are the highlights in the material.
  41667. * The bigger the value the sharper giving a more glossy feeling to the result.
  41668. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41669. */
  41670. specularPower: number;
  41671. private _useAlphaFromDiffuseTexture;
  41672. /**
  41673. * Does the transparency come from the diffuse texture alpha channel.
  41674. */
  41675. useAlphaFromDiffuseTexture: boolean;
  41676. private _useEmissiveAsIllumination;
  41677. /**
  41678. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41679. */
  41680. useEmissiveAsIllumination: boolean;
  41681. private _linkEmissiveWithDiffuse;
  41682. /**
  41683. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41684. * the emissive level when the final color is close to one.
  41685. */
  41686. linkEmissiveWithDiffuse: boolean;
  41687. private _useSpecularOverAlpha;
  41688. /**
  41689. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41690. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41691. */
  41692. useSpecularOverAlpha: boolean;
  41693. private _useReflectionOverAlpha;
  41694. /**
  41695. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41696. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41697. */
  41698. useReflectionOverAlpha: boolean;
  41699. private _disableLighting;
  41700. /**
  41701. * Does lights from the scene impacts this material.
  41702. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41703. */
  41704. disableLighting: boolean;
  41705. private _useObjectSpaceNormalMap;
  41706. /**
  41707. * Allows using an object space normal map (instead of tangent space).
  41708. */
  41709. useObjectSpaceNormalMap: boolean;
  41710. private _useParallax;
  41711. /**
  41712. * Is parallax enabled or not.
  41713. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41714. */
  41715. useParallax: boolean;
  41716. private _useParallaxOcclusion;
  41717. /**
  41718. * Is parallax occlusion enabled or not.
  41719. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41720. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41721. */
  41722. useParallaxOcclusion: boolean;
  41723. /**
  41724. * 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.
  41725. */
  41726. parallaxScaleBias: number;
  41727. private _roughness;
  41728. /**
  41729. * Helps to define how blurry the reflections should appears in the material.
  41730. */
  41731. roughness: number;
  41732. /**
  41733. * In case of refraction, define the value of the index of refraction.
  41734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41735. */
  41736. indexOfRefraction: number;
  41737. /**
  41738. * Invert the refraction texture alongside the y axis.
  41739. * It can be useful with procedural textures or probe for instance.
  41740. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41741. */
  41742. invertRefractionY: boolean;
  41743. /**
  41744. * Defines the alpha limits in alpha test mode.
  41745. */
  41746. alphaCutOff: number;
  41747. private _useLightmapAsShadowmap;
  41748. /**
  41749. * In case of light mapping, define whether the map contains light or shadow informations.
  41750. */
  41751. useLightmapAsShadowmap: boolean;
  41752. private _diffuseFresnelParameters;
  41753. /**
  41754. * Define the diffuse fresnel parameters of the material.
  41755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41756. */
  41757. diffuseFresnelParameters: FresnelParameters;
  41758. private _opacityFresnelParameters;
  41759. /**
  41760. * Define the opacity fresnel parameters of the material.
  41761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41762. */
  41763. opacityFresnelParameters: FresnelParameters;
  41764. private _reflectionFresnelParameters;
  41765. /**
  41766. * Define the reflection fresnel parameters of the material.
  41767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41768. */
  41769. reflectionFresnelParameters: FresnelParameters;
  41770. private _refractionFresnelParameters;
  41771. /**
  41772. * Define the refraction fresnel parameters of the material.
  41773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41774. */
  41775. refractionFresnelParameters: FresnelParameters;
  41776. private _emissiveFresnelParameters;
  41777. /**
  41778. * Define the emissive fresnel parameters of the material.
  41779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41780. */
  41781. emissiveFresnelParameters: FresnelParameters;
  41782. private _useReflectionFresnelFromSpecular;
  41783. /**
  41784. * If true automatically deducts the fresnels values from the material specularity.
  41785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41786. */
  41787. useReflectionFresnelFromSpecular: boolean;
  41788. private _useGlossinessFromSpecularMapAlpha;
  41789. /**
  41790. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41791. */
  41792. useGlossinessFromSpecularMapAlpha: boolean;
  41793. private _maxSimultaneousLights;
  41794. /**
  41795. * Defines the maximum number of lights that can be used in the material
  41796. */
  41797. maxSimultaneousLights: number;
  41798. private _invertNormalMapX;
  41799. /**
  41800. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41801. */
  41802. invertNormalMapX: boolean;
  41803. private _invertNormalMapY;
  41804. /**
  41805. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41806. */
  41807. invertNormalMapY: boolean;
  41808. private _twoSidedLighting;
  41809. /**
  41810. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41811. */
  41812. twoSidedLighting: boolean;
  41813. /**
  41814. * Default configuration related to image processing available in the standard Material.
  41815. */
  41816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41817. /**
  41818. * Gets the image processing configuration used either in this material.
  41819. */
  41820. /**
  41821. * Sets the Default image processing configuration used either in the this material.
  41822. *
  41823. * If sets to null, the scene one is in use.
  41824. */
  41825. imageProcessingConfiguration: ImageProcessingConfiguration;
  41826. /**
  41827. * Keep track of the image processing observer to allow dispose and replace.
  41828. */
  41829. private _imageProcessingObserver;
  41830. /**
  41831. * Attaches a new image processing configuration to the Standard Material.
  41832. * @param configuration
  41833. */
  41834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41835. /**
  41836. * Gets wether the color curves effect is enabled.
  41837. */
  41838. /**
  41839. * Sets wether the color curves effect is enabled.
  41840. */
  41841. cameraColorCurvesEnabled: boolean;
  41842. /**
  41843. * Gets wether the color grading effect is enabled.
  41844. */
  41845. /**
  41846. * Gets wether the color grading effect is enabled.
  41847. */
  41848. cameraColorGradingEnabled: boolean;
  41849. /**
  41850. * Gets wether tonemapping is enabled or not.
  41851. */
  41852. /**
  41853. * Sets wether tonemapping is enabled or not
  41854. */
  41855. cameraToneMappingEnabled: boolean;
  41856. /**
  41857. * The camera exposure used on this material.
  41858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41859. * This corresponds to a photographic exposure.
  41860. */
  41861. /**
  41862. * The camera exposure used on this material.
  41863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41864. * This corresponds to a photographic exposure.
  41865. */
  41866. cameraExposure: number;
  41867. /**
  41868. * Gets The camera contrast used on this material.
  41869. */
  41870. /**
  41871. * Sets The camera contrast used on this material.
  41872. */
  41873. cameraContrast: number;
  41874. /**
  41875. * Gets the Color Grading 2D Lookup Texture.
  41876. */
  41877. /**
  41878. * Sets the Color Grading 2D Lookup Texture.
  41879. */
  41880. cameraColorGradingTexture: Nullable<BaseTexture>;
  41881. /**
  41882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41884. * 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;
  41885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41886. */
  41887. /**
  41888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41890. * 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;
  41891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41892. */
  41893. cameraColorCurves: Nullable<ColorCurves>;
  41894. /**
  41895. * Custom callback helping to override the default shader used in the material.
  41896. */
  41897. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41898. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41899. protected _worldViewProjectionMatrix: Matrix;
  41900. protected _globalAmbientColor: Color3;
  41901. protected _useLogarithmicDepth: boolean;
  41902. protected _rebuildInParallel: boolean;
  41903. /**
  41904. * Instantiates a new standard material.
  41905. * This is the default material used in Babylon. It is the best trade off between quality
  41906. * and performances.
  41907. * @see http://doc.babylonjs.com/babylon101/materials
  41908. * @param name Define the name of the material in the scene
  41909. * @param scene Define the scene the material belong to
  41910. */
  41911. constructor(name: string, scene: Scene);
  41912. /**
  41913. * Gets a boolean indicating that current material needs to register RTT
  41914. */
  41915. readonly hasRenderTargetTextures: boolean;
  41916. /**
  41917. * Gets the current class name of the material e.g. "StandardMaterial"
  41918. * Mainly use in serialization.
  41919. * @returns the class name
  41920. */
  41921. getClassName(): string;
  41922. /**
  41923. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41924. * You can try switching to logarithmic depth.
  41925. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41926. */
  41927. useLogarithmicDepth: boolean;
  41928. /**
  41929. * Specifies if the material will require alpha blending
  41930. * @returns a boolean specifying if alpha blending is needed
  41931. */
  41932. needAlphaBlending(): boolean;
  41933. /**
  41934. * Specifies if this material should be rendered in alpha test mode
  41935. * @returns a boolean specifying if an alpha test is needed.
  41936. */
  41937. needAlphaTesting(): boolean;
  41938. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41939. /**
  41940. * Get the texture used for alpha test purpose.
  41941. * @returns the diffuse texture in case of the standard material.
  41942. */
  41943. getAlphaTestTexture(): Nullable<BaseTexture>;
  41944. /**
  41945. * Get if the submesh is ready to be used and all its information available.
  41946. * Child classes can use it to update shaders
  41947. * @param mesh defines the mesh to check
  41948. * @param subMesh defines which submesh to check
  41949. * @param useInstances specifies that instances should be used
  41950. * @returns a boolean indicating that the submesh is ready or not
  41951. */
  41952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41953. /**
  41954. * Builds the material UBO layouts.
  41955. * Used internally during the effect preparation.
  41956. */
  41957. buildUniformLayout(): void;
  41958. /**
  41959. * Unbinds the material from the mesh
  41960. */
  41961. unbind(): void;
  41962. /**
  41963. * Binds the submesh to this material by preparing the effect and shader to draw
  41964. * @param world defines the world transformation matrix
  41965. * @param mesh defines the mesh containing the submesh
  41966. * @param subMesh defines the submesh to bind the material to
  41967. */
  41968. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41969. /**
  41970. * Get the list of animatables in the material.
  41971. * @returns the list of animatables object used in the material
  41972. */
  41973. getAnimatables(): IAnimatable[];
  41974. /**
  41975. * Gets the active textures from the material
  41976. * @returns an array of textures
  41977. */
  41978. getActiveTextures(): BaseTexture[];
  41979. /**
  41980. * Specifies if the material uses a texture
  41981. * @param texture defines the texture to check against the material
  41982. * @returns a boolean specifying if the material uses the texture
  41983. */
  41984. hasTexture(texture: BaseTexture): boolean;
  41985. /**
  41986. * Disposes the material
  41987. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41988. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41989. */
  41990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41991. /**
  41992. * Makes a duplicate of the material, and gives it a new name
  41993. * @param name defines the new name for the duplicated material
  41994. * @returns the cloned material
  41995. */
  41996. clone(name: string): StandardMaterial;
  41997. /**
  41998. * Serializes this material in a JSON representation
  41999. * @returns the serialized material object
  42000. */
  42001. serialize(): any;
  42002. /**
  42003. * Creates a standard material from parsed material data
  42004. * @param source defines the JSON representation of the material
  42005. * @param scene defines the hosting scene
  42006. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42007. * @returns a new standard material
  42008. */
  42009. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42010. /**
  42011. * Are diffuse textures enabled in the application.
  42012. */
  42013. static DiffuseTextureEnabled: boolean;
  42014. /**
  42015. * Are ambient textures enabled in the application.
  42016. */
  42017. static AmbientTextureEnabled: boolean;
  42018. /**
  42019. * Are opacity textures enabled in the application.
  42020. */
  42021. static OpacityTextureEnabled: boolean;
  42022. /**
  42023. * Are reflection textures enabled in the application.
  42024. */
  42025. static ReflectionTextureEnabled: boolean;
  42026. /**
  42027. * Are emissive textures enabled in the application.
  42028. */
  42029. static EmissiveTextureEnabled: boolean;
  42030. /**
  42031. * Are specular textures enabled in the application.
  42032. */
  42033. static SpecularTextureEnabled: boolean;
  42034. /**
  42035. * Are bump textures enabled in the application.
  42036. */
  42037. static BumpTextureEnabled: boolean;
  42038. /**
  42039. * Are lightmap textures enabled in the application.
  42040. */
  42041. static LightmapTextureEnabled: boolean;
  42042. /**
  42043. * Are refraction textures enabled in the application.
  42044. */
  42045. static RefractionTextureEnabled: boolean;
  42046. /**
  42047. * Are color grading textures enabled in the application.
  42048. */
  42049. static ColorGradingTextureEnabled: boolean;
  42050. /**
  42051. * Are fresnels enabled in the application.
  42052. */
  42053. static FresnelEnabled: boolean;
  42054. }
  42055. }
  42056. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42057. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42059. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42060. /** @hidden */
  42061. export var imageProcessingPixelShader: {
  42062. name: string;
  42063. shader: string;
  42064. };
  42065. }
  42066. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42067. import { Nullable } from "babylonjs/types";
  42068. import { Color4 } from "babylonjs/Maths/math.color";
  42069. import { Camera } from "babylonjs/Cameras/camera";
  42070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42071. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42072. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42074. import { Engine } from "babylonjs/Engines/engine";
  42075. import "babylonjs/Shaders/imageProcessing.fragment";
  42076. import "babylonjs/Shaders/postprocess.vertex";
  42077. /**
  42078. * ImageProcessingPostProcess
  42079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42080. */
  42081. export class ImageProcessingPostProcess extends PostProcess {
  42082. /**
  42083. * Default configuration related to image processing available in the PBR Material.
  42084. */
  42085. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42086. /**
  42087. * Gets the image processing configuration used either in this material.
  42088. */
  42089. /**
  42090. * Sets the Default image processing configuration used either in the this material.
  42091. *
  42092. * If sets to null, the scene one is in use.
  42093. */
  42094. imageProcessingConfiguration: ImageProcessingConfiguration;
  42095. /**
  42096. * Keep track of the image processing observer to allow dispose and replace.
  42097. */
  42098. private _imageProcessingObserver;
  42099. /**
  42100. * Attaches a new image processing configuration to the PBR Material.
  42101. * @param configuration
  42102. */
  42103. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42104. /**
  42105. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42106. */
  42107. /**
  42108. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42109. */
  42110. colorCurves: Nullable<ColorCurves>;
  42111. /**
  42112. * Gets wether the color curves effect is enabled.
  42113. */
  42114. /**
  42115. * Sets wether the color curves effect is enabled.
  42116. */
  42117. colorCurvesEnabled: boolean;
  42118. /**
  42119. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42120. */
  42121. /**
  42122. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42123. */
  42124. colorGradingTexture: Nullable<BaseTexture>;
  42125. /**
  42126. * Gets wether the color grading effect is enabled.
  42127. */
  42128. /**
  42129. * Gets wether the color grading effect is enabled.
  42130. */
  42131. colorGradingEnabled: boolean;
  42132. /**
  42133. * Gets exposure used in the effect.
  42134. */
  42135. /**
  42136. * Sets exposure used in the effect.
  42137. */
  42138. exposure: number;
  42139. /**
  42140. * Gets wether tonemapping is enabled or not.
  42141. */
  42142. /**
  42143. * Sets wether tonemapping is enabled or not
  42144. */
  42145. toneMappingEnabled: boolean;
  42146. /**
  42147. * Gets the type of tone mapping effect.
  42148. */
  42149. /**
  42150. * Sets the type of tone mapping effect.
  42151. */
  42152. toneMappingType: number;
  42153. /**
  42154. * Gets contrast used in the effect.
  42155. */
  42156. /**
  42157. * Sets contrast used in the effect.
  42158. */
  42159. contrast: number;
  42160. /**
  42161. * Gets Vignette stretch size.
  42162. */
  42163. /**
  42164. * Sets Vignette stretch size.
  42165. */
  42166. vignetteStretch: number;
  42167. /**
  42168. * Gets Vignette centre X Offset.
  42169. */
  42170. /**
  42171. * Sets Vignette centre X Offset.
  42172. */
  42173. vignetteCentreX: number;
  42174. /**
  42175. * Gets Vignette centre Y Offset.
  42176. */
  42177. /**
  42178. * Sets Vignette centre Y Offset.
  42179. */
  42180. vignetteCentreY: number;
  42181. /**
  42182. * Gets Vignette weight or intensity of the vignette effect.
  42183. */
  42184. /**
  42185. * Sets Vignette weight or intensity of the vignette effect.
  42186. */
  42187. vignetteWeight: number;
  42188. /**
  42189. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42190. * if vignetteEnabled is set to true.
  42191. */
  42192. /**
  42193. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42194. * if vignetteEnabled is set to true.
  42195. */
  42196. vignetteColor: Color4;
  42197. /**
  42198. * Gets Camera field of view used by the Vignette effect.
  42199. */
  42200. /**
  42201. * Sets Camera field of view used by the Vignette effect.
  42202. */
  42203. vignetteCameraFov: number;
  42204. /**
  42205. * Gets the vignette blend mode allowing different kind of effect.
  42206. */
  42207. /**
  42208. * Sets the vignette blend mode allowing different kind of effect.
  42209. */
  42210. vignetteBlendMode: number;
  42211. /**
  42212. * Gets wether the vignette effect is enabled.
  42213. */
  42214. /**
  42215. * Sets wether the vignette effect is enabled.
  42216. */
  42217. vignetteEnabled: boolean;
  42218. private _fromLinearSpace;
  42219. /**
  42220. * Gets wether the input of the processing is in Gamma or Linear Space.
  42221. */
  42222. /**
  42223. * Sets wether the input of the processing is in Gamma or Linear Space.
  42224. */
  42225. fromLinearSpace: boolean;
  42226. /**
  42227. * Defines cache preventing GC.
  42228. */
  42229. private _defines;
  42230. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42231. /**
  42232. * "ImageProcessingPostProcess"
  42233. * @returns "ImageProcessingPostProcess"
  42234. */
  42235. getClassName(): string;
  42236. protected _updateParameters(): void;
  42237. dispose(camera?: Camera): void;
  42238. }
  42239. }
  42240. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42241. import { Scene } from "babylonjs/scene";
  42242. import { Color3 } from "babylonjs/Maths/math.color";
  42243. import { Mesh } from "babylonjs/Meshes/mesh";
  42244. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42245. import { Nullable } from "babylonjs/types";
  42246. /**
  42247. * Class containing static functions to help procedurally build meshes
  42248. */
  42249. export class GroundBuilder {
  42250. /**
  42251. * Creates a ground mesh
  42252. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42253. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42255. * @param name defines the name of the mesh
  42256. * @param options defines the options used to create the mesh
  42257. * @param scene defines the hosting scene
  42258. * @returns the ground mesh
  42259. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42260. */
  42261. static CreateGround(name: string, options: {
  42262. width?: number;
  42263. height?: number;
  42264. subdivisions?: number;
  42265. subdivisionsX?: number;
  42266. subdivisionsY?: number;
  42267. updatable?: boolean;
  42268. }, scene: any): Mesh;
  42269. /**
  42270. * Creates a tiled ground mesh
  42271. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42272. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42273. * * 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
  42274. * * 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
  42275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42276. * @param name defines the name of the mesh
  42277. * @param options defines the options used to create the mesh
  42278. * @param scene defines the hosting scene
  42279. * @returns the tiled ground mesh
  42280. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42281. */
  42282. static CreateTiledGround(name: string, options: {
  42283. xmin: number;
  42284. zmin: number;
  42285. xmax: number;
  42286. zmax: number;
  42287. subdivisions?: {
  42288. w: number;
  42289. h: number;
  42290. };
  42291. precision?: {
  42292. w: number;
  42293. h: number;
  42294. };
  42295. updatable?: boolean;
  42296. }, scene?: Nullable<Scene>): Mesh;
  42297. /**
  42298. * Creates a ground mesh from a height map
  42299. * * The parameter `url` sets the URL of the height map image resource.
  42300. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42301. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42302. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42303. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42304. * * 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.
  42305. * * 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).
  42306. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42308. * @param name defines the name of the mesh
  42309. * @param url defines the url to the height map
  42310. * @param options defines the options used to create the mesh
  42311. * @param scene defines the hosting scene
  42312. * @returns the ground mesh
  42313. * @see https://doc.babylonjs.com/babylon101/height_map
  42314. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42315. */
  42316. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42317. width?: number;
  42318. height?: number;
  42319. subdivisions?: number;
  42320. minHeight?: number;
  42321. maxHeight?: number;
  42322. colorFilter?: Color3;
  42323. alphaFilter?: number;
  42324. updatable?: boolean;
  42325. onReady?: (mesh: GroundMesh) => void;
  42326. }, scene?: Nullable<Scene>): GroundMesh;
  42327. }
  42328. }
  42329. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42330. import { Vector4 } from "babylonjs/Maths/math.vector";
  42331. import { Mesh } from "babylonjs/Meshes/mesh";
  42332. /**
  42333. * Class containing static functions to help procedurally build meshes
  42334. */
  42335. export class TorusBuilder {
  42336. /**
  42337. * Creates a torus mesh
  42338. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42339. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42340. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42344. * @param name defines the name of the mesh
  42345. * @param options defines the options used to create the mesh
  42346. * @param scene defines the hosting scene
  42347. * @returns the torus mesh
  42348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42349. */
  42350. static CreateTorus(name: string, options: {
  42351. diameter?: number;
  42352. thickness?: number;
  42353. tessellation?: number;
  42354. updatable?: boolean;
  42355. sideOrientation?: number;
  42356. frontUVs?: Vector4;
  42357. backUVs?: Vector4;
  42358. }, scene: any): Mesh;
  42359. }
  42360. }
  42361. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42362. import { Vector4 } from "babylonjs/Maths/math.vector";
  42363. import { Color4 } from "babylonjs/Maths/math.color";
  42364. import { Mesh } from "babylonjs/Meshes/mesh";
  42365. /**
  42366. * Class containing static functions to help procedurally build meshes
  42367. */
  42368. export class CylinderBuilder {
  42369. /**
  42370. * Creates a cylinder or a cone mesh
  42371. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42372. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42373. * * 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.
  42374. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42375. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42376. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42377. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42378. * * 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).
  42379. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42380. * * 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).
  42381. * * 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
  42382. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42383. * * 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
  42384. * * 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.
  42385. * * If `enclose` is false, a ring surface is one element.
  42386. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42387. * * 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
  42388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42391. * @param name defines the name of the mesh
  42392. * @param options defines the options used to create the mesh
  42393. * @param scene defines the hosting scene
  42394. * @returns the cylinder mesh
  42395. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42396. */
  42397. static CreateCylinder(name: string, options: {
  42398. height?: number;
  42399. diameterTop?: number;
  42400. diameterBottom?: number;
  42401. diameter?: number;
  42402. tessellation?: number;
  42403. subdivisions?: number;
  42404. arc?: number;
  42405. faceColors?: Color4[];
  42406. faceUV?: Vector4[];
  42407. updatable?: boolean;
  42408. hasRings?: boolean;
  42409. enclose?: boolean;
  42410. cap?: number;
  42411. sideOrientation?: number;
  42412. frontUVs?: Vector4;
  42413. backUVs?: Vector4;
  42414. }, scene: any): Mesh;
  42415. }
  42416. }
  42417. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42418. import { Observable } from "babylonjs/Misc/observable";
  42419. import { Nullable } from "babylonjs/types";
  42420. import { Camera } from "babylonjs/Cameras/camera";
  42421. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42422. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42423. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42424. import { Scene } from "babylonjs/scene";
  42425. import { Vector3 } from "babylonjs/Maths/math.vector";
  42426. import { Color3 } from "babylonjs/Maths/math.color";
  42427. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42429. import { Mesh } from "babylonjs/Meshes/mesh";
  42430. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42431. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42432. import "babylonjs/Meshes/Builders/groundBuilder";
  42433. import "babylonjs/Meshes/Builders/torusBuilder";
  42434. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42435. import "babylonjs/Gamepads/gamepadSceneComponent";
  42436. import "babylonjs/Animations/animatable";
  42437. /**
  42438. * Options to modify the vr teleportation behavior.
  42439. */
  42440. export interface VRTeleportationOptions {
  42441. /**
  42442. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42443. */
  42444. floorMeshName?: string;
  42445. /**
  42446. * A list of meshes to be used as the teleportation floor. (default: empty)
  42447. */
  42448. floorMeshes?: Mesh[];
  42449. }
  42450. /**
  42451. * Options to modify the vr experience helper's behavior.
  42452. */
  42453. export interface VRExperienceHelperOptions extends WebVROptions {
  42454. /**
  42455. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42456. */
  42457. createDeviceOrientationCamera?: boolean;
  42458. /**
  42459. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42460. */
  42461. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42462. /**
  42463. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42464. */
  42465. laserToggle?: boolean;
  42466. /**
  42467. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42468. */
  42469. floorMeshes?: Mesh[];
  42470. /**
  42471. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42472. */
  42473. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42474. }
  42475. /**
  42476. * Event containing information after VR has been entered
  42477. */
  42478. export class OnAfterEnteringVRObservableEvent {
  42479. /**
  42480. * If entering vr was successful
  42481. */
  42482. success: boolean;
  42483. }
  42484. /**
  42485. * Helps to quickly add VR support to an existing scene.
  42486. * See http://doc.babylonjs.com/how_to/webvr_helper
  42487. */
  42488. export class VRExperienceHelper {
  42489. /** Options to modify the vr experience helper's behavior. */
  42490. webVROptions: VRExperienceHelperOptions;
  42491. private _scene;
  42492. private _position;
  42493. private _btnVR;
  42494. private _btnVRDisplayed;
  42495. private _webVRsupported;
  42496. private _webVRready;
  42497. private _webVRrequesting;
  42498. private _webVRpresenting;
  42499. private _hasEnteredVR;
  42500. private _fullscreenVRpresenting;
  42501. private _canvas;
  42502. private _webVRCamera;
  42503. private _vrDeviceOrientationCamera;
  42504. private _deviceOrientationCamera;
  42505. private _existingCamera;
  42506. private _onKeyDown;
  42507. private _onVrDisplayPresentChange;
  42508. private _onVRDisplayChanged;
  42509. private _onVRRequestPresentStart;
  42510. private _onVRRequestPresentComplete;
  42511. /**
  42512. * 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)
  42513. */
  42514. enableGazeEvenWhenNoPointerLock: boolean;
  42515. /**
  42516. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42517. */
  42518. exitVROnDoubleTap: boolean;
  42519. /**
  42520. * Observable raised right before entering VR.
  42521. */
  42522. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42523. /**
  42524. * Observable raised when entering VR has completed.
  42525. */
  42526. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42527. /**
  42528. * Observable raised when exiting VR.
  42529. */
  42530. onExitingVRObservable: Observable<VRExperienceHelper>;
  42531. /**
  42532. * Observable raised when controller mesh is loaded.
  42533. */
  42534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42535. /** Return this.onEnteringVRObservable
  42536. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42537. */
  42538. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42539. /** Return this.onExitingVRObservable
  42540. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42541. */
  42542. readonly onExitingVR: Observable<VRExperienceHelper>;
  42543. /** Return this.onControllerMeshLoadedObservable
  42544. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42545. */
  42546. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42547. private _rayLength;
  42548. private _useCustomVRButton;
  42549. private _teleportationRequested;
  42550. private _teleportActive;
  42551. private _floorMeshName;
  42552. private _floorMeshesCollection;
  42553. private _rotationAllowed;
  42554. private _teleportBackwardsVector;
  42555. private _teleportationTarget;
  42556. private _isDefaultTeleportationTarget;
  42557. private _postProcessMove;
  42558. private _teleportationFillColor;
  42559. private _teleportationBorderColor;
  42560. private _rotationAngle;
  42561. private _haloCenter;
  42562. private _cameraGazer;
  42563. private _padSensibilityUp;
  42564. private _padSensibilityDown;
  42565. private _leftController;
  42566. private _rightController;
  42567. /**
  42568. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42569. */
  42570. onNewMeshSelected: Observable<AbstractMesh>;
  42571. /**
  42572. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42573. * This observable will provide the mesh and the controller used to select the mesh
  42574. */
  42575. onMeshSelectedWithController: Observable<{
  42576. mesh: AbstractMesh;
  42577. controller: WebVRController;
  42578. }>;
  42579. /**
  42580. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42581. */
  42582. onNewMeshPicked: Observable<PickingInfo>;
  42583. private _circleEase;
  42584. /**
  42585. * Observable raised before camera teleportation
  42586. */
  42587. onBeforeCameraTeleport: Observable<Vector3>;
  42588. /**
  42589. * Observable raised after camera teleportation
  42590. */
  42591. onAfterCameraTeleport: Observable<Vector3>;
  42592. /**
  42593. * Observable raised when current selected mesh gets unselected
  42594. */
  42595. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42596. private _raySelectionPredicate;
  42597. /**
  42598. * To be optionaly changed by user to define custom ray selection
  42599. */
  42600. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42601. /**
  42602. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42603. */
  42604. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42605. /**
  42606. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42607. */
  42608. teleportationEnabled: boolean;
  42609. private _defaultHeight;
  42610. private _teleportationInitialized;
  42611. private _interactionsEnabled;
  42612. private _interactionsRequested;
  42613. private _displayGaze;
  42614. private _displayLaserPointer;
  42615. /**
  42616. * The mesh used to display where the user is going to teleport.
  42617. */
  42618. /**
  42619. * Sets the mesh to be used to display where the user is going to teleport.
  42620. */
  42621. teleportationTarget: Mesh;
  42622. /**
  42623. * 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
  42624. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42625. * See http://doc.babylonjs.com/resources/baking_transformations
  42626. */
  42627. gazeTrackerMesh: Mesh;
  42628. /**
  42629. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42630. */
  42631. updateGazeTrackerScale: boolean;
  42632. /**
  42633. * If the gaze trackers color should be updated when selecting meshes
  42634. */
  42635. updateGazeTrackerColor: boolean;
  42636. /**
  42637. * If the controller laser color should be updated when selecting meshes
  42638. */
  42639. updateControllerLaserColor: boolean;
  42640. /**
  42641. * The gaze tracking mesh corresponding to the left controller
  42642. */
  42643. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42644. /**
  42645. * The gaze tracking mesh corresponding to the right controller
  42646. */
  42647. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42648. /**
  42649. * If the ray of the gaze should be displayed.
  42650. */
  42651. /**
  42652. * Sets if the ray of the gaze should be displayed.
  42653. */
  42654. displayGaze: boolean;
  42655. /**
  42656. * If the ray of the LaserPointer should be displayed.
  42657. */
  42658. /**
  42659. * Sets if the ray of the LaserPointer should be displayed.
  42660. */
  42661. displayLaserPointer: boolean;
  42662. /**
  42663. * The deviceOrientationCamera used as the camera when not in VR.
  42664. */
  42665. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42666. /**
  42667. * Based on the current WebVR support, returns the current VR camera used.
  42668. */
  42669. readonly currentVRCamera: Nullable<Camera>;
  42670. /**
  42671. * The webVRCamera which is used when in VR.
  42672. */
  42673. readonly webVRCamera: WebVRFreeCamera;
  42674. /**
  42675. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42676. */
  42677. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42678. /**
  42679. * The html button that is used to trigger entering into VR.
  42680. */
  42681. readonly vrButton: Nullable<HTMLButtonElement>;
  42682. private readonly _teleportationRequestInitiated;
  42683. /**
  42684. * Defines wether or not Pointer lock should be requested when switching to
  42685. * full screen.
  42686. */
  42687. requestPointerLockOnFullScreen: boolean;
  42688. /**
  42689. * Instantiates a VRExperienceHelper.
  42690. * Helps to quickly add VR support to an existing scene.
  42691. * @param scene The scene the VRExperienceHelper belongs to.
  42692. * @param webVROptions Options to modify the vr experience helper's behavior.
  42693. */
  42694. constructor(scene: Scene,
  42695. /** Options to modify the vr experience helper's behavior. */
  42696. webVROptions?: VRExperienceHelperOptions);
  42697. private _onDefaultMeshLoaded;
  42698. private _onResize;
  42699. private _onFullscreenChange;
  42700. /**
  42701. * Gets a value indicating if we are currently in VR mode.
  42702. */
  42703. readonly isInVRMode: boolean;
  42704. private onVrDisplayPresentChange;
  42705. private onVRDisplayChanged;
  42706. private moveButtonToBottomRight;
  42707. private displayVRButton;
  42708. private updateButtonVisibility;
  42709. private _cachedAngularSensibility;
  42710. /**
  42711. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42712. * Otherwise, will use the fullscreen API.
  42713. */
  42714. enterVR(): void;
  42715. /**
  42716. * Attempt to exit VR, or fullscreen.
  42717. */
  42718. exitVR(): void;
  42719. /**
  42720. * The position of the vr experience helper.
  42721. */
  42722. /**
  42723. * Sets the position of the vr experience helper.
  42724. */
  42725. position: Vector3;
  42726. /**
  42727. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42728. */
  42729. enableInteractions(): void;
  42730. private readonly _noControllerIsActive;
  42731. private beforeRender;
  42732. private _isTeleportationFloor;
  42733. /**
  42734. * Adds a floor mesh to be used for teleportation.
  42735. * @param floorMesh the mesh to be used for teleportation.
  42736. */
  42737. addFloorMesh(floorMesh: Mesh): void;
  42738. /**
  42739. * Removes a floor mesh from being used for teleportation.
  42740. * @param floorMesh the mesh to be removed.
  42741. */
  42742. removeFloorMesh(floorMesh: Mesh): void;
  42743. /**
  42744. * Enables interactions and teleportation using the VR controllers and gaze.
  42745. * @param vrTeleportationOptions options to modify teleportation behavior.
  42746. */
  42747. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42748. private _onNewGamepadConnected;
  42749. private _tryEnableInteractionOnController;
  42750. private _onNewGamepadDisconnected;
  42751. private _enableInteractionOnController;
  42752. private _checkTeleportWithRay;
  42753. private _checkRotate;
  42754. private _checkTeleportBackwards;
  42755. private _enableTeleportationOnController;
  42756. private _createTeleportationCircles;
  42757. private _displayTeleportationTarget;
  42758. private _hideTeleportationTarget;
  42759. private _rotateCamera;
  42760. private _moveTeleportationSelectorTo;
  42761. private _workingVector;
  42762. private _workingQuaternion;
  42763. private _workingMatrix;
  42764. /**
  42765. * Teleports the users feet to the desired location
  42766. * @param location The location where the user's feet should be placed
  42767. */
  42768. teleportCamera(location: Vector3): void;
  42769. private _convertNormalToDirectionOfRay;
  42770. private _castRayAndSelectObject;
  42771. private _notifySelectedMeshUnselected;
  42772. /**
  42773. * Sets the color of the laser ray from the vr controllers.
  42774. * @param color new color for the ray.
  42775. */
  42776. changeLaserColor(color: Color3): void;
  42777. /**
  42778. * Sets the color of the ray from the vr headsets gaze.
  42779. * @param color new color for the ray.
  42780. */
  42781. changeGazeColor(color: Color3): void;
  42782. /**
  42783. * Exits VR and disposes of the vr experience helper
  42784. */
  42785. dispose(): void;
  42786. /**
  42787. * Gets the name of the VRExperienceHelper class
  42788. * @returns "VRExperienceHelper"
  42789. */
  42790. getClassName(): string;
  42791. }
  42792. }
  42793. declare module "babylonjs/Cameras/VR/index" {
  42794. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42795. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42796. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42797. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42798. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42799. export * from "babylonjs/Cameras/VR/webVRCamera";
  42800. }
  42801. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42802. import { Observable } from "babylonjs/Misc/observable";
  42803. import { Nullable } from "babylonjs/types";
  42804. import { IDisposable, Scene } from "babylonjs/scene";
  42805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42806. /**
  42807. * Manages an XRSession to work with Babylon's engine
  42808. * @see https://doc.babylonjs.com/how_to/webxr
  42809. */
  42810. export class WebXRSessionManager implements IDisposable {
  42811. private scene;
  42812. /**
  42813. * Fires every time a new xrFrame arrives which can be used to update the camera
  42814. */
  42815. onXRFrameObservable: Observable<any>;
  42816. /**
  42817. * Fires when the xr session is ended either by the device or manually done
  42818. */
  42819. onXRSessionEnded: Observable<any>;
  42820. /**
  42821. * Underlying xr session
  42822. */
  42823. session: XRSession;
  42824. /**
  42825. * Type of reference space used when creating the session
  42826. */
  42827. referenceSpace: XRReferenceSpace;
  42828. /** @hidden */
  42829. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42830. /**
  42831. * Current XR frame
  42832. */
  42833. currentFrame: Nullable<XRFrame>;
  42834. private _xrNavigator;
  42835. private baseLayer;
  42836. /**
  42837. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42838. * @param scene The scene which the session should be created for
  42839. */
  42840. constructor(scene: Scene);
  42841. /**
  42842. * Initializes the manager
  42843. * After initialization enterXR can be called to start an XR session
  42844. * @returns Promise which resolves after it is initialized
  42845. */
  42846. initializeAsync(): Promise<void>;
  42847. /**
  42848. * Initializes an xr session
  42849. * @param xrSessionMode mode to initialize
  42850. * @returns a promise which will resolve once the session has been initialized
  42851. */
  42852. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42853. /**
  42854. * Sets the reference space on the xr session
  42855. * @param referenceSpace space to set
  42856. * @returns a promise that will resolve once the reference space has been set
  42857. */
  42858. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42859. /**
  42860. * Updates the render state of the session
  42861. * @param state state to set
  42862. * @returns a promise that resolves once the render state has been updated
  42863. */
  42864. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42865. /**
  42866. * Starts rendering to the xr layer
  42867. * @returns a promise that will resolve once rendering has started
  42868. */
  42869. startRenderingToXRAsync(): Promise<void>;
  42870. /**
  42871. * Stops the xrSession and restores the renderloop
  42872. * @returns Promise which resolves after it exits XR
  42873. */
  42874. exitXRAsync(): Promise<unknown>;
  42875. /**
  42876. * Checks if a session would be supported for the creation options specified
  42877. * @param sessionMode session mode to check if supported eg. immersive-vr
  42878. * @returns true if supported
  42879. */
  42880. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42881. /**
  42882. * @hidden
  42883. * Converts the render layer of xrSession to a render target
  42884. * @param session session to create render target for
  42885. * @param scene scene the new render target should be created for
  42886. */
  42887. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42888. /**
  42889. * Disposes of the session manager
  42890. */
  42891. dispose(): void;
  42892. }
  42893. }
  42894. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42895. import { Scene } from "babylonjs/scene";
  42896. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42897. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42898. /**
  42899. * WebXR Camera which holds the views for the xrSession
  42900. * @see https://doc.babylonjs.com/how_to/webxr
  42901. */
  42902. export class WebXRCamera extends FreeCamera {
  42903. private static _TmpMatrix;
  42904. /**
  42905. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42906. * @param name the name of the camera
  42907. * @param scene the scene to add the camera to
  42908. */
  42909. constructor(name: string, scene: Scene);
  42910. private _updateNumberOfRigCameras;
  42911. /** @hidden */
  42912. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42913. /**
  42914. * Updates the cameras position from the current pose information of the XR session
  42915. * @param xrSessionManager the session containing pose information
  42916. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42917. */
  42918. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42919. }
  42920. }
  42921. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42922. import { Nullable } from "babylonjs/types";
  42923. import { IDisposable } from "babylonjs/scene";
  42924. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42925. /**
  42926. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42927. */
  42928. export class WebXRManagedOutputCanvas implements IDisposable {
  42929. private helper;
  42930. private _canvas;
  42931. /**
  42932. * xrpresent context of the canvas which can be used to display/mirror xr content
  42933. */
  42934. canvasContext: WebGLRenderingContext;
  42935. /**
  42936. * xr layer for the canvas
  42937. */
  42938. xrLayer: Nullable<XRWebGLLayer>;
  42939. /**
  42940. * Initializes the xr layer for the session
  42941. * @param xrSession xr session
  42942. * @returns a promise that will resolve once the XR Layer has been created
  42943. */
  42944. initializeXRLayerAsync(xrSession: any): any;
  42945. /**
  42946. * Initializes the canvas to be added/removed upon entering/exiting xr
  42947. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42948. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42949. */
  42950. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42951. /**
  42952. * Disposes of the object
  42953. */
  42954. dispose(): void;
  42955. private _setManagedOutputCanvas;
  42956. private _addCanvas;
  42957. private _removeCanvas;
  42958. }
  42959. }
  42960. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42961. import { Observable } from "babylonjs/Misc/observable";
  42962. import { IDisposable, Scene } from "babylonjs/scene";
  42963. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42966. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42967. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42968. /**
  42969. * States of the webXR experience
  42970. */
  42971. export enum WebXRState {
  42972. /**
  42973. * Transitioning to being in XR mode
  42974. */
  42975. ENTERING_XR = 0,
  42976. /**
  42977. * Transitioning to non XR mode
  42978. */
  42979. EXITING_XR = 1,
  42980. /**
  42981. * In XR mode and presenting
  42982. */
  42983. IN_XR = 2,
  42984. /**
  42985. * Not entered XR mode
  42986. */
  42987. NOT_IN_XR = 3
  42988. }
  42989. /**
  42990. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42991. * @see https://doc.babylonjs.com/how_to/webxr
  42992. */
  42993. export class WebXRExperienceHelper implements IDisposable {
  42994. private scene;
  42995. /**
  42996. * 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
  42997. */
  42998. container: AbstractMesh;
  42999. /**
  43000. * Camera used to render xr content
  43001. */
  43002. camera: WebXRCamera;
  43003. /**
  43004. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43005. */
  43006. state: WebXRState;
  43007. private _setState;
  43008. private static _TmpVector;
  43009. /**
  43010. * Fires when the state of the experience helper has changed
  43011. */
  43012. onStateChangedObservable: Observable<WebXRState>;
  43013. /** Session manager used to keep track of xr session */
  43014. sessionManager: WebXRSessionManager;
  43015. private _nonVRCamera;
  43016. private _originalSceneAutoClear;
  43017. private _supported;
  43018. /**
  43019. * Creates the experience helper
  43020. * @param scene the scene to attach the experience helper to
  43021. * @returns a promise for the experience helper
  43022. */
  43023. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43024. /**
  43025. * Creates a WebXRExperienceHelper
  43026. * @param scene The scene the helper should be created in
  43027. */
  43028. private constructor();
  43029. /**
  43030. * Exits XR mode and returns the scene to its original state
  43031. * @returns promise that resolves after xr mode has exited
  43032. */
  43033. exitXRAsync(): Promise<unknown>;
  43034. /**
  43035. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43036. * @param sessionCreationOptions options for the XR session
  43037. * @param referenceSpaceType frame of reference of the XR session
  43038. * @param outputCanvas the output canvas that will be used to enter XR mode
  43039. * @returns promise that resolves after xr mode has entered
  43040. */
  43041. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43042. /**
  43043. * Updates the global position of the camera by moving the camera's container
  43044. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43045. * @param position The desired global position of the camera
  43046. */
  43047. setPositionOfCameraUsingContainer(position: Vector3): void;
  43048. /**
  43049. * Rotates the xr camera by rotating the camera's container around the camera's position
  43050. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43051. * @param rotation the desired quaternion rotation to apply to the camera
  43052. */
  43053. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43054. /**
  43055. * Disposes of the experience helper
  43056. */
  43057. dispose(): void;
  43058. }
  43059. }
  43060. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43061. import { Nullable } from "babylonjs/types";
  43062. import { Observable } from "babylonjs/Misc/observable";
  43063. import { IDisposable, Scene } from "babylonjs/scene";
  43064. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43065. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43066. /**
  43067. * Button which can be used to enter a different mode of XR
  43068. */
  43069. export class WebXREnterExitUIButton {
  43070. /** button element */
  43071. element: HTMLElement;
  43072. /** XR initialization options for the button */
  43073. sessionMode: XRSessionMode;
  43074. /** Reference space type */
  43075. referenceSpaceType: XRReferenceSpaceType;
  43076. /**
  43077. * Creates a WebXREnterExitUIButton
  43078. * @param element button element
  43079. * @param sessionMode XR initialization session mode
  43080. * @param referenceSpaceType the type of reference space to be used
  43081. */
  43082. constructor(
  43083. /** button element */
  43084. element: HTMLElement,
  43085. /** XR initialization options for the button */
  43086. sessionMode: XRSessionMode,
  43087. /** Reference space type */
  43088. referenceSpaceType: XRReferenceSpaceType);
  43089. /**
  43090. * Overwritable function which can be used to update the button's visuals when the state changes
  43091. * @param activeButton the current active button in the UI
  43092. */
  43093. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43094. }
  43095. /**
  43096. * Options to create the webXR UI
  43097. */
  43098. export class WebXREnterExitUIOptions {
  43099. /**
  43100. * Context to enter xr with
  43101. */
  43102. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43103. /**
  43104. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43105. */
  43106. customButtons?: Array<WebXREnterExitUIButton>;
  43107. }
  43108. /**
  43109. * UI to allow the user to enter/exit XR mode
  43110. */
  43111. export class WebXREnterExitUI implements IDisposable {
  43112. private scene;
  43113. private _overlay;
  43114. private _buttons;
  43115. private _activeButton;
  43116. /**
  43117. * Fired every time the active button is changed.
  43118. *
  43119. * When xr is entered via a button that launches xr that button will be the callback parameter
  43120. *
  43121. * When exiting xr the callback parameter will be null)
  43122. */
  43123. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43124. /**
  43125. * Creates UI to allow the user to enter/exit XR mode
  43126. * @param scene the scene to add the ui to
  43127. * @param helper the xr experience helper to enter/exit xr with
  43128. * @param options options to configure the UI
  43129. * @returns the created ui
  43130. */
  43131. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43132. private constructor();
  43133. private _updateButtons;
  43134. /**
  43135. * Disposes of the object
  43136. */
  43137. dispose(): void;
  43138. }
  43139. }
  43140. declare module "babylonjs/Cameras/XR/webXRController" {
  43141. import { Nullable } from "babylonjs/types";
  43142. import { Observable } from "babylonjs/Misc/observable";
  43143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43144. import { Ray } from "babylonjs/Culling/ray";
  43145. import { Scene } from "babylonjs/scene";
  43146. /**
  43147. * Represents an XR input
  43148. */
  43149. export class WebXRController {
  43150. private scene;
  43151. /** The underlying input source for the controller */
  43152. inputSource: XRInputSource;
  43153. private parentContainer;
  43154. /**
  43155. * 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
  43156. */
  43157. grip?: AbstractMesh;
  43158. /**
  43159. * Pointer which can be used to select objects or attach a visible laser to
  43160. */
  43161. pointer: AbstractMesh;
  43162. /**
  43163. * Event that fires when the controller is removed/disposed
  43164. */
  43165. onDisposeObservable: Observable<{}>;
  43166. private _tmpMatrix;
  43167. private _tmpQuaternion;
  43168. private _tmpVector;
  43169. /**
  43170. * Creates the controller
  43171. * @see https://doc.babylonjs.com/how_to/webxr
  43172. * @param scene the scene which the controller should be associated to
  43173. * @param inputSource the underlying input source for the controller
  43174. * @param parentContainer parent that the controller meshes should be children of
  43175. */
  43176. constructor(scene: Scene,
  43177. /** The underlying input source for the controller */
  43178. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43179. /**
  43180. * Updates the controller pose based on the given XRFrame
  43181. * @param xrFrame xr frame to update the pose with
  43182. * @param referenceSpace reference space to use
  43183. */
  43184. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43185. /**
  43186. * Gets a world space ray coming from the controller
  43187. * @param result the resulting ray
  43188. */
  43189. getWorldPointerRayToRef(result: Ray): void;
  43190. /**
  43191. * Disposes of the object
  43192. */
  43193. dispose(): void;
  43194. }
  43195. }
  43196. declare module "babylonjs/Cameras/XR/webXRInput" {
  43197. import { Observable } from "babylonjs/Misc/observable";
  43198. import { IDisposable } from "babylonjs/scene";
  43199. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43200. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43201. /**
  43202. * XR input used to track XR inputs such as controllers/rays
  43203. */
  43204. export class WebXRInput implements IDisposable {
  43205. /**
  43206. * Base experience the input listens to
  43207. */
  43208. baseExperience: WebXRExperienceHelper;
  43209. /**
  43210. * XR controllers being tracked
  43211. */
  43212. controllers: Array<WebXRController>;
  43213. private _frameObserver;
  43214. private _stateObserver;
  43215. /**
  43216. * Event when a controller has been connected/added
  43217. */
  43218. onControllerAddedObservable: Observable<WebXRController>;
  43219. /**
  43220. * Event when a controller has been removed/disconnected
  43221. */
  43222. onControllerRemovedObservable: Observable<WebXRController>;
  43223. /**
  43224. * Initializes the WebXRInput
  43225. * @param baseExperience experience helper which the input should be created for
  43226. */
  43227. constructor(
  43228. /**
  43229. * Base experience the input listens to
  43230. */
  43231. baseExperience: WebXRExperienceHelper);
  43232. private _onInputSourcesChange;
  43233. private _addAndRemoveControllers;
  43234. /**
  43235. * Disposes of the object
  43236. */
  43237. dispose(): void;
  43238. }
  43239. }
  43240. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43242. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43243. /**
  43244. * Enables teleportation
  43245. */
  43246. export class WebXRControllerTeleportation {
  43247. private _teleportationFillColor;
  43248. private _teleportationBorderColor;
  43249. private _tmpRay;
  43250. private _tmpVector;
  43251. /**
  43252. * Creates a WebXRControllerTeleportation
  43253. * @param input input manager to add teleportation to
  43254. * @param floorMeshes floormeshes which can be teleported to
  43255. */
  43256. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43257. }
  43258. }
  43259. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43260. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43261. /**
  43262. * Handles pointer input automatically for the pointer of XR controllers
  43263. */
  43264. export class WebXRControllerPointerSelection {
  43265. private static _idCounter;
  43266. private _tmpRay;
  43267. /**
  43268. * Creates a WebXRControllerPointerSelection
  43269. * @param input input manager to setup pointer selection
  43270. */
  43271. constructor(input: WebXRInput);
  43272. private _convertNormalToDirectionOfRay;
  43273. private _updatePointerDistance;
  43274. }
  43275. }
  43276. declare module "babylonjs/Loading/sceneLoader" {
  43277. import { Observable } from "babylonjs/Misc/observable";
  43278. import { Nullable } from "babylonjs/types";
  43279. import { Scene } from "babylonjs/scene";
  43280. import { Engine } from "babylonjs/Engines/engine";
  43281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43282. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43283. import { AssetContainer } from "babylonjs/assetContainer";
  43284. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43285. import { Skeleton } from "babylonjs/Bones/skeleton";
  43286. /**
  43287. * Class used to represent data loading progression
  43288. */
  43289. export class SceneLoaderProgressEvent {
  43290. /** defines if data length to load can be evaluated */
  43291. readonly lengthComputable: boolean;
  43292. /** defines the loaded data length */
  43293. readonly loaded: number;
  43294. /** defines the data length to load */
  43295. readonly total: number;
  43296. /**
  43297. * Create a new progress event
  43298. * @param lengthComputable defines if data length to load can be evaluated
  43299. * @param loaded defines the loaded data length
  43300. * @param total defines the data length to load
  43301. */
  43302. constructor(
  43303. /** defines if data length to load can be evaluated */
  43304. lengthComputable: boolean,
  43305. /** defines the loaded data length */
  43306. loaded: number,
  43307. /** defines the data length to load */
  43308. total: number);
  43309. /**
  43310. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43311. * @param event defines the source event
  43312. * @returns a new SceneLoaderProgressEvent
  43313. */
  43314. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43315. }
  43316. /**
  43317. * Interface used by SceneLoader plugins to define supported file extensions
  43318. */
  43319. export interface ISceneLoaderPluginExtensions {
  43320. /**
  43321. * Defines the list of supported extensions
  43322. */
  43323. [extension: string]: {
  43324. isBinary: boolean;
  43325. };
  43326. }
  43327. /**
  43328. * Interface used by SceneLoader plugin factory
  43329. */
  43330. export interface ISceneLoaderPluginFactory {
  43331. /**
  43332. * Defines the name of the factory
  43333. */
  43334. name: string;
  43335. /**
  43336. * Function called to create a new plugin
  43337. * @return the new plugin
  43338. */
  43339. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43340. /**
  43341. * Boolean indicating if the plugin can direct load specific data
  43342. */
  43343. canDirectLoad?: (data: string) => boolean;
  43344. }
  43345. /**
  43346. * Interface used to define a SceneLoader plugin
  43347. */
  43348. export interface ISceneLoaderPlugin {
  43349. /**
  43350. * The friendly name of this plugin.
  43351. */
  43352. name: string;
  43353. /**
  43354. * The file extensions supported by this plugin.
  43355. */
  43356. extensions: string | ISceneLoaderPluginExtensions;
  43357. /**
  43358. * Import meshes into a scene.
  43359. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43360. * @param scene The scene to import into
  43361. * @param data The data to import
  43362. * @param rootUrl The root url for scene and resources
  43363. * @param meshes The meshes array to import into
  43364. * @param particleSystems The particle systems array to import into
  43365. * @param skeletons The skeletons array to import into
  43366. * @param onError The callback when import fails
  43367. * @returns True if successful or false otherwise
  43368. */
  43369. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43370. /**
  43371. * Load into a scene.
  43372. * @param scene The scene to load into
  43373. * @param data The data to import
  43374. * @param rootUrl The root url for scene and resources
  43375. * @param onError The callback when import fails
  43376. * @returns true if successful or false otherwise
  43377. */
  43378. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43379. /**
  43380. * The callback that returns true if the data can be directly loaded.
  43381. */
  43382. canDirectLoad?: (data: string) => boolean;
  43383. /**
  43384. * The callback that allows custom handling of the root url based on the response url.
  43385. */
  43386. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43387. /**
  43388. * Load into an asset container.
  43389. * @param scene The scene to load into
  43390. * @param data The data to import
  43391. * @param rootUrl The root url for scene and resources
  43392. * @param onError The callback when import fails
  43393. * @returns The loaded asset container
  43394. */
  43395. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43396. }
  43397. /**
  43398. * Interface used to define an async SceneLoader plugin
  43399. */
  43400. export interface ISceneLoaderPluginAsync {
  43401. /**
  43402. * The friendly name of this plugin.
  43403. */
  43404. name: string;
  43405. /**
  43406. * The file extensions supported by this plugin.
  43407. */
  43408. extensions: string | ISceneLoaderPluginExtensions;
  43409. /**
  43410. * Import meshes into a scene.
  43411. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43412. * @param scene The scene to import into
  43413. * @param data The data to import
  43414. * @param rootUrl The root url for scene and resources
  43415. * @param onProgress The callback when the load progresses
  43416. * @param fileName Defines the name of the file to load
  43417. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43418. */
  43419. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43420. meshes: AbstractMesh[];
  43421. particleSystems: IParticleSystem[];
  43422. skeletons: Skeleton[];
  43423. animationGroups: AnimationGroup[];
  43424. }>;
  43425. /**
  43426. * Load into a scene.
  43427. * @param scene The scene to load into
  43428. * @param data The data to import
  43429. * @param rootUrl The root url for scene and resources
  43430. * @param onProgress The callback when the load progresses
  43431. * @param fileName Defines the name of the file to load
  43432. * @returns Nothing
  43433. */
  43434. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43435. /**
  43436. * The callback that returns true if the data can be directly loaded.
  43437. */
  43438. canDirectLoad?: (data: string) => boolean;
  43439. /**
  43440. * The callback that allows custom handling of the root url based on the response url.
  43441. */
  43442. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43443. /**
  43444. * Load into an asset container.
  43445. * @param scene The scene to load into
  43446. * @param data The data to import
  43447. * @param rootUrl The root url for scene and resources
  43448. * @param onProgress The callback when the load progresses
  43449. * @param fileName Defines the name of the file to load
  43450. * @returns The loaded asset container
  43451. */
  43452. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43453. }
  43454. /**
  43455. * Class used to load scene from various file formats using registered plugins
  43456. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43457. */
  43458. export class SceneLoader {
  43459. /**
  43460. * No logging while loading
  43461. */
  43462. static readonly NO_LOGGING: number;
  43463. /**
  43464. * Minimal logging while loading
  43465. */
  43466. static readonly MINIMAL_LOGGING: number;
  43467. /**
  43468. * Summary logging while loading
  43469. */
  43470. static readonly SUMMARY_LOGGING: number;
  43471. /**
  43472. * Detailled logging while loading
  43473. */
  43474. static readonly DETAILED_LOGGING: number;
  43475. /**
  43476. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43477. */
  43478. static ForceFullSceneLoadingForIncremental: boolean;
  43479. /**
  43480. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43481. */
  43482. static ShowLoadingScreen: boolean;
  43483. /**
  43484. * Defines the current logging level (while loading the scene)
  43485. * @ignorenaming
  43486. */
  43487. static loggingLevel: number;
  43488. /**
  43489. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43490. */
  43491. static CleanBoneMatrixWeights: boolean;
  43492. /**
  43493. * Event raised when a plugin is used to load a scene
  43494. */
  43495. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43496. private static _registeredPlugins;
  43497. private static _getDefaultPlugin;
  43498. private static _getPluginForExtension;
  43499. private static _getPluginForDirectLoad;
  43500. private static _getPluginForFilename;
  43501. private static _getDirectLoad;
  43502. private static _loadData;
  43503. private static _getFileInfo;
  43504. /**
  43505. * Gets a plugin that can load the given extension
  43506. * @param extension defines the extension to load
  43507. * @returns a plugin or null if none works
  43508. */
  43509. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43510. /**
  43511. * Gets a boolean indicating that the given extension can be loaded
  43512. * @param extension defines the extension to load
  43513. * @returns true if the extension is supported
  43514. */
  43515. static IsPluginForExtensionAvailable(extension: string): boolean;
  43516. /**
  43517. * Adds a new plugin to the list of registered plugins
  43518. * @param plugin defines the plugin to add
  43519. */
  43520. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43521. /**
  43522. * Import meshes into a scene
  43523. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43524. * @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)
  43525. * @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)
  43526. * @param scene the instance of BABYLON.Scene to append to
  43527. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43528. * @param onProgress a callback with a progress event for each file being loaded
  43529. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43530. * @param pluginExtension the extension used to determine the plugin
  43531. * @returns The loaded plugin
  43532. */
  43533. 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>;
  43534. /**
  43535. * Import meshes into a scene
  43536. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43537. * @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)
  43538. * @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)
  43539. * @param scene the instance of BABYLON.Scene to append to
  43540. * @param onProgress a callback with a progress event for each file being loaded
  43541. * @param pluginExtension the extension used to determine the plugin
  43542. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43543. */
  43544. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43545. meshes: AbstractMesh[];
  43546. particleSystems: IParticleSystem[];
  43547. skeletons: Skeleton[];
  43548. animationGroups: AnimationGroup[];
  43549. }>;
  43550. /**
  43551. * Load a scene
  43552. * @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)
  43553. * @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)
  43554. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43555. * @param onSuccess a callback with the scene when import succeeds
  43556. * @param onProgress a callback with a progress event for each file being loaded
  43557. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43558. * @param pluginExtension the extension used to determine the plugin
  43559. * @returns The loaded plugin
  43560. */
  43561. 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>;
  43562. /**
  43563. * Load a scene
  43564. * @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)
  43565. * @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)
  43566. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43567. * @param onProgress a callback with a progress event for each file being loaded
  43568. * @param pluginExtension the extension used to determine the plugin
  43569. * @returns The loaded scene
  43570. */
  43571. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43572. /**
  43573. * Append a scene
  43574. * @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)
  43575. * @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)
  43576. * @param scene is the instance of BABYLON.Scene to append to
  43577. * @param onSuccess a callback with the scene when import succeeds
  43578. * @param onProgress a callback with a progress event for each file being loaded
  43579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43580. * @param pluginExtension the extension used to determine the plugin
  43581. * @returns The loaded plugin
  43582. */
  43583. 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>;
  43584. /**
  43585. * Append a scene
  43586. * @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)
  43587. * @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)
  43588. * @param scene is the instance of BABYLON.Scene to append to
  43589. * @param onProgress a callback with a progress event for each file being loaded
  43590. * @param pluginExtension the extension used to determine the plugin
  43591. * @returns The given scene
  43592. */
  43593. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43594. /**
  43595. * Load a scene into an asset container
  43596. * @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)
  43597. * @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)
  43598. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43599. * @param onSuccess a callback with the scene when import succeeds
  43600. * @param onProgress a callback with a progress event for each file being loaded
  43601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43602. * @param pluginExtension the extension used to determine the plugin
  43603. * @returns The loaded plugin
  43604. */
  43605. 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>;
  43606. /**
  43607. * Load a scene into an asset container
  43608. * @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)
  43609. * @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)
  43610. * @param scene is the instance of Scene to append to
  43611. * @param onProgress a callback with a progress event for each file being loaded
  43612. * @param pluginExtension the extension used to determine the plugin
  43613. * @returns The loaded asset container
  43614. */
  43615. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43616. }
  43617. }
  43618. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43619. import { Scene } from "babylonjs/scene";
  43620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43621. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43622. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43623. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43624. /**
  43625. * Generic Controller
  43626. */
  43627. export class GenericController extends WebVRController {
  43628. /**
  43629. * Base Url for the controller model.
  43630. */
  43631. static readonly MODEL_BASE_URL: string;
  43632. /**
  43633. * File name for the controller model.
  43634. */
  43635. static readonly MODEL_FILENAME: string;
  43636. /**
  43637. * Creates a new GenericController from a gamepad
  43638. * @param vrGamepad the gamepad that the controller should be created from
  43639. */
  43640. constructor(vrGamepad: any);
  43641. /**
  43642. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43643. * @param scene scene in which to add meshes
  43644. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43645. */
  43646. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43647. /**
  43648. * Called once for each button that changed state since the last frame
  43649. * @param buttonIdx Which button index changed
  43650. * @param state New state of the button
  43651. * @param changes Which properties on the state changed since last frame
  43652. */
  43653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43654. }
  43655. }
  43656. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43657. import { Observable } from "babylonjs/Misc/observable";
  43658. import { Scene } from "babylonjs/scene";
  43659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43660. import { Ray } from "babylonjs/Culling/ray";
  43661. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43662. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43663. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43664. /**
  43665. * Defines the WindowsMotionController object that the state of the windows motion controller
  43666. */
  43667. export class WindowsMotionController extends WebVRController {
  43668. /**
  43669. * The base url used to load the left and right controller models
  43670. */
  43671. static MODEL_BASE_URL: string;
  43672. /**
  43673. * The name of the left controller model file
  43674. */
  43675. static MODEL_LEFT_FILENAME: string;
  43676. /**
  43677. * The name of the right controller model file
  43678. */
  43679. static MODEL_RIGHT_FILENAME: string;
  43680. /**
  43681. * The controller name prefix for this controller type
  43682. */
  43683. static readonly GAMEPAD_ID_PREFIX: string;
  43684. /**
  43685. * The controller id pattern for this controller type
  43686. */
  43687. private static readonly GAMEPAD_ID_PATTERN;
  43688. private _loadedMeshInfo;
  43689. private readonly _mapping;
  43690. /**
  43691. * Fired when the trackpad on this controller is clicked
  43692. */
  43693. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43694. /**
  43695. * Fired when the trackpad on this controller is modified
  43696. */
  43697. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43698. /**
  43699. * The current x and y values of this controller's trackpad
  43700. */
  43701. trackpad: StickValues;
  43702. /**
  43703. * Creates a new WindowsMotionController from a gamepad
  43704. * @param vrGamepad the gamepad that the controller should be created from
  43705. */
  43706. constructor(vrGamepad: any);
  43707. /**
  43708. * Fired when the trigger on this controller is modified
  43709. */
  43710. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43711. /**
  43712. * Fired when the menu button on this controller is modified
  43713. */
  43714. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43715. /**
  43716. * Fired when the grip button on this controller is modified
  43717. */
  43718. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43719. /**
  43720. * Fired when the thumbstick button on this controller is modified
  43721. */
  43722. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43723. /**
  43724. * Fired when the touchpad button on this controller is modified
  43725. */
  43726. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43727. /**
  43728. * Fired when the touchpad values on this controller are modified
  43729. */
  43730. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43731. private _updateTrackpad;
  43732. /**
  43733. * Called once per frame by the engine.
  43734. */
  43735. update(): void;
  43736. /**
  43737. * Called once for each button that changed state since the last frame
  43738. * @param buttonIdx Which button index changed
  43739. * @param state New state of the button
  43740. * @param changes Which properties on the state changed since last frame
  43741. */
  43742. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43743. /**
  43744. * Moves the buttons on the controller mesh based on their current state
  43745. * @param buttonName the name of the button to move
  43746. * @param buttonValue the value of the button which determines the buttons new position
  43747. */
  43748. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43749. /**
  43750. * Moves the axis on the controller mesh based on its current state
  43751. * @param axis the index of the axis
  43752. * @param axisValue the value of the axis which determines the meshes new position
  43753. * @hidden
  43754. */
  43755. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43756. /**
  43757. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43758. * @param scene scene in which to add meshes
  43759. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43760. */
  43761. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43762. /**
  43763. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43764. * can be transformed by button presses and axes values, based on this._mapping.
  43765. *
  43766. * @param scene scene in which the meshes exist
  43767. * @param meshes list of meshes that make up the controller model to process
  43768. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43769. */
  43770. private processModel;
  43771. private createMeshInfo;
  43772. /**
  43773. * Gets the ray of the controller in the direction the controller is pointing
  43774. * @param length the length the resulting ray should be
  43775. * @returns a ray in the direction the controller is pointing
  43776. */
  43777. getForwardRay(length?: number): Ray;
  43778. /**
  43779. * Disposes of the controller
  43780. */
  43781. dispose(): void;
  43782. }
  43783. }
  43784. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43785. import { Observable } from "babylonjs/Misc/observable";
  43786. import { Scene } from "babylonjs/scene";
  43787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43788. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43789. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43790. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43791. /**
  43792. * Oculus Touch Controller
  43793. */
  43794. export class OculusTouchController extends WebVRController {
  43795. /**
  43796. * Base Url for the controller model.
  43797. */
  43798. static MODEL_BASE_URL: string;
  43799. /**
  43800. * File name for the left controller model.
  43801. */
  43802. static MODEL_LEFT_FILENAME: string;
  43803. /**
  43804. * File name for the right controller model.
  43805. */
  43806. static MODEL_RIGHT_FILENAME: string;
  43807. /**
  43808. * Base Url for the Quest controller model.
  43809. */
  43810. static QUEST_MODEL_BASE_URL: string;
  43811. /**
  43812. * @hidden
  43813. * If the controllers are running on a device that needs the updated Quest controller models
  43814. */
  43815. static _IsQuest: boolean;
  43816. /**
  43817. * Fired when the secondary trigger on this controller is modified
  43818. */
  43819. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43820. /**
  43821. * Fired when the thumb rest on this controller is modified
  43822. */
  43823. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43824. /**
  43825. * Creates a new OculusTouchController from a gamepad
  43826. * @param vrGamepad the gamepad that the controller should be created from
  43827. */
  43828. constructor(vrGamepad: any);
  43829. /**
  43830. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43831. * @param scene scene in which to add meshes
  43832. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43833. */
  43834. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43835. /**
  43836. * Fired when the A button on this controller is modified
  43837. */
  43838. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43839. /**
  43840. * Fired when the B button on this controller is modified
  43841. */
  43842. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43843. /**
  43844. * Fired when the X button on this controller is modified
  43845. */
  43846. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43847. /**
  43848. * Fired when the Y button on this controller is modified
  43849. */
  43850. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43851. /**
  43852. * Called once for each button that changed state since the last frame
  43853. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43854. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43855. * 2) secondary trigger (same)
  43856. * 3) A (right) X (left), touch, pressed = value
  43857. * 4) B / Y
  43858. * 5) thumb rest
  43859. * @param buttonIdx Which button index changed
  43860. * @param state New state of the button
  43861. * @param changes Which properties on the state changed since last frame
  43862. */
  43863. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43864. }
  43865. }
  43866. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43867. import { Scene } from "babylonjs/scene";
  43868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43869. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43870. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43871. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43872. import { Observable } from "babylonjs/Misc/observable";
  43873. /**
  43874. * Vive Controller
  43875. */
  43876. export class ViveController extends WebVRController {
  43877. /**
  43878. * Base Url for the controller model.
  43879. */
  43880. static MODEL_BASE_URL: string;
  43881. /**
  43882. * File name for the controller model.
  43883. */
  43884. static MODEL_FILENAME: string;
  43885. /**
  43886. * Creates a new ViveController from a gamepad
  43887. * @param vrGamepad the gamepad that the controller should be created from
  43888. */
  43889. constructor(vrGamepad: any);
  43890. /**
  43891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43892. * @param scene scene in which to add meshes
  43893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43894. */
  43895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43896. /**
  43897. * Fired when the left button on this controller is modified
  43898. */
  43899. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43900. /**
  43901. * Fired when the right button on this controller is modified
  43902. */
  43903. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43904. /**
  43905. * Fired when the menu button on this controller is modified
  43906. */
  43907. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43908. /**
  43909. * Called once for each button that changed state since the last frame
  43910. * Vive mapping:
  43911. * 0: touchpad
  43912. * 1: trigger
  43913. * 2: left AND right buttons
  43914. * 3: menu button
  43915. * @param buttonIdx Which button index changed
  43916. * @param state New state of the button
  43917. * @param changes Which properties on the state changed since last frame
  43918. */
  43919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43920. }
  43921. }
  43922. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43923. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43924. /**
  43925. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43926. */
  43927. export class WebXRControllerModelLoader {
  43928. /**
  43929. * Creates the WebXRControllerModelLoader
  43930. * @param input xr input that creates the controllers
  43931. */
  43932. constructor(input: WebXRInput);
  43933. }
  43934. }
  43935. declare module "babylonjs/Cameras/XR/index" {
  43936. export * from "babylonjs/Cameras/XR/webXRCamera";
  43937. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43938. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43939. export * from "babylonjs/Cameras/XR/webXRInput";
  43940. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43941. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43942. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43943. export * from "babylonjs/Cameras/XR/webXRController";
  43944. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43945. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43946. }
  43947. declare module "babylonjs/Cameras/RigModes/index" {
  43948. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43949. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43950. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43951. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43952. }
  43953. declare module "babylonjs/Cameras/index" {
  43954. export * from "babylonjs/Cameras/Inputs/index";
  43955. export * from "babylonjs/Cameras/cameraInputsManager";
  43956. export * from "babylonjs/Cameras/camera";
  43957. export * from "babylonjs/Cameras/targetCamera";
  43958. export * from "babylonjs/Cameras/freeCamera";
  43959. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43960. export * from "babylonjs/Cameras/touchCamera";
  43961. export * from "babylonjs/Cameras/arcRotateCamera";
  43962. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43963. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43964. export * from "babylonjs/Cameras/flyCamera";
  43965. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43966. export * from "babylonjs/Cameras/followCamera";
  43967. export * from "babylonjs/Cameras/followCameraInputsManager";
  43968. export * from "babylonjs/Cameras/gamepadCamera";
  43969. export * from "babylonjs/Cameras/Stereoscopic/index";
  43970. export * from "babylonjs/Cameras/universalCamera";
  43971. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43972. export * from "babylonjs/Cameras/VR/index";
  43973. export * from "babylonjs/Cameras/XR/index";
  43974. export * from "babylonjs/Cameras/RigModes/index";
  43975. }
  43976. declare module "babylonjs/Collisions/index" {
  43977. export * from "babylonjs/Collisions/collider";
  43978. export * from "babylonjs/Collisions/collisionCoordinator";
  43979. export * from "babylonjs/Collisions/pickingInfo";
  43980. export * from "babylonjs/Collisions/intersectionInfo";
  43981. export * from "babylonjs/Collisions/meshCollisionData";
  43982. }
  43983. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43984. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43985. import { Vector3 } from "babylonjs/Maths/math.vector";
  43986. import { Ray } from "babylonjs/Culling/ray";
  43987. import { Plane } from "babylonjs/Maths/math.plane";
  43988. /**
  43989. * Contains an array of blocks representing the octree
  43990. */
  43991. export interface IOctreeContainer<T> {
  43992. /**
  43993. * Blocks within the octree
  43994. */
  43995. blocks: Array<OctreeBlock<T>>;
  43996. }
  43997. /**
  43998. * Class used to store a cell in an octree
  43999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44000. */
  44001. export class OctreeBlock<T> {
  44002. /**
  44003. * Gets the content of the current block
  44004. */
  44005. entries: T[];
  44006. /**
  44007. * Gets the list of block children
  44008. */
  44009. blocks: Array<OctreeBlock<T>>;
  44010. private _depth;
  44011. private _maxDepth;
  44012. private _capacity;
  44013. private _minPoint;
  44014. private _maxPoint;
  44015. private _boundingVectors;
  44016. private _creationFunc;
  44017. /**
  44018. * Creates a new block
  44019. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44020. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44021. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44022. * @param depth defines the current depth of this block in the octree
  44023. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44024. * @param creationFunc defines a callback to call when an element is added to the block
  44025. */
  44026. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44027. /**
  44028. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44029. */
  44030. readonly capacity: number;
  44031. /**
  44032. * Gets the minimum vector (in world space) of the block's bounding box
  44033. */
  44034. readonly minPoint: Vector3;
  44035. /**
  44036. * Gets the maximum vector (in world space) of the block's bounding box
  44037. */
  44038. readonly maxPoint: Vector3;
  44039. /**
  44040. * Add a new element to this block
  44041. * @param entry defines the element to add
  44042. */
  44043. addEntry(entry: T): void;
  44044. /**
  44045. * Remove an element from this block
  44046. * @param entry defines the element to remove
  44047. */
  44048. removeEntry(entry: T): void;
  44049. /**
  44050. * Add an array of elements to this block
  44051. * @param entries defines the array of elements to add
  44052. */
  44053. addEntries(entries: T[]): void;
  44054. /**
  44055. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44056. * @param frustumPlanes defines the frustum planes to test
  44057. * @param selection defines the array to store current content if selection is positive
  44058. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44059. */
  44060. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44061. /**
  44062. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44063. * @param sphereCenter defines the bounding sphere center
  44064. * @param sphereRadius defines the bounding sphere radius
  44065. * @param selection defines the array to store current content if selection is positive
  44066. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44067. */
  44068. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44069. /**
  44070. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44071. * @param ray defines the ray to test with
  44072. * @param selection defines the array to store current content if selection is positive
  44073. */
  44074. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44075. /**
  44076. * Subdivide the content into child blocks (this block will then be empty)
  44077. */
  44078. createInnerBlocks(): void;
  44079. /**
  44080. * @hidden
  44081. */
  44082. 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;
  44083. }
  44084. }
  44085. declare module "babylonjs/Culling/Octrees/octree" {
  44086. import { SmartArray } from "babylonjs/Misc/smartArray";
  44087. import { Vector3 } from "babylonjs/Maths/math.vector";
  44088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44090. import { Ray } from "babylonjs/Culling/ray";
  44091. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44092. import { Plane } from "babylonjs/Maths/math.plane";
  44093. /**
  44094. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44096. */
  44097. export class Octree<T> {
  44098. /** 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.) */
  44099. maxDepth: number;
  44100. /**
  44101. * Blocks within the octree containing objects
  44102. */
  44103. blocks: Array<OctreeBlock<T>>;
  44104. /**
  44105. * Content stored in the octree
  44106. */
  44107. dynamicContent: T[];
  44108. private _maxBlockCapacity;
  44109. private _selectionContent;
  44110. private _creationFunc;
  44111. /**
  44112. * Creates a octree
  44113. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44114. * @param creationFunc function to be used to instatiate the octree
  44115. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44116. * @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.)
  44117. */
  44118. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44119. /** 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.) */
  44120. maxDepth?: number);
  44121. /**
  44122. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44123. * @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);
  44124. * @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);
  44125. * @param entries meshes to be added to the octree blocks
  44126. */
  44127. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44128. /**
  44129. * Adds a mesh to the octree
  44130. * @param entry Mesh to add to the octree
  44131. */
  44132. addMesh(entry: T): void;
  44133. /**
  44134. * Remove an element from the octree
  44135. * @param entry defines the element to remove
  44136. */
  44137. removeMesh(entry: T): void;
  44138. /**
  44139. * Selects an array of meshes within the frustum
  44140. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44141. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44142. * @returns array of meshes within the frustum
  44143. */
  44144. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44145. /**
  44146. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44147. * @param sphereCenter defines the bounding sphere center
  44148. * @param sphereRadius defines the bounding sphere radius
  44149. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44150. * @returns an array of objects that intersect the sphere
  44151. */
  44152. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44153. /**
  44154. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44155. * @param ray defines the ray to test with
  44156. * @returns array of intersected objects
  44157. */
  44158. intersectsRay(ray: Ray): SmartArray<T>;
  44159. /**
  44160. * Adds a mesh into the octree block if it intersects the block
  44161. */
  44162. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44163. /**
  44164. * Adds a submesh into the octree block if it intersects the block
  44165. */
  44166. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44167. }
  44168. }
  44169. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44170. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44171. import { Scene } from "babylonjs/scene";
  44172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44174. import { Ray } from "babylonjs/Culling/ray";
  44175. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44176. import { Collider } from "babylonjs/Collisions/collider";
  44177. module "babylonjs/scene" {
  44178. interface Scene {
  44179. /**
  44180. * @hidden
  44181. * Backing Filed
  44182. */
  44183. _selectionOctree: Octree<AbstractMesh>;
  44184. /**
  44185. * Gets the octree used to boost mesh selection (picking)
  44186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44187. */
  44188. selectionOctree: Octree<AbstractMesh>;
  44189. /**
  44190. * Creates or updates the octree used to boost selection (picking)
  44191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44192. * @param maxCapacity defines the maximum capacity per leaf
  44193. * @param maxDepth defines the maximum depth of the octree
  44194. * @returns an octree of AbstractMesh
  44195. */
  44196. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44197. }
  44198. }
  44199. module "babylonjs/Meshes/abstractMesh" {
  44200. interface AbstractMesh {
  44201. /**
  44202. * @hidden
  44203. * Backing Field
  44204. */
  44205. _submeshesOctree: Octree<SubMesh>;
  44206. /**
  44207. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44208. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44209. * @param maxCapacity defines the maximum size of each block (64 by default)
  44210. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44211. * @returns the new octree
  44212. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44214. */
  44215. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44216. }
  44217. }
  44218. /**
  44219. * Defines the octree scene component responsible to manage any octrees
  44220. * in a given scene.
  44221. */
  44222. export class OctreeSceneComponent {
  44223. /**
  44224. * The component name help to identify the component in the list of scene components.
  44225. */
  44226. readonly name: string;
  44227. /**
  44228. * The scene the component belongs to.
  44229. */
  44230. scene: Scene;
  44231. /**
  44232. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44233. */
  44234. readonly checksIsEnabled: boolean;
  44235. /**
  44236. * Creates a new instance of the component for the given scene
  44237. * @param scene Defines the scene to register the component in
  44238. */
  44239. constructor(scene: Scene);
  44240. /**
  44241. * Registers the component in a given scene
  44242. */
  44243. register(): void;
  44244. /**
  44245. * Return the list of active meshes
  44246. * @returns the list of active meshes
  44247. */
  44248. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44249. /**
  44250. * Return the list of active sub meshes
  44251. * @param mesh The mesh to get the candidates sub meshes from
  44252. * @returns the list of active sub meshes
  44253. */
  44254. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44255. private _tempRay;
  44256. /**
  44257. * Return the list of sub meshes intersecting with a given local ray
  44258. * @param mesh defines the mesh to find the submesh for
  44259. * @param localRay defines the ray in local space
  44260. * @returns the list of intersecting sub meshes
  44261. */
  44262. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44263. /**
  44264. * Return the list of sub meshes colliding with a collider
  44265. * @param mesh defines the mesh to find the submesh for
  44266. * @param collider defines the collider to evaluate the collision against
  44267. * @returns the list of colliding sub meshes
  44268. */
  44269. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44270. /**
  44271. * Rebuilds the elements related to this component in case of
  44272. * context lost for instance.
  44273. */
  44274. rebuild(): void;
  44275. /**
  44276. * Disposes the component and the associated ressources.
  44277. */
  44278. dispose(): void;
  44279. }
  44280. }
  44281. declare module "babylonjs/Culling/Octrees/index" {
  44282. export * from "babylonjs/Culling/Octrees/octree";
  44283. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44284. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44285. }
  44286. declare module "babylonjs/Culling/index" {
  44287. export * from "babylonjs/Culling/boundingBox";
  44288. export * from "babylonjs/Culling/boundingInfo";
  44289. export * from "babylonjs/Culling/boundingSphere";
  44290. export * from "babylonjs/Culling/Octrees/index";
  44291. export * from "babylonjs/Culling/ray";
  44292. }
  44293. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44294. import { IDisposable, Scene } from "babylonjs/scene";
  44295. import { Nullable } from "babylonjs/types";
  44296. import { Observable } from "babylonjs/Misc/observable";
  44297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44298. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44299. import { Camera } from "babylonjs/Cameras/camera";
  44300. /**
  44301. * Renders a layer on top of an existing scene
  44302. */
  44303. export class UtilityLayerRenderer implements IDisposable {
  44304. /** the original scene that will be rendered on top of */
  44305. originalScene: Scene;
  44306. private _pointerCaptures;
  44307. private _lastPointerEvents;
  44308. private static _DefaultUtilityLayer;
  44309. private static _DefaultKeepDepthUtilityLayer;
  44310. private _sharedGizmoLight;
  44311. private _renderCamera;
  44312. /**
  44313. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44314. * @returns the camera that is used when rendering the utility layer
  44315. */
  44316. getRenderCamera(): Nullable<Camera>;
  44317. /**
  44318. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44319. * @param cam the camera that should be used when rendering the utility layer
  44320. */
  44321. setRenderCamera(cam: Nullable<Camera>): void;
  44322. /**
  44323. * @hidden
  44324. * Light which used by gizmos to get light shading
  44325. */
  44326. _getSharedGizmoLight(): HemisphericLight;
  44327. /**
  44328. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44329. */
  44330. pickUtilitySceneFirst: boolean;
  44331. /**
  44332. * 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)
  44333. */
  44334. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44335. /**
  44336. * 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)
  44337. */
  44338. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44339. /**
  44340. * The scene that is rendered on top of the original scene
  44341. */
  44342. utilityLayerScene: Scene;
  44343. /**
  44344. * If the utility layer should automatically be rendered on top of existing scene
  44345. */
  44346. shouldRender: boolean;
  44347. /**
  44348. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44349. */
  44350. onlyCheckPointerDownEvents: boolean;
  44351. /**
  44352. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44353. */
  44354. processAllEvents: boolean;
  44355. /**
  44356. * Observable raised when the pointer move from the utility layer scene to the main scene
  44357. */
  44358. onPointerOutObservable: Observable<number>;
  44359. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44360. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44361. private _afterRenderObserver;
  44362. private _sceneDisposeObserver;
  44363. private _originalPointerObserver;
  44364. /**
  44365. * Instantiates a UtilityLayerRenderer
  44366. * @param originalScene the original scene that will be rendered on top of
  44367. * @param handleEvents boolean indicating if the utility layer should handle events
  44368. */
  44369. constructor(
  44370. /** the original scene that will be rendered on top of */
  44371. originalScene: Scene, handleEvents?: boolean);
  44372. private _notifyObservers;
  44373. /**
  44374. * Renders the utility layers scene on top of the original scene
  44375. */
  44376. render(): void;
  44377. /**
  44378. * Disposes of the renderer
  44379. */
  44380. dispose(): void;
  44381. private _updateCamera;
  44382. }
  44383. }
  44384. declare module "babylonjs/Gizmos/gizmo" {
  44385. import { Nullable } from "babylonjs/types";
  44386. import { IDisposable } from "babylonjs/scene";
  44387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44388. import { Mesh } from "babylonjs/Meshes/mesh";
  44389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44390. /**
  44391. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44392. */
  44393. export class Gizmo implements IDisposable {
  44394. /** The utility layer the gizmo will be added to */
  44395. gizmoLayer: UtilityLayerRenderer;
  44396. /**
  44397. * The root mesh of the gizmo
  44398. */
  44399. _rootMesh: Mesh;
  44400. private _attachedMesh;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * If a custom mesh has been set (Default: false)
  44407. */
  44408. protected _customMeshSet: boolean;
  44409. /**
  44410. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44411. * * When set, interactions will be enabled
  44412. */
  44413. attachedMesh: Nullable<AbstractMesh>;
  44414. /**
  44415. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44416. * @param mesh The mesh to replace the default mesh of the gizmo
  44417. */
  44418. setCustomMesh(mesh: Mesh): void;
  44419. /**
  44420. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44421. */
  44422. updateGizmoRotationToMatchAttachedMesh: boolean;
  44423. /**
  44424. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44425. */
  44426. updateGizmoPositionToMatchAttachedMesh: boolean;
  44427. /**
  44428. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44429. */
  44430. updateScale: boolean;
  44431. protected _interactionsEnabled: boolean;
  44432. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44433. private _beforeRenderObserver;
  44434. private _tempVector;
  44435. /**
  44436. * Creates a gizmo
  44437. * @param gizmoLayer The utility layer the gizmo will be added to
  44438. */
  44439. constructor(
  44440. /** The utility layer the gizmo will be added to */
  44441. gizmoLayer?: UtilityLayerRenderer);
  44442. /**
  44443. * Updates the gizmo to match the attached mesh's position/rotation
  44444. */
  44445. protected _update(): void;
  44446. /**
  44447. * Disposes of the gizmo
  44448. */
  44449. dispose(): void;
  44450. }
  44451. }
  44452. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44453. import { Observable } from "babylonjs/Misc/observable";
  44454. import { Nullable } from "babylonjs/types";
  44455. import { Vector3 } from "babylonjs/Maths/math.vector";
  44456. import { Color3 } from "babylonjs/Maths/math.color";
  44457. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44459. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44460. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44461. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44462. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44463. import { Scene } from "babylonjs/scene";
  44464. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44465. /**
  44466. * Single plane drag gizmo
  44467. */
  44468. export class PlaneDragGizmo extends Gizmo {
  44469. /**
  44470. * Drag behavior responsible for the gizmos dragging interactions
  44471. */
  44472. dragBehavior: PointerDragBehavior;
  44473. private _pointerObserver;
  44474. /**
  44475. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44476. */
  44477. snapDistance: number;
  44478. /**
  44479. * Event that fires each time the gizmo snaps to a new location.
  44480. * * snapDistance is the the change in distance
  44481. */
  44482. onSnapObservable: Observable<{
  44483. snapDistance: number;
  44484. }>;
  44485. private _plane;
  44486. private _coloredMaterial;
  44487. private _hoverMaterial;
  44488. private _isEnabled;
  44489. private _parent;
  44490. /** @hidden */
  44491. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44492. /** @hidden */
  44493. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44494. /**
  44495. * Creates a PlaneDragGizmo
  44496. * @param gizmoLayer The utility layer the gizmo will be added to
  44497. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44498. * @param color The color of the gizmo
  44499. */
  44500. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44501. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44502. /**
  44503. * If the gizmo is enabled
  44504. */
  44505. isEnabled: boolean;
  44506. /**
  44507. * Disposes of the gizmo
  44508. */
  44509. dispose(): void;
  44510. }
  44511. }
  44512. declare module "babylonjs/Gizmos/positionGizmo" {
  44513. import { Observable } from "babylonjs/Misc/observable";
  44514. import { Nullable } from "babylonjs/types";
  44515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44516. import { Mesh } from "babylonjs/Meshes/mesh";
  44517. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44518. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44519. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44520. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44521. /**
  44522. * Gizmo that enables dragging a mesh along 3 axis
  44523. */
  44524. export class PositionGizmo extends Gizmo {
  44525. /**
  44526. * Internal gizmo used for interactions on the x axis
  44527. */
  44528. xGizmo: AxisDragGizmo;
  44529. /**
  44530. * Internal gizmo used for interactions on the y axis
  44531. */
  44532. yGizmo: AxisDragGizmo;
  44533. /**
  44534. * Internal gizmo used for interactions on the z axis
  44535. */
  44536. zGizmo: AxisDragGizmo;
  44537. /**
  44538. * Internal gizmo used for interactions on the yz plane
  44539. */
  44540. xPlaneGizmo: PlaneDragGizmo;
  44541. /**
  44542. * Internal gizmo used for interactions on the xz plane
  44543. */
  44544. yPlaneGizmo: PlaneDragGizmo;
  44545. /**
  44546. * Internal gizmo used for interactions on the xy plane
  44547. */
  44548. zPlaneGizmo: PlaneDragGizmo;
  44549. /**
  44550. * private variables
  44551. */
  44552. private _meshAttached;
  44553. private _updateGizmoRotationToMatchAttachedMesh;
  44554. private _snapDistance;
  44555. private _scaleRatio;
  44556. /** Fires an event when any of it's sub gizmos are dragged */
  44557. onDragStartObservable: Observable<unknown>;
  44558. /** Fires an event when any of it's sub gizmos are released from dragging */
  44559. onDragEndObservable: Observable<unknown>;
  44560. /**
  44561. * If set to true, planar drag is enabled
  44562. */
  44563. private _planarGizmoEnabled;
  44564. attachedMesh: Nullable<AbstractMesh>;
  44565. /**
  44566. * Creates a PositionGizmo
  44567. * @param gizmoLayer The utility layer the gizmo will be added to
  44568. */
  44569. constructor(gizmoLayer?: UtilityLayerRenderer);
  44570. /**
  44571. * If the planar drag gizmo is enabled
  44572. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44573. */
  44574. planarGizmoEnabled: boolean;
  44575. updateGizmoRotationToMatchAttachedMesh: boolean;
  44576. /**
  44577. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44578. */
  44579. snapDistance: number;
  44580. /**
  44581. * Ratio for the scale of the gizmo (Default: 1)
  44582. */
  44583. scaleRatio: number;
  44584. /**
  44585. * Disposes of the gizmo
  44586. */
  44587. dispose(): void;
  44588. /**
  44589. * CustomMeshes are not supported by this gizmo
  44590. * @param mesh The mesh to replace the default mesh of the gizmo
  44591. */
  44592. setCustomMesh(mesh: Mesh): void;
  44593. }
  44594. }
  44595. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44596. import { Observable } from "babylonjs/Misc/observable";
  44597. import { Nullable } from "babylonjs/types";
  44598. import { Vector3 } from "babylonjs/Maths/math.vector";
  44599. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44601. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44602. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44604. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44605. import { Scene } from "babylonjs/scene";
  44606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44607. import { Color3 } from "babylonjs/Maths/math.color";
  44608. /**
  44609. * Single axis drag gizmo
  44610. */
  44611. export class AxisDragGizmo extends Gizmo {
  44612. /**
  44613. * Drag behavior responsible for the gizmos dragging interactions
  44614. */
  44615. dragBehavior: PointerDragBehavior;
  44616. private _pointerObserver;
  44617. /**
  44618. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44619. */
  44620. snapDistance: number;
  44621. /**
  44622. * Event that fires each time the gizmo snaps to a new location.
  44623. * * snapDistance is the the change in distance
  44624. */
  44625. onSnapObservable: Observable<{
  44626. snapDistance: number;
  44627. }>;
  44628. private _isEnabled;
  44629. private _parent;
  44630. private _arrow;
  44631. private _coloredMaterial;
  44632. private _hoverMaterial;
  44633. /** @hidden */
  44634. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44635. /** @hidden */
  44636. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44637. /**
  44638. * Creates an AxisDragGizmo
  44639. * @param gizmoLayer The utility layer the gizmo will be added to
  44640. * @param dragAxis The axis which the gizmo will be able to drag on
  44641. * @param color The color of the gizmo
  44642. */
  44643. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44645. /**
  44646. * If the gizmo is enabled
  44647. */
  44648. isEnabled: boolean;
  44649. /**
  44650. * Disposes of the gizmo
  44651. */
  44652. dispose(): void;
  44653. }
  44654. }
  44655. declare module "babylonjs/Debug/axesViewer" {
  44656. import { Vector3 } from "babylonjs/Maths/math.vector";
  44657. import { Nullable } from "babylonjs/types";
  44658. import { Scene } from "babylonjs/scene";
  44659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44660. /**
  44661. * The Axes viewer will show 3 axes in a specific point in space
  44662. */
  44663. export class AxesViewer {
  44664. private _xAxis;
  44665. private _yAxis;
  44666. private _zAxis;
  44667. private _scaleLinesFactor;
  44668. private _instanced;
  44669. /**
  44670. * Gets the hosting scene
  44671. */
  44672. scene: Scene;
  44673. /**
  44674. * Gets or sets a number used to scale line length
  44675. */
  44676. scaleLines: number;
  44677. /** Gets the node hierarchy used to render x-axis */
  44678. readonly xAxis: TransformNode;
  44679. /** Gets the node hierarchy used to render y-axis */
  44680. readonly yAxis: TransformNode;
  44681. /** Gets the node hierarchy used to render z-axis */
  44682. readonly zAxis: TransformNode;
  44683. /**
  44684. * Creates a new AxesViewer
  44685. * @param scene defines the hosting scene
  44686. * @param scaleLines defines a number used to scale line length (1 by default)
  44687. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44688. * @param xAxis defines the node hierarchy used to render the x-axis
  44689. * @param yAxis defines the node hierarchy used to render the y-axis
  44690. * @param zAxis defines the node hierarchy used to render the z-axis
  44691. */
  44692. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44693. /**
  44694. * Force the viewer to update
  44695. * @param position defines the position of the viewer
  44696. * @param xaxis defines the x axis of the viewer
  44697. * @param yaxis defines the y axis of the viewer
  44698. * @param zaxis defines the z axis of the viewer
  44699. */
  44700. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44701. /**
  44702. * Creates an instance of this axes viewer.
  44703. * @returns a new axes viewer with instanced meshes
  44704. */
  44705. createInstance(): AxesViewer;
  44706. /** Releases resources */
  44707. dispose(): void;
  44708. private static _SetRenderingGroupId;
  44709. }
  44710. }
  44711. declare module "babylonjs/Debug/boneAxesViewer" {
  44712. import { Nullable } from "babylonjs/types";
  44713. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44714. import { Vector3 } from "babylonjs/Maths/math.vector";
  44715. import { Mesh } from "babylonjs/Meshes/mesh";
  44716. import { Bone } from "babylonjs/Bones/bone";
  44717. import { Scene } from "babylonjs/scene";
  44718. /**
  44719. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44720. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44721. */
  44722. export class BoneAxesViewer extends AxesViewer {
  44723. /**
  44724. * Gets or sets the target mesh where to display the axes viewer
  44725. */
  44726. mesh: Nullable<Mesh>;
  44727. /**
  44728. * Gets or sets the target bone where to display the axes viewer
  44729. */
  44730. bone: Nullable<Bone>;
  44731. /** Gets current position */
  44732. pos: Vector3;
  44733. /** Gets direction of X axis */
  44734. xaxis: Vector3;
  44735. /** Gets direction of Y axis */
  44736. yaxis: Vector3;
  44737. /** Gets direction of Z axis */
  44738. zaxis: Vector3;
  44739. /**
  44740. * Creates a new BoneAxesViewer
  44741. * @param scene defines the hosting scene
  44742. * @param bone defines the target bone
  44743. * @param mesh defines the target mesh
  44744. * @param scaleLines defines a scaling factor for line length (1 by default)
  44745. */
  44746. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44747. /**
  44748. * Force the viewer to update
  44749. */
  44750. update(): void;
  44751. /** Releases resources */
  44752. dispose(): void;
  44753. }
  44754. }
  44755. declare module "babylonjs/Debug/debugLayer" {
  44756. import { Scene } from "babylonjs/scene";
  44757. /**
  44758. * Interface used to define scene explorer extensibility option
  44759. */
  44760. export interface IExplorerExtensibilityOption {
  44761. /**
  44762. * Define the option label
  44763. */
  44764. label: string;
  44765. /**
  44766. * Defines the action to execute on click
  44767. */
  44768. action: (entity: any) => void;
  44769. }
  44770. /**
  44771. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44772. */
  44773. export interface IExplorerExtensibilityGroup {
  44774. /**
  44775. * Defines a predicate to test if a given type mut be extended
  44776. */
  44777. predicate: (entity: any) => boolean;
  44778. /**
  44779. * Gets the list of options added to a type
  44780. */
  44781. entries: IExplorerExtensibilityOption[];
  44782. }
  44783. /**
  44784. * Interface used to define the options to use to create the Inspector
  44785. */
  44786. export interface IInspectorOptions {
  44787. /**
  44788. * Display in overlay mode (default: false)
  44789. */
  44790. overlay?: boolean;
  44791. /**
  44792. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44793. */
  44794. globalRoot?: HTMLElement;
  44795. /**
  44796. * Display the Scene explorer
  44797. */
  44798. showExplorer?: boolean;
  44799. /**
  44800. * Display the property inspector
  44801. */
  44802. showInspector?: boolean;
  44803. /**
  44804. * Display in embed mode (both panes on the right)
  44805. */
  44806. embedMode?: boolean;
  44807. /**
  44808. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44809. */
  44810. handleResize?: boolean;
  44811. /**
  44812. * Allow the panes to popup (default: true)
  44813. */
  44814. enablePopup?: boolean;
  44815. /**
  44816. * Allow the panes to be closed by users (default: true)
  44817. */
  44818. enableClose?: boolean;
  44819. /**
  44820. * Optional list of extensibility entries
  44821. */
  44822. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44823. /**
  44824. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44825. */
  44826. inspectorURL?: string;
  44827. }
  44828. module "babylonjs/scene" {
  44829. interface Scene {
  44830. /**
  44831. * @hidden
  44832. * Backing field
  44833. */
  44834. _debugLayer: DebugLayer;
  44835. /**
  44836. * Gets the debug layer (aka Inspector) associated with the scene
  44837. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44838. */
  44839. debugLayer: DebugLayer;
  44840. }
  44841. }
  44842. /**
  44843. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44844. * what is happening in your scene
  44845. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44846. */
  44847. export class DebugLayer {
  44848. /**
  44849. * Define the url to get the inspector script from.
  44850. * By default it uses the babylonjs CDN.
  44851. * @ignoreNaming
  44852. */
  44853. static InspectorURL: string;
  44854. private _scene;
  44855. private BJSINSPECTOR;
  44856. private _onPropertyChangedObservable?;
  44857. /**
  44858. * Observable triggered when a property is changed through the inspector.
  44859. */
  44860. readonly onPropertyChangedObservable: any;
  44861. /**
  44862. * Instantiates a new debug layer.
  44863. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44864. * what is happening in your scene
  44865. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44866. * @param scene Defines the scene to inspect
  44867. */
  44868. constructor(scene: Scene);
  44869. /** Creates the inspector window. */
  44870. private _createInspector;
  44871. /**
  44872. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44873. * @param entity defines the entity to select
  44874. * @param lineContainerTitle defines the specific block to highlight
  44875. */
  44876. select(entity: any, lineContainerTitle?: string): void;
  44877. /** Get the inspector from bundle or global */
  44878. private _getGlobalInspector;
  44879. /**
  44880. * Get if the inspector is visible or not.
  44881. * @returns true if visible otherwise, false
  44882. */
  44883. isVisible(): boolean;
  44884. /**
  44885. * Hide the inspector and close its window.
  44886. */
  44887. hide(): void;
  44888. /**
  44889. * Launch the debugLayer.
  44890. * @param config Define the configuration of the inspector
  44891. * @return a promise fulfilled when the debug layer is visible
  44892. */
  44893. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44894. }
  44895. }
  44896. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44897. import { Nullable } from "babylonjs/types";
  44898. import { Scene } from "babylonjs/scene";
  44899. import { Vector4 } from "babylonjs/Maths/math.vector";
  44900. import { Color4 } from "babylonjs/Maths/math.color";
  44901. import { Mesh } from "babylonjs/Meshes/mesh";
  44902. /**
  44903. * Class containing static functions to help procedurally build meshes
  44904. */
  44905. export class BoxBuilder {
  44906. /**
  44907. * Creates a box mesh
  44908. * * The parameter `size` sets the size (float) of each box side (default 1)
  44909. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44910. * * 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)
  44911. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44915. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44916. * @param name defines the name of the mesh
  44917. * @param options defines the options used to create the mesh
  44918. * @param scene defines the hosting scene
  44919. * @returns the box mesh
  44920. */
  44921. static CreateBox(name: string, options: {
  44922. size?: number;
  44923. width?: number;
  44924. height?: number;
  44925. depth?: number;
  44926. faceUV?: Vector4[];
  44927. faceColors?: Color4[];
  44928. sideOrientation?: number;
  44929. frontUVs?: Vector4;
  44930. backUVs?: Vector4;
  44931. wrap?: boolean;
  44932. topBaseAt?: number;
  44933. bottomBaseAt?: number;
  44934. updatable?: boolean;
  44935. }, scene?: Nullable<Scene>): Mesh;
  44936. }
  44937. }
  44938. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44939. import { Vector4 } from "babylonjs/Maths/math.vector";
  44940. import { Mesh } from "babylonjs/Meshes/mesh";
  44941. import { Scene } from "babylonjs/scene";
  44942. import { Nullable } from "babylonjs/types";
  44943. /**
  44944. * Class containing static functions to help procedurally build meshes
  44945. */
  44946. export class SphereBuilder {
  44947. /**
  44948. * Creates a sphere mesh
  44949. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44950. * * 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`)
  44951. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44952. * * 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
  44953. * * 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)
  44954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44957. * @param name defines the name of the mesh
  44958. * @param options defines the options used to create the mesh
  44959. * @param scene defines the hosting scene
  44960. * @returns the sphere mesh
  44961. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44962. */
  44963. static CreateSphere(name: string, options: {
  44964. segments?: number;
  44965. diameter?: number;
  44966. diameterX?: number;
  44967. diameterY?: number;
  44968. diameterZ?: number;
  44969. arc?: number;
  44970. slice?: number;
  44971. sideOrientation?: number;
  44972. frontUVs?: Vector4;
  44973. backUVs?: Vector4;
  44974. updatable?: boolean;
  44975. }, scene?: Nullable<Scene>): Mesh;
  44976. }
  44977. }
  44978. declare module "babylonjs/Debug/physicsViewer" {
  44979. import { Nullable } from "babylonjs/types";
  44980. import { Scene } from "babylonjs/scene";
  44981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44982. import { Mesh } from "babylonjs/Meshes/mesh";
  44983. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44984. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44985. /**
  44986. * Used to show the physics impostor around the specific mesh
  44987. */
  44988. export class PhysicsViewer {
  44989. /** @hidden */
  44990. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44991. /** @hidden */
  44992. protected _meshes: Array<Nullable<AbstractMesh>>;
  44993. /** @hidden */
  44994. protected _scene: Nullable<Scene>;
  44995. /** @hidden */
  44996. protected _numMeshes: number;
  44997. /** @hidden */
  44998. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44999. private _renderFunction;
  45000. private _utilityLayer;
  45001. private _debugBoxMesh;
  45002. private _debugSphereMesh;
  45003. private _debugCylinderMesh;
  45004. private _debugMaterial;
  45005. private _debugMeshMeshes;
  45006. /**
  45007. * Creates a new PhysicsViewer
  45008. * @param scene defines the hosting scene
  45009. */
  45010. constructor(scene: Scene);
  45011. /** @hidden */
  45012. protected _updateDebugMeshes(): void;
  45013. /**
  45014. * Renders a specified physic impostor
  45015. * @param impostor defines the impostor to render
  45016. * @param targetMesh defines the mesh represented by the impostor
  45017. * @returns the new debug mesh used to render the impostor
  45018. */
  45019. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45020. /**
  45021. * Hides a specified physic impostor
  45022. * @param impostor defines the impostor to hide
  45023. */
  45024. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45025. private _getDebugMaterial;
  45026. private _getDebugBoxMesh;
  45027. private _getDebugSphereMesh;
  45028. private _getDebugCylinderMesh;
  45029. private _getDebugMeshMesh;
  45030. private _getDebugMesh;
  45031. /** Releases all resources */
  45032. dispose(): void;
  45033. }
  45034. }
  45035. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45036. import { Vector3 } from "babylonjs/Maths/math.vector";
  45037. import { Color4 } from "babylonjs/Maths/math.color";
  45038. import { Nullable } from "babylonjs/types";
  45039. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45040. import { Scene } from "babylonjs/scene";
  45041. /**
  45042. * Class containing static functions to help procedurally build meshes
  45043. */
  45044. export class LinesBuilder {
  45045. /**
  45046. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45047. * * 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
  45048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45049. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45050. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45051. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45053. * * 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
  45054. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45057. * @param name defines the name of the new line system
  45058. * @param options defines the options used to create the line system
  45059. * @param scene defines the hosting scene
  45060. * @returns a new line system mesh
  45061. */
  45062. static CreateLineSystem(name: string, options: {
  45063. lines: Vector3[][];
  45064. updatable?: boolean;
  45065. instance?: Nullable<LinesMesh>;
  45066. colors?: Nullable<Color4[][]>;
  45067. useVertexAlpha?: boolean;
  45068. }, scene: Nullable<Scene>): LinesMesh;
  45069. /**
  45070. * Creates a line mesh
  45071. * 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
  45072. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45073. * * The parameter `points` is an array successive Vector3
  45074. * * 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
  45075. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45076. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45077. * * When updating an instance, remember that only point positions can change, not the number of points
  45078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45080. * @param name defines the name of the new line system
  45081. * @param options defines the options used to create the line system
  45082. * @param scene defines the hosting scene
  45083. * @returns a new line mesh
  45084. */
  45085. static CreateLines(name: string, options: {
  45086. points: Vector3[];
  45087. updatable?: boolean;
  45088. instance?: Nullable<LinesMesh>;
  45089. colors?: Color4[];
  45090. useVertexAlpha?: boolean;
  45091. }, scene?: Nullable<Scene>): LinesMesh;
  45092. /**
  45093. * Creates a dashed line mesh
  45094. * * 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
  45095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45096. * * The parameter `points` is an array successive Vector3
  45097. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45098. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45099. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45100. * * 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
  45101. * * When updating an instance, remember that only point positions can change, not the number of points
  45102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45103. * @param name defines the name of the mesh
  45104. * @param options defines the options used to create the mesh
  45105. * @param scene defines the hosting scene
  45106. * @returns the dashed line mesh
  45107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45108. */
  45109. static CreateDashedLines(name: string, options: {
  45110. points: Vector3[];
  45111. dashSize?: number;
  45112. gapSize?: number;
  45113. dashNb?: number;
  45114. updatable?: boolean;
  45115. instance?: LinesMesh;
  45116. }, scene?: Nullable<Scene>): LinesMesh;
  45117. }
  45118. }
  45119. declare module "babylonjs/Debug/rayHelper" {
  45120. import { Nullable } from "babylonjs/types";
  45121. import { Ray } from "babylonjs/Culling/ray";
  45122. import { Vector3 } from "babylonjs/Maths/math.vector";
  45123. import { Color3 } from "babylonjs/Maths/math.color";
  45124. import { Scene } from "babylonjs/scene";
  45125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45126. import "babylonjs/Meshes/Builders/linesBuilder";
  45127. /**
  45128. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45129. * in order to better appreciate the issue one might have.
  45130. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45131. */
  45132. export class RayHelper {
  45133. /**
  45134. * Defines the ray we are currently tryin to visualize.
  45135. */
  45136. ray: Nullable<Ray>;
  45137. private _renderPoints;
  45138. private _renderLine;
  45139. private _renderFunction;
  45140. private _scene;
  45141. private _updateToMeshFunction;
  45142. private _attachedToMesh;
  45143. private _meshSpaceDirection;
  45144. private _meshSpaceOrigin;
  45145. /**
  45146. * Helper function to create a colored helper in a scene in one line.
  45147. * @param ray Defines the ray we are currently tryin to visualize
  45148. * @param scene Defines the scene the ray is used in
  45149. * @param color Defines the color we want to see the ray in
  45150. * @returns The newly created ray helper.
  45151. */
  45152. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45153. /**
  45154. * Instantiate a new ray helper.
  45155. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45156. * in order to better appreciate the issue one might have.
  45157. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45158. * @param ray Defines the ray we are currently tryin to visualize
  45159. */
  45160. constructor(ray: Ray);
  45161. /**
  45162. * Shows the ray we are willing to debug.
  45163. * @param scene Defines the scene the ray needs to be rendered in
  45164. * @param color Defines the color the ray needs to be rendered in
  45165. */
  45166. show(scene: Scene, color?: Color3): void;
  45167. /**
  45168. * Hides the ray we are debugging.
  45169. */
  45170. hide(): void;
  45171. private _render;
  45172. /**
  45173. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45174. * @param mesh Defines the mesh we want the helper attached to
  45175. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45176. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45177. * @param length Defines the length of the ray
  45178. */
  45179. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45180. /**
  45181. * Detach the ray helper from the mesh it has previously been attached to.
  45182. */
  45183. detachFromMesh(): void;
  45184. private _updateToMesh;
  45185. /**
  45186. * Dispose the helper and release its associated resources.
  45187. */
  45188. dispose(): void;
  45189. }
  45190. }
  45191. declare module "babylonjs/Debug/skeletonViewer" {
  45192. import { Color3 } from "babylonjs/Maths/math.color";
  45193. import { Scene } from "babylonjs/scene";
  45194. import { Nullable } from "babylonjs/types";
  45195. import { Skeleton } from "babylonjs/Bones/skeleton";
  45196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45197. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45198. /**
  45199. * Class used to render a debug view of a given skeleton
  45200. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45201. */
  45202. export class SkeletonViewer {
  45203. /** defines the skeleton to render */
  45204. skeleton: Skeleton;
  45205. /** defines the mesh attached to the skeleton */
  45206. mesh: AbstractMesh;
  45207. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45208. autoUpdateBonesMatrices: boolean;
  45209. /** defines the rendering group id to use with the viewer */
  45210. renderingGroupId: number;
  45211. /** Gets or sets the color used to render the skeleton */
  45212. color: Color3;
  45213. private _scene;
  45214. private _debugLines;
  45215. private _debugMesh;
  45216. private _isEnabled;
  45217. private _renderFunction;
  45218. private _utilityLayer;
  45219. /**
  45220. * Returns the mesh used to render the bones
  45221. */
  45222. readonly debugMesh: Nullable<LinesMesh>;
  45223. /**
  45224. * Creates a new SkeletonViewer
  45225. * @param skeleton defines the skeleton to render
  45226. * @param mesh defines the mesh attached to the skeleton
  45227. * @param scene defines the hosting scene
  45228. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45229. * @param renderingGroupId defines the rendering group id to use with the viewer
  45230. */
  45231. constructor(
  45232. /** defines the skeleton to render */
  45233. skeleton: Skeleton,
  45234. /** defines the mesh attached to the skeleton */
  45235. mesh: AbstractMesh, scene: Scene,
  45236. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45237. autoUpdateBonesMatrices?: boolean,
  45238. /** defines the rendering group id to use with the viewer */
  45239. renderingGroupId?: number);
  45240. /** Gets or sets a boolean indicating if the viewer is enabled */
  45241. isEnabled: boolean;
  45242. private _getBonePosition;
  45243. private _getLinesForBonesWithLength;
  45244. private _getLinesForBonesNoLength;
  45245. /** Update the viewer to sync with current skeleton state */
  45246. update(): void;
  45247. /** Release associated resources */
  45248. dispose(): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Debug/index" {
  45252. export * from "babylonjs/Debug/axesViewer";
  45253. export * from "babylonjs/Debug/boneAxesViewer";
  45254. export * from "babylonjs/Debug/debugLayer";
  45255. export * from "babylonjs/Debug/physicsViewer";
  45256. export * from "babylonjs/Debug/rayHelper";
  45257. export * from "babylonjs/Debug/skeletonViewer";
  45258. }
  45259. declare module "babylonjs/Engines/nullEngine" {
  45260. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45261. import { Scene } from "babylonjs/scene";
  45262. import { Engine } from "babylonjs/Engines/engine";
  45263. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45264. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45265. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45266. import { Effect } from "babylonjs/Materials/effect";
  45267. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45269. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45270. /**
  45271. * Options to create the null engine
  45272. */
  45273. export class NullEngineOptions {
  45274. /**
  45275. * Render width (Default: 512)
  45276. */
  45277. renderWidth: number;
  45278. /**
  45279. * Render height (Default: 256)
  45280. */
  45281. renderHeight: number;
  45282. /**
  45283. * Texture size (Default: 512)
  45284. */
  45285. textureSize: number;
  45286. /**
  45287. * If delta time between frames should be constant
  45288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45289. */
  45290. deterministicLockstep: boolean;
  45291. /**
  45292. * Maximum about of steps between frames (Default: 4)
  45293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45294. */
  45295. lockstepMaxSteps: number;
  45296. }
  45297. /**
  45298. * The null engine class provides support for headless version of babylon.js.
  45299. * This can be used in server side scenario or for testing purposes
  45300. */
  45301. export class NullEngine extends Engine {
  45302. private _options;
  45303. /**
  45304. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45306. * @returns true if engine is in deterministic lock step mode
  45307. */
  45308. isDeterministicLockStep(): boolean;
  45309. /**
  45310. * Gets the max steps when engine is running in deterministic lock step
  45311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45312. * @returns the max steps
  45313. */
  45314. getLockstepMaxSteps(): number;
  45315. /**
  45316. * Gets the current hardware scaling level.
  45317. * By default the hardware scaling level is computed from the window device ratio.
  45318. * 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.
  45319. * @returns a number indicating the current hardware scaling level
  45320. */
  45321. getHardwareScalingLevel(): number;
  45322. constructor(options?: NullEngineOptions);
  45323. /**
  45324. * Creates a vertex buffer
  45325. * @param vertices the data for the vertex buffer
  45326. * @returns the new WebGL static buffer
  45327. */
  45328. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45329. /**
  45330. * Creates a new index buffer
  45331. * @param indices defines the content of the index buffer
  45332. * @param updatable defines if the index buffer must be updatable
  45333. * @returns a new webGL buffer
  45334. */
  45335. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45336. /**
  45337. * Clear the current render buffer or the current render target (if any is set up)
  45338. * @param color defines the color to use
  45339. * @param backBuffer defines if the back buffer must be cleared
  45340. * @param depth defines if the depth buffer must be cleared
  45341. * @param stencil defines if the stencil buffer must be cleared
  45342. */
  45343. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45344. /**
  45345. * Gets the current render width
  45346. * @param useScreen defines if screen size must be used (or the current render target if any)
  45347. * @returns a number defining the current render width
  45348. */
  45349. getRenderWidth(useScreen?: boolean): number;
  45350. /**
  45351. * Gets the current render height
  45352. * @param useScreen defines if screen size must be used (or the current render target if any)
  45353. * @returns a number defining the current render height
  45354. */
  45355. getRenderHeight(useScreen?: boolean): number;
  45356. /**
  45357. * Set the WebGL's viewport
  45358. * @param viewport defines the viewport element to be used
  45359. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45360. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45361. */
  45362. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45363. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45364. /**
  45365. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45366. * @param pipelineContext defines the pipeline context to use
  45367. * @param uniformsNames defines the list of uniform names
  45368. * @returns an array of webGL uniform locations
  45369. */
  45370. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45371. /**
  45372. * Gets the lsit of active attributes for a given webGL program
  45373. * @param pipelineContext defines the pipeline context to use
  45374. * @param attributesNames defines the list of attribute names to get
  45375. * @returns an array of indices indicating the offset of each attribute
  45376. */
  45377. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45378. /**
  45379. * Binds an effect to the webGL context
  45380. * @param effect defines the effect to bind
  45381. */
  45382. bindSamplers(effect: Effect): void;
  45383. /**
  45384. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45385. * @param effect defines the effect to activate
  45386. */
  45387. enableEffect(effect: Effect): void;
  45388. /**
  45389. * Set various states to the webGL context
  45390. * @param culling defines backface culling state
  45391. * @param zOffset defines the value to apply to zOffset (0 by default)
  45392. * @param force defines if states must be applied even if cache is up to date
  45393. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45394. */
  45395. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45396. /**
  45397. * Set the value of an uniform to an array of int32
  45398. * @param uniform defines the webGL uniform location where to store the value
  45399. * @param array defines the array of int32 to store
  45400. */
  45401. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45402. /**
  45403. * Set the value of an uniform to an array of int32 (stored as vec2)
  45404. * @param uniform defines the webGL uniform location where to store the value
  45405. * @param array defines the array of int32 to store
  45406. */
  45407. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45408. /**
  45409. * Set the value of an uniform to an array of int32 (stored as vec3)
  45410. * @param uniform defines the webGL uniform location where to store the value
  45411. * @param array defines the array of int32 to store
  45412. */
  45413. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45414. /**
  45415. * Set the value of an uniform to an array of int32 (stored as vec4)
  45416. * @param uniform defines the webGL uniform location where to store the value
  45417. * @param array defines the array of int32 to store
  45418. */
  45419. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45420. /**
  45421. * Set the value of an uniform to an array of float32
  45422. * @param uniform defines the webGL uniform location where to store the value
  45423. * @param array defines the array of float32 to store
  45424. */
  45425. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45426. /**
  45427. * Set the value of an uniform to an array of float32 (stored as vec2)
  45428. * @param uniform defines the webGL uniform location where to store the value
  45429. * @param array defines the array of float32 to store
  45430. */
  45431. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45432. /**
  45433. * Set the value of an uniform to an array of float32 (stored as vec3)
  45434. * @param uniform defines the webGL uniform location where to store the value
  45435. * @param array defines the array of float32 to store
  45436. */
  45437. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45438. /**
  45439. * Set the value of an uniform to an array of float32 (stored as vec4)
  45440. * @param uniform defines the webGL uniform location where to store the value
  45441. * @param array defines the array of float32 to store
  45442. */
  45443. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45444. /**
  45445. * Set the value of an uniform to an array of number
  45446. * @param uniform defines the webGL uniform location where to store the value
  45447. * @param array defines the array of number to store
  45448. */
  45449. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45450. /**
  45451. * Set the value of an uniform to an array of number (stored as vec2)
  45452. * @param uniform defines the webGL uniform location where to store the value
  45453. * @param array defines the array of number to store
  45454. */
  45455. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45456. /**
  45457. * Set the value of an uniform to an array of number (stored as vec3)
  45458. * @param uniform defines the webGL uniform location where to store the value
  45459. * @param array defines the array of number to store
  45460. */
  45461. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45462. /**
  45463. * Set the value of an uniform to an array of number (stored as vec4)
  45464. * @param uniform defines the webGL uniform location where to store the value
  45465. * @param array defines the array of number to store
  45466. */
  45467. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45468. /**
  45469. * Set the value of an uniform to an array of float32 (stored as matrices)
  45470. * @param uniform defines the webGL uniform location where to store the value
  45471. * @param matrices defines the array of float32 to store
  45472. */
  45473. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45474. /**
  45475. * Set the value of an uniform to a matrix (3x3)
  45476. * @param uniform defines the webGL uniform location where to store the value
  45477. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45478. */
  45479. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45480. /**
  45481. * Set the value of an uniform to a matrix (2x2)
  45482. * @param uniform defines the webGL uniform location where to store the value
  45483. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45484. */
  45485. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45486. /**
  45487. * Set the value of an uniform to a number (float)
  45488. * @param uniform defines the webGL uniform location where to store the value
  45489. * @param value defines the float number to store
  45490. */
  45491. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45492. /**
  45493. * Set the value of an uniform to a vec2
  45494. * @param uniform defines the webGL uniform location where to store the value
  45495. * @param x defines the 1st component of the value
  45496. * @param y defines the 2nd component of the value
  45497. */
  45498. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45499. /**
  45500. * Set the value of an uniform to a vec3
  45501. * @param uniform defines the webGL uniform location where to store the value
  45502. * @param x defines the 1st component of the value
  45503. * @param y defines the 2nd component of the value
  45504. * @param z defines the 3rd component of the value
  45505. */
  45506. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45507. /**
  45508. * Set the value of an uniform to a boolean
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param bool defines the boolean to store
  45511. */
  45512. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45513. /**
  45514. * Set the value of an uniform to a vec4
  45515. * @param uniform defines the webGL uniform location where to store the value
  45516. * @param x defines the 1st component of the value
  45517. * @param y defines the 2nd component of the value
  45518. * @param z defines the 3rd component of the value
  45519. * @param w defines the 4th component of the value
  45520. */
  45521. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45522. /**
  45523. * Sets the current alpha mode
  45524. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45525. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45526. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45527. */
  45528. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45529. /**
  45530. * Bind webGl buffers directly to the webGL context
  45531. * @param vertexBuffers defines the vertex buffer to bind
  45532. * @param indexBuffer defines the index buffer to bind
  45533. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45534. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45535. * @param effect defines the effect associated with the vertex buffer
  45536. */
  45537. bindBuffers(vertexBuffers: {
  45538. [key: string]: VertexBuffer;
  45539. }, indexBuffer: DataBuffer, effect: Effect): void;
  45540. /**
  45541. * Force the entire cache to be cleared
  45542. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45543. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45544. */
  45545. wipeCaches(bruteForce?: boolean): void;
  45546. /**
  45547. * Send a draw order
  45548. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45549. * @param indexStart defines the starting index
  45550. * @param indexCount defines the number of index to draw
  45551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45552. */
  45553. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45554. /**
  45555. * Draw a list of indexed primitives
  45556. * @param fillMode defines the primitive to use
  45557. * @param indexStart defines the starting index
  45558. * @param indexCount defines the number of index to draw
  45559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45560. */
  45561. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45562. /**
  45563. * Draw a list of unindexed primitives
  45564. * @param fillMode defines the primitive to use
  45565. * @param verticesStart defines the index of first vertex to draw
  45566. * @param verticesCount defines the count of vertices to draw
  45567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45568. */
  45569. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45570. /** @hidden */
  45571. _createTexture(): WebGLTexture;
  45572. /** @hidden */
  45573. _releaseTexture(texture: InternalTexture): void;
  45574. /**
  45575. * Usually called from Texture.ts.
  45576. * Passed information to create a WebGLTexture
  45577. * @param urlArg defines a value which contains one of the following:
  45578. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45579. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45580. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45582. * @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)
  45583. * @param scene needed for loading to the correct scene
  45584. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45585. * @param onLoad optional callback to be called upon successful completion
  45586. * @param onError optional callback to be called upon failure
  45587. * @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
  45588. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45589. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45590. * @param forcedExtension defines the extension to use to pick the right loader
  45591. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45592. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45593. */
  45594. 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;
  45595. /**
  45596. * Creates a new render target texture
  45597. * @param size defines the size of the texture
  45598. * @param options defines the options used to create the texture
  45599. * @returns a new render target texture stored in an InternalTexture
  45600. */
  45601. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45602. /**
  45603. * Update the sampling mode of a given texture
  45604. * @param samplingMode defines the required sampling mode
  45605. * @param texture defines the texture to update
  45606. */
  45607. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45608. /**
  45609. * Binds the frame buffer to the specified texture.
  45610. * @param texture The texture to render to or null for the default canvas
  45611. * @param faceIndex The face of the texture to render to in case of cube texture
  45612. * @param requiredWidth The width of the target to render to
  45613. * @param requiredHeight The height of the target to render to
  45614. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45615. * @param depthStencilTexture The depth stencil texture to use to render
  45616. * @param lodLevel defines le lod level to bind to the frame buffer
  45617. */
  45618. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45619. /**
  45620. * Unbind the current render target texture from the webGL context
  45621. * @param texture defines the render target texture to unbind
  45622. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45623. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45624. */
  45625. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45626. /**
  45627. * Creates a dynamic vertex buffer
  45628. * @param vertices the data for the dynamic vertex buffer
  45629. * @returns the new WebGL dynamic buffer
  45630. */
  45631. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45632. /**
  45633. * Update the content of a dynamic texture
  45634. * @param texture defines the texture to update
  45635. * @param canvas defines the canvas containing the source
  45636. * @param invertY defines if data must be stored with Y axis inverted
  45637. * @param premulAlpha defines if alpha is stored as premultiplied
  45638. * @param format defines the format of the data
  45639. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45640. */
  45641. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45642. /**
  45643. * Gets a boolean indicating if all created effects are ready
  45644. * @returns true if all effects are ready
  45645. */
  45646. areAllEffectsReady(): boolean;
  45647. /**
  45648. * @hidden
  45649. * Get the current error code of the webGL context
  45650. * @returns the error code
  45651. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45652. */
  45653. getError(): number;
  45654. /** @hidden */
  45655. _getUnpackAlignement(): number;
  45656. /** @hidden */
  45657. _unpackFlipY(value: boolean): void;
  45658. /**
  45659. * Update a dynamic index buffer
  45660. * @param indexBuffer defines the target index buffer
  45661. * @param indices defines the data to update
  45662. * @param offset defines the offset in the target index buffer where update should start
  45663. */
  45664. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45665. /**
  45666. * Updates a dynamic vertex buffer.
  45667. * @param vertexBuffer the vertex buffer to update
  45668. * @param vertices the data used to update the vertex buffer
  45669. * @param byteOffset the byte offset of the data (optional)
  45670. * @param byteLength the byte length of the data (optional)
  45671. */
  45672. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45673. /** @hidden */
  45674. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45675. /** @hidden */
  45676. _bindTexture(channel: number, texture: InternalTexture): void;
  45677. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45678. /**
  45679. * 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
  45680. */
  45681. releaseEffects(): void;
  45682. displayLoadingUI(): void;
  45683. hideLoadingUI(): void;
  45684. /** @hidden */
  45685. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45686. /** @hidden */
  45687. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45688. /** @hidden */
  45689. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45690. /** @hidden */
  45691. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45692. }
  45693. }
  45694. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45695. import { Nullable, int } from "babylonjs/types";
  45696. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45697. /** @hidden */
  45698. export class _OcclusionDataStorage {
  45699. /** @hidden */
  45700. occlusionInternalRetryCounter: number;
  45701. /** @hidden */
  45702. isOcclusionQueryInProgress: boolean;
  45703. /** @hidden */
  45704. isOccluded: boolean;
  45705. /** @hidden */
  45706. occlusionRetryCount: number;
  45707. /** @hidden */
  45708. occlusionType: number;
  45709. /** @hidden */
  45710. occlusionQueryAlgorithmType: number;
  45711. }
  45712. module "babylonjs/Engines/engine" {
  45713. interface Engine {
  45714. /**
  45715. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45716. * @return the new query
  45717. */
  45718. createQuery(): WebGLQuery;
  45719. /**
  45720. * Delete and release a webGL query
  45721. * @param query defines the query to delete
  45722. * @return the current engine
  45723. */
  45724. deleteQuery(query: WebGLQuery): Engine;
  45725. /**
  45726. * Check if a given query has resolved and got its value
  45727. * @param query defines the query to check
  45728. * @returns true if the query got its value
  45729. */
  45730. isQueryResultAvailable(query: WebGLQuery): boolean;
  45731. /**
  45732. * Gets the value of a given query
  45733. * @param query defines the query to check
  45734. * @returns the value of the query
  45735. */
  45736. getQueryResult(query: WebGLQuery): number;
  45737. /**
  45738. * Initiates an occlusion query
  45739. * @param algorithmType defines the algorithm to use
  45740. * @param query defines the query to use
  45741. * @returns the current engine
  45742. * @see http://doc.babylonjs.com/features/occlusionquery
  45743. */
  45744. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45745. /**
  45746. * Ends an occlusion query
  45747. * @see http://doc.babylonjs.com/features/occlusionquery
  45748. * @param algorithmType defines the algorithm to use
  45749. * @returns the current engine
  45750. */
  45751. endOcclusionQuery(algorithmType: number): Engine;
  45752. /**
  45753. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45754. * Please note that only one query can be issued at a time
  45755. * @returns a time token used to track the time span
  45756. */
  45757. startTimeQuery(): Nullable<_TimeToken>;
  45758. /**
  45759. * Ends a time query
  45760. * @param token defines the token used to measure the time span
  45761. * @returns the time spent (in ns)
  45762. */
  45763. endTimeQuery(token: _TimeToken): int;
  45764. /** @hidden */
  45765. _currentNonTimestampToken: Nullable<_TimeToken>;
  45766. /** @hidden */
  45767. _createTimeQuery(): WebGLQuery;
  45768. /** @hidden */
  45769. _deleteTimeQuery(query: WebGLQuery): void;
  45770. /** @hidden */
  45771. _getGlAlgorithmType(algorithmType: number): number;
  45772. /** @hidden */
  45773. _getTimeQueryResult(query: WebGLQuery): any;
  45774. /** @hidden */
  45775. _getTimeQueryAvailability(query: WebGLQuery): any;
  45776. }
  45777. }
  45778. module "babylonjs/Meshes/abstractMesh" {
  45779. interface AbstractMesh {
  45780. /**
  45781. * Backing filed
  45782. * @hidden
  45783. */
  45784. __occlusionDataStorage: _OcclusionDataStorage;
  45785. /**
  45786. * Access property
  45787. * @hidden
  45788. */
  45789. _occlusionDataStorage: _OcclusionDataStorage;
  45790. /**
  45791. * 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.
  45792. * The default value is -1 which means don't break the query and wait till the result
  45793. * @see http://doc.babylonjs.com/features/occlusionquery
  45794. */
  45795. occlusionRetryCount: number;
  45796. /**
  45797. * 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:
  45798. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45799. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45800. * * 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.
  45801. * @see http://doc.babylonjs.com/features/occlusionquery
  45802. */
  45803. occlusionType: number;
  45804. /**
  45805. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45806. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45807. * * 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.
  45808. * @see http://doc.babylonjs.com/features/occlusionquery
  45809. */
  45810. occlusionQueryAlgorithmType: number;
  45811. /**
  45812. * 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
  45813. * @see http://doc.babylonjs.com/features/occlusionquery
  45814. */
  45815. isOccluded: boolean;
  45816. /**
  45817. * Flag to check the progress status of the query
  45818. * @see http://doc.babylonjs.com/features/occlusionquery
  45819. */
  45820. isOcclusionQueryInProgress: boolean;
  45821. }
  45822. }
  45823. }
  45824. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45825. import { Nullable } from "babylonjs/types";
  45826. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45827. /** @hidden */
  45828. export var _forceTransformFeedbackToBundle: boolean;
  45829. module "babylonjs/Engines/engine" {
  45830. interface Engine {
  45831. /**
  45832. * Creates a webGL transform feedback object
  45833. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45834. * @returns the webGL transform feedback object
  45835. */
  45836. createTransformFeedback(): WebGLTransformFeedback;
  45837. /**
  45838. * Delete a webGL transform feedback object
  45839. * @param value defines the webGL transform feedback object to delete
  45840. */
  45841. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45842. /**
  45843. * Bind a webGL transform feedback object to the webgl context
  45844. * @param value defines the webGL transform feedback object to bind
  45845. */
  45846. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45847. /**
  45848. * Begins a transform feedback operation
  45849. * @param usePoints defines if points or triangles must be used
  45850. */
  45851. beginTransformFeedback(usePoints: boolean): void;
  45852. /**
  45853. * Ends a transform feedback operation
  45854. */
  45855. endTransformFeedback(): void;
  45856. /**
  45857. * Specify the varyings to use with transform feedback
  45858. * @param program defines the associated webGL program
  45859. * @param value defines the list of strings representing the varying names
  45860. */
  45861. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45862. /**
  45863. * Bind a webGL buffer for a transform feedback operation
  45864. * @param value defines the webGL buffer to bind
  45865. */
  45866. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45867. }
  45868. }
  45869. }
  45870. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45871. import { Scene } from "babylonjs/scene";
  45872. import { Engine } from "babylonjs/Engines/engine";
  45873. import { Texture } from "babylonjs/Materials/Textures/texture";
  45874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45875. import "babylonjs/Engines/Extensions/engine.multiRender";
  45876. /**
  45877. * Creation options of the multi render target texture.
  45878. */
  45879. export interface IMultiRenderTargetOptions {
  45880. /**
  45881. * Define if the texture needs to create mip maps after render.
  45882. */
  45883. generateMipMaps?: boolean;
  45884. /**
  45885. * Define the types of all the draw buffers we want to create
  45886. */
  45887. types?: number[];
  45888. /**
  45889. * Define the sampling modes of all the draw buffers we want to create
  45890. */
  45891. samplingModes?: number[];
  45892. /**
  45893. * Define if a depth buffer is required
  45894. */
  45895. generateDepthBuffer?: boolean;
  45896. /**
  45897. * Define if a stencil buffer is required
  45898. */
  45899. generateStencilBuffer?: boolean;
  45900. /**
  45901. * Define if a depth texture is required instead of a depth buffer
  45902. */
  45903. generateDepthTexture?: boolean;
  45904. /**
  45905. * Define the number of desired draw buffers
  45906. */
  45907. textureCount?: number;
  45908. /**
  45909. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45910. */
  45911. doNotChangeAspectRatio?: boolean;
  45912. /**
  45913. * Define the default type of the buffers we are creating
  45914. */
  45915. defaultType?: number;
  45916. }
  45917. /**
  45918. * A multi render target, like a render target provides the ability to render to a texture.
  45919. * Unlike the render target, it can render to several draw buffers in one draw.
  45920. * This is specially interesting in deferred rendering or for any effects requiring more than
  45921. * just one color from a single pass.
  45922. */
  45923. export class MultiRenderTarget extends RenderTargetTexture {
  45924. private _internalTextures;
  45925. private _textures;
  45926. private _multiRenderTargetOptions;
  45927. /**
  45928. * Get if draw buffers are currently supported by the used hardware and browser.
  45929. */
  45930. readonly isSupported: boolean;
  45931. /**
  45932. * Get the list of textures generated by the multi render target.
  45933. */
  45934. readonly textures: Texture[];
  45935. /**
  45936. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45937. */
  45938. readonly depthTexture: Texture;
  45939. /**
  45940. * Set the wrapping mode on U of all the textures we are rendering to.
  45941. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45942. */
  45943. wrapU: number;
  45944. /**
  45945. * Set the wrapping mode on V of all the textures we are rendering to.
  45946. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45947. */
  45948. wrapV: number;
  45949. /**
  45950. * Instantiate a new multi render target texture.
  45951. * A multi render target, like a render target provides the ability to render to a texture.
  45952. * Unlike the render target, it can render to several draw buffers in one draw.
  45953. * This is specially interesting in deferred rendering or for any effects requiring more than
  45954. * just one color from a single pass.
  45955. * @param name Define the name of the texture
  45956. * @param size Define the size of the buffers to render to
  45957. * @param count Define the number of target we are rendering into
  45958. * @param scene Define the scene the texture belongs to
  45959. * @param options Define the options used to create the multi render target
  45960. */
  45961. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45962. /** @hidden */
  45963. _rebuild(): void;
  45964. private _createInternalTextures;
  45965. private _createTextures;
  45966. /**
  45967. * Define the number of samples used if MSAA is enabled.
  45968. */
  45969. samples: number;
  45970. /**
  45971. * Resize all the textures in the multi render target.
  45972. * Be carrefull as it will recreate all the data in the new texture.
  45973. * @param size Define the new size
  45974. */
  45975. resize(size: any): void;
  45976. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45977. /**
  45978. * Dispose the render targets and their associated resources
  45979. */
  45980. dispose(): void;
  45981. /**
  45982. * Release all the underlying texture used as draw buffers.
  45983. */
  45984. releaseInternalTextures(): void;
  45985. }
  45986. }
  45987. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45989. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45990. import { Nullable } from "babylonjs/types";
  45991. module "babylonjs/Engines/thinEngine" {
  45992. interface ThinEngine {
  45993. /**
  45994. * Unbind a list of render target textures from the webGL context
  45995. * This is used only when drawBuffer extension or webGL2 are active
  45996. * @param textures defines the render target textures to unbind
  45997. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45998. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45999. */
  46000. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46001. /**
  46002. * Create a multi render target texture
  46003. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46004. * @param size defines the size of the texture
  46005. * @param options defines the creation options
  46006. * @returns the cube texture as an InternalTexture
  46007. */
  46008. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46009. /**
  46010. * Update the sample count for a given multiple render target texture
  46011. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46012. * @param textures defines the textures to update
  46013. * @param samples defines the sample count to set
  46014. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46015. */
  46016. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46017. }
  46018. }
  46019. }
  46020. declare module "babylonjs/Engines/Extensions/index" {
  46021. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46022. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46023. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46024. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46025. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46026. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46027. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46028. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46029. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46030. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46031. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46032. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46033. }
  46034. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46035. import { Nullable } from "babylonjs/types";
  46036. /**
  46037. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46038. */
  46039. export interface CubeMapInfo {
  46040. /**
  46041. * The pixel array for the front face.
  46042. * This is stored in format, left to right, up to down format.
  46043. */
  46044. front: Nullable<ArrayBufferView>;
  46045. /**
  46046. * The pixel array for the back face.
  46047. * This is stored in format, left to right, up to down format.
  46048. */
  46049. back: Nullable<ArrayBufferView>;
  46050. /**
  46051. * The pixel array for the left face.
  46052. * This is stored in format, left to right, up to down format.
  46053. */
  46054. left: Nullable<ArrayBufferView>;
  46055. /**
  46056. * The pixel array for the right face.
  46057. * This is stored in format, left to right, up to down format.
  46058. */
  46059. right: Nullable<ArrayBufferView>;
  46060. /**
  46061. * The pixel array for the up face.
  46062. * This is stored in format, left to right, up to down format.
  46063. */
  46064. up: Nullable<ArrayBufferView>;
  46065. /**
  46066. * The pixel array for the down face.
  46067. * This is stored in format, left to right, up to down format.
  46068. */
  46069. down: Nullable<ArrayBufferView>;
  46070. /**
  46071. * The size of the cubemap stored.
  46072. *
  46073. * Each faces will be size * size pixels.
  46074. */
  46075. size: number;
  46076. /**
  46077. * The format of the texture.
  46078. *
  46079. * RGBA, RGB.
  46080. */
  46081. format: number;
  46082. /**
  46083. * The type of the texture data.
  46084. *
  46085. * UNSIGNED_INT, FLOAT.
  46086. */
  46087. type: number;
  46088. /**
  46089. * Specifies whether the texture is in gamma space.
  46090. */
  46091. gammaSpace: boolean;
  46092. }
  46093. /**
  46094. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46095. */
  46096. export class PanoramaToCubeMapTools {
  46097. private static FACE_FRONT;
  46098. private static FACE_BACK;
  46099. private static FACE_RIGHT;
  46100. private static FACE_LEFT;
  46101. private static FACE_DOWN;
  46102. private static FACE_UP;
  46103. /**
  46104. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46105. *
  46106. * @param float32Array The source data.
  46107. * @param inputWidth The width of the input panorama.
  46108. * @param inputHeight The height of the input panorama.
  46109. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46110. * @return The cubemap data
  46111. */
  46112. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46113. private static CreateCubemapTexture;
  46114. private static CalcProjectionSpherical;
  46115. }
  46116. }
  46117. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46118. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46120. import { Nullable } from "babylonjs/types";
  46121. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46122. /**
  46123. * Helper class dealing with the extraction of spherical polynomial dataArray
  46124. * from a cube map.
  46125. */
  46126. export class CubeMapToSphericalPolynomialTools {
  46127. private static FileFaces;
  46128. /**
  46129. * Converts a texture to the according Spherical Polynomial data.
  46130. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46131. *
  46132. * @param texture The texture to extract the information from.
  46133. * @return The Spherical Polynomial data.
  46134. */
  46135. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46136. /**
  46137. * Converts a cubemap to the according Spherical Polynomial data.
  46138. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46139. *
  46140. * @param cubeInfo The Cube map to extract the information from.
  46141. * @return The Spherical Polynomial data.
  46142. */
  46143. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46144. }
  46145. }
  46146. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46147. import { Nullable } from "babylonjs/types";
  46148. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46149. module "babylonjs/Materials/Textures/baseTexture" {
  46150. interface BaseTexture {
  46151. /**
  46152. * Get the polynomial representation of the texture data.
  46153. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46154. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46155. */
  46156. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46157. }
  46158. }
  46159. }
  46160. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46161. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46162. /** @hidden */
  46163. export var rgbdEncodePixelShader: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46169. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46170. /** @hidden */
  46171. export var rgbdDecodePixelShader: {
  46172. name: string;
  46173. shader: string;
  46174. };
  46175. }
  46176. declare module "babylonjs/Misc/environmentTextureTools" {
  46177. import { Nullable } from "babylonjs/types";
  46178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46181. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46182. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46183. import "babylonjs/Shaders/rgbdEncode.fragment";
  46184. import "babylonjs/Shaders/rgbdDecode.fragment";
  46185. /**
  46186. * Raw texture data and descriptor sufficient for WebGL texture upload
  46187. */
  46188. export interface EnvironmentTextureInfo {
  46189. /**
  46190. * Version of the environment map
  46191. */
  46192. version: number;
  46193. /**
  46194. * Width of image
  46195. */
  46196. width: number;
  46197. /**
  46198. * Irradiance information stored in the file.
  46199. */
  46200. irradiance: any;
  46201. /**
  46202. * Specular information stored in the file.
  46203. */
  46204. specular: any;
  46205. }
  46206. /**
  46207. * Defines One Image in the file. It requires only the position in the file
  46208. * as well as the length.
  46209. */
  46210. interface BufferImageData {
  46211. /**
  46212. * Length of the image data.
  46213. */
  46214. length: number;
  46215. /**
  46216. * Position of the data from the null terminator delimiting the end of the JSON.
  46217. */
  46218. position: number;
  46219. }
  46220. /**
  46221. * Defines the specular data enclosed in the file.
  46222. * This corresponds to the version 1 of the data.
  46223. */
  46224. export interface EnvironmentTextureSpecularInfoV1 {
  46225. /**
  46226. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46227. */
  46228. specularDataPosition?: number;
  46229. /**
  46230. * This contains all the images data needed to reconstruct the cubemap.
  46231. */
  46232. mipmaps: Array<BufferImageData>;
  46233. /**
  46234. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46235. */
  46236. lodGenerationScale: number;
  46237. }
  46238. /**
  46239. * Sets of helpers addressing the serialization and deserialization of environment texture
  46240. * stored in a BabylonJS env file.
  46241. * Those files are usually stored as .env files.
  46242. */
  46243. export class EnvironmentTextureTools {
  46244. /**
  46245. * Magic number identifying the env file.
  46246. */
  46247. private static _MagicBytes;
  46248. /**
  46249. * Gets the environment info from an env file.
  46250. * @param data The array buffer containing the .env bytes.
  46251. * @returns the environment file info (the json header) if successfully parsed.
  46252. */
  46253. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46254. /**
  46255. * Creates an environment texture from a loaded cube texture.
  46256. * @param texture defines the cube texture to convert in env file
  46257. * @return a promise containing the environment data if succesfull.
  46258. */
  46259. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46260. /**
  46261. * Creates a JSON representation of the spherical data.
  46262. * @param texture defines the texture containing the polynomials
  46263. * @return the JSON representation of the spherical info
  46264. */
  46265. private static _CreateEnvTextureIrradiance;
  46266. /**
  46267. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46268. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46269. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46270. * @return the views described by info providing access to the underlying buffer
  46271. */
  46272. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46273. /**
  46274. * Uploads the texture info contained in the env file to the GPU.
  46275. * @param texture defines the internal texture to upload to
  46276. * @param arrayBuffer defines the buffer cotaining the data to load
  46277. * @param info defines the texture info retrieved through the GetEnvInfo method
  46278. * @returns a promise
  46279. */
  46280. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46281. /**
  46282. * Uploads the levels of image data to the GPU.
  46283. * @param texture defines the internal texture to upload to
  46284. * @param imageData defines the array buffer views of image data [mipmap][face]
  46285. * @returns a promise
  46286. */
  46287. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46288. /**
  46289. * Uploads spherical polynomials information to the texture.
  46290. * @param texture defines the texture we are trying to upload the information to
  46291. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46292. */
  46293. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46294. /** @hidden */
  46295. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46296. }
  46297. }
  46298. declare module "babylonjs/Maths/math.vertexFormat" {
  46299. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46300. /**
  46301. * Contains position and normal vectors for a vertex
  46302. */
  46303. export class PositionNormalVertex {
  46304. /** the position of the vertex (defaut: 0,0,0) */
  46305. position: Vector3;
  46306. /** the normal of the vertex (defaut: 0,1,0) */
  46307. normal: Vector3;
  46308. /**
  46309. * Creates a PositionNormalVertex
  46310. * @param position the position of the vertex (defaut: 0,0,0)
  46311. * @param normal the normal of the vertex (defaut: 0,1,0)
  46312. */
  46313. constructor(
  46314. /** the position of the vertex (defaut: 0,0,0) */
  46315. position?: Vector3,
  46316. /** the normal of the vertex (defaut: 0,1,0) */
  46317. normal?: Vector3);
  46318. /**
  46319. * Clones the PositionNormalVertex
  46320. * @returns the cloned PositionNormalVertex
  46321. */
  46322. clone(): PositionNormalVertex;
  46323. }
  46324. /**
  46325. * Contains position, normal and uv vectors for a vertex
  46326. */
  46327. export class PositionNormalTextureVertex {
  46328. /** the position of the vertex (defaut: 0,0,0) */
  46329. position: Vector3;
  46330. /** the normal of the vertex (defaut: 0,1,0) */
  46331. normal: Vector3;
  46332. /** the uv of the vertex (default: 0,0) */
  46333. uv: Vector2;
  46334. /**
  46335. * Creates a PositionNormalTextureVertex
  46336. * @param position the position of the vertex (defaut: 0,0,0)
  46337. * @param normal the normal of the vertex (defaut: 0,1,0)
  46338. * @param uv the uv of the vertex (default: 0,0)
  46339. */
  46340. constructor(
  46341. /** the position of the vertex (defaut: 0,0,0) */
  46342. position?: Vector3,
  46343. /** the normal of the vertex (defaut: 0,1,0) */
  46344. normal?: Vector3,
  46345. /** the uv of the vertex (default: 0,0) */
  46346. uv?: Vector2);
  46347. /**
  46348. * Clones the PositionNormalTextureVertex
  46349. * @returns the cloned PositionNormalTextureVertex
  46350. */
  46351. clone(): PositionNormalTextureVertex;
  46352. }
  46353. }
  46354. declare module "babylonjs/Maths/math" {
  46355. export * from "babylonjs/Maths/math.axis";
  46356. export * from "babylonjs/Maths/math.color";
  46357. export * from "babylonjs/Maths/math.constants";
  46358. export * from "babylonjs/Maths/math.frustum";
  46359. export * from "babylonjs/Maths/math.path";
  46360. export * from "babylonjs/Maths/math.plane";
  46361. export * from "babylonjs/Maths/math.size";
  46362. export * from "babylonjs/Maths/math.vector";
  46363. export * from "babylonjs/Maths/math.vertexFormat";
  46364. export * from "babylonjs/Maths/math.viewport";
  46365. }
  46366. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46367. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46368. /** @hidden */
  46369. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46370. private _genericAttributeLocation;
  46371. private _varyingLocationCount;
  46372. private _varyingLocationMap;
  46373. private _replacements;
  46374. private _textureCount;
  46375. private _uniforms;
  46376. lineProcessor(line: string): string;
  46377. attributeProcessor(attribute: string): string;
  46378. varyingProcessor(varying: string, isFragment: boolean): string;
  46379. uniformProcessor(uniform: string): string;
  46380. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46381. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46382. }
  46383. }
  46384. declare module "babylonjs/Engines/nativeEngine" {
  46385. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46386. import { Engine } from "babylonjs/Engines/engine";
  46387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46390. import { Effect } from "babylonjs/Materials/effect";
  46391. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46392. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46393. import { Scene } from "babylonjs/scene";
  46394. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46395. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46396. /**
  46397. * Container for accessors for natively-stored mesh data buffers.
  46398. */
  46399. class NativeDataBuffer extends DataBuffer {
  46400. /**
  46401. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46402. */
  46403. nativeIndexBuffer?: any;
  46404. /**
  46405. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46406. */
  46407. nativeVertexBuffer?: any;
  46408. }
  46409. /** @hidden */
  46410. export class NativeEngine extends Engine {
  46411. private readonly _native;
  46412. getHardwareScalingLevel(): number;
  46413. constructor();
  46414. /**
  46415. * Can be used to override the current requestAnimationFrame requester.
  46416. * @hidden
  46417. */
  46418. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46419. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46420. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46421. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46422. recordVertexArrayObject(vertexBuffers: {
  46423. [key: string]: VertexBuffer;
  46424. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46425. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46426. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46428. /**
  46429. * Draw a list of indexed primitives
  46430. * @param fillMode defines the primitive to use
  46431. * @param indexStart defines the starting index
  46432. * @param indexCount defines the number of index to draw
  46433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46434. */
  46435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46436. /**
  46437. * Draw a list of unindexed primitives
  46438. * @param fillMode defines the primitive to use
  46439. * @param verticesStart defines the index of first vertex to draw
  46440. * @param verticesCount defines the count of vertices to draw
  46441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46442. */
  46443. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46444. createPipelineContext(): IPipelineContext;
  46445. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46446. /** @hidden */
  46447. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46448. /** @hidden */
  46449. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46450. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46451. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46452. protected _setProgram(program: WebGLProgram): void;
  46453. _releaseEffect(effect: Effect): void;
  46454. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46455. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46456. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46457. bindSamplers(effect: Effect): void;
  46458. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46459. getRenderWidth(useScreen?: boolean): number;
  46460. getRenderHeight(useScreen?: boolean): number;
  46461. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46462. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46463. /**
  46464. * Set the z offset to apply to current rendering
  46465. * @param value defines the offset to apply
  46466. */
  46467. setZOffset(value: number): void;
  46468. /**
  46469. * Gets the current value of the zOffset
  46470. * @returns the current zOffset state
  46471. */
  46472. getZOffset(): number;
  46473. /**
  46474. * Enable or disable depth buffering
  46475. * @param enable defines the state to set
  46476. */
  46477. setDepthBuffer(enable: boolean): void;
  46478. /**
  46479. * Gets a boolean indicating if depth writing is enabled
  46480. * @returns the current depth writing state
  46481. */
  46482. getDepthWrite(): boolean;
  46483. /**
  46484. * Enable or disable depth writing
  46485. * @param enable defines the state to set
  46486. */
  46487. setDepthWrite(enable: boolean): void;
  46488. /**
  46489. * Enable or disable color writing
  46490. * @param enable defines the state to set
  46491. */
  46492. setColorWrite(enable: boolean): void;
  46493. /**
  46494. * Gets a boolean indicating if color writing is enabled
  46495. * @returns the current color writing state
  46496. */
  46497. getColorWrite(): boolean;
  46498. /**
  46499. * Sets alpha constants used by some alpha blending modes
  46500. * @param r defines the red component
  46501. * @param g defines the green component
  46502. * @param b defines the blue component
  46503. * @param a defines the alpha component
  46504. */
  46505. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46506. /**
  46507. * Sets the current alpha mode
  46508. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46509. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46511. */
  46512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46513. /**
  46514. * Gets the current alpha mode
  46515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46516. * @returns the current alpha mode
  46517. */
  46518. getAlphaMode(): number;
  46519. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46520. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46521. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46522. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46523. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46524. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46525. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46526. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46527. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46528. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46529. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46530. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46531. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46532. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46533. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46534. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46535. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46536. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46537. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46538. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46539. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46540. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46541. wipeCaches(bruteForce?: boolean): void;
  46542. _createTexture(): WebGLTexture;
  46543. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46544. /**
  46545. * Usually called from BABYLON.Texture.ts.
  46546. * Passed information to create a WebGLTexture
  46547. * @param urlArg defines a value which contains one of the following:
  46548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46552. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46553. * @param scene needed for loading to the correct scene
  46554. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46555. * @param onLoad optional callback to be called upon successful completion
  46556. * @param onError optional callback to be called upon failure
  46557. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46560. * @param forcedExtension defines the extension to use to pick the right loader
  46561. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46562. */
  46563. 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;
  46564. /**
  46565. * Creates a cube texture
  46566. * @param rootUrl defines the url where the files to load is located
  46567. * @param scene defines the current scene
  46568. * @param files defines the list of files to load (1 per face)
  46569. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46570. * @param onLoad defines an optional callback raised when the texture is loaded
  46571. * @param onError defines an optional callback raised if there is an issue to load the texture
  46572. * @param format defines the format of the data
  46573. * @param forcedExtension defines the extension to use to pick the right loader
  46574. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46577. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46578. * @returns the cube texture as an InternalTexture
  46579. */
  46580. 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;
  46581. private _getSamplingFilter;
  46582. private static _GetNativeTextureFormat;
  46583. createRenderTargetTexture(size: number | {
  46584. width: number;
  46585. height: number;
  46586. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46587. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46588. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46589. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46590. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46591. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46592. /**
  46593. * Updates a dynamic vertex buffer.
  46594. * @param vertexBuffer the vertex buffer to update
  46595. * @param data the data used to update the vertex buffer
  46596. * @param byteOffset the byte offset of the data (optional)
  46597. * @param byteLength the byte length of the data (optional)
  46598. */
  46599. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46600. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46601. private _updateAnisotropicLevel;
  46602. private _getAddressMode;
  46603. /** @hidden */
  46604. _bindTexture(channel: number, texture: InternalTexture): void;
  46605. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46606. releaseEffects(): void;
  46607. /** @hidden */
  46608. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46609. /** @hidden */
  46610. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46611. /** @hidden */
  46612. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46613. /** @hidden */
  46614. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46615. }
  46616. }
  46617. declare module "babylonjs/Engines/index" {
  46618. export * from "babylonjs/Engines/constants";
  46619. export * from "babylonjs/Engines/engineCapabilities";
  46620. export * from "babylonjs/Engines/instancingAttributeInfo";
  46621. export * from "babylonjs/Engines/thinEngine";
  46622. export * from "babylonjs/Engines/engine";
  46623. export * from "babylonjs/Engines/engineStore";
  46624. export * from "babylonjs/Engines/nullEngine";
  46625. export * from "babylonjs/Engines/Extensions/index";
  46626. export * from "babylonjs/Engines/IPipelineContext";
  46627. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46628. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46629. export * from "babylonjs/Engines/nativeEngine";
  46630. }
  46631. declare module "babylonjs/Events/clipboardEvents" {
  46632. /**
  46633. * Gather the list of clipboard event types as constants.
  46634. */
  46635. export class ClipboardEventTypes {
  46636. /**
  46637. * The clipboard event is fired when a copy command is active (pressed).
  46638. */
  46639. static readonly COPY: number;
  46640. /**
  46641. * The clipboard event is fired when a cut command is active (pressed).
  46642. */
  46643. static readonly CUT: number;
  46644. /**
  46645. * The clipboard event is fired when a paste command is active (pressed).
  46646. */
  46647. static readonly PASTE: number;
  46648. }
  46649. /**
  46650. * This class is used to store clipboard related info for the onClipboardObservable event.
  46651. */
  46652. export class ClipboardInfo {
  46653. /**
  46654. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46655. */
  46656. type: number;
  46657. /**
  46658. * Defines the related dom event
  46659. */
  46660. event: ClipboardEvent;
  46661. /**
  46662. *Creates an instance of ClipboardInfo.
  46663. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46664. * @param event Defines the related dom event
  46665. */
  46666. constructor(
  46667. /**
  46668. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46669. */
  46670. type: number,
  46671. /**
  46672. * Defines the related dom event
  46673. */
  46674. event: ClipboardEvent);
  46675. /**
  46676. * Get the clipboard event's type from the keycode.
  46677. * @param keyCode Defines the keyCode for the current keyboard event.
  46678. * @return {number}
  46679. */
  46680. static GetTypeFromCharacter(keyCode: number): number;
  46681. }
  46682. }
  46683. declare module "babylonjs/Events/index" {
  46684. export * from "babylonjs/Events/keyboardEvents";
  46685. export * from "babylonjs/Events/pointerEvents";
  46686. export * from "babylonjs/Events/clipboardEvents";
  46687. }
  46688. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46689. import { Scene } from "babylonjs/scene";
  46690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46691. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46692. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46693. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46694. /**
  46695. * Google Daydream controller
  46696. */
  46697. export class DaydreamController extends WebVRController {
  46698. /**
  46699. * Base Url for the controller model.
  46700. */
  46701. static MODEL_BASE_URL: string;
  46702. /**
  46703. * File name for the controller model.
  46704. */
  46705. static MODEL_FILENAME: string;
  46706. /**
  46707. * Gamepad Id prefix used to identify Daydream Controller.
  46708. */
  46709. static readonly GAMEPAD_ID_PREFIX: string;
  46710. /**
  46711. * Creates a new DaydreamController from a gamepad
  46712. * @param vrGamepad the gamepad that the controller should be created from
  46713. */
  46714. constructor(vrGamepad: any);
  46715. /**
  46716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46717. * @param scene scene in which to add meshes
  46718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46719. */
  46720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46721. /**
  46722. * Called once for each button that changed state since the last frame
  46723. * @param buttonIdx Which button index changed
  46724. * @param state New state of the button
  46725. * @param changes Which properties on the state changed since last frame
  46726. */
  46727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46728. }
  46729. }
  46730. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46731. import { Scene } from "babylonjs/scene";
  46732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46733. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46734. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46735. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46736. /**
  46737. * Gear VR Controller
  46738. */
  46739. export class GearVRController extends WebVRController {
  46740. /**
  46741. * Base Url for the controller model.
  46742. */
  46743. static MODEL_BASE_URL: string;
  46744. /**
  46745. * File name for the controller model.
  46746. */
  46747. static MODEL_FILENAME: string;
  46748. /**
  46749. * Gamepad Id prefix used to identify this controller.
  46750. */
  46751. static readonly GAMEPAD_ID_PREFIX: string;
  46752. private readonly _buttonIndexToObservableNameMap;
  46753. /**
  46754. * Creates a new GearVRController from a gamepad
  46755. * @param vrGamepad the gamepad that the controller should be created from
  46756. */
  46757. constructor(vrGamepad: any);
  46758. /**
  46759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46760. * @param scene scene in which to add meshes
  46761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46762. */
  46763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46764. /**
  46765. * Called once for each button that changed state since the last frame
  46766. * @param buttonIdx Which button index changed
  46767. * @param state New state of the button
  46768. * @param changes Which properties on the state changed since last frame
  46769. */
  46770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46771. }
  46772. }
  46773. declare module "babylonjs/Gamepads/Controllers/index" {
  46774. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46775. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46776. export * from "babylonjs/Gamepads/Controllers/genericController";
  46777. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46778. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46779. export * from "babylonjs/Gamepads/Controllers/viveController";
  46780. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46781. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46782. }
  46783. declare module "babylonjs/Gamepads/index" {
  46784. export * from "babylonjs/Gamepads/Controllers/index";
  46785. export * from "babylonjs/Gamepads/gamepad";
  46786. export * from "babylonjs/Gamepads/gamepadManager";
  46787. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46788. export * from "babylonjs/Gamepads/xboxGamepad";
  46789. export * from "babylonjs/Gamepads/dualShockGamepad";
  46790. }
  46791. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46792. import { Scene } from "babylonjs/scene";
  46793. import { Vector4 } from "babylonjs/Maths/math.vector";
  46794. import { Color4 } from "babylonjs/Maths/math.color";
  46795. import { Mesh } from "babylonjs/Meshes/mesh";
  46796. import { Nullable } from "babylonjs/types";
  46797. /**
  46798. * Class containing static functions to help procedurally build meshes
  46799. */
  46800. export class PolyhedronBuilder {
  46801. /**
  46802. * Creates a polyhedron mesh
  46803. * * 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
  46804. * * The parameter `size` (positive float, default 1) sets the polygon size
  46805. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46806. * * 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`
  46807. * * 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
  46808. * * 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)`)
  46809. * * 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
  46810. * * 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
  46811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46814. * @param name defines the name of the mesh
  46815. * @param options defines the options used to create the mesh
  46816. * @param scene defines the hosting scene
  46817. * @returns the polyhedron mesh
  46818. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46819. */
  46820. static CreatePolyhedron(name: string, options: {
  46821. type?: number;
  46822. size?: number;
  46823. sizeX?: number;
  46824. sizeY?: number;
  46825. sizeZ?: number;
  46826. custom?: any;
  46827. faceUV?: Vector4[];
  46828. faceColors?: Color4[];
  46829. flat?: boolean;
  46830. updatable?: boolean;
  46831. sideOrientation?: number;
  46832. frontUVs?: Vector4;
  46833. backUVs?: Vector4;
  46834. }, scene?: Nullable<Scene>): Mesh;
  46835. }
  46836. }
  46837. declare module "babylonjs/Gizmos/scaleGizmo" {
  46838. import { Observable } from "babylonjs/Misc/observable";
  46839. import { Nullable } from "babylonjs/types";
  46840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46841. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46842. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46844. /**
  46845. * Gizmo that enables scaling a mesh along 3 axis
  46846. */
  46847. export class ScaleGizmo extends Gizmo {
  46848. /**
  46849. * Internal gizmo used for interactions on the x axis
  46850. */
  46851. xGizmo: AxisScaleGizmo;
  46852. /**
  46853. * Internal gizmo used for interactions on the y axis
  46854. */
  46855. yGizmo: AxisScaleGizmo;
  46856. /**
  46857. * Internal gizmo used for interactions on the z axis
  46858. */
  46859. zGizmo: AxisScaleGizmo;
  46860. /**
  46861. * Internal gizmo used to scale all axis equally
  46862. */
  46863. uniformScaleGizmo: AxisScaleGizmo;
  46864. private _meshAttached;
  46865. private _updateGizmoRotationToMatchAttachedMesh;
  46866. private _snapDistance;
  46867. private _scaleRatio;
  46868. private _uniformScalingMesh;
  46869. private _octahedron;
  46870. /** Fires an event when any of it's sub gizmos are dragged */
  46871. onDragStartObservable: Observable<unknown>;
  46872. /** Fires an event when any of it's sub gizmos are released from dragging */
  46873. onDragEndObservable: Observable<unknown>;
  46874. attachedMesh: Nullable<AbstractMesh>;
  46875. /**
  46876. * Creates a ScaleGizmo
  46877. * @param gizmoLayer The utility layer the gizmo will be added to
  46878. */
  46879. constructor(gizmoLayer?: UtilityLayerRenderer);
  46880. updateGizmoRotationToMatchAttachedMesh: boolean;
  46881. /**
  46882. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46883. */
  46884. snapDistance: number;
  46885. /**
  46886. * Ratio for the scale of the gizmo (Default: 1)
  46887. */
  46888. scaleRatio: number;
  46889. /**
  46890. * Disposes of the gizmo
  46891. */
  46892. dispose(): void;
  46893. }
  46894. }
  46895. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46896. import { Observable } from "babylonjs/Misc/observable";
  46897. import { Nullable } from "babylonjs/types";
  46898. import { Vector3 } from "babylonjs/Maths/math.vector";
  46899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46900. import { Mesh } from "babylonjs/Meshes/mesh";
  46901. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46902. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46903. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46904. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46905. import { Color3 } from "babylonjs/Maths/math.color";
  46906. /**
  46907. * Single axis scale gizmo
  46908. */
  46909. export class AxisScaleGizmo extends Gizmo {
  46910. /**
  46911. * Drag behavior responsible for the gizmos dragging interactions
  46912. */
  46913. dragBehavior: PointerDragBehavior;
  46914. private _pointerObserver;
  46915. /**
  46916. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46917. */
  46918. snapDistance: number;
  46919. /**
  46920. * Event that fires each time the gizmo snaps to a new location.
  46921. * * snapDistance is the the change in distance
  46922. */
  46923. onSnapObservable: Observable<{
  46924. snapDistance: number;
  46925. }>;
  46926. /**
  46927. * If the scaling operation should be done on all axis (default: false)
  46928. */
  46929. uniformScaling: boolean;
  46930. private _isEnabled;
  46931. private _parent;
  46932. private _arrow;
  46933. private _coloredMaterial;
  46934. private _hoverMaterial;
  46935. /**
  46936. * Creates an AxisScaleGizmo
  46937. * @param gizmoLayer The utility layer the gizmo will be added to
  46938. * @param dragAxis The axis which the gizmo will be able to scale on
  46939. * @param color The color of the gizmo
  46940. */
  46941. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46942. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46943. /**
  46944. * If the gizmo is enabled
  46945. */
  46946. isEnabled: boolean;
  46947. /**
  46948. * Disposes of the gizmo
  46949. */
  46950. dispose(): void;
  46951. /**
  46952. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46953. * @param mesh The mesh to replace the default mesh of the gizmo
  46954. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46955. */
  46956. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46957. }
  46958. }
  46959. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46960. import { Observable } from "babylonjs/Misc/observable";
  46961. import { Nullable } from "babylonjs/types";
  46962. import { Vector3 } from "babylonjs/Maths/math.vector";
  46963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46964. import { Mesh } from "babylonjs/Meshes/mesh";
  46965. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46966. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46967. import { Color3 } from "babylonjs/Maths/math.color";
  46968. import "babylonjs/Meshes/Builders/boxBuilder";
  46969. /**
  46970. * Bounding box gizmo
  46971. */
  46972. export class BoundingBoxGizmo extends Gizmo {
  46973. private _lineBoundingBox;
  46974. private _rotateSpheresParent;
  46975. private _scaleBoxesParent;
  46976. private _boundingDimensions;
  46977. private _renderObserver;
  46978. private _pointerObserver;
  46979. private _scaleDragSpeed;
  46980. private _tmpQuaternion;
  46981. private _tmpVector;
  46982. private _tmpRotationMatrix;
  46983. /**
  46984. * 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)
  46985. */
  46986. ignoreChildren: boolean;
  46987. /**
  46988. * 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)
  46989. */
  46990. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46991. /**
  46992. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46993. */
  46994. rotationSphereSize: number;
  46995. /**
  46996. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46997. */
  46998. scaleBoxSize: number;
  46999. /**
  47000. * 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)
  47001. */
  47002. fixedDragMeshScreenSize: boolean;
  47003. /**
  47004. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47005. */
  47006. fixedDragMeshScreenSizeDistanceFactor: number;
  47007. /**
  47008. * Fired when a rotation sphere or scale box is dragged
  47009. */
  47010. onDragStartObservable: Observable<{}>;
  47011. /**
  47012. * Fired when a scale box is dragged
  47013. */
  47014. onScaleBoxDragObservable: Observable<{}>;
  47015. /**
  47016. * Fired when a scale box drag is ended
  47017. */
  47018. onScaleBoxDragEndObservable: Observable<{}>;
  47019. /**
  47020. * Fired when a rotation sphere is dragged
  47021. */
  47022. onRotationSphereDragObservable: Observable<{}>;
  47023. /**
  47024. * Fired when a rotation sphere drag is ended
  47025. */
  47026. onRotationSphereDragEndObservable: Observable<{}>;
  47027. /**
  47028. * 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)
  47029. */
  47030. scalePivot: Nullable<Vector3>;
  47031. /**
  47032. * Mesh used as a pivot to rotate the attached mesh
  47033. */
  47034. private _anchorMesh;
  47035. private _existingMeshScale;
  47036. private _dragMesh;
  47037. private pointerDragBehavior;
  47038. private coloredMaterial;
  47039. private hoverColoredMaterial;
  47040. /**
  47041. * Sets the color of the bounding box gizmo
  47042. * @param color the color to set
  47043. */
  47044. setColor(color: Color3): void;
  47045. /**
  47046. * Creates an BoundingBoxGizmo
  47047. * @param gizmoLayer The utility layer the gizmo will be added to
  47048. * @param color The color of the gizmo
  47049. */
  47050. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47051. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47052. private _selectNode;
  47053. /**
  47054. * Updates the bounding box information for the Gizmo
  47055. */
  47056. updateBoundingBox(): void;
  47057. private _updateRotationSpheres;
  47058. private _updateScaleBoxes;
  47059. /**
  47060. * Enables rotation on the specified axis and disables rotation on the others
  47061. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47062. */
  47063. setEnabledRotationAxis(axis: string): void;
  47064. /**
  47065. * Enables/disables scaling
  47066. * @param enable if scaling should be enabled
  47067. */
  47068. setEnabledScaling(enable: boolean): void;
  47069. private _updateDummy;
  47070. /**
  47071. * Enables a pointer drag behavior on the bounding box of the gizmo
  47072. */
  47073. enableDragBehavior(): void;
  47074. /**
  47075. * Disposes of the gizmo
  47076. */
  47077. dispose(): void;
  47078. /**
  47079. * 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)
  47080. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47081. * @returns the bounding box mesh with the passed in mesh as a child
  47082. */
  47083. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47084. /**
  47085. * CustomMeshes are not supported by this gizmo
  47086. * @param mesh The mesh to replace the default mesh of the gizmo
  47087. */
  47088. setCustomMesh(mesh: Mesh): void;
  47089. }
  47090. }
  47091. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47092. import { Observable } from "babylonjs/Misc/observable";
  47093. import { Nullable } from "babylonjs/types";
  47094. import { Vector3 } from "babylonjs/Maths/math.vector";
  47095. import { Color3 } from "babylonjs/Maths/math.color";
  47096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47097. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47098. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47099. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47100. import "babylonjs/Meshes/Builders/linesBuilder";
  47101. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47102. /**
  47103. * Single plane rotation gizmo
  47104. */
  47105. export class PlaneRotationGizmo extends Gizmo {
  47106. /**
  47107. * Drag behavior responsible for the gizmos dragging interactions
  47108. */
  47109. dragBehavior: PointerDragBehavior;
  47110. private _pointerObserver;
  47111. /**
  47112. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47113. */
  47114. snapDistance: number;
  47115. /**
  47116. * Event that fires each time the gizmo snaps to a new location.
  47117. * * snapDistance is the the change in distance
  47118. */
  47119. onSnapObservable: Observable<{
  47120. snapDistance: number;
  47121. }>;
  47122. private _isEnabled;
  47123. private _parent;
  47124. /**
  47125. * Creates a PlaneRotationGizmo
  47126. * @param gizmoLayer The utility layer the gizmo will be added to
  47127. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47128. * @param color The color of the gizmo
  47129. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47130. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47131. */
  47132. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47133. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47134. /**
  47135. * If the gizmo is enabled
  47136. */
  47137. isEnabled: boolean;
  47138. /**
  47139. * Disposes of the gizmo
  47140. */
  47141. dispose(): void;
  47142. }
  47143. }
  47144. declare module "babylonjs/Gizmos/rotationGizmo" {
  47145. import { Observable } from "babylonjs/Misc/observable";
  47146. import { Nullable } from "babylonjs/types";
  47147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47148. import { Mesh } from "babylonjs/Meshes/mesh";
  47149. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47150. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47151. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47152. /**
  47153. * Gizmo that enables rotating a mesh along 3 axis
  47154. */
  47155. export class RotationGizmo extends Gizmo {
  47156. /**
  47157. * Internal gizmo used for interactions on the x axis
  47158. */
  47159. xGizmo: PlaneRotationGizmo;
  47160. /**
  47161. * Internal gizmo used for interactions on the y axis
  47162. */
  47163. yGizmo: PlaneRotationGizmo;
  47164. /**
  47165. * Internal gizmo used for interactions on the z axis
  47166. */
  47167. zGizmo: PlaneRotationGizmo;
  47168. /** Fires an event when any of it's sub gizmos are dragged */
  47169. onDragStartObservable: Observable<unknown>;
  47170. /** Fires an event when any of it's sub gizmos are released from dragging */
  47171. onDragEndObservable: Observable<unknown>;
  47172. private _meshAttached;
  47173. attachedMesh: Nullable<AbstractMesh>;
  47174. /**
  47175. * Creates a RotationGizmo
  47176. * @param gizmoLayer The utility layer the gizmo will be added to
  47177. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47178. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47179. */
  47180. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47181. updateGizmoRotationToMatchAttachedMesh: boolean;
  47182. /**
  47183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47184. */
  47185. snapDistance: number;
  47186. /**
  47187. * Ratio for the scale of the gizmo (Default: 1)
  47188. */
  47189. scaleRatio: number;
  47190. /**
  47191. * Disposes of the gizmo
  47192. */
  47193. dispose(): void;
  47194. /**
  47195. * CustomMeshes are not supported by this gizmo
  47196. * @param mesh The mesh to replace the default mesh of the gizmo
  47197. */
  47198. setCustomMesh(mesh: Mesh): void;
  47199. }
  47200. }
  47201. declare module "babylonjs/Gizmos/gizmoManager" {
  47202. import { Observable } from "babylonjs/Misc/observable";
  47203. import { Nullable } from "babylonjs/types";
  47204. import { Scene, IDisposable } from "babylonjs/scene";
  47205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47206. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47207. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47208. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47209. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47210. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47211. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47212. /**
  47213. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47214. */
  47215. export class GizmoManager implements IDisposable {
  47216. private scene;
  47217. /**
  47218. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47219. */
  47220. gizmos: {
  47221. positionGizmo: Nullable<PositionGizmo>;
  47222. rotationGizmo: Nullable<RotationGizmo>;
  47223. scaleGizmo: Nullable<ScaleGizmo>;
  47224. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47225. };
  47226. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47227. clearGizmoOnEmptyPointerEvent: boolean;
  47228. /** Fires an event when the manager is attached to a mesh */
  47229. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47230. private _gizmosEnabled;
  47231. private _pointerObserver;
  47232. private _attachedMesh;
  47233. private _boundingBoxColor;
  47234. private _defaultUtilityLayer;
  47235. private _defaultKeepDepthUtilityLayer;
  47236. /**
  47237. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47238. */
  47239. boundingBoxDragBehavior: SixDofDragBehavior;
  47240. /**
  47241. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47242. */
  47243. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47244. /**
  47245. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47246. */
  47247. usePointerToAttachGizmos: boolean;
  47248. /**
  47249. * Utility layer that the bounding box gizmo belongs to
  47250. */
  47251. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47252. /**
  47253. * Utility layer that all gizmos besides bounding box belong to
  47254. */
  47255. readonly utilityLayer: UtilityLayerRenderer;
  47256. /**
  47257. * Instatiates a gizmo manager
  47258. * @param scene the scene to overlay the gizmos on top of
  47259. */
  47260. constructor(scene: Scene);
  47261. /**
  47262. * Attaches a set of gizmos to the specified mesh
  47263. * @param mesh The mesh the gizmo's should be attached to
  47264. */
  47265. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47266. /**
  47267. * If the position gizmo is enabled
  47268. */
  47269. positionGizmoEnabled: boolean;
  47270. /**
  47271. * If the rotation gizmo is enabled
  47272. */
  47273. rotationGizmoEnabled: boolean;
  47274. /**
  47275. * If the scale gizmo is enabled
  47276. */
  47277. scaleGizmoEnabled: boolean;
  47278. /**
  47279. * If the boundingBox gizmo is enabled
  47280. */
  47281. boundingBoxGizmoEnabled: boolean;
  47282. /**
  47283. * Disposes of the gizmo manager
  47284. */
  47285. dispose(): void;
  47286. }
  47287. }
  47288. declare module "babylonjs/Lights/directionalLight" {
  47289. import { Camera } from "babylonjs/Cameras/camera";
  47290. import { Scene } from "babylonjs/scene";
  47291. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47293. import { Light } from "babylonjs/Lights/light";
  47294. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47295. import { Effect } from "babylonjs/Materials/effect";
  47296. /**
  47297. * A directional light is defined by a direction (what a surprise!).
  47298. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47299. * 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.
  47300. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47301. */
  47302. export class DirectionalLight extends ShadowLight {
  47303. private _shadowFrustumSize;
  47304. /**
  47305. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47306. */
  47307. /**
  47308. * Specifies a fix frustum size for the shadow generation.
  47309. */
  47310. shadowFrustumSize: number;
  47311. private _shadowOrthoScale;
  47312. /**
  47313. * Gets the shadow projection scale against the optimal computed one.
  47314. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47315. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47316. */
  47317. /**
  47318. * Sets the shadow projection scale against the optimal computed one.
  47319. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47320. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47321. */
  47322. shadowOrthoScale: number;
  47323. /**
  47324. * Automatically compute the projection matrix to best fit (including all the casters)
  47325. * on each frame.
  47326. */
  47327. autoUpdateExtends: boolean;
  47328. private _orthoLeft;
  47329. private _orthoRight;
  47330. private _orthoTop;
  47331. private _orthoBottom;
  47332. /**
  47333. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47334. * The directional light is emitted from everywhere in the given direction.
  47335. * It can cast shadows.
  47336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47337. * @param name The friendly name of the light
  47338. * @param direction The direction of the light
  47339. * @param scene The scene the light belongs to
  47340. */
  47341. constructor(name: string, direction: Vector3, scene: Scene);
  47342. /**
  47343. * Returns the string "DirectionalLight".
  47344. * @return The class name
  47345. */
  47346. getClassName(): string;
  47347. /**
  47348. * Returns the integer 1.
  47349. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47350. */
  47351. getTypeID(): number;
  47352. /**
  47353. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47354. * Returns the DirectionalLight Shadow projection matrix.
  47355. */
  47356. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47357. /**
  47358. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47359. * Returns the DirectionalLight Shadow projection matrix.
  47360. */
  47361. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47362. /**
  47363. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47364. * Returns the DirectionalLight Shadow projection matrix.
  47365. */
  47366. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47367. protected _buildUniformLayout(): void;
  47368. /**
  47369. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47370. * @param effect The effect to update
  47371. * @param lightIndex The index of the light in the effect to update
  47372. * @returns The directional light
  47373. */
  47374. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47375. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47376. /**
  47377. * Gets the minZ used for shadow according to both the scene and the light.
  47378. *
  47379. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47380. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47381. * @param activeCamera The camera we are returning the min for
  47382. * @returns the depth min z
  47383. */
  47384. getDepthMinZ(activeCamera: Camera): number;
  47385. /**
  47386. * Gets the maxZ used for shadow according to both the scene and the light.
  47387. *
  47388. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47389. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47390. * @param activeCamera The camera we are returning the max for
  47391. * @returns the depth max z
  47392. */
  47393. getDepthMaxZ(activeCamera: Camera): number;
  47394. /**
  47395. * Prepares the list of defines specific to the light type.
  47396. * @param defines the list of defines
  47397. * @param lightIndex defines the index of the light for the effect
  47398. */
  47399. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47400. }
  47401. }
  47402. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47403. import { Mesh } from "babylonjs/Meshes/mesh";
  47404. /**
  47405. * Class containing static functions to help procedurally build meshes
  47406. */
  47407. export class HemisphereBuilder {
  47408. /**
  47409. * Creates a hemisphere mesh
  47410. * @param name defines the name of the mesh
  47411. * @param options defines the options used to create the mesh
  47412. * @param scene defines the hosting scene
  47413. * @returns the hemisphere mesh
  47414. */
  47415. static CreateHemisphere(name: string, options: {
  47416. segments?: number;
  47417. diameter?: number;
  47418. sideOrientation?: number;
  47419. }, scene: any): Mesh;
  47420. }
  47421. }
  47422. declare module "babylonjs/Lights/spotLight" {
  47423. import { Nullable } from "babylonjs/types";
  47424. import { Scene } from "babylonjs/scene";
  47425. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47427. import { Effect } from "babylonjs/Materials/effect";
  47428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47429. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47430. /**
  47431. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47432. * These values define a cone of light starting from the position, emitting toward the direction.
  47433. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47434. * and the exponent defines the speed of the decay of the light with distance (reach).
  47435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47436. */
  47437. export class SpotLight extends ShadowLight {
  47438. private _angle;
  47439. private _innerAngle;
  47440. private _cosHalfAngle;
  47441. private _lightAngleScale;
  47442. private _lightAngleOffset;
  47443. /**
  47444. * Gets the cone angle of the spot light in Radians.
  47445. */
  47446. /**
  47447. * Sets the cone angle of the spot light in Radians.
  47448. */
  47449. angle: number;
  47450. /**
  47451. * Only used in gltf falloff mode, this defines the angle where
  47452. * the directional falloff will start before cutting at angle which could be seen
  47453. * as outer angle.
  47454. */
  47455. /**
  47456. * Only used in gltf falloff mode, this defines the angle where
  47457. * the directional falloff will start before cutting at angle which could be seen
  47458. * as outer angle.
  47459. */
  47460. innerAngle: number;
  47461. private _shadowAngleScale;
  47462. /**
  47463. * Allows scaling the angle of the light for shadow generation only.
  47464. */
  47465. /**
  47466. * Allows scaling the angle of the light for shadow generation only.
  47467. */
  47468. shadowAngleScale: number;
  47469. /**
  47470. * The light decay speed with the distance from the emission spot.
  47471. */
  47472. exponent: number;
  47473. private _projectionTextureMatrix;
  47474. /**
  47475. * Allows reading the projecton texture
  47476. */
  47477. readonly projectionTextureMatrix: Matrix;
  47478. protected _projectionTextureLightNear: number;
  47479. /**
  47480. * Gets the near clip of the Spotlight for texture projection.
  47481. */
  47482. /**
  47483. * Sets the near clip of the Spotlight for texture projection.
  47484. */
  47485. projectionTextureLightNear: number;
  47486. protected _projectionTextureLightFar: number;
  47487. /**
  47488. * Gets the far clip of the Spotlight for texture projection.
  47489. */
  47490. /**
  47491. * Sets the far clip of the Spotlight for texture projection.
  47492. */
  47493. projectionTextureLightFar: number;
  47494. protected _projectionTextureUpDirection: Vector3;
  47495. /**
  47496. * Gets the Up vector of the Spotlight for texture projection.
  47497. */
  47498. /**
  47499. * Sets the Up vector of the Spotlight for texture projection.
  47500. */
  47501. projectionTextureUpDirection: Vector3;
  47502. private _projectionTexture;
  47503. /**
  47504. * Gets the projection texture of the light.
  47505. */
  47506. /**
  47507. * Sets the projection texture of the light.
  47508. */
  47509. projectionTexture: Nullable<BaseTexture>;
  47510. private _projectionTextureViewLightDirty;
  47511. private _projectionTextureProjectionLightDirty;
  47512. private _projectionTextureDirty;
  47513. private _projectionTextureViewTargetVector;
  47514. private _projectionTextureViewLightMatrix;
  47515. private _projectionTextureProjectionLightMatrix;
  47516. private _projectionTextureScalingMatrix;
  47517. /**
  47518. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47519. * It can cast shadows.
  47520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47521. * @param name The light friendly name
  47522. * @param position The position of the spot light in the scene
  47523. * @param direction The direction of the light in the scene
  47524. * @param angle The cone angle of the light in Radians
  47525. * @param exponent The light decay speed with the distance from the emission spot
  47526. * @param scene The scene the lights belongs to
  47527. */
  47528. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47529. /**
  47530. * Returns the string "SpotLight".
  47531. * @returns the class name
  47532. */
  47533. getClassName(): string;
  47534. /**
  47535. * Returns the integer 2.
  47536. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47537. */
  47538. getTypeID(): number;
  47539. /**
  47540. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47541. */
  47542. protected _setDirection(value: Vector3): void;
  47543. /**
  47544. * Overrides the position setter to recompute the projection texture view light Matrix.
  47545. */
  47546. protected _setPosition(value: Vector3): void;
  47547. /**
  47548. * 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.
  47549. * Returns the SpotLight.
  47550. */
  47551. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47552. protected _computeProjectionTextureViewLightMatrix(): void;
  47553. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47554. /**
  47555. * Main function for light texture projection matrix computing.
  47556. */
  47557. protected _computeProjectionTextureMatrix(): void;
  47558. protected _buildUniformLayout(): void;
  47559. private _computeAngleValues;
  47560. /**
  47561. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47562. * @param effect The effect to update
  47563. * @param lightIndex The index of the light in the effect to update
  47564. * @returns The spot light
  47565. */
  47566. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47567. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47568. /**
  47569. * Disposes the light and the associated resources.
  47570. */
  47571. dispose(): void;
  47572. /**
  47573. * Prepares the list of defines specific to the light type.
  47574. * @param defines the list of defines
  47575. * @param lightIndex defines the index of the light for the effect
  47576. */
  47577. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47578. }
  47579. }
  47580. declare module "babylonjs/Gizmos/lightGizmo" {
  47581. import { Nullable } from "babylonjs/types";
  47582. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47583. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47584. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47585. import { Light } from "babylonjs/Lights/light";
  47586. /**
  47587. * Gizmo that enables viewing a light
  47588. */
  47589. export class LightGizmo extends Gizmo {
  47590. private _lightMesh;
  47591. private _material;
  47592. private cachedPosition;
  47593. private cachedForward;
  47594. /**
  47595. * Creates a LightGizmo
  47596. * @param gizmoLayer The utility layer the gizmo will be added to
  47597. */
  47598. constructor(gizmoLayer?: UtilityLayerRenderer);
  47599. private _light;
  47600. /**
  47601. * The light that the gizmo is attached to
  47602. */
  47603. light: Nullable<Light>;
  47604. /**
  47605. * Gets the material used to render the light gizmo
  47606. */
  47607. readonly material: StandardMaterial;
  47608. /**
  47609. * @hidden
  47610. * Updates the gizmo to match the attached mesh's position/rotation
  47611. */
  47612. protected _update(): void;
  47613. private static _Scale;
  47614. /**
  47615. * Creates the lines for a light mesh
  47616. */
  47617. private static _createLightLines;
  47618. /**
  47619. * Disposes of the light gizmo
  47620. */
  47621. dispose(): void;
  47622. private static _CreateHemisphericLightMesh;
  47623. private static _CreatePointLightMesh;
  47624. private static _CreateSpotLightMesh;
  47625. private static _CreateDirectionalLightMesh;
  47626. }
  47627. }
  47628. declare module "babylonjs/Gizmos/index" {
  47629. export * from "babylonjs/Gizmos/axisDragGizmo";
  47630. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47631. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47632. export * from "babylonjs/Gizmos/gizmo";
  47633. export * from "babylonjs/Gizmos/gizmoManager";
  47634. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47635. export * from "babylonjs/Gizmos/positionGizmo";
  47636. export * from "babylonjs/Gizmos/rotationGizmo";
  47637. export * from "babylonjs/Gizmos/scaleGizmo";
  47638. export * from "babylonjs/Gizmos/lightGizmo";
  47639. export * from "babylonjs/Gizmos/planeDragGizmo";
  47640. }
  47641. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47642. /** @hidden */
  47643. export var backgroundFragmentDeclaration: {
  47644. name: string;
  47645. shader: string;
  47646. };
  47647. }
  47648. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47649. /** @hidden */
  47650. export var backgroundUboDeclaration: {
  47651. name: string;
  47652. shader: string;
  47653. };
  47654. }
  47655. declare module "babylonjs/Shaders/background.fragment" {
  47656. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47657. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47658. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47659. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47660. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47661. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47662. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47663. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47664. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47665. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47666. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47667. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47668. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47669. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47670. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47671. /** @hidden */
  47672. export var backgroundPixelShader: {
  47673. name: string;
  47674. shader: string;
  47675. };
  47676. }
  47677. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47678. /** @hidden */
  47679. export var backgroundVertexDeclaration: {
  47680. name: string;
  47681. shader: string;
  47682. };
  47683. }
  47684. declare module "babylonjs/Shaders/background.vertex" {
  47685. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47686. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47687. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47688. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47691. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47694. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47695. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47697. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47698. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47699. /** @hidden */
  47700. export var backgroundVertexShader: {
  47701. name: string;
  47702. shader: string;
  47703. };
  47704. }
  47705. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47706. import { Nullable, int, float } from "babylonjs/types";
  47707. import { Scene } from "babylonjs/scene";
  47708. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47709. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47711. import { Mesh } from "babylonjs/Meshes/mesh";
  47712. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47713. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47714. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47716. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47717. import { Color3 } from "babylonjs/Maths/math.color";
  47718. import "babylonjs/Shaders/background.fragment";
  47719. import "babylonjs/Shaders/background.vertex";
  47720. /**
  47721. * Background material used to create an efficient environement around your scene.
  47722. */
  47723. export class BackgroundMaterial extends PushMaterial {
  47724. /**
  47725. * Standard reflectance value at parallel view angle.
  47726. */
  47727. static StandardReflectance0: number;
  47728. /**
  47729. * Standard reflectance value at grazing angle.
  47730. */
  47731. static StandardReflectance90: number;
  47732. protected _primaryColor: Color3;
  47733. /**
  47734. * Key light Color (multiply against the environement texture)
  47735. */
  47736. primaryColor: Color3;
  47737. protected __perceptualColor: Nullable<Color3>;
  47738. /**
  47739. * Experimental Internal Use Only.
  47740. *
  47741. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47742. * This acts as a helper to set the primary color to a more "human friendly" value.
  47743. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47744. * output color as close as possible from the chosen value.
  47745. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47746. * part of lighting setup.)
  47747. */
  47748. _perceptualColor: Nullable<Color3>;
  47749. protected _primaryColorShadowLevel: float;
  47750. /**
  47751. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47752. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47753. */
  47754. primaryColorShadowLevel: float;
  47755. protected _primaryColorHighlightLevel: float;
  47756. /**
  47757. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47758. * The primary color is used at the level chosen to define what the white area would look.
  47759. */
  47760. primaryColorHighlightLevel: float;
  47761. protected _reflectionTexture: Nullable<BaseTexture>;
  47762. /**
  47763. * Reflection Texture used in the material.
  47764. * Should be author in a specific way for the best result (refer to the documentation).
  47765. */
  47766. reflectionTexture: Nullable<BaseTexture>;
  47767. protected _reflectionBlur: float;
  47768. /**
  47769. * Reflection Texture level of blur.
  47770. *
  47771. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47772. * texture twice.
  47773. */
  47774. reflectionBlur: float;
  47775. protected _diffuseTexture: Nullable<BaseTexture>;
  47776. /**
  47777. * Diffuse Texture used in the material.
  47778. * Should be author in a specific way for the best result (refer to the documentation).
  47779. */
  47780. diffuseTexture: Nullable<BaseTexture>;
  47781. protected _shadowLights: Nullable<IShadowLight[]>;
  47782. /**
  47783. * Specify the list of lights casting shadow on the material.
  47784. * All scene shadow lights will be included if null.
  47785. */
  47786. shadowLights: Nullable<IShadowLight[]>;
  47787. protected _shadowLevel: float;
  47788. /**
  47789. * Helps adjusting the shadow to a softer level if required.
  47790. * 0 means black shadows and 1 means no shadows.
  47791. */
  47792. shadowLevel: float;
  47793. protected _sceneCenter: Vector3;
  47794. /**
  47795. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47796. * It is usually zero but might be interesting to modify according to your setup.
  47797. */
  47798. sceneCenter: Vector3;
  47799. protected _opacityFresnel: boolean;
  47800. /**
  47801. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47802. * This helps ensuring a nice transition when the camera goes under the ground.
  47803. */
  47804. opacityFresnel: boolean;
  47805. protected _reflectionFresnel: boolean;
  47806. /**
  47807. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47808. * This helps adding a mirror texture on the ground.
  47809. */
  47810. reflectionFresnel: boolean;
  47811. protected _reflectionFalloffDistance: number;
  47812. /**
  47813. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47814. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47815. */
  47816. reflectionFalloffDistance: number;
  47817. protected _reflectionAmount: number;
  47818. /**
  47819. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47820. */
  47821. reflectionAmount: number;
  47822. protected _reflectionReflectance0: number;
  47823. /**
  47824. * This specifies the weight of the reflection at grazing angle.
  47825. */
  47826. reflectionReflectance0: number;
  47827. protected _reflectionReflectance90: number;
  47828. /**
  47829. * This specifies the weight of the reflection at a perpendicular point of view.
  47830. */
  47831. reflectionReflectance90: number;
  47832. /**
  47833. * Sets the reflection reflectance fresnel values according to the default standard
  47834. * empirically know to work well :-)
  47835. */
  47836. reflectionStandardFresnelWeight: number;
  47837. protected _useRGBColor: boolean;
  47838. /**
  47839. * Helps to directly use the maps channels instead of their level.
  47840. */
  47841. useRGBColor: boolean;
  47842. protected _enableNoise: boolean;
  47843. /**
  47844. * This helps reducing the banding effect that could occur on the background.
  47845. */
  47846. enableNoise: boolean;
  47847. /**
  47848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47849. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47850. * Recommended to be keep at 1.0 except for special cases.
  47851. */
  47852. fovMultiplier: number;
  47853. private _fovMultiplier;
  47854. /**
  47855. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47856. */
  47857. useEquirectangularFOV: boolean;
  47858. private _maxSimultaneousLights;
  47859. /**
  47860. * Number of Simultaneous lights allowed on the material.
  47861. */
  47862. maxSimultaneousLights: int;
  47863. /**
  47864. * Default configuration related to image processing available in the Background Material.
  47865. */
  47866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47867. /**
  47868. * Keep track of the image processing observer to allow dispose and replace.
  47869. */
  47870. private _imageProcessingObserver;
  47871. /**
  47872. * Attaches a new image processing configuration to the PBR Material.
  47873. * @param configuration (if null the scene configuration will be use)
  47874. */
  47875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47876. /**
  47877. * Gets the image processing configuration used either in this material.
  47878. */
  47879. /**
  47880. * Sets the Default image processing configuration used either in the this material.
  47881. *
  47882. * If sets to null, the scene one is in use.
  47883. */
  47884. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47885. /**
  47886. * Gets wether the color curves effect is enabled.
  47887. */
  47888. /**
  47889. * Sets wether the color curves effect is enabled.
  47890. */
  47891. cameraColorCurvesEnabled: boolean;
  47892. /**
  47893. * Gets wether the color grading effect is enabled.
  47894. */
  47895. /**
  47896. * Gets wether the color grading effect is enabled.
  47897. */
  47898. cameraColorGradingEnabled: boolean;
  47899. /**
  47900. * Gets wether tonemapping is enabled or not.
  47901. */
  47902. /**
  47903. * Sets wether tonemapping is enabled or not
  47904. */
  47905. cameraToneMappingEnabled: boolean;
  47906. /**
  47907. * The camera exposure used on this material.
  47908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47909. * This corresponds to a photographic exposure.
  47910. */
  47911. /**
  47912. * The camera exposure used on this material.
  47913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47914. * This corresponds to a photographic exposure.
  47915. */
  47916. cameraExposure: float;
  47917. /**
  47918. * Gets The camera contrast used on this material.
  47919. */
  47920. /**
  47921. * Sets The camera contrast used on this material.
  47922. */
  47923. cameraContrast: float;
  47924. /**
  47925. * Gets the Color Grading 2D Lookup Texture.
  47926. */
  47927. /**
  47928. * Sets the Color Grading 2D Lookup Texture.
  47929. */
  47930. cameraColorGradingTexture: Nullable<BaseTexture>;
  47931. /**
  47932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47934. * 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;
  47935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47936. */
  47937. /**
  47938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47940. * 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;
  47941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47942. */
  47943. cameraColorCurves: Nullable<ColorCurves>;
  47944. /**
  47945. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47946. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47947. */
  47948. switchToBGR: boolean;
  47949. private _renderTargets;
  47950. private _reflectionControls;
  47951. private _white;
  47952. private _primaryShadowColor;
  47953. private _primaryHighlightColor;
  47954. /**
  47955. * Instantiates a Background Material in the given scene
  47956. * @param name The friendly name of the material
  47957. * @param scene The scene to add the material to
  47958. */
  47959. constructor(name: string, scene: Scene);
  47960. /**
  47961. * Gets a boolean indicating that current material needs to register RTT
  47962. */
  47963. readonly hasRenderTargetTextures: boolean;
  47964. /**
  47965. * The entire material has been created in order to prevent overdraw.
  47966. * @returns false
  47967. */
  47968. needAlphaTesting(): boolean;
  47969. /**
  47970. * The entire material has been created in order to prevent overdraw.
  47971. * @returns true if blending is enable
  47972. */
  47973. needAlphaBlending(): boolean;
  47974. /**
  47975. * Checks wether the material is ready to be rendered for a given mesh.
  47976. * @param mesh The mesh to render
  47977. * @param subMesh The submesh to check against
  47978. * @param useInstances Specify wether or not the material is used with instances
  47979. * @returns true if all the dependencies are ready (Textures, Effects...)
  47980. */
  47981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47982. /**
  47983. * Compute the primary color according to the chosen perceptual color.
  47984. */
  47985. private _computePrimaryColorFromPerceptualColor;
  47986. /**
  47987. * Compute the highlights and shadow colors according to their chosen levels.
  47988. */
  47989. private _computePrimaryColors;
  47990. /**
  47991. * Build the uniform buffer used in the material.
  47992. */
  47993. buildUniformLayout(): void;
  47994. /**
  47995. * Unbind the material.
  47996. */
  47997. unbind(): void;
  47998. /**
  47999. * Bind only the world matrix to the material.
  48000. * @param world The world matrix to bind.
  48001. */
  48002. bindOnlyWorldMatrix(world: Matrix): void;
  48003. /**
  48004. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48005. * @param world The world matrix to bind.
  48006. * @param subMesh The submesh to bind for.
  48007. */
  48008. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48009. /**
  48010. * Checks to see if a texture is used in the material.
  48011. * @param texture - Base texture to use.
  48012. * @returns - Boolean specifying if a texture is used in the material.
  48013. */
  48014. hasTexture(texture: BaseTexture): boolean;
  48015. /**
  48016. * Dispose the material.
  48017. * @param forceDisposeEffect Force disposal of the associated effect.
  48018. * @param forceDisposeTextures Force disposal of the associated textures.
  48019. */
  48020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48021. /**
  48022. * Clones the material.
  48023. * @param name The cloned name.
  48024. * @returns The cloned material.
  48025. */
  48026. clone(name: string): BackgroundMaterial;
  48027. /**
  48028. * Serializes the current material to its JSON representation.
  48029. * @returns The JSON representation.
  48030. */
  48031. serialize(): any;
  48032. /**
  48033. * Gets the class name of the material
  48034. * @returns "BackgroundMaterial"
  48035. */
  48036. getClassName(): string;
  48037. /**
  48038. * Parse a JSON input to create back a background material.
  48039. * @param source The JSON data to parse
  48040. * @param scene The scene to create the parsed material in
  48041. * @param rootUrl The root url of the assets the material depends upon
  48042. * @returns the instantiated BackgroundMaterial.
  48043. */
  48044. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48045. }
  48046. }
  48047. declare module "babylonjs/Helpers/environmentHelper" {
  48048. import { Observable } from "babylonjs/Misc/observable";
  48049. import { Nullable } from "babylonjs/types";
  48050. import { Scene } from "babylonjs/scene";
  48051. import { Vector3 } from "babylonjs/Maths/math.vector";
  48052. import { Color3 } from "babylonjs/Maths/math.color";
  48053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48054. import { Mesh } from "babylonjs/Meshes/mesh";
  48055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48056. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48057. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48058. import "babylonjs/Meshes/Builders/planeBuilder";
  48059. import "babylonjs/Meshes/Builders/boxBuilder";
  48060. /**
  48061. * Represents the different options available during the creation of
  48062. * a Environment helper.
  48063. *
  48064. * This can control the default ground, skybox and image processing setup of your scene.
  48065. */
  48066. export interface IEnvironmentHelperOptions {
  48067. /**
  48068. * Specifies wether or not to create a ground.
  48069. * True by default.
  48070. */
  48071. createGround: boolean;
  48072. /**
  48073. * Specifies the ground size.
  48074. * 15 by default.
  48075. */
  48076. groundSize: number;
  48077. /**
  48078. * The texture used on the ground for the main color.
  48079. * Comes from the BabylonJS CDN by default.
  48080. *
  48081. * Remarks: Can be either a texture or a url.
  48082. */
  48083. groundTexture: string | BaseTexture;
  48084. /**
  48085. * The color mixed in the ground texture by default.
  48086. * BabylonJS clearColor by default.
  48087. */
  48088. groundColor: Color3;
  48089. /**
  48090. * Specifies the ground opacity.
  48091. * 1 by default.
  48092. */
  48093. groundOpacity: number;
  48094. /**
  48095. * Enables the ground to receive shadows.
  48096. * True by default.
  48097. */
  48098. enableGroundShadow: boolean;
  48099. /**
  48100. * Helps preventing the shadow to be fully black on the ground.
  48101. * 0.5 by default.
  48102. */
  48103. groundShadowLevel: number;
  48104. /**
  48105. * Creates a mirror texture attach to the ground.
  48106. * false by default.
  48107. */
  48108. enableGroundMirror: boolean;
  48109. /**
  48110. * Specifies the ground mirror size ratio.
  48111. * 0.3 by default as the default kernel is 64.
  48112. */
  48113. groundMirrorSizeRatio: number;
  48114. /**
  48115. * Specifies the ground mirror blur kernel size.
  48116. * 64 by default.
  48117. */
  48118. groundMirrorBlurKernel: number;
  48119. /**
  48120. * Specifies the ground mirror visibility amount.
  48121. * 1 by default
  48122. */
  48123. groundMirrorAmount: number;
  48124. /**
  48125. * Specifies the ground mirror reflectance weight.
  48126. * This uses the standard weight of the background material to setup the fresnel effect
  48127. * of the mirror.
  48128. * 1 by default.
  48129. */
  48130. groundMirrorFresnelWeight: number;
  48131. /**
  48132. * Specifies the ground mirror Falloff distance.
  48133. * This can helps reducing the size of the reflection.
  48134. * 0 by Default.
  48135. */
  48136. groundMirrorFallOffDistance: number;
  48137. /**
  48138. * Specifies the ground mirror texture type.
  48139. * Unsigned Int by Default.
  48140. */
  48141. groundMirrorTextureType: number;
  48142. /**
  48143. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48144. * the shown objects.
  48145. */
  48146. groundYBias: number;
  48147. /**
  48148. * Specifies wether or not to create a skybox.
  48149. * True by default.
  48150. */
  48151. createSkybox: boolean;
  48152. /**
  48153. * Specifies the skybox size.
  48154. * 20 by default.
  48155. */
  48156. skyboxSize: number;
  48157. /**
  48158. * The texture used on the skybox for the main color.
  48159. * Comes from the BabylonJS CDN by default.
  48160. *
  48161. * Remarks: Can be either a texture or a url.
  48162. */
  48163. skyboxTexture: string | BaseTexture;
  48164. /**
  48165. * The color mixed in the skybox texture by default.
  48166. * BabylonJS clearColor by default.
  48167. */
  48168. skyboxColor: Color3;
  48169. /**
  48170. * The background rotation around the Y axis of the scene.
  48171. * This helps aligning the key lights of your scene with the background.
  48172. * 0 by default.
  48173. */
  48174. backgroundYRotation: number;
  48175. /**
  48176. * Compute automatically the size of the elements to best fit with the scene.
  48177. */
  48178. sizeAuto: boolean;
  48179. /**
  48180. * Default position of the rootMesh if autoSize is not true.
  48181. */
  48182. rootPosition: Vector3;
  48183. /**
  48184. * Sets up the image processing in the scene.
  48185. * true by default.
  48186. */
  48187. setupImageProcessing: boolean;
  48188. /**
  48189. * The texture used as your environment texture in the scene.
  48190. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48191. *
  48192. * Remarks: Can be either a texture or a url.
  48193. */
  48194. environmentTexture: string | BaseTexture;
  48195. /**
  48196. * The value of the exposure to apply to the scene.
  48197. * 0.6 by default if setupImageProcessing is true.
  48198. */
  48199. cameraExposure: number;
  48200. /**
  48201. * The value of the contrast to apply to the scene.
  48202. * 1.6 by default if setupImageProcessing is true.
  48203. */
  48204. cameraContrast: number;
  48205. /**
  48206. * Specifies wether or not tonemapping should be enabled in the scene.
  48207. * true by default if setupImageProcessing is true.
  48208. */
  48209. toneMappingEnabled: boolean;
  48210. }
  48211. /**
  48212. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48213. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48214. * It also helps with the default setup of your imageProcessing configuration.
  48215. */
  48216. export class EnvironmentHelper {
  48217. /**
  48218. * Default ground texture URL.
  48219. */
  48220. private static _groundTextureCDNUrl;
  48221. /**
  48222. * Default skybox texture URL.
  48223. */
  48224. private static _skyboxTextureCDNUrl;
  48225. /**
  48226. * Default environment texture URL.
  48227. */
  48228. private static _environmentTextureCDNUrl;
  48229. /**
  48230. * Creates the default options for the helper.
  48231. */
  48232. private static _getDefaultOptions;
  48233. private _rootMesh;
  48234. /**
  48235. * Gets the root mesh created by the helper.
  48236. */
  48237. readonly rootMesh: Mesh;
  48238. private _skybox;
  48239. /**
  48240. * Gets the skybox created by the helper.
  48241. */
  48242. readonly skybox: Nullable<Mesh>;
  48243. private _skyboxTexture;
  48244. /**
  48245. * Gets the skybox texture created by the helper.
  48246. */
  48247. readonly skyboxTexture: Nullable<BaseTexture>;
  48248. private _skyboxMaterial;
  48249. /**
  48250. * Gets the skybox material created by the helper.
  48251. */
  48252. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48253. private _ground;
  48254. /**
  48255. * Gets the ground mesh created by the helper.
  48256. */
  48257. readonly ground: Nullable<Mesh>;
  48258. private _groundTexture;
  48259. /**
  48260. * Gets the ground texture created by the helper.
  48261. */
  48262. readonly groundTexture: Nullable<BaseTexture>;
  48263. private _groundMirror;
  48264. /**
  48265. * Gets the ground mirror created by the helper.
  48266. */
  48267. readonly groundMirror: Nullable<MirrorTexture>;
  48268. /**
  48269. * Gets the ground mirror render list to helps pushing the meshes
  48270. * you wish in the ground reflection.
  48271. */
  48272. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48273. private _groundMaterial;
  48274. /**
  48275. * Gets the ground material created by the helper.
  48276. */
  48277. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48278. /**
  48279. * Stores the creation options.
  48280. */
  48281. private readonly _scene;
  48282. private _options;
  48283. /**
  48284. * This observable will be notified with any error during the creation of the environment,
  48285. * mainly texture creation errors.
  48286. */
  48287. onErrorObservable: Observable<{
  48288. message?: string;
  48289. exception?: any;
  48290. }>;
  48291. /**
  48292. * constructor
  48293. * @param options Defines the options we want to customize the helper
  48294. * @param scene The scene to add the material to
  48295. */
  48296. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48297. /**
  48298. * Updates the background according to the new options
  48299. * @param options
  48300. */
  48301. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48302. /**
  48303. * Sets the primary color of all the available elements.
  48304. * @param color the main color to affect to the ground and the background
  48305. */
  48306. setMainColor(color: Color3): void;
  48307. /**
  48308. * Setup the image processing according to the specified options.
  48309. */
  48310. private _setupImageProcessing;
  48311. /**
  48312. * Setup the environment texture according to the specified options.
  48313. */
  48314. private _setupEnvironmentTexture;
  48315. /**
  48316. * Setup the background according to the specified options.
  48317. */
  48318. private _setupBackground;
  48319. /**
  48320. * Get the scene sizes according to the setup.
  48321. */
  48322. private _getSceneSize;
  48323. /**
  48324. * Setup the ground according to the specified options.
  48325. */
  48326. private _setupGround;
  48327. /**
  48328. * Setup the ground material according to the specified options.
  48329. */
  48330. private _setupGroundMaterial;
  48331. /**
  48332. * Setup the ground diffuse texture according to the specified options.
  48333. */
  48334. private _setupGroundDiffuseTexture;
  48335. /**
  48336. * Setup the ground mirror texture according to the specified options.
  48337. */
  48338. private _setupGroundMirrorTexture;
  48339. /**
  48340. * Setup the ground to receive the mirror texture.
  48341. */
  48342. private _setupMirrorInGroundMaterial;
  48343. /**
  48344. * Setup the skybox according to the specified options.
  48345. */
  48346. private _setupSkybox;
  48347. /**
  48348. * Setup the skybox material according to the specified options.
  48349. */
  48350. private _setupSkyboxMaterial;
  48351. /**
  48352. * Setup the skybox reflection texture according to the specified options.
  48353. */
  48354. private _setupSkyboxReflectionTexture;
  48355. private _errorHandler;
  48356. /**
  48357. * Dispose all the elements created by the Helper.
  48358. */
  48359. dispose(): void;
  48360. }
  48361. }
  48362. declare module "babylonjs/Helpers/photoDome" {
  48363. import { Observable } from "babylonjs/Misc/observable";
  48364. import { Nullable } from "babylonjs/types";
  48365. import { Scene } from "babylonjs/scene";
  48366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48367. import { Mesh } from "babylonjs/Meshes/mesh";
  48368. import { Texture } from "babylonjs/Materials/Textures/texture";
  48369. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48370. import "babylonjs/Meshes/Builders/sphereBuilder";
  48371. /**
  48372. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48373. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48374. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48375. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48376. */
  48377. export class PhotoDome extends TransformNode {
  48378. /**
  48379. * Define the image as a Monoscopic panoramic 360 image.
  48380. */
  48381. static readonly MODE_MONOSCOPIC: number;
  48382. /**
  48383. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48384. */
  48385. static readonly MODE_TOPBOTTOM: number;
  48386. /**
  48387. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48388. */
  48389. static readonly MODE_SIDEBYSIDE: number;
  48390. private _useDirectMapping;
  48391. /**
  48392. * The texture being displayed on the sphere
  48393. */
  48394. protected _photoTexture: Texture;
  48395. /**
  48396. * Gets or sets the texture being displayed on the sphere
  48397. */
  48398. photoTexture: Texture;
  48399. /**
  48400. * Observable raised when an error occured while loading the 360 image
  48401. */
  48402. onLoadErrorObservable: Observable<string>;
  48403. /**
  48404. * The skybox material
  48405. */
  48406. protected _material: BackgroundMaterial;
  48407. /**
  48408. * The surface used for the skybox
  48409. */
  48410. protected _mesh: Mesh;
  48411. /**
  48412. * Gets the mesh used for the skybox.
  48413. */
  48414. readonly mesh: Mesh;
  48415. /**
  48416. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48417. * Also see the options.resolution property.
  48418. */
  48419. fovMultiplier: number;
  48420. private _imageMode;
  48421. /**
  48422. * Gets or set the current video mode for the video. It can be:
  48423. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48424. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48425. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48426. */
  48427. imageMode: number;
  48428. /**
  48429. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48430. * @param name Element's name, child elements will append suffixes for their own names.
  48431. * @param urlsOfPhoto defines the url of the photo to display
  48432. * @param options defines an object containing optional or exposed sub element properties
  48433. * @param onError defines a callback called when an error occured while loading the texture
  48434. */
  48435. constructor(name: string, urlOfPhoto: string, options: {
  48436. resolution?: number;
  48437. size?: number;
  48438. useDirectMapping?: boolean;
  48439. faceForward?: boolean;
  48440. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48441. private _onBeforeCameraRenderObserver;
  48442. private _changeImageMode;
  48443. /**
  48444. * Releases resources associated with this node.
  48445. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48446. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48447. */
  48448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48449. }
  48450. }
  48451. declare module "babylonjs/Misc/rgbdTextureTools" {
  48452. import "babylonjs/Shaders/rgbdDecode.fragment";
  48453. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48454. import { Texture } from "babylonjs/Materials/Textures/texture";
  48455. /**
  48456. * Class used to host RGBD texture specific utilities
  48457. */
  48458. export class RGBDTextureTools {
  48459. /**
  48460. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48461. * @param texture the texture to expand.
  48462. */
  48463. static ExpandRGBDTexture(texture: Texture): void;
  48464. }
  48465. }
  48466. declare module "babylonjs/Misc/brdfTextureTools" {
  48467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48468. import { Scene } from "babylonjs/scene";
  48469. /**
  48470. * Class used to host texture specific utilities
  48471. */
  48472. export class BRDFTextureTools {
  48473. /**
  48474. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48475. * @param scene defines the hosting scene
  48476. * @returns the environment BRDF texture
  48477. */
  48478. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48479. private static _environmentBRDFBase64Texture;
  48480. }
  48481. }
  48482. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48483. import { Nullable } from "babylonjs/types";
  48484. import { Color3 } from "babylonjs/Maths/math.color";
  48485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48486. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48488. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48489. import { Engine } from "babylonjs/Engines/engine";
  48490. import { Scene } from "babylonjs/scene";
  48491. /**
  48492. * @hidden
  48493. */
  48494. export interface IMaterialClearCoatDefines {
  48495. CLEARCOAT: boolean;
  48496. CLEARCOAT_DEFAULTIOR: boolean;
  48497. CLEARCOAT_TEXTURE: boolean;
  48498. CLEARCOAT_TEXTUREDIRECTUV: number;
  48499. CLEARCOAT_BUMP: boolean;
  48500. CLEARCOAT_BUMPDIRECTUV: number;
  48501. CLEARCOAT_TINT: boolean;
  48502. CLEARCOAT_TINT_TEXTURE: boolean;
  48503. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48504. /** @hidden */
  48505. _areTexturesDirty: boolean;
  48506. }
  48507. /**
  48508. * Define the code related to the clear coat parameters of the pbr material.
  48509. */
  48510. export class PBRClearCoatConfiguration {
  48511. /**
  48512. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48513. * The default fits with a polyurethane material.
  48514. */
  48515. private static readonly _DefaultIndexOfRefraction;
  48516. private _isEnabled;
  48517. /**
  48518. * Defines if the clear coat is enabled in the material.
  48519. */
  48520. isEnabled: boolean;
  48521. /**
  48522. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48523. */
  48524. intensity: number;
  48525. /**
  48526. * Defines the clear coat layer roughness.
  48527. */
  48528. roughness: number;
  48529. private _indexOfRefraction;
  48530. /**
  48531. * Defines the index of refraction of the clear coat.
  48532. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48533. * The default fits with a polyurethane material.
  48534. * Changing the default value is more performance intensive.
  48535. */
  48536. indexOfRefraction: number;
  48537. private _texture;
  48538. /**
  48539. * Stores the clear coat values in a texture.
  48540. */
  48541. texture: Nullable<BaseTexture>;
  48542. private _bumpTexture;
  48543. /**
  48544. * Define the clear coat specific bump texture.
  48545. */
  48546. bumpTexture: Nullable<BaseTexture>;
  48547. private _isTintEnabled;
  48548. /**
  48549. * Defines if the clear coat tint is enabled in the material.
  48550. */
  48551. isTintEnabled: boolean;
  48552. /**
  48553. * Defines the clear coat tint of the material.
  48554. * This is only use if tint is enabled
  48555. */
  48556. tintColor: Color3;
  48557. /**
  48558. * Defines the distance at which the tint color should be found in the
  48559. * clear coat media.
  48560. * This is only use if tint is enabled
  48561. */
  48562. tintColorAtDistance: number;
  48563. /**
  48564. * Defines the clear coat layer thickness.
  48565. * This is only use if tint is enabled
  48566. */
  48567. tintThickness: number;
  48568. private _tintTexture;
  48569. /**
  48570. * Stores the clear tint values in a texture.
  48571. * rgb is tint
  48572. * a is a thickness factor
  48573. */
  48574. tintTexture: Nullable<BaseTexture>;
  48575. /** @hidden */
  48576. private _internalMarkAllSubMeshesAsTexturesDirty;
  48577. /** @hidden */
  48578. _markAllSubMeshesAsTexturesDirty(): void;
  48579. /**
  48580. * Instantiate a new istance of clear coat configuration.
  48581. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48582. */
  48583. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48584. /**
  48585. * Gets wehter the submesh is ready to be used or not.
  48586. * @param defines the list of "defines" to update.
  48587. * @param scene defines the scene the material belongs to.
  48588. * @param engine defines the engine the material belongs to.
  48589. * @param disableBumpMap defines wether the material disables bump or not.
  48590. * @returns - boolean indicating that the submesh is ready or not.
  48591. */
  48592. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48593. /**
  48594. * Checks to see if a texture is used in the material.
  48595. * @param defines the list of "defines" to update.
  48596. * @param scene defines the scene to the material belongs to.
  48597. */
  48598. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48599. /**
  48600. * Binds the material data.
  48601. * @param uniformBuffer defines the Uniform buffer to fill in.
  48602. * @param scene defines the scene the material belongs to.
  48603. * @param engine defines the engine the material belongs to.
  48604. * @param disableBumpMap defines wether the material disables bump or not.
  48605. * @param isFrozen defines wether the material is frozen or not.
  48606. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48607. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48608. */
  48609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48610. /**
  48611. * Checks to see if a texture is used in the material.
  48612. * @param texture - Base texture to use.
  48613. * @returns - Boolean specifying if a texture is used in the material.
  48614. */
  48615. hasTexture(texture: BaseTexture): boolean;
  48616. /**
  48617. * Returns an array of the actively used textures.
  48618. * @param activeTextures Array of BaseTextures
  48619. */
  48620. getActiveTextures(activeTextures: BaseTexture[]): void;
  48621. /**
  48622. * Returns the animatable textures.
  48623. * @param animatables Array of animatable textures.
  48624. */
  48625. getAnimatables(animatables: IAnimatable[]): void;
  48626. /**
  48627. * Disposes the resources of the material.
  48628. * @param forceDisposeTextures - Forces the disposal of all textures.
  48629. */
  48630. dispose(forceDisposeTextures?: boolean): void;
  48631. /**
  48632. * Get the current class name of the texture useful for serialization or dynamic coding.
  48633. * @returns "PBRClearCoatConfiguration"
  48634. */
  48635. getClassName(): string;
  48636. /**
  48637. * Add fallbacks to the effect fallbacks list.
  48638. * @param defines defines the Base texture to use.
  48639. * @param fallbacks defines the current fallback list.
  48640. * @param currentRank defines the current fallback rank.
  48641. * @returns the new fallback rank.
  48642. */
  48643. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48644. /**
  48645. * Add the required uniforms to the current list.
  48646. * @param uniforms defines the current uniform list.
  48647. */
  48648. static AddUniforms(uniforms: string[]): void;
  48649. /**
  48650. * Add the required samplers to the current list.
  48651. * @param samplers defines the current sampler list.
  48652. */
  48653. static AddSamplers(samplers: string[]): void;
  48654. /**
  48655. * Add the required uniforms to the current buffer.
  48656. * @param uniformBuffer defines the current uniform buffer.
  48657. */
  48658. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48659. /**
  48660. * Makes a duplicate of the current configuration into another one.
  48661. * @param clearCoatConfiguration define the config where to copy the info
  48662. */
  48663. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48664. /**
  48665. * Serializes this clear coat configuration.
  48666. * @returns - An object with the serialized config.
  48667. */
  48668. serialize(): any;
  48669. /**
  48670. * Parses a anisotropy Configuration from a serialized object.
  48671. * @param source - Serialized object.
  48672. * @param scene Defines the scene we are parsing for
  48673. * @param rootUrl Defines the rootUrl to load from
  48674. */
  48675. parse(source: any, scene: Scene, rootUrl: string): void;
  48676. }
  48677. }
  48678. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48679. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48681. import { Vector2 } from "babylonjs/Maths/math.vector";
  48682. import { Scene } from "babylonjs/scene";
  48683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48684. import { Nullable } from "babylonjs/types";
  48685. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48686. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48687. /**
  48688. * @hidden
  48689. */
  48690. export interface IMaterialAnisotropicDefines {
  48691. ANISOTROPIC: boolean;
  48692. ANISOTROPIC_TEXTURE: boolean;
  48693. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48694. MAINUV1: boolean;
  48695. _areTexturesDirty: boolean;
  48696. _needUVs: boolean;
  48697. }
  48698. /**
  48699. * Define the code related to the anisotropic parameters of the pbr material.
  48700. */
  48701. export class PBRAnisotropicConfiguration {
  48702. private _isEnabled;
  48703. /**
  48704. * Defines if the anisotropy is enabled in the material.
  48705. */
  48706. isEnabled: boolean;
  48707. /**
  48708. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48709. */
  48710. intensity: number;
  48711. /**
  48712. * Defines if the effect is along the tangents, bitangents or in between.
  48713. * By default, the effect is "strectching" the highlights along the tangents.
  48714. */
  48715. direction: Vector2;
  48716. private _texture;
  48717. /**
  48718. * Stores the anisotropy values in a texture.
  48719. * rg is direction (like normal from -1 to 1)
  48720. * b is a intensity
  48721. */
  48722. texture: Nullable<BaseTexture>;
  48723. /** @hidden */
  48724. private _internalMarkAllSubMeshesAsTexturesDirty;
  48725. /** @hidden */
  48726. _markAllSubMeshesAsTexturesDirty(): void;
  48727. /**
  48728. * Instantiate a new istance of anisotropy configuration.
  48729. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48730. */
  48731. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48732. /**
  48733. * Specifies that the submesh is ready to be used.
  48734. * @param defines the list of "defines" to update.
  48735. * @param scene defines the scene the material belongs to.
  48736. * @returns - boolean indicating that the submesh is ready or not.
  48737. */
  48738. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48739. /**
  48740. * Checks to see if a texture is used in the material.
  48741. * @param defines the list of "defines" to update.
  48742. * @param mesh the mesh we are preparing the defines for.
  48743. * @param scene defines the scene the material belongs to.
  48744. */
  48745. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48746. /**
  48747. * Binds the material data.
  48748. * @param uniformBuffer defines the Uniform buffer to fill in.
  48749. * @param scene defines the scene the material belongs to.
  48750. * @param isFrozen defines wether the material is frozen or not.
  48751. */
  48752. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48753. /**
  48754. * Checks to see if a texture is used in the material.
  48755. * @param texture - Base texture to use.
  48756. * @returns - Boolean specifying if a texture is used in the material.
  48757. */
  48758. hasTexture(texture: BaseTexture): boolean;
  48759. /**
  48760. * Returns an array of the actively used textures.
  48761. * @param activeTextures Array of BaseTextures
  48762. */
  48763. getActiveTextures(activeTextures: BaseTexture[]): void;
  48764. /**
  48765. * Returns the animatable textures.
  48766. * @param animatables Array of animatable textures.
  48767. */
  48768. getAnimatables(animatables: IAnimatable[]): void;
  48769. /**
  48770. * Disposes the resources of the material.
  48771. * @param forceDisposeTextures - Forces the disposal of all textures.
  48772. */
  48773. dispose(forceDisposeTextures?: boolean): void;
  48774. /**
  48775. * Get the current class name of the texture useful for serialization or dynamic coding.
  48776. * @returns "PBRAnisotropicConfiguration"
  48777. */
  48778. getClassName(): string;
  48779. /**
  48780. * Add fallbacks to the effect fallbacks list.
  48781. * @param defines defines the Base texture to use.
  48782. * @param fallbacks defines the current fallback list.
  48783. * @param currentRank defines the current fallback rank.
  48784. * @returns the new fallback rank.
  48785. */
  48786. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48787. /**
  48788. * Add the required uniforms to the current list.
  48789. * @param uniforms defines the current uniform list.
  48790. */
  48791. static AddUniforms(uniforms: string[]): void;
  48792. /**
  48793. * Add the required uniforms to the current buffer.
  48794. * @param uniformBuffer defines the current uniform buffer.
  48795. */
  48796. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48797. /**
  48798. * Add the required samplers to the current list.
  48799. * @param samplers defines the current sampler list.
  48800. */
  48801. static AddSamplers(samplers: string[]): void;
  48802. /**
  48803. * Makes a duplicate of the current configuration into another one.
  48804. * @param anisotropicConfiguration define the config where to copy the info
  48805. */
  48806. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48807. /**
  48808. * Serializes this anisotropy configuration.
  48809. * @returns - An object with the serialized config.
  48810. */
  48811. serialize(): any;
  48812. /**
  48813. * Parses a anisotropy Configuration from a serialized object.
  48814. * @param source - Serialized object.
  48815. * @param scene Defines the scene we are parsing for
  48816. * @param rootUrl Defines the rootUrl to load from
  48817. */
  48818. parse(source: any, scene: Scene, rootUrl: string): void;
  48819. }
  48820. }
  48821. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48822. import { Scene } from "babylonjs/scene";
  48823. /**
  48824. * @hidden
  48825. */
  48826. export interface IMaterialBRDFDefines {
  48827. BRDF_V_HEIGHT_CORRELATED: boolean;
  48828. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48829. SPHERICAL_HARMONICS: boolean;
  48830. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48831. /** @hidden */
  48832. _areMiscDirty: boolean;
  48833. }
  48834. /**
  48835. * Define the code related to the BRDF parameters of the pbr material.
  48836. */
  48837. export class PBRBRDFConfiguration {
  48838. /**
  48839. * Default value used for the energy conservation.
  48840. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48841. */
  48842. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48843. /**
  48844. * Default value used for the Smith Visibility Height Correlated mode.
  48845. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48846. */
  48847. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48848. /**
  48849. * Default value used for the IBL diffuse part.
  48850. * This can help switching back to the polynomials mode globally which is a tiny bit
  48851. * less GPU intensive at the drawback of a lower quality.
  48852. */
  48853. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48854. /**
  48855. * Default value used for activating energy conservation for the specular workflow.
  48856. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48857. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48858. */
  48859. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48860. private _useEnergyConservation;
  48861. /**
  48862. * Defines if the material uses energy conservation.
  48863. */
  48864. useEnergyConservation: boolean;
  48865. private _useSmithVisibilityHeightCorrelated;
  48866. /**
  48867. * LEGACY Mode set to false
  48868. * Defines if the material uses height smith correlated visibility term.
  48869. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48870. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48871. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48872. * Not relying on height correlated will also disable energy conservation.
  48873. */
  48874. useSmithVisibilityHeightCorrelated: boolean;
  48875. private _useSphericalHarmonics;
  48876. /**
  48877. * LEGACY Mode set to false
  48878. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48879. * diffuse part of the IBL.
  48880. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48881. * to the ground truth.
  48882. */
  48883. useSphericalHarmonics: boolean;
  48884. private _useSpecularGlossinessInputEnergyConservation;
  48885. /**
  48886. * Defines if the material uses energy conservation, when the specular workflow is active.
  48887. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48888. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48889. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48890. */
  48891. useSpecularGlossinessInputEnergyConservation: boolean;
  48892. /** @hidden */
  48893. private _internalMarkAllSubMeshesAsMiscDirty;
  48894. /** @hidden */
  48895. _markAllSubMeshesAsMiscDirty(): void;
  48896. /**
  48897. * Instantiate a new istance of clear coat configuration.
  48898. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48899. */
  48900. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48901. /**
  48902. * Checks to see if a texture is used in the material.
  48903. * @param defines the list of "defines" to update.
  48904. */
  48905. prepareDefines(defines: IMaterialBRDFDefines): void;
  48906. /**
  48907. * Get the current class name of the texture useful for serialization or dynamic coding.
  48908. * @returns "PBRClearCoatConfiguration"
  48909. */
  48910. getClassName(): string;
  48911. /**
  48912. * Makes a duplicate of the current configuration into another one.
  48913. * @param brdfConfiguration define the config where to copy the info
  48914. */
  48915. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48916. /**
  48917. * Serializes this BRDF configuration.
  48918. * @returns - An object with the serialized config.
  48919. */
  48920. serialize(): any;
  48921. /**
  48922. * Parses a anisotropy Configuration from a serialized object.
  48923. * @param source - Serialized object.
  48924. * @param scene Defines the scene we are parsing for
  48925. * @param rootUrl Defines the rootUrl to load from
  48926. */
  48927. parse(source: any, scene: Scene, rootUrl: string): void;
  48928. }
  48929. }
  48930. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48932. import { Color3 } from "babylonjs/Maths/math.color";
  48933. import { Scene } from "babylonjs/scene";
  48934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48935. import { Nullable } from "babylonjs/types";
  48936. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48937. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48938. /**
  48939. * @hidden
  48940. */
  48941. export interface IMaterialSheenDefines {
  48942. SHEEN: boolean;
  48943. SHEEN_TEXTURE: boolean;
  48944. SHEEN_TEXTUREDIRECTUV: number;
  48945. SHEEN_LINKWITHALBEDO: boolean;
  48946. /** @hidden */
  48947. _areTexturesDirty: boolean;
  48948. }
  48949. /**
  48950. * Define the code related to the Sheen parameters of the pbr material.
  48951. */
  48952. export class PBRSheenConfiguration {
  48953. private _isEnabled;
  48954. /**
  48955. * Defines if the material uses sheen.
  48956. */
  48957. isEnabled: boolean;
  48958. private _linkSheenWithAlbedo;
  48959. /**
  48960. * Defines if the sheen is linked to the sheen color.
  48961. */
  48962. linkSheenWithAlbedo: boolean;
  48963. /**
  48964. * Defines the sheen intensity.
  48965. */
  48966. intensity: number;
  48967. /**
  48968. * Defines the sheen color.
  48969. */
  48970. color: Color3;
  48971. private _texture;
  48972. /**
  48973. * Stores the sheen tint values in a texture.
  48974. * rgb is tint
  48975. * a is a intensity
  48976. */
  48977. texture: Nullable<BaseTexture>;
  48978. /** @hidden */
  48979. private _internalMarkAllSubMeshesAsTexturesDirty;
  48980. /** @hidden */
  48981. _markAllSubMeshesAsTexturesDirty(): void;
  48982. /**
  48983. * Instantiate a new istance of clear coat configuration.
  48984. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48985. */
  48986. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48987. /**
  48988. * Specifies that the submesh is ready to be used.
  48989. * @param defines the list of "defines" to update.
  48990. * @param scene defines the scene the material belongs to.
  48991. * @returns - boolean indicating that the submesh is ready or not.
  48992. */
  48993. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48994. /**
  48995. * Checks to see if a texture is used in the material.
  48996. * @param defines the list of "defines" to update.
  48997. * @param scene defines the scene the material belongs to.
  48998. */
  48999. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49000. /**
  49001. * Binds the material data.
  49002. * @param uniformBuffer defines the Uniform buffer to fill in.
  49003. * @param scene defines the scene the material belongs to.
  49004. * @param isFrozen defines wether the material is frozen or not.
  49005. */
  49006. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49007. /**
  49008. * Checks to see if a texture is used in the material.
  49009. * @param texture - Base texture to use.
  49010. * @returns - Boolean specifying if a texture is used in the material.
  49011. */
  49012. hasTexture(texture: BaseTexture): boolean;
  49013. /**
  49014. * Returns an array of the actively used textures.
  49015. * @param activeTextures Array of BaseTextures
  49016. */
  49017. getActiveTextures(activeTextures: BaseTexture[]): void;
  49018. /**
  49019. * Returns the animatable textures.
  49020. * @param animatables Array of animatable textures.
  49021. */
  49022. getAnimatables(animatables: IAnimatable[]): void;
  49023. /**
  49024. * Disposes the resources of the material.
  49025. * @param forceDisposeTextures - Forces the disposal of all textures.
  49026. */
  49027. dispose(forceDisposeTextures?: boolean): void;
  49028. /**
  49029. * Get the current class name of the texture useful for serialization or dynamic coding.
  49030. * @returns "PBRSheenConfiguration"
  49031. */
  49032. getClassName(): string;
  49033. /**
  49034. * Add fallbacks to the effect fallbacks list.
  49035. * @param defines defines the Base texture to use.
  49036. * @param fallbacks defines the current fallback list.
  49037. * @param currentRank defines the current fallback rank.
  49038. * @returns the new fallback rank.
  49039. */
  49040. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49041. /**
  49042. * Add the required uniforms to the current list.
  49043. * @param uniforms defines the current uniform list.
  49044. */
  49045. static AddUniforms(uniforms: string[]): void;
  49046. /**
  49047. * Add the required uniforms to the current buffer.
  49048. * @param uniformBuffer defines the current uniform buffer.
  49049. */
  49050. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49051. /**
  49052. * Add the required samplers to the current list.
  49053. * @param samplers defines the current sampler list.
  49054. */
  49055. static AddSamplers(samplers: string[]): void;
  49056. /**
  49057. * Makes a duplicate of the current configuration into another one.
  49058. * @param sheenConfiguration define the config where to copy the info
  49059. */
  49060. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49061. /**
  49062. * Serializes this BRDF configuration.
  49063. * @returns - An object with the serialized config.
  49064. */
  49065. serialize(): any;
  49066. /**
  49067. * Parses a anisotropy Configuration from a serialized object.
  49068. * @param source - Serialized object.
  49069. * @param scene Defines the scene we are parsing for
  49070. * @param rootUrl Defines the rootUrl to load from
  49071. */
  49072. parse(source: any, scene: Scene, rootUrl: string): void;
  49073. }
  49074. }
  49075. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49076. import { Nullable } from "babylonjs/types";
  49077. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49078. import { Color3 } from "babylonjs/Maths/math.color";
  49079. import { SmartArray } from "babylonjs/Misc/smartArray";
  49080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49082. import { Effect } from "babylonjs/Materials/effect";
  49083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49084. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49085. import { Engine } from "babylonjs/Engines/engine";
  49086. import { Scene } from "babylonjs/scene";
  49087. /**
  49088. * @hidden
  49089. */
  49090. export interface IMaterialSubSurfaceDefines {
  49091. SUBSURFACE: boolean;
  49092. SS_REFRACTION: boolean;
  49093. SS_TRANSLUCENCY: boolean;
  49094. SS_SCATERRING: boolean;
  49095. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49096. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49097. SS_REFRACTIONMAP_3D: boolean;
  49098. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49099. SS_LODINREFRACTIONALPHA: boolean;
  49100. SS_GAMMAREFRACTION: boolean;
  49101. SS_RGBDREFRACTION: boolean;
  49102. SS_LINEARSPECULARREFRACTION: boolean;
  49103. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49104. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49105. /** @hidden */
  49106. _areTexturesDirty: boolean;
  49107. }
  49108. /**
  49109. * Define the code related to the sub surface parameters of the pbr material.
  49110. */
  49111. export class PBRSubSurfaceConfiguration {
  49112. private _isRefractionEnabled;
  49113. /**
  49114. * Defines if the refraction is enabled in the material.
  49115. */
  49116. isRefractionEnabled: boolean;
  49117. private _isTranslucencyEnabled;
  49118. /**
  49119. * Defines if the translucency is enabled in the material.
  49120. */
  49121. isTranslucencyEnabled: boolean;
  49122. private _isScatteringEnabled;
  49123. /**
  49124. * Defines the refraction intensity of the material.
  49125. * The refraction when enabled replaces the Diffuse part of the material.
  49126. * The intensity helps transitionning between diffuse and refraction.
  49127. */
  49128. refractionIntensity: number;
  49129. /**
  49130. * Defines the translucency intensity of the material.
  49131. * When translucency has been enabled, this defines how much of the "translucency"
  49132. * is addded to the diffuse part of the material.
  49133. */
  49134. translucencyIntensity: number;
  49135. /**
  49136. * Defines the scattering intensity of the material.
  49137. * When scattering has been enabled, this defines how much of the "scattered light"
  49138. * is addded to the diffuse part of the material.
  49139. */
  49140. scatteringIntensity: number;
  49141. private _thicknessTexture;
  49142. /**
  49143. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49144. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49145. * 0 would mean minimumThickness
  49146. * 1 would mean maximumThickness
  49147. * The other channels might be use as a mask to vary the different effects intensity.
  49148. */
  49149. thicknessTexture: Nullable<BaseTexture>;
  49150. private _refractionTexture;
  49151. /**
  49152. * Defines the texture to use for refraction.
  49153. */
  49154. refractionTexture: Nullable<BaseTexture>;
  49155. private _indexOfRefraction;
  49156. /**
  49157. * Defines the index of refraction used in the material.
  49158. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49159. */
  49160. indexOfRefraction: number;
  49161. private _invertRefractionY;
  49162. /**
  49163. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49164. */
  49165. invertRefractionY: boolean;
  49166. private _linkRefractionWithTransparency;
  49167. /**
  49168. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49169. * Materials half opaque for instance using refraction could benefit from this control.
  49170. */
  49171. linkRefractionWithTransparency: boolean;
  49172. /**
  49173. * Defines the minimum thickness stored in the thickness map.
  49174. * If no thickness map is defined, this value will be used to simulate thickness.
  49175. */
  49176. minimumThickness: number;
  49177. /**
  49178. * Defines the maximum thickness stored in the thickness map.
  49179. */
  49180. maximumThickness: number;
  49181. /**
  49182. * Defines the volume tint of the material.
  49183. * This is used for both translucency and scattering.
  49184. */
  49185. tintColor: Color3;
  49186. /**
  49187. * Defines the distance at which the tint color should be found in the media.
  49188. * This is used for refraction only.
  49189. */
  49190. tintColorAtDistance: number;
  49191. /**
  49192. * Defines how far each channel transmit through the media.
  49193. * It is defined as a color to simplify it selection.
  49194. */
  49195. diffusionDistance: Color3;
  49196. private _useMaskFromThicknessTexture;
  49197. /**
  49198. * Stores the intensity of the different subsurface effects in the thickness texture.
  49199. * * the green channel is the translucency intensity.
  49200. * * the blue channel is the scattering intensity.
  49201. * * the alpha channel is the refraction intensity.
  49202. */
  49203. useMaskFromThicknessTexture: boolean;
  49204. /** @hidden */
  49205. private _internalMarkAllSubMeshesAsTexturesDirty;
  49206. /** @hidden */
  49207. _markAllSubMeshesAsTexturesDirty(): void;
  49208. /**
  49209. * Instantiate a new istance of sub surface configuration.
  49210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49211. */
  49212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49213. /**
  49214. * Gets wehter the submesh is ready to be used or not.
  49215. * @param defines the list of "defines" to update.
  49216. * @param scene defines the scene the material belongs to.
  49217. * @returns - boolean indicating that the submesh is ready or not.
  49218. */
  49219. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49220. /**
  49221. * Checks to see if a texture is used in the material.
  49222. * @param defines the list of "defines" to update.
  49223. * @param scene defines the scene to the material belongs to.
  49224. */
  49225. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49226. /**
  49227. * Binds the material data.
  49228. * @param uniformBuffer defines the Uniform buffer to fill in.
  49229. * @param scene defines the scene the material belongs to.
  49230. * @param engine defines the engine the material belongs to.
  49231. * @param isFrozen defines wether the material is frozen or not.
  49232. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49233. */
  49234. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49235. /**
  49236. * Unbinds the material from the mesh.
  49237. * @param activeEffect defines the effect that should be unbound from.
  49238. * @returns true if unbound, otherwise false
  49239. */
  49240. unbind(activeEffect: Effect): boolean;
  49241. /**
  49242. * Returns the texture used for refraction or null if none is used.
  49243. * @param scene defines the scene the material belongs to.
  49244. * @returns - Refraction texture if present. If no refraction texture and refraction
  49245. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49246. */
  49247. private _getRefractionTexture;
  49248. /**
  49249. * Returns true if alpha blending should be disabled.
  49250. */
  49251. readonly disableAlphaBlending: boolean;
  49252. /**
  49253. * Fills the list of render target textures.
  49254. * @param renderTargets the list of render targets to update
  49255. */
  49256. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49257. /**
  49258. * Checks to see if a texture is used in the material.
  49259. * @param texture - Base texture to use.
  49260. * @returns - Boolean specifying if a texture is used in the material.
  49261. */
  49262. hasTexture(texture: BaseTexture): boolean;
  49263. /**
  49264. * Gets a boolean indicating that current material needs to register RTT
  49265. * @returns true if this uses a render target otherwise false.
  49266. */
  49267. hasRenderTargetTextures(): boolean;
  49268. /**
  49269. * Returns an array of the actively used textures.
  49270. * @param activeTextures Array of BaseTextures
  49271. */
  49272. getActiveTextures(activeTextures: BaseTexture[]): void;
  49273. /**
  49274. * Returns the animatable textures.
  49275. * @param animatables Array of animatable textures.
  49276. */
  49277. getAnimatables(animatables: IAnimatable[]): void;
  49278. /**
  49279. * Disposes the resources of the material.
  49280. * @param forceDisposeTextures - Forces the disposal of all textures.
  49281. */
  49282. dispose(forceDisposeTextures?: boolean): void;
  49283. /**
  49284. * Get the current class name of the texture useful for serialization or dynamic coding.
  49285. * @returns "PBRSubSurfaceConfiguration"
  49286. */
  49287. getClassName(): string;
  49288. /**
  49289. * Add fallbacks to the effect fallbacks list.
  49290. * @param defines defines the Base texture to use.
  49291. * @param fallbacks defines the current fallback list.
  49292. * @param currentRank defines the current fallback rank.
  49293. * @returns the new fallback rank.
  49294. */
  49295. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49296. /**
  49297. * Add the required uniforms to the current list.
  49298. * @param uniforms defines the current uniform list.
  49299. */
  49300. static AddUniforms(uniforms: string[]): void;
  49301. /**
  49302. * Add the required samplers to the current list.
  49303. * @param samplers defines the current sampler list.
  49304. */
  49305. static AddSamplers(samplers: string[]): void;
  49306. /**
  49307. * Add the required uniforms to the current buffer.
  49308. * @param uniformBuffer defines the current uniform buffer.
  49309. */
  49310. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49311. /**
  49312. * Makes a duplicate of the current configuration into another one.
  49313. * @param configuration define the config where to copy the info
  49314. */
  49315. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49316. /**
  49317. * Serializes this Sub Surface configuration.
  49318. * @returns - An object with the serialized config.
  49319. */
  49320. serialize(): any;
  49321. /**
  49322. * Parses a anisotropy Configuration from a serialized object.
  49323. * @param source - Serialized object.
  49324. * @param scene Defines the scene we are parsing for
  49325. * @param rootUrl Defines the rootUrl to load from
  49326. */
  49327. parse(source: any, scene: Scene, rootUrl: string): void;
  49328. }
  49329. }
  49330. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49331. /** @hidden */
  49332. export var pbrFragmentDeclaration: {
  49333. name: string;
  49334. shader: string;
  49335. };
  49336. }
  49337. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49338. /** @hidden */
  49339. export var pbrUboDeclaration: {
  49340. name: string;
  49341. shader: string;
  49342. };
  49343. }
  49344. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49345. /** @hidden */
  49346. export var pbrFragmentExtraDeclaration: {
  49347. name: string;
  49348. shader: string;
  49349. };
  49350. }
  49351. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49352. /** @hidden */
  49353. export var pbrFragmentSamplersDeclaration: {
  49354. name: string;
  49355. shader: string;
  49356. };
  49357. }
  49358. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49359. /** @hidden */
  49360. export var pbrHelperFunctions: {
  49361. name: string;
  49362. shader: string;
  49363. };
  49364. }
  49365. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49366. /** @hidden */
  49367. export var harmonicsFunctions: {
  49368. name: string;
  49369. shader: string;
  49370. };
  49371. }
  49372. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49373. /** @hidden */
  49374. export var pbrDirectLightingSetupFunctions: {
  49375. name: string;
  49376. shader: string;
  49377. };
  49378. }
  49379. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49380. /** @hidden */
  49381. export var pbrDirectLightingFalloffFunctions: {
  49382. name: string;
  49383. shader: string;
  49384. };
  49385. }
  49386. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49387. /** @hidden */
  49388. export var pbrBRDFFunctions: {
  49389. name: string;
  49390. shader: string;
  49391. };
  49392. }
  49393. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49394. /** @hidden */
  49395. export var pbrDirectLightingFunctions: {
  49396. name: string;
  49397. shader: string;
  49398. };
  49399. }
  49400. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49401. /** @hidden */
  49402. export var pbrIBLFunctions: {
  49403. name: string;
  49404. shader: string;
  49405. };
  49406. }
  49407. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49408. /** @hidden */
  49409. export var pbrDebug: {
  49410. name: string;
  49411. shader: string;
  49412. };
  49413. }
  49414. declare module "babylonjs/Shaders/pbr.fragment" {
  49415. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49416. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49418. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49419. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49420. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49421. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49423. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49424. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49426. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49427. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49429. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49430. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49431. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49432. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49433. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49434. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49435. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49436. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49437. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49438. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49439. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49440. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49441. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49442. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49443. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49444. /** @hidden */
  49445. export var pbrPixelShader: {
  49446. name: string;
  49447. shader: string;
  49448. };
  49449. }
  49450. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49451. /** @hidden */
  49452. export var pbrVertexDeclaration: {
  49453. name: string;
  49454. shader: string;
  49455. };
  49456. }
  49457. declare module "babylonjs/Shaders/pbr.vertex" {
  49458. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49459. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49460. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49461. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49462. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49463. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49464. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49465. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49466. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49467. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49468. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49470. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49471. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49472. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49473. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49474. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49475. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49476. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49477. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49478. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49479. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49480. /** @hidden */
  49481. export var pbrVertexShader: {
  49482. name: string;
  49483. shader: string;
  49484. };
  49485. }
  49486. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49487. import { Nullable } from "babylonjs/types";
  49488. import { Scene } from "babylonjs/scene";
  49489. import { Matrix } from "babylonjs/Maths/math.vector";
  49490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49492. import { Mesh } from "babylonjs/Meshes/mesh";
  49493. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49494. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49495. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49496. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49497. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49498. import { Color3 } from "babylonjs/Maths/math.color";
  49499. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49500. import { Material } from "babylonjs/Materials/material";
  49501. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49502. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49504. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49505. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49506. import "babylonjs/Shaders/pbr.fragment";
  49507. import "babylonjs/Shaders/pbr.vertex";
  49508. /**
  49509. * Manages the defines for the PBR Material.
  49510. * @hidden
  49511. */
  49512. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49513. PBR: boolean;
  49514. MAINUV1: boolean;
  49515. MAINUV2: boolean;
  49516. UV1: boolean;
  49517. UV2: boolean;
  49518. ALBEDO: boolean;
  49519. ALBEDODIRECTUV: number;
  49520. VERTEXCOLOR: boolean;
  49521. AMBIENT: boolean;
  49522. AMBIENTDIRECTUV: number;
  49523. AMBIENTINGRAYSCALE: boolean;
  49524. OPACITY: boolean;
  49525. VERTEXALPHA: boolean;
  49526. OPACITYDIRECTUV: number;
  49527. OPACITYRGB: boolean;
  49528. ALPHATEST: boolean;
  49529. DEPTHPREPASS: boolean;
  49530. ALPHABLEND: boolean;
  49531. ALPHAFROMALBEDO: boolean;
  49532. ALPHATESTVALUE: string;
  49533. SPECULAROVERALPHA: boolean;
  49534. RADIANCEOVERALPHA: boolean;
  49535. ALPHAFRESNEL: boolean;
  49536. LINEARALPHAFRESNEL: boolean;
  49537. PREMULTIPLYALPHA: boolean;
  49538. EMISSIVE: boolean;
  49539. EMISSIVEDIRECTUV: number;
  49540. REFLECTIVITY: boolean;
  49541. REFLECTIVITYDIRECTUV: number;
  49542. SPECULARTERM: boolean;
  49543. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49544. MICROSURFACEAUTOMATIC: boolean;
  49545. LODBASEDMICROSFURACE: boolean;
  49546. MICROSURFACEMAP: boolean;
  49547. MICROSURFACEMAPDIRECTUV: number;
  49548. METALLICWORKFLOW: boolean;
  49549. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49550. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49551. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49552. AOSTOREINMETALMAPRED: boolean;
  49553. ENVIRONMENTBRDF: boolean;
  49554. ENVIRONMENTBRDF_RGBD: boolean;
  49555. NORMAL: boolean;
  49556. TANGENT: boolean;
  49557. BUMP: boolean;
  49558. BUMPDIRECTUV: number;
  49559. OBJECTSPACE_NORMALMAP: boolean;
  49560. PARALLAX: boolean;
  49561. PARALLAXOCCLUSION: boolean;
  49562. NORMALXYSCALE: boolean;
  49563. LIGHTMAP: boolean;
  49564. LIGHTMAPDIRECTUV: number;
  49565. USELIGHTMAPASSHADOWMAP: boolean;
  49566. GAMMALIGHTMAP: boolean;
  49567. RGBDLIGHTMAP: boolean;
  49568. REFLECTION: boolean;
  49569. REFLECTIONMAP_3D: boolean;
  49570. REFLECTIONMAP_SPHERICAL: boolean;
  49571. REFLECTIONMAP_PLANAR: boolean;
  49572. REFLECTIONMAP_CUBIC: boolean;
  49573. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49574. REFLECTIONMAP_PROJECTION: boolean;
  49575. REFLECTIONMAP_SKYBOX: boolean;
  49576. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49577. REFLECTIONMAP_EXPLICIT: boolean;
  49578. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49579. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49580. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49581. INVERTCUBICMAP: boolean;
  49582. USESPHERICALFROMREFLECTIONMAP: boolean;
  49583. USEIRRADIANCEMAP: boolean;
  49584. SPHERICAL_HARMONICS: boolean;
  49585. USESPHERICALINVERTEX: boolean;
  49586. REFLECTIONMAP_OPPOSITEZ: boolean;
  49587. LODINREFLECTIONALPHA: boolean;
  49588. GAMMAREFLECTION: boolean;
  49589. RGBDREFLECTION: boolean;
  49590. LINEARSPECULARREFLECTION: boolean;
  49591. RADIANCEOCCLUSION: boolean;
  49592. HORIZONOCCLUSION: boolean;
  49593. INSTANCES: boolean;
  49594. NUM_BONE_INFLUENCERS: number;
  49595. BonesPerMesh: number;
  49596. BONETEXTURE: boolean;
  49597. NONUNIFORMSCALING: boolean;
  49598. MORPHTARGETS: boolean;
  49599. MORPHTARGETS_NORMAL: boolean;
  49600. MORPHTARGETS_TANGENT: boolean;
  49601. MORPHTARGETS_UV: boolean;
  49602. NUM_MORPH_INFLUENCERS: number;
  49603. IMAGEPROCESSING: boolean;
  49604. VIGNETTE: boolean;
  49605. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49606. VIGNETTEBLENDMODEOPAQUE: boolean;
  49607. TONEMAPPING: boolean;
  49608. TONEMAPPING_ACES: boolean;
  49609. CONTRAST: boolean;
  49610. COLORCURVES: boolean;
  49611. COLORGRADING: boolean;
  49612. COLORGRADING3D: boolean;
  49613. SAMPLER3DGREENDEPTH: boolean;
  49614. SAMPLER3DBGRMAP: boolean;
  49615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49616. EXPOSURE: boolean;
  49617. MULTIVIEW: boolean;
  49618. USEPHYSICALLIGHTFALLOFF: boolean;
  49619. USEGLTFLIGHTFALLOFF: boolean;
  49620. TWOSIDEDLIGHTING: boolean;
  49621. SHADOWFLOAT: boolean;
  49622. CLIPPLANE: boolean;
  49623. CLIPPLANE2: boolean;
  49624. CLIPPLANE3: boolean;
  49625. CLIPPLANE4: boolean;
  49626. POINTSIZE: boolean;
  49627. FOG: boolean;
  49628. LOGARITHMICDEPTH: boolean;
  49629. FORCENORMALFORWARD: boolean;
  49630. SPECULARAA: boolean;
  49631. CLEARCOAT: boolean;
  49632. CLEARCOAT_DEFAULTIOR: boolean;
  49633. CLEARCOAT_TEXTURE: boolean;
  49634. CLEARCOAT_TEXTUREDIRECTUV: number;
  49635. CLEARCOAT_BUMP: boolean;
  49636. CLEARCOAT_BUMPDIRECTUV: number;
  49637. CLEARCOAT_TINT: boolean;
  49638. CLEARCOAT_TINT_TEXTURE: boolean;
  49639. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49640. ANISOTROPIC: boolean;
  49641. ANISOTROPIC_TEXTURE: boolean;
  49642. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49643. BRDF_V_HEIGHT_CORRELATED: boolean;
  49644. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49645. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49646. SHEEN: boolean;
  49647. SHEEN_TEXTURE: boolean;
  49648. SHEEN_TEXTUREDIRECTUV: number;
  49649. SHEEN_LINKWITHALBEDO: boolean;
  49650. SUBSURFACE: boolean;
  49651. SS_REFRACTION: boolean;
  49652. SS_TRANSLUCENCY: boolean;
  49653. SS_SCATERRING: boolean;
  49654. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49655. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49656. SS_REFRACTIONMAP_3D: boolean;
  49657. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49658. SS_LODINREFRACTIONALPHA: boolean;
  49659. SS_GAMMAREFRACTION: boolean;
  49660. SS_RGBDREFRACTION: boolean;
  49661. SS_LINEARSPECULARREFRACTION: boolean;
  49662. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49663. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49664. UNLIT: boolean;
  49665. DEBUGMODE: number;
  49666. /**
  49667. * Initializes the PBR Material defines.
  49668. */
  49669. constructor();
  49670. /**
  49671. * Resets the PBR Material defines.
  49672. */
  49673. reset(): void;
  49674. }
  49675. /**
  49676. * The Physically based material base class of BJS.
  49677. *
  49678. * This offers the main features of a standard PBR material.
  49679. * For more information, please refer to the documentation :
  49680. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49681. */
  49682. export abstract class PBRBaseMaterial extends PushMaterial {
  49683. /**
  49684. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49685. */
  49686. static readonly PBRMATERIAL_OPAQUE: number;
  49687. /**
  49688. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49689. */
  49690. static readonly PBRMATERIAL_ALPHATEST: number;
  49691. /**
  49692. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49693. */
  49694. static readonly PBRMATERIAL_ALPHABLEND: number;
  49695. /**
  49696. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49697. * They are also discarded below the alpha cutoff threshold to improve performances.
  49698. */
  49699. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49700. /**
  49701. * Defines the default value of how much AO map is occluding the analytical lights
  49702. * (point spot...).
  49703. */
  49704. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49705. /**
  49706. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49707. */
  49708. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49709. /**
  49710. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49711. * to enhance interoperability with other engines.
  49712. */
  49713. static readonly LIGHTFALLOFF_GLTF: number;
  49714. /**
  49715. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49716. * to enhance interoperability with other materials.
  49717. */
  49718. static readonly LIGHTFALLOFF_STANDARD: number;
  49719. /**
  49720. * Intensity of the direct lights e.g. the four lights available in your scene.
  49721. * This impacts both the direct diffuse and specular highlights.
  49722. */
  49723. protected _directIntensity: number;
  49724. /**
  49725. * Intensity of the emissive part of the material.
  49726. * This helps controlling the emissive effect without modifying the emissive color.
  49727. */
  49728. protected _emissiveIntensity: number;
  49729. /**
  49730. * Intensity of the environment e.g. how much the environment will light the object
  49731. * either through harmonics for rough material or through the refelction for shiny ones.
  49732. */
  49733. protected _environmentIntensity: number;
  49734. /**
  49735. * This is a special control allowing the reduction of the specular highlights coming from the
  49736. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49737. */
  49738. protected _specularIntensity: number;
  49739. /**
  49740. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49741. */
  49742. private _lightingInfos;
  49743. /**
  49744. * Debug Control allowing disabling the bump map on this material.
  49745. */
  49746. protected _disableBumpMap: boolean;
  49747. /**
  49748. * AKA Diffuse Texture in standard nomenclature.
  49749. */
  49750. protected _albedoTexture: Nullable<BaseTexture>;
  49751. /**
  49752. * AKA Occlusion Texture in other nomenclature.
  49753. */
  49754. protected _ambientTexture: Nullable<BaseTexture>;
  49755. /**
  49756. * AKA Occlusion Texture Intensity in other nomenclature.
  49757. */
  49758. protected _ambientTextureStrength: number;
  49759. /**
  49760. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49761. * 1 means it completely occludes it
  49762. * 0 mean it has no impact
  49763. */
  49764. protected _ambientTextureImpactOnAnalyticalLights: number;
  49765. /**
  49766. * Stores the alpha values in a texture.
  49767. */
  49768. protected _opacityTexture: Nullable<BaseTexture>;
  49769. /**
  49770. * Stores the reflection values in a texture.
  49771. */
  49772. protected _reflectionTexture: Nullable<BaseTexture>;
  49773. /**
  49774. * Stores the emissive values in a texture.
  49775. */
  49776. protected _emissiveTexture: Nullable<BaseTexture>;
  49777. /**
  49778. * AKA Specular texture in other nomenclature.
  49779. */
  49780. protected _reflectivityTexture: Nullable<BaseTexture>;
  49781. /**
  49782. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49783. */
  49784. protected _metallicTexture: Nullable<BaseTexture>;
  49785. /**
  49786. * Specifies the metallic scalar of the metallic/roughness workflow.
  49787. * Can also be used to scale the metalness values of the metallic texture.
  49788. */
  49789. protected _metallic: Nullable<number>;
  49790. /**
  49791. * Specifies the roughness scalar of the metallic/roughness workflow.
  49792. * Can also be used to scale the roughness values of the metallic texture.
  49793. */
  49794. protected _roughness: Nullable<number>;
  49795. /**
  49796. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49797. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49798. */
  49799. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49800. /**
  49801. * Stores surface normal data used to displace a mesh in a texture.
  49802. */
  49803. protected _bumpTexture: Nullable<BaseTexture>;
  49804. /**
  49805. * Stores the pre-calculated light information of a mesh in a texture.
  49806. */
  49807. protected _lightmapTexture: Nullable<BaseTexture>;
  49808. /**
  49809. * The color of a material in ambient lighting.
  49810. */
  49811. protected _ambientColor: Color3;
  49812. /**
  49813. * AKA Diffuse Color in other nomenclature.
  49814. */
  49815. protected _albedoColor: Color3;
  49816. /**
  49817. * AKA Specular Color in other nomenclature.
  49818. */
  49819. protected _reflectivityColor: Color3;
  49820. /**
  49821. * The color applied when light is reflected from a material.
  49822. */
  49823. protected _reflectionColor: Color3;
  49824. /**
  49825. * The color applied when light is emitted from a material.
  49826. */
  49827. protected _emissiveColor: Color3;
  49828. /**
  49829. * AKA Glossiness in other nomenclature.
  49830. */
  49831. protected _microSurface: number;
  49832. /**
  49833. * Specifies that the material will use the light map as a show map.
  49834. */
  49835. protected _useLightmapAsShadowmap: boolean;
  49836. /**
  49837. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49838. * makes the reflect vector face the model (under horizon).
  49839. */
  49840. protected _useHorizonOcclusion: boolean;
  49841. /**
  49842. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49843. * too much the area relying on ambient texture to define their ambient occlusion.
  49844. */
  49845. protected _useRadianceOcclusion: boolean;
  49846. /**
  49847. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49848. */
  49849. protected _useAlphaFromAlbedoTexture: boolean;
  49850. /**
  49851. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49852. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49853. */
  49854. protected _useSpecularOverAlpha: boolean;
  49855. /**
  49856. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49857. */
  49858. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49859. /**
  49860. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49861. */
  49862. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49863. /**
  49864. * Specifies if the metallic texture contains the roughness information in its green channel.
  49865. */
  49866. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49867. /**
  49868. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49869. */
  49870. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49871. /**
  49872. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49873. */
  49874. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49875. /**
  49876. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49877. */
  49878. protected _useAmbientInGrayScale: boolean;
  49879. /**
  49880. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49881. * The material will try to infer what glossiness each pixel should be.
  49882. */
  49883. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49884. /**
  49885. * Defines the falloff type used in this material.
  49886. * It by default is Physical.
  49887. */
  49888. protected _lightFalloff: number;
  49889. /**
  49890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49892. */
  49893. protected _useRadianceOverAlpha: boolean;
  49894. /**
  49895. * Allows using an object space normal map (instead of tangent space).
  49896. */
  49897. protected _useObjectSpaceNormalMap: boolean;
  49898. /**
  49899. * Allows using the bump map in parallax mode.
  49900. */
  49901. protected _useParallax: boolean;
  49902. /**
  49903. * Allows using the bump map in parallax occlusion mode.
  49904. */
  49905. protected _useParallaxOcclusion: boolean;
  49906. /**
  49907. * Controls the scale bias of the parallax mode.
  49908. */
  49909. protected _parallaxScaleBias: number;
  49910. /**
  49911. * If sets to true, disables all the lights affecting the material.
  49912. */
  49913. protected _disableLighting: boolean;
  49914. /**
  49915. * Number of Simultaneous lights allowed on the material.
  49916. */
  49917. protected _maxSimultaneousLights: number;
  49918. /**
  49919. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49920. */
  49921. protected _invertNormalMapX: boolean;
  49922. /**
  49923. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49924. */
  49925. protected _invertNormalMapY: boolean;
  49926. /**
  49927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49928. */
  49929. protected _twoSidedLighting: boolean;
  49930. /**
  49931. * Defines the alpha limits in alpha test mode.
  49932. */
  49933. protected _alphaCutOff: number;
  49934. /**
  49935. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49936. */
  49937. protected _forceAlphaTest: boolean;
  49938. /**
  49939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49940. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49941. */
  49942. protected _useAlphaFresnel: boolean;
  49943. /**
  49944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49945. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49946. */
  49947. protected _useLinearAlphaFresnel: boolean;
  49948. /**
  49949. * The transparency mode of the material.
  49950. */
  49951. protected _transparencyMode: Nullable<number>;
  49952. /**
  49953. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49954. * from cos thetav and roughness:
  49955. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49956. */
  49957. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49958. /**
  49959. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49960. */
  49961. protected _forceIrradianceInFragment: boolean;
  49962. /**
  49963. * Force normal to face away from face.
  49964. */
  49965. protected _forceNormalForward: boolean;
  49966. /**
  49967. * Enables specular anti aliasing in the PBR shader.
  49968. * It will both interacts on the Geometry for analytical and IBL lighting.
  49969. * It also prefilter the roughness map based on the bump values.
  49970. */
  49971. protected _enableSpecularAntiAliasing: boolean;
  49972. /**
  49973. * Default configuration related to image processing available in the PBR Material.
  49974. */
  49975. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49976. /**
  49977. * Keep track of the image processing observer to allow dispose and replace.
  49978. */
  49979. private _imageProcessingObserver;
  49980. /**
  49981. * Attaches a new image processing configuration to the PBR Material.
  49982. * @param configuration
  49983. */
  49984. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49985. /**
  49986. * Stores the available render targets.
  49987. */
  49988. private _renderTargets;
  49989. /**
  49990. * Sets the global ambient color for the material used in lighting calculations.
  49991. */
  49992. private _globalAmbientColor;
  49993. /**
  49994. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49995. */
  49996. private _useLogarithmicDepth;
  49997. /**
  49998. * If set to true, no lighting calculations will be applied.
  49999. */
  50000. private _unlit;
  50001. private _debugMode;
  50002. /**
  50003. * @hidden
  50004. * This is reserved for the inspector.
  50005. * Defines the material debug mode.
  50006. * It helps seeing only some components of the material while troubleshooting.
  50007. */
  50008. debugMode: number;
  50009. /**
  50010. * @hidden
  50011. * This is reserved for the inspector.
  50012. * Specify from where on screen the debug mode should start.
  50013. * The value goes from -1 (full screen) to 1 (not visible)
  50014. * It helps with side by side comparison against the final render
  50015. * This defaults to -1
  50016. */
  50017. private debugLimit;
  50018. /**
  50019. * @hidden
  50020. * This is reserved for the inspector.
  50021. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50022. * You can use the factor to better multiply the final value.
  50023. */
  50024. private debugFactor;
  50025. /**
  50026. * Defines the clear coat layer parameters for the material.
  50027. */
  50028. readonly clearCoat: PBRClearCoatConfiguration;
  50029. /**
  50030. * Defines the anisotropic parameters for the material.
  50031. */
  50032. readonly anisotropy: PBRAnisotropicConfiguration;
  50033. /**
  50034. * Defines the BRDF parameters for the material.
  50035. */
  50036. readonly brdf: PBRBRDFConfiguration;
  50037. /**
  50038. * Defines the Sheen parameters for the material.
  50039. */
  50040. readonly sheen: PBRSheenConfiguration;
  50041. /**
  50042. * Defines the SubSurface parameters for the material.
  50043. */
  50044. readonly subSurface: PBRSubSurfaceConfiguration;
  50045. /**
  50046. * Custom callback helping to override the default shader used in the material.
  50047. */
  50048. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50049. protected _rebuildInParallel: boolean;
  50050. /**
  50051. * Instantiates a new PBRMaterial instance.
  50052. *
  50053. * @param name The material name
  50054. * @param scene The scene the material will be use in.
  50055. */
  50056. constructor(name: string, scene: Scene);
  50057. /**
  50058. * Gets a boolean indicating that current material needs to register RTT
  50059. */
  50060. readonly hasRenderTargetTextures: boolean;
  50061. /**
  50062. * Gets the name of the material class.
  50063. */
  50064. getClassName(): string;
  50065. /**
  50066. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50067. */
  50068. /**
  50069. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50070. */
  50071. useLogarithmicDepth: boolean;
  50072. /**
  50073. * Gets the current transparency mode.
  50074. */
  50075. /**
  50076. * Sets the transparency mode of the material.
  50077. *
  50078. * | Value | Type | Description |
  50079. * | ----- | ----------------------------------- | ----------- |
  50080. * | 0 | OPAQUE | |
  50081. * | 1 | ALPHATEST | |
  50082. * | 2 | ALPHABLEND | |
  50083. * | 3 | ALPHATESTANDBLEND | |
  50084. *
  50085. */
  50086. transparencyMode: Nullable<number>;
  50087. /**
  50088. * Returns true if alpha blending should be disabled.
  50089. */
  50090. private readonly _disableAlphaBlending;
  50091. /**
  50092. * Specifies whether or not this material should be rendered in alpha blend mode.
  50093. */
  50094. needAlphaBlending(): boolean;
  50095. /**
  50096. * Specifies if the mesh will require alpha blending.
  50097. * @param mesh - BJS mesh.
  50098. */
  50099. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50100. /**
  50101. * Specifies whether or not this material should be rendered in alpha test mode.
  50102. */
  50103. needAlphaTesting(): boolean;
  50104. /**
  50105. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50106. */
  50107. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50108. /**
  50109. * Gets the texture used for the alpha test.
  50110. */
  50111. getAlphaTestTexture(): Nullable<BaseTexture>;
  50112. /**
  50113. * Specifies that the submesh is ready to be used.
  50114. * @param mesh - BJS mesh.
  50115. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50116. * @param useInstances - Specifies that instances should be used.
  50117. * @returns - boolean indicating that the submesh is ready or not.
  50118. */
  50119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50120. /**
  50121. * Specifies if the material uses metallic roughness workflow.
  50122. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50123. */
  50124. isMetallicWorkflow(): boolean;
  50125. private _prepareEffect;
  50126. private _prepareDefines;
  50127. /**
  50128. * Force shader compilation
  50129. */
  50130. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50131. clipPlane: boolean;
  50132. }>): void;
  50133. /**
  50134. * Initializes the uniform buffer layout for the shader.
  50135. */
  50136. buildUniformLayout(): void;
  50137. /**
  50138. * Unbinds the material from the mesh
  50139. */
  50140. unbind(): void;
  50141. /**
  50142. * Binds the submesh data.
  50143. * @param world - The world matrix.
  50144. * @param mesh - The BJS mesh.
  50145. * @param subMesh - A submesh of the BJS mesh.
  50146. */
  50147. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50148. /**
  50149. * Returns the animatable textures.
  50150. * @returns - Array of animatable textures.
  50151. */
  50152. getAnimatables(): IAnimatable[];
  50153. /**
  50154. * Returns the texture used for reflections.
  50155. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50156. */
  50157. private _getReflectionTexture;
  50158. /**
  50159. * Returns an array of the actively used textures.
  50160. * @returns - Array of BaseTextures
  50161. */
  50162. getActiveTextures(): BaseTexture[];
  50163. /**
  50164. * Checks to see if a texture is used in the material.
  50165. * @param texture - Base texture to use.
  50166. * @returns - Boolean specifying if a texture is used in the material.
  50167. */
  50168. hasTexture(texture: BaseTexture): boolean;
  50169. /**
  50170. * Disposes the resources of the material.
  50171. * @param forceDisposeEffect - Forces the disposal of effects.
  50172. * @param forceDisposeTextures - Forces the disposal of all textures.
  50173. */
  50174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50175. }
  50176. }
  50177. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50178. import { Nullable } from "babylonjs/types";
  50179. import { Scene } from "babylonjs/scene";
  50180. import { Color3 } from "babylonjs/Maths/math.color";
  50181. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50182. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50184. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50185. /**
  50186. * The Physically based material of BJS.
  50187. *
  50188. * This offers the main features of a standard PBR material.
  50189. * For more information, please refer to the documentation :
  50190. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50191. */
  50192. export class PBRMaterial extends PBRBaseMaterial {
  50193. /**
  50194. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50195. */
  50196. static readonly PBRMATERIAL_OPAQUE: number;
  50197. /**
  50198. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50199. */
  50200. static readonly PBRMATERIAL_ALPHATEST: number;
  50201. /**
  50202. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50203. */
  50204. static readonly PBRMATERIAL_ALPHABLEND: number;
  50205. /**
  50206. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50207. * They are also discarded below the alpha cutoff threshold to improve performances.
  50208. */
  50209. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50210. /**
  50211. * Defines the default value of how much AO map is occluding the analytical lights
  50212. * (point spot...).
  50213. */
  50214. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50215. /**
  50216. * Intensity of the direct lights e.g. the four lights available in your scene.
  50217. * This impacts both the direct diffuse and specular highlights.
  50218. */
  50219. directIntensity: number;
  50220. /**
  50221. * Intensity of the emissive part of the material.
  50222. * This helps controlling the emissive effect without modifying the emissive color.
  50223. */
  50224. emissiveIntensity: number;
  50225. /**
  50226. * Intensity of the environment e.g. how much the environment will light the object
  50227. * either through harmonics for rough material or through the refelction for shiny ones.
  50228. */
  50229. environmentIntensity: number;
  50230. /**
  50231. * This is a special control allowing the reduction of the specular highlights coming from the
  50232. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50233. */
  50234. specularIntensity: number;
  50235. /**
  50236. * Debug Control allowing disabling the bump map on this material.
  50237. */
  50238. disableBumpMap: boolean;
  50239. /**
  50240. * AKA Diffuse Texture in standard nomenclature.
  50241. */
  50242. albedoTexture: BaseTexture;
  50243. /**
  50244. * AKA Occlusion Texture in other nomenclature.
  50245. */
  50246. ambientTexture: BaseTexture;
  50247. /**
  50248. * AKA Occlusion Texture Intensity in other nomenclature.
  50249. */
  50250. ambientTextureStrength: number;
  50251. /**
  50252. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50253. * 1 means it completely occludes it
  50254. * 0 mean it has no impact
  50255. */
  50256. ambientTextureImpactOnAnalyticalLights: number;
  50257. /**
  50258. * Stores the alpha values in a texture.
  50259. */
  50260. opacityTexture: BaseTexture;
  50261. /**
  50262. * Stores the reflection values in a texture.
  50263. */
  50264. reflectionTexture: Nullable<BaseTexture>;
  50265. /**
  50266. * Stores the emissive values in a texture.
  50267. */
  50268. emissiveTexture: BaseTexture;
  50269. /**
  50270. * AKA Specular texture in other nomenclature.
  50271. */
  50272. reflectivityTexture: BaseTexture;
  50273. /**
  50274. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50275. */
  50276. metallicTexture: BaseTexture;
  50277. /**
  50278. * Specifies the metallic scalar of the metallic/roughness workflow.
  50279. * Can also be used to scale the metalness values of the metallic texture.
  50280. */
  50281. metallic: Nullable<number>;
  50282. /**
  50283. * Specifies the roughness scalar of the metallic/roughness workflow.
  50284. * Can also be used to scale the roughness values of the metallic texture.
  50285. */
  50286. roughness: Nullable<number>;
  50287. /**
  50288. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50289. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50290. */
  50291. microSurfaceTexture: BaseTexture;
  50292. /**
  50293. * Stores surface normal data used to displace a mesh in a texture.
  50294. */
  50295. bumpTexture: BaseTexture;
  50296. /**
  50297. * Stores the pre-calculated light information of a mesh in a texture.
  50298. */
  50299. lightmapTexture: BaseTexture;
  50300. /**
  50301. * Stores the refracted light information in a texture.
  50302. */
  50303. refractionTexture: Nullable<BaseTexture>;
  50304. /**
  50305. * The color of a material in ambient lighting.
  50306. */
  50307. ambientColor: Color3;
  50308. /**
  50309. * AKA Diffuse Color in other nomenclature.
  50310. */
  50311. albedoColor: Color3;
  50312. /**
  50313. * AKA Specular Color in other nomenclature.
  50314. */
  50315. reflectivityColor: Color3;
  50316. /**
  50317. * The color reflected from the material.
  50318. */
  50319. reflectionColor: Color3;
  50320. /**
  50321. * The color emitted from the material.
  50322. */
  50323. emissiveColor: Color3;
  50324. /**
  50325. * AKA Glossiness in other nomenclature.
  50326. */
  50327. microSurface: number;
  50328. /**
  50329. * source material index of refraction (IOR)' / 'destination material IOR.
  50330. */
  50331. indexOfRefraction: number;
  50332. /**
  50333. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50334. */
  50335. invertRefractionY: boolean;
  50336. /**
  50337. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50338. * Materials half opaque for instance using refraction could benefit from this control.
  50339. */
  50340. linkRefractionWithTransparency: boolean;
  50341. /**
  50342. * If true, the light map contains occlusion information instead of lighting info.
  50343. */
  50344. useLightmapAsShadowmap: boolean;
  50345. /**
  50346. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50347. */
  50348. useAlphaFromAlbedoTexture: boolean;
  50349. /**
  50350. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50351. */
  50352. forceAlphaTest: boolean;
  50353. /**
  50354. * Defines the alpha limits in alpha test mode.
  50355. */
  50356. alphaCutOff: number;
  50357. /**
  50358. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50359. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50360. */
  50361. useSpecularOverAlpha: boolean;
  50362. /**
  50363. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50364. */
  50365. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50366. /**
  50367. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50368. */
  50369. useRoughnessFromMetallicTextureAlpha: boolean;
  50370. /**
  50371. * Specifies if the metallic texture contains the roughness information in its green channel.
  50372. */
  50373. useRoughnessFromMetallicTextureGreen: boolean;
  50374. /**
  50375. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50376. */
  50377. useMetallnessFromMetallicTextureBlue: boolean;
  50378. /**
  50379. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50380. */
  50381. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50382. /**
  50383. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50384. */
  50385. useAmbientInGrayScale: boolean;
  50386. /**
  50387. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50388. * The material will try to infer what glossiness each pixel should be.
  50389. */
  50390. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50391. /**
  50392. * BJS is using an harcoded light falloff based on a manually sets up range.
  50393. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50394. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50395. */
  50396. /**
  50397. * BJS is using an harcoded light falloff based on a manually sets up range.
  50398. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50399. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50400. */
  50401. usePhysicalLightFalloff: boolean;
  50402. /**
  50403. * In order to support the falloff compatibility with gltf, a special mode has been added
  50404. * to reproduce the gltf light falloff.
  50405. */
  50406. /**
  50407. * In order to support the falloff compatibility with gltf, a special mode has been added
  50408. * to reproduce the gltf light falloff.
  50409. */
  50410. useGLTFLightFalloff: boolean;
  50411. /**
  50412. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50413. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50414. */
  50415. useRadianceOverAlpha: boolean;
  50416. /**
  50417. * Allows using an object space normal map (instead of tangent space).
  50418. */
  50419. useObjectSpaceNormalMap: boolean;
  50420. /**
  50421. * Allows using the bump map in parallax mode.
  50422. */
  50423. useParallax: boolean;
  50424. /**
  50425. * Allows using the bump map in parallax occlusion mode.
  50426. */
  50427. useParallaxOcclusion: boolean;
  50428. /**
  50429. * Controls the scale bias of the parallax mode.
  50430. */
  50431. parallaxScaleBias: number;
  50432. /**
  50433. * If sets to true, disables all the lights affecting the material.
  50434. */
  50435. disableLighting: boolean;
  50436. /**
  50437. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50438. */
  50439. forceIrradianceInFragment: boolean;
  50440. /**
  50441. * Number of Simultaneous lights allowed on the material.
  50442. */
  50443. maxSimultaneousLights: number;
  50444. /**
  50445. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50446. */
  50447. invertNormalMapX: boolean;
  50448. /**
  50449. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50450. */
  50451. invertNormalMapY: boolean;
  50452. /**
  50453. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50454. */
  50455. twoSidedLighting: boolean;
  50456. /**
  50457. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50458. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50459. */
  50460. useAlphaFresnel: boolean;
  50461. /**
  50462. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50463. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50464. */
  50465. useLinearAlphaFresnel: boolean;
  50466. /**
  50467. * Let user defines the brdf lookup texture used for IBL.
  50468. * A default 8bit version is embedded but you could point at :
  50469. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50470. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50471. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50472. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50473. */
  50474. environmentBRDFTexture: Nullable<BaseTexture>;
  50475. /**
  50476. * Force normal to face away from face.
  50477. */
  50478. forceNormalForward: boolean;
  50479. /**
  50480. * Enables specular anti aliasing in the PBR shader.
  50481. * It will both interacts on the Geometry for analytical and IBL lighting.
  50482. * It also prefilter the roughness map based on the bump values.
  50483. */
  50484. enableSpecularAntiAliasing: boolean;
  50485. /**
  50486. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50487. * makes the reflect vector face the model (under horizon).
  50488. */
  50489. useHorizonOcclusion: boolean;
  50490. /**
  50491. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50492. * too much the area relying on ambient texture to define their ambient occlusion.
  50493. */
  50494. useRadianceOcclusion: boolean;
  50495. /**
  50496. * If set to true, no lighting calculations will be applied.
  50497. */
  50498. unlit: boolean;
  50499. /**
  50500. * Gets the image processing configuration used either in this material.
  50501. */
  50502. /**
  50503. * Sets the Default image processing configuration used either in the this material.
  50504. *
  50505. * If sets to null, the scene one is in use.
  50506. */
  50507. imageProcessingConfiguration: ImageProcessingConfiguration;
  50508. /**
  50509. * Gets wether the color curves effect is enabled.
  50510. */
  50511. /**
  50512. * Sets wether the color curves effect is enabled.
  50513. */
  50514. cameraColorCurvesEnabled: boolean;
  50515. /**
  50516. * Gets wether the color grading effect is enabled.
  50517. */
  50518. /**
  50519. * Gets wether the color grading effect is enabled.
  50520. */
  50521. cameraColorGradingEnabled: boolean;
  50522. /**
  50523. * Gets wether tonemapping is enabled or not.
  50524. */
  50525. /**
  50526. * Sets wether tonemapping is enabled or not
  50527. */
  50528. cameraToneMappingEnabled: boolean;
  50529. /**
  50530. * The camera exposure used on this material.
  50531. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50532. * This corresponds to a photographic exposure.
  50533. */
  50534. /**
  50535. * The camera exposure used on this material.
  50536. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50537. * This corresponds to a photographic exposure.
  50538. */
  50539. cameraExposure: number;
  50540. /**
  50541. * Gets The camera contrast used on this material.
  50542. */
  50543. /**
  50544. * Sets The camera contrast used on this material.
  50545. */
  50546. cameraContrast: number;
  50547. /**
  50548. * Gets the Color Grading 2D Lookup Texture.
  50549. */
  50550. /**
  50551. * Sets the Color Grading 2D Lookup Texture.
  50552. */
  50553. cameraColorGradingTexture: Nullable<BaseTexture>;
  50554. /**
  50555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50557. * 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;
  50558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50559. */
  50560. /**
  50561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50563. * 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;
  50564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50565. */
  50566. cameraColorCurves: Nullable<ColorCurves>;
  50567. /**
  50568. * Instantiates a new PBRMaterial instance.
  50569. *
  50570. * @param name The material name
  50571. * @param scene The scene the material will be use in.
  50572. */
  50573. constructor(name: string, scene: Scene);
  50574. /**
  50575. * Returns the name of this material class.
  50576. */
  50577. getClassName(): string;
  50578. /**
  50579. * Makes a duplicate of the current material.
  50580. * @param name - name to use for the new material.
  50581. */
  50582. clone(name: string): PBRMaterial;
  50583. /**
  50584. * Serializes this PBR Material.
  50585. * @returns - An object with the serialized material.
  50586. */
  50587. serialize(): any;
  50588. /**
  50589. * Parses a PBR Material from a serialized object.
  50590. * @param source - Serialized object.
  50591. * @param scene - BJS scene instance.
  50592. * @param rootUrl - url for the scene object
  50593. * @returns - PBRMaterial
  50594. */
  50595. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50596. }
  50597. }
  50598. declare module "babylonjs/Misc/dds" {
  50599. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50601. import { Nullable } from "babylonjs/types";
  50602. import { Scene } from "babylonjs/scene";
  50603. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50604. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50605. /**
  50606. * Direct draw surface info
  50607. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50608. */
  50609. export interface DDSInfo {
  50610. /**
  50611. * Width of the texture
  50612. */
  50613. width: number;
  50614. /**
  50615. * Width of the texture
  50616. */
  50617. height: number;
  50618. /**
  50619. * Number of Mipmaps for the texture
  50620. * @see https://en.wikipedia.org/wiki/Mipmap
  50621. */
  50622. mipmapCount: number;
  50623. /**
  50624. * If the textures format is a known fourCC format
  50625. * @see https://www.fourcc.org/
  50626. */
  50627. isFourCC: boolean;
  50628. /**
  50629. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50630. */
  50631. isRGB: boolean;
  50632. /**
  50633. * If the texture is a lumincance format
  50634. */
  50635. isLuminance: boolean;
  50636. /**
  50637. * If this is a cube texture
  50638. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50639. */
  50640. isCube: boolean;
  50641. /**
  50642. * If the texture is a compressed format eg. FOURCC_DXT1
  50643. */
  50644. isCompressed: boolean;
  50645. /**
  50646. * The dxgiFormat of the texture
  50647. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50648. */
  50649. dxgiFormat: number;
  50650. /**
  50651. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50652. */
  50653. textureType: number;
  50654. /**
  50655. * Sphericle polynomial created for the dds texture
  50656. */
  50657. sphericalPolynomial?: SphericalPolynomial;
  50658. }
  50659. /**
  50660. * Class used to provide DDS decompression tools
  50661. */
  50662. export class DDSTools {
  50663. /**
  50664. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50665. */
  50666. static StoreLODInAlphaChannel: boolean;
  50667. /**
  50668. * Gets DDS information from an array buffer
  50669. * @param arrayBuffer defines the array buffer to read data from
  50670. * @returns the DDS information
  50671. */
  50672. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50673. private static _FloatView;
  50674. private static _Int32View;
  50675. private static _ToHalfFloat;
  50676. private static _FromHalfFloat;
  50677. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50678. private static _GetHalfFloatRGBAArrayBuffer;
  50679. private static _GetFloatRGBAArrayBuffer;
  50680. private static _GetFloatAsUIntRGBAArrayBuffer;
  50681. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50682. private static _GetRGBAArrayBuffer;
  50683. private static _ExtractLongWordOrder;
  50684. private static _GetRGBArrayBuffer;
  50685. private static _GetLuminanceArrayBuffer;
  50686. /**
  50687. * Uploads DDS Levels to a Babylon Texture
  50688. * @hidden
  50689. */
  50690. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50691. }
  50692. module "babylonjs/Engines/thinEngine" {
  50693. interface ThinEngine {
  50694. /**
  50695. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50696. * @param rootUrl defines the url where the file to load is located
  50697. * @param scene defines the current scene
  50698. * @param lodScale defines scale to apply to the mip map selection
  50699. * @param lodOffset defines offset to apply to the mip map selection
  50700. * @param onLoad defines an optional callback raised when the texture is loaded
  50701. * @param onError defines an optional callback raised if there is an issue to load the texture
  50702. * @param format defines the format of the data
  50703. * @param forcedExtension defines the extension to use to pick the right loader
  50704. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50705. * @returns the cube texture as an InternalTexture
  50706. */
  50707. 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;
  50708. }
  50709. }
  50710. }
  50711. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50712. import { Nullable } from "babylonjs/types";
  50713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50714. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50715. /**
  50716. * Implementation of the DDS Texture Loader.
  50717. * @hidden
  50718. */
  50719. export class _DDSTextureLoader implements IInternalTextureLoader {
  50720. /**
  50721. * Defines wether the loader supports cascade loading the different faces.
  50722. */
  50723. readonly supportCascades: boolean;
  50724. /**
  50725. * This returns if the loader support the current file information.
  50726. * @param extension defines the file extension of the file being loaded
  50727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50728. * @param fallback defines the fallback internal texture if any
  50729. * @param isBase64 defines whether the texture is encoded as a base64
  50730. * @param isBuffer defines whether the texture data are stored as a buffer
  50731. * @returns true if the loader can load the specified file
  50732. */
  50733. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50734. /**
  50735. * Transform the url before loading if required.
  50736. * @param rootUrl the url of the texture
  50737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50738. * @returns the transformed texture
  50739. */
  50740. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50741. /**
  50742. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50743. * @param rootUrl the url of the texture
  50744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50745. * @returns the fallback texture
  50746. */
  50747. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50748. /**
  50749. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50750. * @param data contains the texture data
  50751. * @param texture defines the BabylonJS internal texture
  50752. * @param createPolynomials will be true if polynomials have been requested
  50753. * @param onLoad defines the callback to trigger once the texture is ready
  50754. * @param onError defines the callback to trigger in case of error
  50755. */
  50756. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50757. /**
  50758. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50759. * @param data contains the texture data
  50760. * @param texture defines the BabylonJS internal texture
  50761. * @param callback defines the method to call once ready to upload
  50762. */
  50763. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50764. }
  50765. }
  50766. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50767. import { Nullable } from "babylonjs/types";
  50768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50769. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50770. /**
  50771. * Implementation of the ENV Texture Loader.
  50772. * @hidden
  50773. */
  50774. export class _ENVTextureLoader implements IInternalTextureLoader {
  50775. /**
  50776. * Defines wether the loader supports cascade loading the different faces.
  50777. */
  50778. readonly supportCascades: boolean;
  50779. /**
  50780. * This returns if the loader support the current file information.
  50781. * @param extension defines the file extension of the file being loaded
  50782. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50783. * @param fallback defines the fallback internal texture if any
  50784. * @param isBase64 defines whether the texture is encoded as a base64
  50785. * @param isBuffer defines whether the texture data are stored as a buffer
  50786. * @returns true if the loader can load the specified file
  50787. */
  50788. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50789. /**
  50790. * Transform the url before loading if required.
  50791. * @param rootUrl the url of the texture
  50792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50793. * @returns the transformed texture
  50794. */
  50795. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50796. /**
  50797. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50798. * @param rootUrl the url of the texture
  50799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50800. * @returns the fallback texture
  50801. */
  50802. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50803. /**
  50804. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50805. * @param data contains the texture data
  50806. * @param texture defines the BabylonJS internal texture
  50807. * @param createPolynomials will be true if polynomials have been requested
  50808. * @param onLoad defines the callback to trigger once the texture is ready
  50809. * @param onError defines the callback to trigger in case of error
  50810. */
  50811. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50812. /**
  50813. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50814. * @param data contains the texture data
  50815. * @param texture defines the BabylonJS internal texture
  50816. * @param callback defines the method to call once ready to upload
  50817. */
  50818. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50819. }
  50820. }
  50821. declare module "babylonjs/Misc/khronosTextureContainer" {
  50822. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50823. /**
  50824. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50825. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50826. */
  50827. export class KhronosTextureContainer {
  50828. /** contents of the KTX container file */
  50829. arrayBuffer: any;
  50830. private static HEADER_LEN;
  50831. private static COMPRESSED_2D;
  50832. private static COMPRESSED_3D;
  50833. private static TEX_2D;
  50834. private static TEX_3D;
  50835. /**
  50836. * Gets the openGL type
  50837. */
  50838. glType: number;
  50839. /**
  50840. * Gets the openGL type size
  50841. */
  50842. glTypeSize: number;
  50843. /**
  50844. * Gets the openGL format
  50845. */
  50846. glFormat: number;
  50847. /**
  50848. * Gets the openGL internal format
  50849. */
  50850. glInternalFormat: number;
  50851. /**
  50852. * Gets the base internal format
  50853. */
  50854. glBaseInternalFormat: number;
  50855. /**
  50856. * Gets image width in pixel
  50857. */
  50858. pixelWidth: number;
  50859. /**
  50860. * Gets image height in pixel
  50861. */
  50862. pixelHeight: number;
  50863. /**
  50864. * Gets image depth in pixels
  50865. */
  50866. pixelDepth: number;
  50867. /**
  50868. * Gets the number of array elements
  50869. */
  50870. numberOfArrayElements: number;
  50871. /**
  50872. * Gets the number of faces
  50873. */
  50874. numberOfFaces: number;
  50875. /**
  50876. * Gets the number of mipmap levels
  50877. */
  50878. numberOfMipmapLevels: number;
  50879. /**
  50880. * Gets the bytes of key value data
  50881. */
  50882. bytesOfKeyValueData: number;
  50883. /**
  50884. * Gets the load type
  50885. */
  50886. loadType: number;
  50887. /**
  50888. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50889. */
  50890. isInvalid: boolean;
  50891. /**
  50892. * Creates a new KhronosTextureContainer
  50893. * @param arrayBuffer contents of the KTX container file
  50894. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50895. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50896. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50897. */
  50898. constructor(
  50899. /** contents of the KTX container file */
  50900. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50901. /**
  50902. * Uploads KTX content to a Babylon Texture.
  50903. * It is assumed that the texture has already been created & is currently bound
  50904. * @hidden
  50905. */
  50906. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50907. private _upload2DCompressedLevels;
  50908. }
  50909. }
  50910. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50911. import { Nullable } from "babylonjs/types";
  50912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50913. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50914. /**
  50915. * Implementation of the KTX Texture Loader.
  50916. * @hidden
  50917. */
  50918. export class _KTXTextureLoader implements IInternalTextureLoader {
  50919. /**
  50920. * Defines wether the loader supports cascade loading the different faces.
  50921. */
  50922. readonly supportCascades: boolean;
  50923. /**
  50924. * This returns if the loader support the current file information.
  50925. * @param extension defines the file extension of the file being loaded
  50926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50927. * @param fallback defines the fallback internal texture if any
  50928. * @param isBase64 defines whether the texture is encoded as a base64
  50929. * @param isBuffer defines whether the texture data are stored as a buffer
  50930. * @returns true if the loader can load the specified file
  50931. */
  50932. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50933. /**
  50934. * Transform the url before loading if required.
  50935. * @param rootUrl the url of the texture
  50936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50937. * @returns the transformed texture
  50938. */
  50939. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50940. /**
  50941. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50942. * @param rootUrl the url of the texture
  50943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50944. * @returns the fallback texture
  50945. */
  50946. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50947. /**
  50948. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50949. * @param data contains the texture data
  50950. * @param texture defines the BabylonJS internal texture
  50951. * @param createPolynomials will be true if polynomials have been requested
  50952. * @param onLoad defines the callback to trigger once the texture is ready
  50953. * @param onError defines the callback to trigger in case of error
  50954. */
  50955. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50956. /**
  50957. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50958. * @param data contains the texture data
  50959. * @param texture defines the BabylonJS internal texture
  50960. * @param callback defines the method to call once ready to upload
  50961. */
  50962. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50963. }
  50964. }
  50965. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50966. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50967. import { Scene } from "babylonjs/scene";
  50968. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50969. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50970. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50971. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50972. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50973. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50975. /**
  50976. * Options for the default xr helper
  50977. */
  50978. export class WebXRDefaultExperienceOptions {
  50979. /**
  50980. * Floor meshes that should be used for teleporting
  50981. */
  50982. floorMeshes: Array<AbstractMesh>;
  50983. }
  50984. /**
  50985. * Default experience which provides a similar setup to the previous webVRExperience
  50986. */
  50987. export class WebXRDefaultExperience {
  50988. /**
  50989. * Base experience
  50990. */
  50991. baseExperience: WebXRExperienceHelper;
  50992. /**
  50993. * Input experience extension
  50994. */
  50995. input: WebXRInput;
  50996. /**
  50997. * Loads the controller models
  50998. */
  50999. controllerModelLoader: WebXRControllerModelLoader;
  51000. /**
  51001. * Enables laser pointer and selection
  51002. */
  51003. pointerSelection: WebXRControllerPointerSelection;
  51004. /**
  51005. * Enables teleportation
  51006. */
  51007. teleportation: WebXRControllerTeleportation;
  51008. /**
  51009. * Enables ui for enetering/exiting xr
  51010. */
  51011. enterExitUI: WebXREnterExitUI;
  51012. /**
  51013. * Default output canvas xr should render to
  51014. */
  51015. outputCanvas: WebXRManagedOutputCanvas;
  51016. /**
  51017. * Creates the default xr experience
  51018. * @param scene scene
  51019. * @param options options for basic configuration
  51020. * @returns resulting WebXRDefaultExperience
  51021. */
  51022. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51023. private constructor();
  51024. /**
  51025. * DIsposes of the experience helper
  51026. */
  51027. dispose(): void;
  51028. }
  51029. }
  51030. declare module "babylonjs/Helpers/sceneHelpers" {
  51031. import { Nullable } from "babylonjs/types";
  51032. import { Mesh } from "babylonjs/Meshes/mesh";
  51033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51034. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51035. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51036. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51037. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51038. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51039. import "babylonjs/Meshes/Builders/boxBuilder";
  51040. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51041. /** @hidden */
  51042. export var _forceSceneHelpersToBundle: boolean;
  51043. module "babylonjs/scene" {
  51044. interface Scene {
  51045. /**
  51046. * Creates a default light for the scene.
  51047. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51048. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51049. */
  51050. createDefaultLight(replace?: boolean): void;
  51051. /**
  51052. * Creates a default camera for the scene.
  51053. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51054. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51055. * @param replace has default false, when true replaces the active camera in the scene
  51056. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51057. */
  51058. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51059. /**
  51060. * Creates a default camera and a default light.
  51061. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51062. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51063. * @param replace has the default false, when true replaces the active camera/light in the scene
  51064. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51065. */
  51066. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51067. /**
  51068. * Creates a new sky box
  51069. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51070. * @param environmentTexture defines the texture to use as environment texture
  51071. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51072. * @param scale defines the overall scale of the skybox
  51073. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51074. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51075. * @returns a new mesh holding the sky box
  51076. */
  51077. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51078. /**
  51079. * Creates a new environment
  51080. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51081. * @param options defines the options you can use to configure the environment
  51082. * @returns the new EnvironmentHelper
  51083. */
  51084. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51085. /**
  51086. * Creates a new VREXperienceHelper
  51087. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51088. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51089. * @returns a new VREXperienceHelper
  51090. */
  51091. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51092. /**
  51093. * Creates a new WebXRDefaultExperience
  51094. * @see http://doc.babylonjs.com/how_to/webxr
  51095. * @param options experience options
  51096. * @returns a promise for a new WebXRDefaultExperience
  51097. */
  51098. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51099. }
  51100. }
  51101. }
  51102. declare module "babylonjs/Helpers/videoDome" {
  51103. import { Scene } from "babylonjs/scene";
  51104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51105. import { Mesh } from "babylonjs/Meshes/mesh";
  51106. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51107. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51108. import "babylonjs/Meshes/Builders/sphereBuilder";
  51109. /**
  51110. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51111. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51112. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51113. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51114. */
  51115. export class VideoDome extends TransformNode {
  51116. /**
  51117. * Define the video source as a Monoscopic panoramic 360 video.
  51118. */
  51119. static readonly MODE_MONOSCOPIC: number;
  51120. /**
  51121. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51122. */
  51123. static readonly MODE_TOPBOTTOM: number;
  51124. /**
  51125. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51126. */
  51127. static readonly MODE_SIDEBYSIDE: number;
  51128. private _halfDome;
  51129. private _useDirectMapping;
  51130. /**
  51131. * The video texture being displayed on the sphere
  51132. */
  51133. protected _videoTexture: VideoTexture;
  51134. /**
  51135. * Gets the video texture being displayed on the sphere
  51136. */
  51137. readonly videoTexture: VideoTexture;
  51138. /**
  51139. * The skybox material
  51140. */
  51141. protected _material: BackgroundMaterial;
  51142. /**
  51143. * The surface used for the skybox
  51144. */
  51145. protected _mesh: Mesh;
  51146. /**
  51147. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51148. */
  51149. private _halfDomeMask;
  51150. /**
  51151. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51152. * Also see the options.resolution property.
  51153. */
  51154. fovMultiplier: number;
  51155. private _videoMode;
  51156. /**
  51157. * Gets or set the current video mode for the video. It can be:
  51158. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51159. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51160. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51161. */
  51162. videoMode: number;
  51163. /**
  51164. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51165. *
  51166. */
  51167. /**
  51168. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51169. */
  51170. halfDome: boolean;
  51171. /**
  51172. * Oberserver used in Stereoscopic VR Mode.
  51173. */
  51174. private _onBeforeCameraRenderObserver;
  51175. /**
  51176. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51177. * @param name Element's name, child elements will append suffixes for their own names.
  51178. * @param urlsOrVideo defines the url(s) or the video element to use
  51179. * @param options An object containing optional or exposed sub element properties
  51180. */
  51181. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51182. resolution?: number;
  51183. clickToPlay?: boolean;
  51184. autoPlay?: boolean;
  51185. loop?: boolean;
  51186. size?: number;
  51187. poster?: string;
  51188. faceForward?: boolean;
  51189. useDirectMapping?: boolean;
  51190. halfDomeMode?: boolean;
  51191. }, scene: Scene);
  51192. private _changeVideoMode;
  51193. /**
  51194. * Releases resources associated with this node.
  51195. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51196. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51197. */
  51198. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51199. }
  51200. }
  51201. declare module "babylonjs/Helpers/index" {
  51202. export * from "babylonjs/Helpers/environmentHelper";
  51203. export * from "babylonjs/Helpers/photoDome";
  51204. export * from "babylonjs/Helpers/sceneHelpers";
  51205. export * from "babylonjs/Helpers/videoDome";
  51206. }
  51207. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51208. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51209. import { IDisposable } from "babylonjs/scene";
  51210. import { Engine } from "babylonjs/Engines/engine";
  51211. /**
  51212. * This class can be used to get instrumentation data from a Babylon engine
  51213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51214. */
  51215. export class EngineInstrumentation implements IDisposable {
  51216. /**
  51217. * Define the instrumented engine.
  51218. */
  51219. engine: Engine;
  51220. private _captureGPUFrameTime;
  51221. private _gpuFrameTimeToken;
  51222. private _gpuFrameTime;
  51223. private _captureShaderCompilationTime;
  51224. private _shaderCompilationTime;
  51225. private _onBeginFrameObserver;
  51226. private _onEndFrameObserver;
  51227. private _onBeforeShaderCompilationObserver;
  51228. private _onAfterShaderCompilationObserver;
  51229. /**
  51230. * Gets the perf counter used for GPU frame time
  51231. */
  51232. readonly gpuFrameTimeCounter: PerfCounter;
  51233. /**
  51234. * Gets the GPU frame time capture status
  51235. */
  51236. /**
  51237. * Enable or disable the GPU frame time capture
  51238. */
  51239. captureGPUFrameTime: boolean;
  51240. /**
  51241. * Gets the perf counter used for shader compilation time
  51242. */
  51243. readonly shaderCompilationTimeCounter: PerfCounter;
  51244. /**
  51245. * Gets the shader compilation time capture status
  51246. */
  51247. /**
  51248. * Enable or disable the shader compilation time capture
  51249. */
  51250. captureShaderCompilationTime: boolean;
  51251. /**
  51252. * Instantiates a new engine instrumentation.
  51253. * This class can be used to get instrumentation data from a Babylon engine
  51254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51255. * @param engine Defines the engine to instrument
  51256. */
  51257. constructor(
  51258. /**
  51259. * Define the instrumented engine.
  51260. */
  51261. engine: Engine);
  51262. /**
  51263. * Dispose and release associated resources.
  51264. */
  51265. dispose(): void;
  51266. }
  51267. }
  51268. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51269. import { Scene, IDisposable } from "babylonjs/scene";
  51270. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51271. /**
  51272. * This class can be used to get instrumentation data from a Babylon engine
  51273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51274. */
  51275. export class SceneInstrumentation implements IDisposable {
  51276. /**
  51277. * Defines the scene to instrument
  51278. */
  51279. scene: Scene;
  51280. private _captureActiveMeshesEvaluationTime;
  51281. private _activeMeshesEvaluationTime;
  51282. private _captureRenderTargetsRenderTime;
  51283. private _renderTargetsRenderTime;
  51284. private _captureFrameTime;
  51285. private _frameTime;
  51286. private _captureRenderTime;
  51287. private _renderTime;
  51288. private _captureInterFrameTime;
  51289. private _interFrameTime;
  51290. private _captureParticlesRenderTime;
  51291. private _particlesRenderTime;
  51292. private _captureSpritesRenderTime;
  51293. private _spritesRenderTime;
  51294. private _capturePhysicsTime;
  51295. private _physicsTime;
  51296. private _captureAnimationsTime;
  51297. private _animationsTime;
  51298. private _captureCameraRenderTime;
  51299. private _cameraRenderTime;
  51300. private _onBeforeActiveMeshesEvaluationObserver;
  51301. private _onAfterActiveMeshesEvaluationObserver;
  51302. private _onBeforeRenderTargetsRenderObserver;
  51303. private _onAfterRenderTargetsRenderObserver;
  51304. private _onAfterRenderObserver;
  51305. private _onBeforeDrawPhaseObserver;
  51306. private _onAfterDrawPhaseObserver;
  51307. private _onBeforeAnimationsObserver;
  51308. private _onBeforeParticlesRenderingObserver;
  51309. private _onAfterParticlesRenderingObserver;
  51310. private _onBeforeSpritesRenderingObserver;
  51311. private _onAfterSpritesRenderingObserver;
  51312. private _onBeforePhysicsObserver;
  51313. private _onAfterPhysicsObserver;
  51314. private _onAfterAnimationsObserver;
  51315. private _onBeforeCameraRenderObserver;
  51316. private _onAfterCameraRenderObserver;
  51317. /**
  51318. * Gets the perf counter used for active meshes evaluation time
  51319. */
  51320. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51321. /**
  51322. * Gets the active meshes evaluation time capture status
  51323. */
  51324. /**
  51325. * Enable or disable the active meshes evaluation time capture
  51326. */
  51327. captureActiveMeshesEvaluationTime: boolean;
  51328. /**
  51329. * Gets the perf counter used for render targets render time
  51330. */
  51331. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51332. /**
  51333. * Gets the render targets render time capture status
  51334. */
  51335. /**
  51336. * Enable or disable the render targets render time capture
  51337. */
  51338. captureRenderTargetsRenderTime: boolean;
  51339. /**
  51340. * Gets the perf counter used for particles render time
  51341. */
  51342. readonly particlesRenderTimeCounter: PerfCounter;
  51343. /**
  51344. * Gets the particles render time capture status
  51345. */
  51346. /**
  51347. * Enable or disable the particles render time capture
  51348. */
  51349. captureParticlesRenderTime: boolean;
  51350. /**
  51351. * Gets the perf counter used for sprites render time
  51352. */
  51353. readonly spritesRenderTimeCounter: PerfCounter;
  51354. /**
  51355. * Gets the sprites render time capture status
  51356. */
  51357. /**
  51358. * Enable or disable the sprites render time capture
  51359. */
  51360. captureSpritesRenderTime: boolean;
  51361. /**
  51362. * Gets the perf counter used for physics time
  51363. */
  51364. readonly physicsTimeCounter: PerfCounter;
  51365. /**
  51366. * Gets the physics time capture status
  51367. */
  51368. /**
  51369. * Enable or disable the physics time capture
  51370. */
  51371. capturePhysicsTime: boolean;
  51372. /**
  51373. * Gets the perf counter used for animations time
  51374. */
  51375. readonly animationsTimeCounter: PerfCounter;
  51376. /**
  51377. * Gets the animations time capture status
  51378. */
  51379. /**
  51380. * Enable or disable the animations time capture
  51381. */
  51382. captureAnimationsTime: boolean;
  51383. /**
  51384. * Gets the perf counter used for frame time capture
  51385. */
  51386. readonly frameTimeCounter: PerfCounter;
  51387. /**
  51388. * Gets the frame time capture status
  51389. */
  51390. /**
  51391. * Enable or disable the frame time capture
  51392. */
  51393. captureFrameTime: boolean;
  51394. /**
  51395. * Gets the perf counter used for inter-frames time capture
  51396. */
  51397. readonly interFrameTimeCounter: PerfCounter;
  51398. /**
  51399. * Gets the inter-frames time capture status
  51400. */
  51401. /**
  51402. * Enable or disable the inter-frames time capture
  51403. */
  51404. captureInterFrameTime: boolean;
  51405. /**
  51406. * Gets the perf counter used for render time capture
  51407. */
  51408. readonly renderTimeCounter: PerfCounter;
  51409. /**
  51410. * Gets the render time capture status
  51411. */
  51412. /**
  51413. * Enable or disable the render time capture
  51414. */
  51415. captureRenderTime: boolean;
  51416. /**
  51417. * Gets the perf counter used for camera render time capture
  51418. */
  51419. readonly cameraRenderTimeCounter: PerfCounter;
  51420. /**
  51421. * Gets the camera render time capture status
  51422. */
  51423. /**
  51424. * Enable or disable the camera render time capture
  51425. */
  51426. captureCameraRenderTime: boolean;
  51427. /**
  51428. * Gets the perf counter used for draw calls
  51429. */
  51430. readonly drawCallsCounter: PerfCounter;
  51431. /**
  51432. * Instantiates a new scene instrumentation.
  51433. * This class can be used to get instrumentation data from a Babylon engine
  51434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51435. * @param scene Defines the scene to instrument
  51436. */
  51437. constructor(
  51438. /**
  51439. * Defines the scene to instrument
  51440. */
  51441. scene: Scene);
  51442. /**
  51443. * Dispose and release associated resources.
  51444. */
  51445. dispose(): void;
  51446. }
  51447. }
  51448. declare module "babylonjs/Instrumentation/index" {
  51449. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51450. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51451. export * from "babylonjs/Instrumentation/timeToken";
  51452. }
  51453. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51454. /** @hidden */
  51455. export var glowMapGenerationPixelShader: {
  51456. name: string;
  51457. shader: string;
  51458. };
  51459. }
  51460. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51461. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51468. /** @hidden */
  51469. export var glowMapGenerationVertexShader: {
  51470. name: string;
  51471. shader: string;
  51472. };
  51473. }
  51474. declare module "babylonjs/Layers/effectLayer" {
  51475. import { Observable } from "babylonjs/Misc/observable";
  51476. import { Nullable } from "babylonjs/types";
  51477. import { Camera } from "babylonjs/Cameras/camera";
  51478. import { Scene } from "babylonjs/scene";
  51479. import { ISize } from "babylonjs/Maths/math.size";
  51480. import { Color4 } from "babylonjs/Maths/math.color";
  51481. import { Engine } from "babylonjs/Engines/engine";
  51482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51484. import { Mesh } from "babylonjs/Meshes/mesh";
  51485. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51488. import { Effect } from "babylonjs/Materials/effect";
  51489. import { Material } from "babylonjs/Materials/material";
  51490. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51491. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51492. /**
  51493. * Effect layer options. This helps customizing the behaviour
  51494. * of the effect layer.
  51495. */
  51496. export interface IEffectLayerOptions {
  51497. /**
  51498. * Multiplication factor apply to the canvas size to compute the render target size
  51499. * used to generated the objects (the smaller the faster).
  51500. */
  51501. mainTextureRatio: number;
  51502. /**
  51503. * Enforces a fixed size texture to ensure effect stability across devices.
  51504. */
  51505. mainTextureFixedSize?: number;
  51506. /**
  51507. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51508. */
  51509. alphaBlendingMode: number;
  51510. /**
  51511. * The camera attached to the layer.
  51512. */
  51513. camera: Nullable<Camera>;
  51514. /**
  51515. * The rendering group to draw the layer in.
  51516. */
  51517. renderingGroupId: number;
  51518. }
  51519. /**
  51520. * The effect layer Helps adding post process effect blended with the main pass.
  51521. *
  51522. * This can be for instance use to generate glow or higlight effects on the scene.
  51523. *
  51524. * The effect layer class can not be used directly and is intented to inherited from to be
  51525. * customized per effects.
  51526. */
  51527. export abstract class EffectLayer {
  51528. private _vertexBuffers;
  51529. private _indexBuffer;
  51530. private _cachedDefines;
  51531. private _effectLayerMapGenerationEffect;
  51532. private _effectLayerOptions;
  51533. private _mergeEffect;
  51534. protected _scene: Scene;
  51535. protected _engine: Engine;
  51536. protected _maxSize: number;
  51537. protected _mainTextureDesiredSize: ISize;
  51538. protected _mainTexture: RenderTargetTexture;
  51539. protected _shouldRender: boolean;
  51540. protected _postProcesses: PostProcess[];
  51541. protected _textures: BaseTexture[];
  51542. protected _emissiveTextureAndColor: {
  51543. texture: Nullable<BaseTexture>;
  51544. color: Color4;
  51545. };
  51546. /**
  51547. * The name of the layer
  51548. */
  51549. name: string;
  51550. /**
  51551. * The clear color of the texture used to generate the glow map.
  51552. */
  51553. neutralColor: Color4;
  51554. /**
  51555. * Specifies wether the highlight layer is enabled or not.
  51556. */
  51557. isEnabled: boolean;
  51558. /**
  51559. * Gets the camera attached to the layer.
  51560. */
  51561. readonly camera: Nullable<Camera>;
  51562. /**
  51563. * Gets the rendering group id the layer should render in.
  51564. */
  51565. renderingGroupId: number;
  51566. /**
  51567. * An event triggered when the effect layer has been disposed.
  51568. */
  51569. onDisposeObservable: Observable<EffectLayer>;
  51570. /**
  51571. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51572. */
  51573. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51574. /**
  51575. * An event triggered when the generated texture is being merged in the scene.
  51576. */
  51577. onBeforeComposeObservable: Observable<EffectLayer>;
  51578. /**
  51579. * An event triggered when the generated texture has been merged in the scene.
  51580. */
  51581. onAfterComposeObservable: Observable<EffectLayer>;
  51582. /**
  51583. * An event triggered when the efffect layer changes its size.
  51584. */
  51585. onSizeChangedObservable: Observable<EffectLayer>;
  51586. /** @hidden */
  51587. static _SceneComponentInitialization: (scene: Scene) => void;
  51588. /**
  51589. * Instantiates a new effect Layer and references it in the scene.
  51590. * @param name The name of the layer
  51591. * @param scene The scene to use the layer in
  51592. */
  51593. constructor(
  51594. /** The Friendly of the effect in the scene */
  51595. name: string, scene: Scene);
  51596. /**
  51597. * Get the effect name of the layer.
  51598. * @return The effect name
  51599. */
  51600. abstract getEffectName(): string;
  51601. /**
  51602. * Checks for the readiness of the element composing the layer.
  51603. * @param subMesh the mesh to check for
  51604. * @param useInstances specify wether or not to use instances to render the mesh
  51605. * @return true if ready otherwise, false
  51606. */
  51607. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51608. /**
  51609. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51610. * @returns true if the effect requires stencil during the main canvas render pass.
  51611. */
  51612. abstract needStencil(): boolean;
  51613. /**
  51614. * Create the merge effect. This is the shader use to blit the information back
  51615. * to the main canvas at the end of the scene rendering.
  51616. * @returns The effect containing the shader used to merge the effect on the main canvas
  51617. */
  51618. protected abstract _createMergeEffect(): Effect;
  51619. /**
  51620. * Creates the render target textures and post processes used in the effect layer.
  51621. */
  51622. protected abstract _createTextureAndPostProcesses(): void;
  51623. /**
  51624. * Implementation specific of rendering the generating effect on the main canvas.
  51625. * @param effect The effect used to render through
  51626. */
  51627. protected abstract _internalRender(effect: Effect): void;
  51628. /**
  51629. * Sets the required values for both the emissive texture and and the main color.
  51630. */
  51631. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51632. /**
  51633. * Free any resources and references associated to a mesh.
  51634. * Internal use
  51635. * @param mesh The mesh to free.
  51636. */
  51637. abstract _disposeMesh(mesh: Mesh): void;
  51638. /**
  51639. * Serializes this layer (Glow or Highlight for example)
  51640. * @returns a serialized layer object
  51641. */
  51642. abstract serialize?(): any;
  51643. /**
  51644. * Initializes the effect layer with the required options.
  51645. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51646. */
  51647. protected _init(options: Partial<IEffectLayerOptions>): void;
  51648. /**
  51649. * Generates the index buffer of the full screen quad blending to the main canvas.
  51650. */
  51651. private _generateIndexBuffer;
  51652. /**
  51653. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51654. */
  51655. private _generateVertexBuffer;
  51656. /**
  51657. * Sets the main texture desired size which is the closest power of two
  51658. * of the engine canvas size.
  51659. */
  51660. private _setMainTextureSize;
  51661. /**
  51662. * Creates the main texture for the effect layer.
  51663. */
  51664. protected _createMainTexture(): void;
  51665. /**
  51666. * Adds specific effects defines.
  51667. * @param defines The defines to add specifics to.
  51668. */
  51669. protected _addCustomEffectDefines(defines: string[]): void;
  51670. /**
  51671. * Checks for the readiness of the element composing the layer.
  51672. * @param subMesh the mesh to check for
  51673. * @param useInstances specify wether or not to use instances to render the mesh
  51674. * @param emissiveTexture the associated emissive texture used to generate the glow
  51675. * @return true if ready otherwise, false
  51676. */
  51677. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51678. /**
  51679. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51680. */
  51681. render(): void;
  51682. /**
  51683. * Determine if a given mesh will be used in the current effect.
  51684. * @param mesh mesh to test
  51685. * @returns true if the mesh will be used
  51686. */
  51687. hasMesh(mesh: AbstractMesh): boolean;
  51688. /**
  51689. * Returns true if the layer contains information to display, otherwise false.
  51690. * @returns true if the glow layer should be rendered
  51691. */
  51692. shouldRender(): boolean;
  51693. /**
  51694. * Returns true if the mesh should render, otherwise false.
  51695. * @param mesh The mesh to render
  51696. * @returns true if it should render otherwise false
  51697. */
  51698. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51699. /**
  51700. * Returns true if the mesh can be rendered, otherwise false.
  51701. * @param mesh The mesh to render
  51702. * @param material The material used on the mesh
  51703. * @returns true if it can be rendered otherwise false
  51704. */
  51705. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51706. /**
  51707. * Returns true if the mesh should render, otherwise false.
  51708. * @param mesh The mesh to render
  51709. * @returns true if it should render otherwise false
  51710. */
  51711. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51712. /**
  51713. * Renders the submesh passed in parameter to the generation map.
  51714. */
  51715. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51716. /**
  51717. * Rebuild the required buffers.
  51718. * @hidden Internal use only.
  51719. */
  51720. _rebuild(): void;
  51721. /**
  51722. * Dispose only the render target textures and post process.
  51723. */
  51724. private _disposeTextureAndPostProcesses;
  51725. /**
  51726. * Dispose the highlight layer and free resources.
  51727. */
  51728. dispose(): void;
  51729. /**
  51730. * Gets the class name of the effect layer
  51731. * @returns the string with the class name of the effect layer
  51732. */
  51733. getClassName(): string;
  51734. /**
  51735. * Creates an effect layer from parsed effect layer data
  51736. * @param parsedEffectLayer defines effect layer data
  51737. * @param scene defines the current scene
  51738. * @param rootUrl defines the root URL containing the effect layer information
  51739. * @returns a parsed effect Layer
  51740. */
  51741. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51742. }
  51743. }
  51744. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51745. import { Scene } from "babylonjs/scene";
  51746. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51747. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51748. import { AbstractScene } from "babylonjs/abstractScene";
  51749. module "babylonjs/abstractScene" {
  51750. interface AbstractScene {
  51751. /**
  51752. * The list of effect layers (highlights/glow) added to the scene
  51753. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51754. * @see http://doc.babylonjs.com/how_to/glow_layer
  51755. */
  51756. effectLayers: Array<EffectLayer>;
  51757. /**
  51758. * Removes the given effect layer from this scene.
  51759. * @param toRemove defines the effect layer to remove
  51760. * @returns the index of the removed effect layer
  51761. */
  51762. removeEffectLayer(toRemove: EffectLayer): number;
  51763. /**
  51764. * Adds the given effect layer to this scene
  51765. * @param newEffectLayer defines the effect layer to add
  51766. */
  51767. addEffectLayer(newEffectLayer: EffectLayer): void;
  51768. }
  51769. }
  51770. /**
  51771. * Defines the layer scene component responsible to manage any effect layers
  51772. * in a given scene.
  51773. */
  51774. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51775. /**
  51776. * The component name helpfull to identify the component in the list of scene components.
  51777. */
  51778. readonly name: string;
  51779. /**
  51780. * The scene the component belongs to.
  51781. */
  51782. scene: Scene;
  51783. private _engine;
  51784. private _renderEffects;
  51785. private _needStencil;
  51786. private _previousStencilState;
  51787. /**
  51788. * Creates a new instance of the component for the given scene
  51789. * @param scene Defines the scene to register the component in
  51790. */
  51791. constructor(scene: Scene);
  51792. /**
  51793. * Registers the component in a given scene
  51794. */
  51795. register(): void;
  51796. /**
  51797. * Rebuilds the elements related to this component in case of
  51798. * context lost for instance.
  51799. */
  51800. rebuild(): void;
  51801. /**
  51802. * Serializes the component data to the specified json object
  51803. * @param serializationObject The object to serialize to
  51804. */
  51805. serialize(serializationObject: any): void;
  51806. /**
  51807. * Adds all the elements from the container to the scene
  51808. * @param container the container holding the elements
  51809. */
  51810. addFromContainer(container: AbstractScene): void;
  51811. /**
  51812. * Removes all the elements in the container from the scene
  51813. * @param container contains the elements to remove
  51814. * @param dispose if the removed element should be disposed (default: false)
  51815. */
  51816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51817. /**
  51818. * Disposes the component and the associated ressources.
  51819. */
  51820. dispose(): void;
  51821. private _isReadyForMesh;
  51822. private _renderMainTexture;
  51823. private _setStencil;
  51824. private _setStencilBack;
  51825. private _draw;
  51826. private _drawCamera;
  51827. private _drawRenderingGroup;
  51828. }
  51829. }
  51830. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51831. /** @hidden */
  51832. export var glowMapMergePixelShader: {
  51833. name: string;
  51834. shader: string;
  51835. };
  51836. }
  51837. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51838. /** @hidden */
  51839. export var glowMapMergeVertexShader: {
  51840. name: string;
  51841. shader: string;
  51842. };
  51843. }
  51844. declare module "babylonjs/Layers/glowLayer" {
  51845. import { Nullable } from "babylonjs/types";
  51846. import { Camera } from "babylonjs/Cameras/camera";
  51847. import { Scene } from "babylonjs/scene";
  51848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51850. import { Mesh } from "babylonjs/Meshes/mesh";
  51851. import { Texture } from "babylonjs/Materials/Textures/texture";
  51852. import { Effect } from "babylonjs/Materials/effect";
  51853. import { Material } from "babylonjs/Materials/material";
  51854. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51855. import { Color4 } from "babylonjs/Maths/math.color";
  51856. import "babylonjs/Shaders/glowMapMerge.fragment";
  51857. import "babylonjs/Shaders/glowMapMerge.vertex";
  51858. import "babylonjs/Layers/effectLayerSceneComponent";
  51859. module "babylonjs/abstractScene" {
  51860. interface AbstractScene {
  51861. /**
  51862. * Return a the first highlight layer of the scene with a given name.
  51863. * @param name The name of the highlight layer to look for.
  51864. * @return The highlight layer if found otherwise null.
  51865. */
  51866. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51867. }
  51868. }
  51869. /**
  51870. * Glow layer options. This helps customizing the behaviour
  51871. * of the glow layer.
  51872. */
  51873. export interface IGlowLayerOptions {
  51874. /**
  51875. * Multiplication factor apply to the canvas size to compute the render target size
  51876. * used to generated the glowing objects (the smaller the faster).
  51877. */
  51878. mainTextureRatio: number;
  51879. /**
  51880. * Enforces a fixed size texture to ensure resize independant blur.
  51881. */
  51882. mainTextureFixedSize?: number;
  51883. /**
  51884. * How big is the kernel of the blur texture.
  51885. */
  51886. blurKernelSize: number;
  51887. /**
  51888. * The camera attached to the layer.
  51889. */
  51890. camera: Nullable<Camera>;
  51891. /**
  51892. * Enable MSAA by chosing the number of samples.
  51893. */
  51894. mainTextureSamples?: number;
  51895. /**
  51896. * The rendering group to draw the layer in.
  51897. */
  51898. renderingGroupId: number;
  51899. }
  51900. /**
  51901. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51902. *
  51903. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51904. * glowy meshes to your scene.
  51905. *
  51906. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51907. */
  51908. export class GlowLayer extends EffectLayer {
  51909. /**
  51910. * Effect Name of the layer.
  51911. */
  51912. static readonly EffectName: string;
  51913. /**
  51914. * The default blur kernel size used for the glow.
  51915. */
  51916. static DefaultBlurKernelSize: number;
  51917. /**
  51918. * The default texture size ratio used for the glow.
  51919. */
  51920. static DefaultTextureRatio: number;
  51921. /**
  51922. * Sets the kernel size of the blur.
  51923. */
  51924. /**
  51925. * Gets the kernel size of the blur.
  51926. */
  51927. blurKernelSize: number;
  51928. /**
  51929. * Sets the glow intensity.
  51930. */
  51931. /**
  51932. * Gets the glow intensity.
  51933. */
  51934. intensity: number;
  51935. private _options;
  51936. private _intensity;
  51937. private _horizontalBlurPostprocess1;
  51938. private _verticalBlurPostprocess1;
  51939. private _horizontalBlurPostprocess2;
  51940. private _verticalBlurPostprocess2;
  51941. private _blurTexture1;
  51942. private _blurTexture2;
  51943. private _postProcesses1;
  51944. private _postProcesses2;
  51945. private _includedOnlyMeshes;
  51946. private _excludedMeshes;
  51947. /**
  51948. * Callback used to let the user override the color selection on a per mesh basis
  51949. */
  51950. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51951. /**
  51952. * Callback used to let the user override the texture selection on a per mesh basis
  51953. */
  51954. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51955. /**
  51956. * Instantiates a new glow Layer and references it to the scene.
  51957. * @param name The name of the layer
  51958. * @param scene The scene to use the layer in
  51959. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51960. */
  51961. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51962. /**
  51963. * Get the effect name of the layer.
  51964. * @return The effect name
  51965. */
  51966. getEffectName(): string;
  51967. /**
  51968. * Create the merge effect. This is the shader use to blit the information back
  51969. * to the main canvas at the end of the scene rendering.
  51970. */
  51971. protected _createMergeEffect(): Effect;
  51972. /**
  51973. * Creates the render target textures and post processes used in the glow layer.
  51974. */
  51975. protected _createTextureAndPostProcesses(): void;
  51976. /**
  51977. * Checks for the readiness of the element composing the layer.
  51978. * @param subMesh the mesh to check for
  51979. * @param useInstances specify wether or not to use instances to render the mesh
  51980. * @param emissiveTexture the associated emissive texture used to generate the glow
  51981. * @return true if ready otherwise, false
  51982. */
  51983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51984. /**
  51985. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51986. */
  51987. needStencil(): boolean;
  51988. /**
  51989. * Returns true if the mesh can be rendered, otherwise false.
  51990. * @param mesh The mesh to render
  51991. * @param material The material used on the mesh
  51992. * @returns true if it can be rendered otherwise false
  51993. */
  51994. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51995. /**
  51996. * Implementation specific of rendering the generating effect on the main canvas.
  51997. * @param effect The effect used to render through
  51998. */
  51999. protected _internalRender(effect: Effect): void;
  52000. /**
  52001. * Sets the required values for both the emissive texture and and the main color.
  52002. */
  52003. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52004. /**
  52005. * Returns true if the mesh should render, otherwise false.
  52006. * @param mesh The mesh to render
  52007. * @returns true if it should render otherwise false
  52008. */
  52009. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52010. /**
  52011. * Adds specific effects defines.
  52012. * @param defines The defines to add specifics to.
  52013. */
  52014. protected _addCustomEffectDefines(defines: string[]): void;
  52015. /**
  52016. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52017. * @param mesh The mesh to exclude from the glow layer
  52018. */
  52019. addExcludedMesh(mesh: Mesh): void;
  52020. /**
  52021. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52022. * @param mesh The mesh to remove
  52023. */
  52024. removeExcludedMesh(mesh: Mesh): void;
  52025. /**
  52026. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52027. * @param mesh The mesh to include in the glow layer
  52028. */
  52029. addIncludedOnlyMesh(mesh: Mesh): void;
  52030. /**
  52031. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52032. * @param mesh The mesh to remove
  52033. */
  52034. removeIncludedOnlyMesh(mesh: Mesh): void;
  52035. /**
  52036. * Determine if a given mesh will be used in the glow layer
  52037. * @param mesh The mesh to test
  52038. * @returns true if the mesh will be highlighted by the current glow layer
  52039. */
  52040. hasMesh(mesh: AbstractMesh): boolean;
  52041. /**
  52042. * Free any resources and references associated to a mesh.
  52043. * Internal use
  52044. * @param mesh The mesh to free.
  52045. * @hidden
  52046. */
  52047. _disposeMesh(mesh: Mesh): void;
  52048. /**
  52049. * Gets the class name of the effect layer
  52050. * @returns the string with the class name of the effect layer
  52051. */
  52052. getClassName(): string;
  52053. /**
  52054. * Serializes this glow layer
  52055. * @returns a serialized glow layer object
  52056. */
  52057. serialize(): any;
  52058. /**
  52059. * Creates a Glow Layer from parsed glow layer data
  52060. * @param parsedGlowLayer defines glow layer data
  52061. * @param scene defines the current scene
  52062. * @param rootUrl defines the root URL containing the glow layer information
  52063. * @returns a parsed Glow Layer
  52064. */
  52065. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52066. }
  52067. }
  52068. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52069. /** @hidden */
  52070. export var glowBlurPostProcessPixelShader: {
  52071. name: string;
  52072. shader: string;
  52073. };
  52074. }
  52075. declare module "babylonjs/Layers/highlightLayer" {
  52076. import { Observable } from "babylonjs/Misc/observable";
  52077. import { Nullable } from "babylonjs/types";
  52078. import { Camera } from "babylonjs/Cameras/camera";
  52079. import { Scene } from "babylonjs/scene";
  52080. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52082. import { Mesh } from "babylonjs/Meshes/mesh";
  52083. import { Effect } from "babylonjs/Materials/effect";
  52084. import { Material } from "babylonjs/Materials/material";
  52085. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52086. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52087. import "babylonjs/Shaders/glowMapMerge.fragment";
  52088. import "babylonjs/Shaders/glowMapMerge.vertex";
  52089. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52090. module "babylonjs/abstractScene" {
  52091. interface AbstractScene {
  52092. /**
  52093. * Return a the first highlight layer of the scene with a given name.
  52094. * @param name The name of the highlight layer to look for.
  52095. * @return The highlight layer if found otherwise null.
  52096. */
  52097. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52098. }
  52099. }
  52100. /**
  52101. * Highlight layer options. This helps customizing the behaviour
  52102. * of the highlight layer.
  52103. */
  52104. export interface IHighlightLayerOptions {
  52105. /**
  52106. * Multiplication factor apply to the canvas size to compute the render target size
  52107. * used to generated the glowing objects (the smaller the faster).
  52108. */
  52109. mainTextureRatio: number;
  52110. /**
  52111. * Enforces a fixed size texture to ensure resize independant blur.
  52112. */
  52113. mainTextureFixedSize?: number;
  52114. /**
  52115. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52116. * of the picture to blur (the smaller the faster).
  52117. */
  52118. blurTextureSizeRatio: number;
  52119. /**
  52120. * How big in texel of the blur texture is the vertical blur.
  52121. */
  52122. blurVerticalSize: number;
  52123. /**
  52124. * How big in texel of the blur texture is the horizontal blur.
  52125. */
  52126. blurHorizontalSize: number;
  52127. /**
  52128. * Alpha blending mode used to apply the blur. Default is combine.
  52129. */
  52130. alphaBlendingMode: number;
  52131. /**
  52132. * The camera attached to the layer.
  52133. */
  52134. camera: Nullable<Camera>;
  52135. /**
  52136. * Should we display highlight as a solid stroke?
  52137. */
  52138. isStroke?: boolean;
  52139. /**
  52140. * The rendering group to draw the layer in.
  52141. */
  52142. renderingGroupId: number;
  52143. }
  52144. /**
  52145. * The highlight layer Helps adding a glow effect around a mesh.
  52146. *
  52147. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52148. * glowy meshes to your scene.
  52149. *
  52150. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52151. */
  52152. export class HighlightLayer extends EffectLayer {
  52153. name: string;
  52154. /**
  52155. * Effect Name of the highlight layer.
  52156. */
  52157. static readonly EffectName: string;
  52158. /**
  52159. * The neutral color used during the preparation of the glow effect.
  52160. * This is black by default as the blend operation is a blend operation.
  52161. */
  52162. static NeutralColor: Color4;
  52163. /**
  52164. * Stencil value used for glowing meshes.
  52165. */
  52166. static GlowingMeshStencilReference: number;
  52167. /**
  52168. * Stencil value used for the other meshes in the scene.
  52169. */
  52170. static NormalMeshStencilReference: number;
  52171. /**
  52172. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52173. */
  52174. innerGlow: boolean;
  52175. /**
  52176. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52177. */
  52178. outerGlow: boolean;
  52179. /**
  52180. * Specifies the horizontal size of the blur.
  52181. */
  52182. /**
  52183. * Gets the horizontal size of the blur.
  52184. */
  52185. blurHorizontalSize: number;
  52186. /**
  52187. * Specifies the vertical size of the blur.
  52188. */
  52189. /**
  52190. * Gets the vertical size of the blur.
  52191. */
  52192. blurVerticalSize: number;
  52193. /**
  52194. * An event triggered when the highlight layer is being blurred.
  52195. */
  52196. onBeforeBlurObservable: Observable<HighlightLayer>;
  52197. /**
  52198. * An event triggered when the highlight layer has been blurred.
  52199. */
  52200. onAfterBlurObservable: Observable<HighlightLayer>;
  52201. private _instanceGlowingMeshStencilReference;
  52202. private _options;
  52203. private _downSamplePostprocess;
  52204. private _horizontalBlurPostprocess;
  52205. private _verticalBlurPostprocess;
  52206. private _blurTexture;
  52207. private _meshes;
  52208. private _excludedMeshes;
  52209. /**
  52210. * Instantiates a new highlight Layer and references it to the scene..
  52211. * @param name The name of the layer
  52212. * @param scene The scene to use the layer in
  52213. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52214. */
  52215. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52216. /**
  52217. * Get the effect name of the layer.
  52218. * @return The effect name
  52219. */
  52220. getEffectName(): string;
  52221. /**
  52222. * Create the merge effect. This is the shader use to blit the information back
  52223. * to the main canvas at the end of the scene rendering.
  52224. */
  52225. protected _createMergeEffect(): Effect;
  52226. /**
  52227. * Creates the render target textures and post processes used in the highlight layer.
  52228. */
  52229. protected _createTextureAndPostProcesses(): void;
  52230. /**
  52231. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52232. */
  52233. needStencil(): boolean;
  52234. /**
  52235. * Checks for the readiness of the element composing the layer.
  52236. * @param subMesh the mesh to check for
  52237. * @param useInstances specify wether or not to use instances to render the mesh
  52238. * @param emissiveTexture the associated emissive texture used to generate the glow
  52239. * @return true if ready otherwise, false
  52240. */
  52241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52242. /**
  52243. * Implementation specific of rendering the generating effect on the main canvas.
  52244. * @param effect The effect used to render through
  52245. */
  52246. protected _internalRender(effect: Effect): void;
  52247. /**
  52248. * Returns true if the layer contains information to display, otherwise false.
  52249. */
  52250. shouldRender(): boolean;
  52251. /**
  52252. * Returns true if the mesh should render, otherwise false.
  52253. * @param mesh The mesh to render
  52254. * @returns true if it should render otherwise false
  52255. */
  52256. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52257. /**
  52258. * Sets the required values for both the emissive texture and and the main color.
  52259. */
  52260. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52261. /**
  52262. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52263. * @param mesh The mesh to exclude from the highlight layer
  52264. */
  52265. addExcludedMesh(mesh: Mesh): void;
  52266. /**
  52267. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52268. * @param mesh The mesh to highlight
  52269. */
  52270. removeExcludedMesh(mesh: Mesh): void;
  52271. /**
  52272. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52273. * @param mesh mesh to test
  52274. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52275. */
  52276. hasMesh(mesh: AbstractMesh): boolean;
  52277. /**
  52278. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52279. * @param mesh The mesh to highlight
  52280. * @param color The color of the highlight
  52281. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52282. */
  52283. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52284. /**
  52285. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52286. * @param mesh The mesh to highlight
  52287. */
  52288. removeMesh(mesh: Mesh): void;
  52289. /**
  52290. * Force the stencil to the normal expected value for none glowing parts
  52291. */
  52292. private _defaultStencilReference;
  52293. /**
  52294. * Free any resources and references associated to a mesh.
  52295. * Internal use
  52296. * @param mesh The mesh to free.
  52297. * @hidden
  52298. */
  52299. _disposeMesh(mesh: Mesh): void;
  52300. /**
  52301. * Dispose the highlight layer and free resources.
  52302. */
  52303. dispose(): void;
  52304. /**
  52305. * Gets the class name of the effect layer
  52306. * @returns the string with the class name of the effect layer
  52307. */
  52308. getClassName(): string;
  52309. /**
  52310. * Serializes this Highlight layer
  52311. * @returns a serialized Highlight layer object
  52312. */
  52313. serialize(): any;
  52314. /**
  52315. * Creates a Highlight layer from parsed Highlight layer data
  52316. * @param parsedHightlightLayer defines the Highlight layer data
  52317. * @param scene defines the current scene
  52318. * @param rootUrl defines the root URL containing the Highlight layer information
  52319. * @returns a parsed Highlight layer
  52320. */
  52321. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52322. }
  52323. }
  52324. declare module "babylonjs/Layers/layerSceneComponent" {
  52325. import { Scene } from "babylonjs/scene";
  52326. import { ISceneComponent } from "babylonjs/sceneComponent";
  52327. import { Layer } from "babylonjs/Layers/layer";
  52328. import { AbstractScene } from "babylonjs/abstractScene";
  52329. module "babylonjs/abstractScene" {
  52330. interface AbstractScene {
  52331. /**
  52332. * The list of layers (background and foreground) of the scene
  52333. */
  52334. layers: Array<Layer>;
  52335. }
  52336. }
  52337. /**
  52338. * Defines the layer scene component responsible to manage any layers
  52339. * in a given scene.
  52340. */
  52341. export class LayerSceneComponent implements ISceneComponent {
  52342. /**
  52343. * The component name helpfull to identify the component in the list of scene components.
  52344. */
  52345. readonly name: string;
  52346. /**
  52347. * The scene the component belongs to.
  52348. */
  52349. scene: Scene;
  52350. private _engine;
  52351. /**
  52352. * Creates a new instance of the component for the given scene
  52353. * @param scene Defines the scene to register the component in
  52354. */
  52355. constructor(scene: Scene);
  52356. /**
  52357. * Registers the component in a given scene
  52358. */
  52359. register(): void;
  52360. /**
  52361. * Rebuilds the elements related to this component in case of
  52362. * context lost for instance.
  52363. */
  52364. rebuild(): void;
  52365. /**
  52366. * Disposes the component and the associated ressources.
  52367. */
  52368. dispose(): void;
  52369. private _draw;
  52370. private _drawCameraPredicate;
  52371. private _drawCameraBackground;
  52372. private _drawCameraForeground;
  52373. private _drawRenderTargetPredicate;
  52374. private _drawRenderTargetBackground;
  52375. private _drawRenderTargetForeground;
  52376. /**
  52377. * Adds all the elements from the container to the scene
  52378. * @param container the container holding the elements
  52379. */
  52380. addFromContainer(container: AbstractScene): void;
  52381. /**
  52382. * Removes all the elements in the container from the scene
  52383. * @param container contains the elements to remove
  52384. * @param dispose if the removed element should be disposed (default: false)
  52385. */
  52386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52387. }
  52388. }
  52389. declare module "babylonjs/Shaders/layer.fragment" {
  52390. /** @hidden */
  52391. export var layerPixelShader: {
  52392. name: string;
  52393. shader: string;
  52394. };
  52395. }
  52396. declare module "babylonjs/Shaders/layer.vertex" {
  52397. /** @hidden */
  52398. export var layerVertexShader: {
  52399. name: string;
  52400. shader: string;
  52401. };
  52402. }
  52403. declare module "babylonjs/Layers/layer" {
  52404. import { Observable } from "babylonjs/Misc/observable";
  52405. import { Nullable } from "babylonjs/types";
  52406. import { Scene } from "babylonjs/scene";
  52407. import { Vector2 } from "babylonjs/Maths/math.vector";
  52408. import { Color4 } from "babylonjs/Maths/math.color";
  52409. import { Texture } from "babylonjs/Materials/Textures/texture";
  52410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52411. import "babylonjs/Shaders/layer.fragment";
  52412. import "babylonjs/Shaders/layer.vertex";
  52413. /**
  52414. * This represents a full screen 2d layer.
  52415. * This can be useful to display a picture in the background of your scene for instance.
  52416. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52417. */
  52418. export class Layer {
  52419. /**
  52420. * Define the name of the layer.
  52421. */
  52422. name: string;
  52423. /**
  52424. * Define the texture the layer should display.
  52425. */
  52426. texture: Nullable<Texture>;
  52427. /**
  52428. * Is the layer in background or foreground.
  52429. */
  52430. isBackground: boolean;
  52431. /**
  52432. * Define the color of the layer (instead of texture).
  52433. */
  52434. color: Color4;
  52435. /**
  52436. * Define the scale of the layer in order to zoom in out of the texture.
  52437. */
  52438. scale: Vector2;
  52439. /**
  52440. * Define an offset for the layer in order to shift the texture.
  52441. */
  52442. offset: Vector2;
  52443. /**
  52444. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52445. */
  52446. alphaBlendingMode: number;
  52447. /**
  52448. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52449. * Alpha test will not mix with the background color in case of transparency.
  52450. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52451. */
  52452. alphaTest: boolean;
  52453. /**
  52454. * Define a mask to restrict the layer to only some of the scene cameras.
  52455. */
  52456. layerMask: number;
  52457. /**
  52458. * Define the list of render target the layer is visible into.
  52459. */
  52460. renderTargetTextures: RenderTargetTexture[];
  52461. /**
  52462. * Define if the layer is only used in renderTarget or if it also
  52463. * renders in the main frame buffer of the canvas.
  52464. */
  52465. renderOnlyInRenderTargetTextures: boolean;
  52466. private _scene;
  52467. private _vertexBuffers;
  52468. private _indexBuffer;
  52469. private _effect;
  52470. private _alphaTestEffect;
  52471. /**
  52472. * An event triggered when the layer is disposed.
  52473. */
  52474. onDisposeObservable: Observable<Layer>;
  52475. private _onDisposeObserver;
  52476. /**
  52477. * Back compatibility with callback before the onDisposeObservable existed.
  52478. * The set callback will be triggered when the layer has been disposed.
  52479. */
  52480. onDispose: () => void;
  52481. /**
  52482. * An event triggered before rendering the scene
  52483. */
  52484. onBeforeRenderObservable: Observable<Layer>;
  52485. private _onBeforeRenderObserver;
  52486. /**
  52487. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52488. * The set callback will be triggered just before rendering the layer.
  52489. */
  52490. onBeforeRender: () => void;
  52491. /**
  52492. * An event triggered after rendering the scene
  52493. */
  52494. onAfterRenderObservable: Observable<Layer>;
  52495. private _onAfterRenderObserver;
  52496. /**
  52497. * Back compatibility with callback before the onAfterRenderObservable existed.
  52498. * The set callback will be triggered just after rendering the layer.
  52499. */
  52500. onAfterRender: () => void;
  52501. /**
  52502. * Instantiates a new layer.
  52503. * This represents a full screen 2d layer.
  52504. * This can be useful to display a picture in the background of your scene for instance.
  52505. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52506. * @param name Define the name of the layer in the scene
  52507. * @param imgUrl Define the url of the texture to display in the layer
  52508. * @param scene Define the scene the layer belongs to
  52509. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52510. * @param color Defines a color for the layer
  52511. */
  52512. constructor(
  52513. /**
  52514. * Define the name of the layer.
  52515. */
  52516. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52517. private _createIndexBuffer;
  52518. /** @hidden */
  52519. _rebuild(): void;
  52520. /**
  52521. * Renders the layer in the scene.
  52522. */
  52523. render(): void;
  52524. /**
  52525. * Disposes and releases the associated ressources.
  52526. */
  52527. dispose(): void;
  52528. }
  52529. }
  52530. declare module "babylonjs/Layers/index" {
  52531. export * from "babylonjs/Layers/effectLayer";
  52532. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52533. export * from "babylonjs/Layers/glowLayer";
  52534. export * from "babylonjs/Layers/highlightLayer";
  52535. export * from "babylonjs/Layers/layer";
  52536. export * from "babylonjs/Layers/layerSceneComponent";
  52537. }
  52538. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52539. /** @hidden */
  52540. export var lensFlarePixelShader: {
  52541. name: string;
  52542. shader: string;
  52543. };
  52544. }
  52545. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52546. /** @hidden */
  52547. export var lensFlareVertexShader: {
  52548. name: string;
  52549. shader: string;
  52550. };
  52551. }
  52552. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52553. import { Scene } from "babylonjs/scene";
  52554. import { Vector3 } from "babylonjs/Maths/math.vector";
  52555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52556. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52557. import "babylonjs/Shaders/lensFlare.fragment";
  52558. import "babylonjs/Shaders/lensFlare.vertex";
  52559. import { Viewport } from "babylonjs/Maths/math.viewport";
  52560. /**
  52561. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52562. * It is usually composed of several `lensFlare`.
  52563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52564. */
  52565. export class LensFlareSystem {
  52566. /**
  52567. * Define the name of the lens flare system
  52568. */
  52569. name: string;
  52570. /**
  52571. * List of lens flares used in this system.
  52572. */
  52573. lensFlares: LensFlare[];
  52574. /**
  52575. * Define a limit from the border the lens flare can be visible.
  52576. */
  52577. borderLimit: number;
  52578. /**
  52579. * Define a viewport border we do not want to see the lens flare in.
  52580. */
  52581. viewportBorder: number;
  52582. /**
  52583. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52584. */
  52585. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52586. /**
  52587. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52588. */
  52589. layerMask: number;
  52590. /**
  52591. * Define the id of the lens flare system in the scene.
  52592. * (equal to name by default)
  52593. */
  52594. id: string;
  52595. private _scene;
  52596. private _emitter;
  52597. private _vertexBuffers;
  52598. private _indexBuffer;
  52599. private _effect;
  52600. private _positionX;
  52601. private _positionY;
  52602. private _isEnabled;
  52603. /** @hidden */
  52604. static _SceneComponentInitialization: (scene: Scene) => void;
  52605. /**
  52606. * Instantiates a lens flare system.
  52607. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52608. * It is usually composed of several `lensFlare`.
  52609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52610. * @param name Define the name of the lens flare system in the scene
  52611. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52612. * @param scene Define the scene the lens flare system belongs to
  52613. */
  52614. constructor(
  52615. /**
  52616. * Define the name of the lens flare system
  52617. */
  52618. name: string, emitter: any, scene: Scene);
  52619. /**
  52620. * Define if the lens flare system is enabled.
  52621. */
  52622. isEnabled: boolean;
  52623. /**
  52624. * Get the scene the effects belongs to.
  52625. * @returns the scene holding the lens flare system
  52626. */
  52627. getScene(): Scene;
  52628. /**
  52629. * Get the emitter of the lens flare system.
  52630. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52631. * @returns the emitter of the lens flare system
  52632. */
  52633. getEmitter(): any;
  52634. /**
  52635. * Set the emitter of the lens flare system.
  52636. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52637. * @param newEmitter Define the new emitter of the system
  52638. */
  52639. setEmitter(newEmitter: any): void;
  52640. /**
  52641. * Get the lens flare system emitter position.
  52642. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52643. * @returns the position
  52644. */
  52645. getEmitterPosition(): Vector3;
  52646. /**
  52647. * @hidden
  52648. */
  52649. computeEffectivePosition(globalViewport: Viewport): boolean;
  52650. /** @hidden */
  52651. _isVisible(): boolean;
  52652. /**
  52653. * @hidden
  52654. */
  52655. render(): boolean;
  52656. /**
  52657. * Dispose and release the lens flare with its associated resources.
  52658. */
  52659. dispose(): void;
  52660. /**
  52661. * Parse a lens flare system from a JSON repressentation
  52662. * @param parsedLensFlareSystem Define the JSON to parse
  52663. * @param scene Define the scene the parsed system should be instantiated in
  52664. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52665. * @returns the parsed system
  52666. */
  52667. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52668. /**
  52669. * Serialize the current Lens Flare System into a JSON representation.
  52670. * @returns the serialized JSON
  52671. */
  52672. serialize(): any;
  52673. }
  52674. }
  52675. declare module "babylonjs/LensFlares/lensFlare" {
  52676. import { Nullable } from "babylonjs/types";
  52677. import { Color3 } from "babylonjs/Maths/math.color";
  52678. import { Texture } from "babylonjs/Materials/Textures/texture";
  52679. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52680. /**
  52681. * This represents one of the lens effect in a `lensFlareSystem`.
  52682. * It controls one of the indiviual texture used in the effect.
  52683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52684. */
  52685. export class LensFlare {
  52686. /**
  52687. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52688. */
  52689. size: number;
  52690. /**
  52691. * 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.
  52692. */
  52693. position: number;
  52694. /**
  52695. * Define the lens color.
  52696. */
  52697. color: Color3;
  52698. /**
  52699. * Define the lens texture.
  52700. */
  52701. texture: Nullable<Texture>;
  52702. /**
  52703. * Define the alpha mode to render this particular lens.
  52704. */
  52705. alphaMode: number;
  52706. private _system;
  52707. /**
  52708. * Creates a new Lens Flare.
  52709. * This represents one of the lens effect in a `lensFlareSystem`.
  52710. * It controls one of the indiviual texture used in the effect.
  52711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52712. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52713. * @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.
  52714. * @param color Define the lens color
  52715. * @param imgUrl Define the lens texture url
  52716. * @param system Define the `lensFlareSystem` this flare is part of
  52717. * @returns The newly created Lens Flare
  52718. */
  52719. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52720. /**
  52721. * Instantiates a new Lens Flare.
  52722. * This represents one of the lens effect in a `lensFlareSystem`.
  52723. * It controls one of the indiviual texture used in the effect.
  52724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52725. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52726. * @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.
  52727. * @param color Define the lens color
  52728. * @param imgUrl Define the lens texture url
  52729. * @param system Define the `lensFlareSystem` this flare is part of
  52730. */
  52731. constructor(
  52732. /**
  52733. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52734. */
  52735. size: number,
  52736. /**
  52737. * 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.
  52738. */
  52739. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52740. /**
  52741. * Dispose and release the lens flare with its associated resources.
  52742. */
  52743. dispose(): void;
  52744. }
  52745. }
  52746. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52747. import { Nullable } from "babylonjs/types";
  52748. import { Scene } from "babylonjs/scene";
  52749. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52750. import { AbstractScene } from "babylonjs/abstractScene";
  52751. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52752. module "babylonjs/abstractScene" {
  52753. interface AbstractScene {
  52754. /**
  52755. * The list of lens flare system added to the scene
  52756. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52757. */
  52758. lensFlareSystems: Array<LensFlareSystem>;
  52759. /**
  52760. * Removes the given lens flare system from this scene.
  52761. * @param toRemove The lens flare system to remove
  52762. * @returns The index of the removed lens flare system
  52763. */
  52764. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52765. /**
  52766. * Adds the given lens flare system to this scene
  52767. * @param newLensFlareSystem The lens flare system to add
  52768. */
  52769. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52770. /**
  52771. * Gets a lens flare system using its name
  52772. * @param name defines the name to look for
  52773. * @returns the lens flare system or null if not found
  52774. */
  52775. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52776. /**
  52777. * Gets a lens flare system using its id
  52778. * @param id defines the id to look for
  52779. * @returns the lens flare system or null if not found
  52780. */
  52781. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52782. }
  52783. }
  52784. /**
  52785. * Defines the lens flare scene component responsible to manage any lens flares
  52786. * in a given scene.
  52787. */
  52788. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52789. /**
  52790. * The component name helpfull to identify the component in the list of scene components.
  52791. */
  52792. readonly name: string;
  52793. /**
  52794. * The scene the component belongs to.
  52795. */
  52796. scene: Scene;
  52797. /**
  52798. * Creates a new instance of the component for the given scene
  52799. * @param scene Defines the scene to register the component in
  52800. */
  52801. constructor(scene: Scene);
  52802. /**
  52803. * Registers the component in a given scene
  52804. */
  52805. register(): void;
  52806. /**
  52807. * Rebuilds the elements related to this component in case of
  52808. * context lost for instance.
  52809. */
  52810. rebuild(): void;
  52811. /**
  52812. * Adds all the elements from the container to the scene
  52813. * @param container the container holding the elements
  52814. */
  52815. addFromContainer(container: AbstractScene): void;
  52816. /**
  52817. * Removes all the elements in the container from the scene
  52818. * @param container contains the elements to remove
  52819. * @param dispose if the removed element should be disposed (default: false)
  52820. */
  52821. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52822. /**
  52823. * Serializes the component data to the specified json object
  52824. * @param serializationObject The object to serialize to
  52825. */
  52826. serialize(serializationObject: any): void;
  52827. /**
  52828. * Disposes the component and the associated ressources.
  52829. */
  52830. dispose(): void;
  52831. private _draw;
  52832. }
  52833. }
  52834. declare module "babylonjs/LensFlares/index" {
  52835. export * from "babylonjs/LensFlares/lensFlare";
  52836. export * from "babylonjs/LensFlares/lensFlareSystem";
  52837. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52838. }
  52839. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52840. import { Scene } from "babylonjs/scene";
  52841. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52842. import { AbstractScene } from "babylonjs/abstractScene";
  52843. /**
  52844. * Defines the shadow generator component responsible to manage any shadow generators
  52845. * in a given scene.
  52846. */
  52847. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52848. /**
  52849. * The component name helpfull to identify the component in the list of scene components.
  52850. */
  52851. readonly name: string;
  52852. /**
  52853. * The scene the component belongs to.
  52854. */
  52855. scene: Scene;
  52856. /**
  52857. * Creates a new instance of the component for the given scene
  52858. * @param scene Defines the scene to register the component in
  52859. */
  52860. constructor(scene: Scene);
  52861. /**
  52862. * Registers the component in a given scene
  52863. */
  52864. register(): void;
  52865. /**
  52866. * Rebuilds the elements related to this component in case of
  52867. * context lost for instance.
  52868. */
  52869. rebuild(): void;
  52870. /**
  52871. * Serializes the component data to the specified json object
  52872. * @param serializationObject The object to serialize to
  52873. */
  52874. serialize(serializationObject: any): void;
  52875. /**
  52876. * Adds all the elements from the container to the scene
  52877. * @param container the container holding the elements
  52878. */
  52879. addFromContainer(container: AbstractScene): void;
  52880. /**
  52881. * Removes all the elements in the container from the scene
  52882. * @param container contains the elements to remove
  52883. * @param dispose if the removed element should be disposed (default: false)
  52884. */
  52885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52886. /**
  52887. * Rebuilds the elements related to this component in case of
  52888. * context lost for instance.
  52889. */
  52890. dispose(): void;
  52891. private _gatherRenderTargets;
  52892. }
  52893. }
  52894. declare module "babylonjs/Lights/Shadows/index" {
  52895. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52896. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52897. }
  52898. declare module "babylonjs/Lights/pointLight" {
  52899. import { Scene } from "babylonjs/scene";
  52900. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52902. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52903. import { Effect } from "babylonjs/Materials/effect";
  52904. /**
  52905. * A point light is a light defined by an unique point in world space.
  52906. * The light is emitted in every direction from this point.
  52907. * A good example of a point light is a standard light bulb.
  52908. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52909. */
  52910. export class PointLight extends ShadowLight {
  52911. private _shadowAngle;
  52912. /**
  52913. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52914. * This specifies what angle the shadow will use to be created.
  52915. *
  52916. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52917. */
  52918. /**
  52919. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52920. * This specifies what angle the shadow will use to be created.
  52921. *
  52922. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52923. */
  52924. shadowAngle: number;
  52925. /**
  52926. * Gets the direction if it has been set.
  52927. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52928. */
  52929. /**
  52930. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52931. */
  52932. direction: Vector3;
  52933. /**
  52934. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52935. * A PointLight emits the light in every direction.
  52936. * It can cast shadows.
  52937. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52938. * ```javascript
  52939. * var pointLight = new PointLight("pl", camera.position, scene);
  52940. * ```
  52941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52942. * @param name The light friendly name
  52943. * @param position The position of the point light in the scene
  52944. * @param scene The scene the lights belongs to
  52945. */
  52946. constructor(name: string, position: Vector3, scene: Scene);
  52947. /**
  52948. * Returns the string "PointLight"
  52949. * @returns the class name
  52950. */
  52951. getClassName(): string;
  52952. /**
  52953. * Returns the integer 0.
  52954. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52955. */
  52956. getTypeID(): number;
  52957. /**
  52958. * Specifies wether or not the shadowmap should be a cube texture.
  52959. * @returns true if the shadowmap needs to be a cube texture.
  52960. */
  52961. needCube(): boolean;
  52962. /**
  52963. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52964. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52965. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52966. */
  52967. getShadowDirection(faceIndex?: number): Vector3;
  52968. /**
  52969. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52970. * - fov = PI / 2
  52971. * - aspect ratio : 1.0
  52972. * - z-near and far equal to the active camera minZ and maxZ.
  52973. * Returns the PointLight.
  52974. */
  52975. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52976. protected _buildUniformLayout(): void;
  52977. /**
  52978. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52979. * @param effect The effect to update
  52980. * @param lightIndex The index of the light in the effect to update
  52981. * @returns The point light
  52982. */
  52983. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52985. /**
  52986. * Prepares the list of defines specific to the light type.
  52987. * @param defines the list of defines
  52988. * @param lightIndex defines the index of the light for the effect
  52989. */
  52990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52991. }
  52992. }
  52993. declare module "babylonjs/Lights/index" {
  52994. export * from "babylonjs/Lights/light";
  52995. export * from "babylonjs/Lights/shadowLight";
  52996. export * from "babylonjs/Lights/Shadows/index";
  52997. export * from "babylonjs/Lights/directionalLight";
  52998. export * from "babylonjs/Lights/hemisphericLight";
  52999. export * from "babylonjs/Lights/pointLight";
  53000. export * from "babylonjs/Lights/spotLight";
  53001. }
  53002. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53003. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53004. /**
  53005. * Header information of HDR texture files.
  53006. */
  53007. export interface HDRInfo {
  53008. /**
  53009. * The height of the texture in pixels.
  53010. */
  53011. height: number;
  53012. /**
  53013. * The width of the texture in pixels.
  53014. */
  53015. width: number;
  53016. /**
  53017. * The index of the beginning of the data in the binary file.
  53018. */
  53019. dataPosition: number;
  53020. }
  53021. /**
  53022. * This groups tools to convert HDR texture to native colors array.
  53023. */
  53024. export class HDRTools {
  53025. private static Ldexp;
  53026. private static Rgbe2float;
  53027. private static readStringLine;
  53028. /**
  53029. * Reads header information from an RGBE texture stored in a native array.
  53030. * More information on this format are available here:
  53031. * https://en.wikipedia.org/wiki/RGBE_image_format
  53032. *
  53033. * @param uint8array The binary file stored in native array.
  53034. * @return The header information.
  53035. */
  53036. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53037. /**
  53038. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53039. * This RGBE texture needs to store the information as a panorama.
  53040. *
  53041. * More information on this format are available here:
  53042. * https://en.wikipedia.org/wiki/RGBE_image_format
  53043. *
  53044. * @param buffer The binary file stored in an array buffer.
  53045. * @param size The expected size of the extracted cubemap.
  53046. * @return The Cube Map information.
  53047. */
  53048. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53049. /**
  53050. * Returns the pixels data extracted from an RGBE texture.
  53051. * This pixels will be stored left to right up to down in the R G B order in one array.
  53052. *
  53053. * More information on this format are available here:
  53054. * https://en.wikipedia.org/wiki/RGBE_image_format
  53055. *
  53056. * @param uint8array The binary file stored in an array buffer.
  53057. * @param hdrInfo The header information of the file.
  53058. * @return The pixels data in RGB right to left up to down order.
  53059. */
  53060. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53061. private static RGBE_ReadPixels_RLE;
  53062. }
  53063. }
  53064. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53065. import { Nullable } from "babylonjs/types";
  53066. import { Scene } from "babylonjs/scene";
  53067. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53069. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53070. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53071. /**
  53072. * This represents a texture coming from an HDR input.
  53073. *
  53074. * The only supported format is currently panorama picture stored in RGBE format.
  53075. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53076. */
  53077. export class HDRCubeTexture extends BaseTexture {
  53078. private static _facesMapping;
  53079. private _generateHarmonics;
  53080. private _noMipmap;
  53081. private _textureMatrix;
  53082. private _size;
  53083. private _onLoad;
  53084. private _onError;
  53085. /**
  53086. * The texture URL.
  53087. */
  53088. url: string;
  53089. /**
  53090. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53091. */
  53092. coordinatesMode: number;
  53093. protected _isBlocking: boolean;
  53094. /**
  53095. * Sets wether or not the texture is blocking during loading.
  53096. */
  53097. /**
  53098. * Gets wether or not the texture is blocking during loading.
  53099. */
  53100. isBlocking: boolean;
  53101. protected _rotationY: number;
  53102. /**
  53103. * Sets texture matrix rotation angle around Y axis in radians.
  53104. */
  53105. /**
  53106. * Gets texture matrix rotation angle around Y axis radians.
  53107. */
  53108. rotationY: number;
  53109. /**
  53110. * Gets or sets the center of the bounding box associated with the cube texture
  53111. * It must define where the camera used to render the texture was set
  53112. */
  53113. boundingBoxPosition: Vector3;
  53114. private _boundingBoxSize;
  53115. /**
  53116. * Gets or sets the size of the bounding box associated with the cube texture
  53117. * When defined, the cubemap will switch to local mode
  53118. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53119. * @example https://www.babylonjs-playground.com/#RNASML
  53120. */
  53121. boundingBoxSize: Vector3;
  53122. /**
  53123. * Instantiates an HDRTexture from the following parameters.
  53124. *
  53125. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53126. * @param scene The scene the texture will be used in
  53127. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53128. * @param noMipmap Forces to not generate the mipmap if true
  53129. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53130. * @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)
  53131. * @param reserved Reserved flag for internal use.
  53132. */
  53133. 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>);
  53134. /**
  53135. * Get the current class name of the texture useful for serialization or dynamic coding.
  53136. * @returns "HDRCubeTexture"
  53137. */
  53138. getClassName(): string;
  53139. /**
  53140. * Occurs when the file is raw .hdr file.
  53141. */
  53142. private loadTexture;
  53143. clone(): HDRCubeTexture;
  53144. delayLoad(): void;
  53145. /**
  53146. * Get the texture reflection matrix used to rotate/transform the reflection.
  53147. * @returns the reflection matrix
  53148. */
  53149. getReflectionTextureMatrix(): Matrix;
  53150. /**
  53151. * Set the texture reflection matrix used to rotate/transform the reflection.
  53152. * @param value Define the reflection matrix to set
  53153. */
  53154. setReflectionTextureMatrix(value: Matrix): void;
  53155. /**
  53156. * Parses a JSON representation of an HDR Texture in order to create the texture
  53157. * @param parsedTexture Define the JSON representation
  53158. * @param scene Define the scene the texture should be created in
  53159. * @param rootUrl Define the root url in case we need to load relative dependencies
  53160. * @returns the newly created texture after parsing
  53161. */
  53162. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53163. serialize(): any;
  53164. }
  53165. }
  53166. declare module "babylonjs/Physics/physicsEngine" {
  53167. import { Nullable } from "babylonjs/types";
  53168. import { Vector3 } from "babylonjs/Maths/math.vector";
  53169. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53170. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53171. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53172. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53173. /**
  53174. * Class used to control physics engine
  53175. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53176. */
  53177. export class PhysicsEngine implements IPhysicsEngine {
  53178. private _physicsPlugin;
  53179. /**
  53180. * Global value used to control the smallest number supported by the simulation
  53181. */
  53182. static Epsilon: number;
  53183. private _impostors;
  53184. private _joints;
  53185. /**
  53186. * Gets the gravity vector used by the simulation
  53187. */
  53188. gravity: Vector3;
  53189. /**
  53190. * Factory used to create the default physics plugin.
  53191. * @returns The default physics plugin
  53192. */
  53193. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53194. /**
  53195. * Creates a new Physics Engine
  53196. * @param gravity defines the gravity vector used by the simulation
  53197. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53198. */
  53199. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53200. /**
  53201. * Sets the gravity vector used by the simulation
  53202. * @param gravity defines the gravity vector to use
  53203. */
  53204. setGravity(gravity: Vector3): void;
  53205. /**
  53206. * Set the time step of the physics engine.
  53207. * Default is 1/60.
  53208. * To slow it down, enter 1/600 for example.
  53209. * To speed it up, 1/30
  53210. * @param newTimeStep defines the new timestep to apply to this world.
  53211. */
  53212. setTimeStep(newTimeStep?: number): void;
  53213. /**
  53214. * Get the time step of the physics engine.
  53215. * @returns the current time step
  53216. */
  53217. getTimeStep(): number;
  53218. /**
  53219. * Release all resources
  53220. */
  53221. dispose(): void;
  53222. /**
  53223. * Gets the name of the current physics plugin
  53224. * @returns the name of the plugin
  53225. */
  53226. getPhysicsPluginName(): string;
  53227. /**
  53228. * Adding a new impostor for the impostor tracking.
  53229. * This will be done by the impostor itself.
  53230. * @param impostor the impostor to add
  53231. */
  53232. addImpostor(impostor: PhysicsImpostor): void;
  53233. /**
  53234. * Remove an impostor from the engine.
  53235. * This impostor and its mesh will not longer be updated by the physics engine.
  53236. * @param impostor the impostor to remove
  53237. */
  53238. removeImpostor(impostor: PhysicsImpostor): void;
  53239. /**
  53240. * Add a joint to the physics engine
  53241. * @param mainImpostor defines the main impostor to which the joint is added.
  53242. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53243. * @param joint defines the joint that will connect both impostors.
  53244. */
  53245. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53246. /**
  53247. * Removes a joint from the simulation
  53248. * @param mainImpostor defines the impostor used with the joint
  53249. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53250. * @param joint defines the joint to remove
  53251. */
  53252. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53253. /**
  53254. * Called by the scene. No need to call it.
  53255. * @param delta defines the timespam between frames
  53256. */
  53257. _step(delta: number): void;
  53258. /**
  53259. * Gets the current plugin used to run the simulation
  53260. * @returns current plugin
  53261. */
  53262. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53263. /**
  53264. * Gets the list of physic impostors
  53265. * @returns an array of PhysicsImpostor
  53266. */
  53267. getImpostors(): Array<PhysicsImpostor>;
  53268. /**
  53269. * Gets the impostor for a physics enabled object
  53270. * @param object defines the object impersonated by the impostor
  53271. * @returns the PhysicsImpostor or null if not found
  53272. */
  53273. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53274. /**
  53275. * Gets the impostor for a physics body object
  53276. * @param body defines physics body used by the impostor
  53277. * @returns the PhysicsImpostor or null if not found
  53278. */
  53279. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53280. /**
  53281. * Does a raycast in the physics world
  53282. * @param from when should the ray start?
  53283. * @param to when should the ray end?
  53284. * @returns PhysicsRaycastResult
  53285. */
  53286. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53287. }
  53288. }
  53289. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53290. import { Nullable } from "babylonjs/types";
  53291. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53293. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53295. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53296. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53297. /** @hidden */
  53298. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53299. private _useDeltaForWorldStep;
  53300. world: any;
  53301. name: string;
  53302. private _physicsMaterials;
  53303. private _fixedTimeStep;
  53304. private _cannonRaycastResult;
  53305. private _raycastResult;
  53306. private _physicsBodysToRemoveAfterStep;
  53307. BJSCANNON: any;
  53308. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53309. setGravity(gravity: Vector3): void;
  53310. setTimeStep(timeStep: number): void;
  53311. getTimeStep(): number;
  53312. executeStep(delta: number): void;
  53313. private _removeMarkedPhysicsBodiesFromWorld;
  53314. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53315. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53316. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53317. private _processChildMeshes;
  53318. removePhysicsBody(impostor: PhysicsImpostor): void;
  53319. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53320. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53321. private _addMaterial;
  53322. private _checkWithEpsilon;
  53323. private _createShape;
  53324. private _createHeightmap;
  53325. private _minus90X;
  53326. private _plus90X;
  53327. private _tmpPosition;
  53328. private _tmpDeltaPosition;
  53329. private _tmpUnityRotation;
  53330. private _updatePhysicsBodyTransformation;
  53331. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53332. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53333. isSupported(): boolean;
  53334. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53335. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53336. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53337. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53338. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53339. getBodyMass(impostor: PhysicsImpostor): number;
  53340. getBodyFriction(impostor: PhysicsImpostor): number;
  53341. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53342. getBodyRestitution(impostor: PhysicsImpostor): number;
  53343. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53344. sleepBody(impostor: PhysicsImpostor): void;
  53345. wakeUpBody(impostor: PhysicsImpostor): void;
  53346. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53347. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53348. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53349. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53350. getRadius(impostor: PhysicsImpostor): number;
  53351. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53352. dispose(): void;
  53353. private _extendNamespace;
  53354. /**
  53355. * Does a raycast in the physics world
  53356. * @param from when should the ray start?
  53357. * @param to when should the ray end?
  53358. * @returns PhysicsRaycastResult
  53359. */
  53360. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53361. }
  53362. }
  53363. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53364. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53365. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53366. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53368. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53369. import { Nullable } from "babylonjs/types";
  53370. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53371. /** @hidden */
  53372. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53373. world: any;
  53374. name: string;
  53375. BJSOIMO: any;
  53376. private _raycastResult;
  53377. constructor(iterations?: number, oimoInjection?: any);
  53378. setGravity(gravity: Vector3): void;
  53379. setTimeStep(timeStep: number): void;
  53380. getTimeStep(): number;
  53381. private _tmpImpostorsArray;
  53382. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53386. private _tmpPositionVector;
  53387. removePhysicsBody(impostor: PhysicsImpostor): void;
  53388. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53390. isSupported(): boolean;
  53391. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53392. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53393. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53394. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53395. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53396. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53397. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53398. getBodyMass(impostor: PhysicsImpostor): number;
  53399. getBodyFriction(impostor: PhysicsImpostor): number;
  53400. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53401. getBodyRestitution(impostor: PhysicsImpostor): number;
  53402. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53403. sleepBody(impostor: PhysicsImpostor): void;
  53404. wakeUpBody(impostor: PhysicsImpostor): void;
  53405. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53406. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53407. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53408. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53409. getRadius(impostor: PhysicsImpostor): number;
  53410. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53411. dispose(): void;
  53412. /**
  53413. * Does a raycast in the physics world
  53414. * @param from when should the ray start?
  53415. * @param to when should the ray end?
  53416. * @returns PhysicsRaycastResult
  53417. */
  53418. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53419. }
  53420. }
  53421. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53422. import { Nullable } from "babylonjs/types";
  53423. import { Scene } from "babylonjs/scene";
  53424. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53425. import { Color4 } from "babylonjs/Maths/math.color";
  53426. import { Mesh } from "babylonjs/Meshes/mesh";
  53427. /**
  53428. * Class containing static functions to help procedurally build meshes
  53429. */
  53430. export class RibbonBuilder {
  53431. /**
  53432. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53433. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53434. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53435. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53436. * * 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
  53437. * * 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
  53438. * * 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
  53439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53442. * * 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
  53443. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53444. * * 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
  53445. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53447. * @param name defines the name of the mesh
  53448. * @param options defines the options used to create the mesh
  53449. * @param scene defines the hosting scene
  53450. * @returns the ribbon mesh
  53451. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53452. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53453. */
  53454. static CreateRibbon(name: string, options: {
  53455. pathArray: Vector3[][];
  53456. closeArray?: boolean;
  53457. closePath?: boolean;
  53458. offset?: number;
  53459. updatable?: boolean;
  53460. sideOrientation?: number;
  53461. frontUVs?: Vector4;
  53462. backUVs?: Vector4;
  53463. instance?: Mesh;
  53464. invertUV?: boolean;
  53465. uvs?: Vector2[];
  53466. colors?: Color4[];
  53467. }, scene?: Nullable<Scene>): Mesh;
  53468. }
  53469. }
  53470. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53471. import { Nullable } from "babylonjs/types";
  53472. import { Scene } from "babylonjs/scene";
  53473. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53474. import { Mesh } from "babylonjs/Meshes/mesh";
  53475. /**
  53476. * Class containing static functions to help procedurally build meshes
  53477. */
  53478. export class ShapeBuilder {
  53479. /**
  53480. * 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.
  53481. * * 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.
  53482. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53483. * * 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.
  53484. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53485. * * 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
  53486. * * 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
  53487. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53492. * @param name defines the name of the mesh
  53493. * @param options defines the options used to create the mesh
  53494. * @param scene defines the hosting scene
  53495. * @returns the extruded shape mesh
  53496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53498. */
  53499. static ExtrudeShape(name: string, options: {
  53500. shape: Vector3[];
  53501. path: Vector3[];
  53502. scale?: number;
  53503. rotation?: number;
  53504. cap?: number;
  53505. updatable?: boolean;
  53506. sideOrientation?: number;
  53507. frontUVs?: Vector4;
  53508. backUVs?: Vector4;
  53509. instance?: Mesh;
  53510. invertUV?: boolean;
  53511. }, scene?: Nullable<Scene>): Mesh;
  53512. /**
  53513. * Creates an custom extruded shape mesh.
  53514. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53515. * * 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.
  53516. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53517. * * 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
  53518. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53519. * * 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
  53520. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53521. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53522. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53523. * * 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
  53524. * * 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
  53525. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53530. * @param name defines the name of the mesh
  53531. * @param options defines the options used to create the mesh
  53532. * @param scene defines the hosting scene
  53533. * @returns the custom extruded shape mesh
  53534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53535. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53537. */
  53538. static ExtrudeShapeCustom(name: string, options: {
  53539. shape: Vector3[];
  53540. path: Vector3[];
  53541. scaleFunction?: any;
  53542. rotationFunction?: any;
  53543. ribbonCloseArray?: boolean;
  53544. ribbonClosePath?: boolean;
  53545. cap?: number;
  53546. updatable?: boolean;
  53547. sideOrientation?: number;
  53548. frontUVs?: Vector4;
  53549. backUVs?: Vector4;
  53550. instance?: Mesh;
  53551. invertUV?: boolean;
  53552. }, scene?: Nullable<Scene>): Mesh;
  53553. private static _ExtrudeShapeGeneric;
  53554. }
  53555. }
  53556. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53557. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53558. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53559. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53560. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53561. import { Nullable } from "babylonjs/types";
  53562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53563. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53564. /**
  53565. * AmmoJS Physics plugin
  53566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53567. * @see https://github.com/kripken/ammo.js/
  53568. */
  53569. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53570. private _useDeltaForWorldStep;
  53571. /**
  53572. * Reference to the Ammo library
  53573. */
  53574. bjsAMMO: any;
  53575. /**
  53576. * Created ammoJS world which physics bodies are added to
  53577. */
  53578. world: any;
  53579. /**
  53580. * Name of the plugin
  53581. */
  53582. name: string;
  53583. private _timeStep;
  53584. private _fixedTimeStep;
  53585. private _maxSteps;
  53586. private _tmpQuaternion;
  53587. private _tmpAmmoTransform;
  53588. private _tmpAmmoQuaternion;
  53589. private _tmpAmmoConcreteContactResultCallback;
  53590. private _collisionConfiguration;
  53591. private _dispatcher;
  53592. private _overlappingPairCache;
  53593. private _solver;
  53594. private _softBodySolver;
  53595. private _tmpAmmoVectorA;
  53596. private _tmpAmmoVectorB;
  53597. private _tmpAmmoVectorC;
  53598. private _tmpAmmoVectorD;
  53599. private _tmpContactCallbackResult;
  53600. private _tmpAmmoVectorRCA;
  53601. private _tmpAmmoVectorRCB;
  53602. private _raycastResult;
  53603. private static readonly DISABLE_COLLISION_FLAG;
  53604. private static readonly KINEMATIC_FLAG;
  53605. private static readonly DISABLE_DEACTIVATION_FLAG;
  53606. /**
  53607. * Initializes the ammoJS plugin
  53608. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53609. * @param ammoInjection can be used to inject your own ammo reference
  53610. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53611. */
  53612. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53613. /**
  53614. * Sets the gravity of the physics world (m/(s^2))
  53615. * @param gravity Gravity to set
  53616. */
  53617. setGravity(gravity: Vector3): void;
  53618. /**
  53619. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53620. * @param timeStep timestep to use in seconds
  53621. */
  53622. setTimeStep(timeStep: number): void;
  53623. /**
  53624. * 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)
  53625. * @param fixedTimeStep fixedTimeStep to use in seconds
  53626. */
  53627. setFixedTimeStep(fixedTimeStep: number): void;
  53628. /**
  53629. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53630. * @param maxSteps the maximum number of steps by the physics engine per frame
  53631. */
  53632. setMaxSteps(maxSteps: number): void;
  53633. /**
  53634. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53635. * @returns the current timestep in seconds
  53636. */
  53637. getTimeStep(): number;
  53638. private _isImpostorInContact;
  53639. private _isImpostorPairInContact;
  53640. private _stepSimulation;
  53641. /**
  53642. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53643. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53644. * After the step the babylon meshes are set to the position of the physics imposters
  53645. * @param delta amount of time to step forward
  53646. * @param impostors array of imposters to update before/after the step
  53647. */
  53648. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53649. /**
  53650. * Update babylon mesh to match physics world object
  53651. * @param impostor imposter to match
  53652. */
  53653. private _afterSoftStep;
  53654. /**
  53655. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53656. * @param impostor imposter to match
  53657. */
  53658. private _ropeStep;
  53659. /**
  53660. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53661. * @param impostor imposter to match
  53662. */
  53663. private _softbodyOrClothStep;
  53664. private _tmpVector;
  53665. private _tmpMatrix;
  53666. /**
  53667. * Applies an impulse on the imposter
  53668. * @param impostor imposter to apply impulse to
  53669. * @param force amount of force to be applied to the imposter
  53670. * @param contactPoint the location to apply the impulse on the imposter
  53671. */
  53672. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53673. /**
  53674. * Applies a force on the imposter
  53675. * @param impostor imposter to apply force
  53676. * @param force amount of force to be applied to the imposter
  53677. * @param contactPoint the location to apply the force on the imposter
  53678. */
  53679. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53680. /**
  53681. * Creates a physics body using the plugin
  53682. * @param impostor the imposter to create the physics body on
  53683. */
  53684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53685. /**
  53686. * Removes the physics body from the imposter and disposes of the body's memory
  53687. * @param impostor imposter to remove the physics body from
  53688. */
  53689. removePhysicsBody(impostor: PhysicsImpostor): void;
  53690. /**
  53691. * Generates a joint
  53692. * @param impostorJoint the imposter joint to create the joint with
  53693. */
  53694. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53695. /**
  53696. * Removes a joint
  53697. * @param impostorJoint the imposter joint to remove the joint from
  53698. */
  53699. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53700. private _addMeshVerts;
  53701. /**
  53702. * Initialise the soft body vertices to match its object's (mesh) vertices
  53703. * Softbody vertices (nodes) are in world space and to match this
  53704. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53705. * @param impostor to create the softbody for
  53706. */
  53707. private _softVertexData;
  53708. /**
  53709. * Create an impostor's soft body
  53710. * @param impostor to create the softbody for
  53711. */
  53712. private _createSoftbody;
  53713. /**
  53714. * Create cloth for an impostor
  53715. * @param impostor to create the softbody for
  53716. */
  53717. private _createCloth;
  53718. /**
  53719. * Create rope for an impostor
  53720. * @param impostor to create the softbody for
  53721. */
  53722. private _createRope;
  53723. private _addHullVerts;
  53724. private _createShape;
  53725. /**
  53726. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53727. * @param impostor imposter containing the physics body and babylon object
  53728. */
  53729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53730. /**
  53731. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53732. * @param impostor imposter containing the physics body and babylon object
  53733. * @param newPosition new position
  53734. * @param newRotation new rotation
  53735. */
  53736. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53737. /**
  53738. * If this plugin is supported
  53739. * @returns true if its supported
  53740. */
  53741. isSupported(): boolean;
  53742. /**
  53743. * Sets the linear velocity of the physics body
  53744. * @param impostor imposter to set the velocity on
  53745. * @param velocity velocity to set
  53746. */
  53747. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53748. /**
  53749. * Sets the angular velocity of the physics body
  53750. * @param impostor imposter to set the velocity on
  53751. * @param velocity velocity to set
  53752. */
  53753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53754. /**
  53755. * gets the linear velocity
  53756. * @param impostor imposter to get linear velocity from
  53757. * @returns linear velocity
  53758. */
  53759. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53760. /**
  53761. * gets the angular velocity
  53762. * @param impostor imposter to get angular velocity from
  53763. * @returns angular velocity
  53764. */
  53765. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53766. /**
  53767. * Sets the mass of physics body
  53768. * @param impostor imposter to set the mass on
  53769. * @param mass mass to set
  53770. */
  53771. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53772. /**
  53773. * Gets the mass of the physics body
  53774. * @param impostor imposter to get the mass from
  53775. * @returns mass
  53776. */
  53777. getBodyMass(impostor: PhysicsImpostor): number;
  53778. /**
  53779. * Gets friction of the impostor
  53780. * @param impostor impostor to get friction from
  53781. * @returns friction value
  53782. */
  53783. getBodyFriction(impostor: PhysicsImpostor): number;
  53784. /**
  53785. * Sets friction of the impostor
  53786. * @param impostor impostor to set friction on
  53787. * @param friction friction value
  53788. */
  53789. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53790. /**
  53791. * Gets restitution of the impostor
  53792. * @param impostor impostor to get restitution from
  53793. * @returns restitution value
  53794. */
  53795. getBodyRestitution(impostor: PhysicsImpostor): number;
  53796. /**
  53797. * Sets resitution of the impostor
  53798. * @param impostor impostor to set resitution on
  53799. * @param restitution resitution value
  53800. */
  53801. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53802. /**
  53803. * Gets pressure inside the impostor
  53804. * @param impostor impostor to get pressure from
  53805. * @returns pressure value
  53806. */
  53807. getBodyPressure(impostor: PhysicsImpostor): number;
  53808. /**
  53809. * Sets pressure inside a soft body impostor
  53810. * Cloth and rope must remain 0 pressure
  53811. * @param impostor impostor to set pressure on
  53812. * @param pressure pressure value
  53813. */
  53814. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53815. /**
  53816. * Gets stiffness of the impostor
  53817. * @param impostor impostor to get stiffness from
  53818. * @returns pressure value
  53819. */
  53820. getBodyStiffness(impostor: PhysicsImpostor): number;
  53821. /**
  53822. * Sets stiffness of the impostor
  53823. * @param impostor impostor to set stiffness on
  53824. * @param stiffness stiffness value from 0 to 1
  53825. */
  53826. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53827. /**
  53828. * Gets velocityIterations of the impostor
  53829. * @param impostor impostor to get velocity iterations from
  53830. * @returns velocityIterations value
  53831. */
  53832. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53833. /**
  53834. * Sets velocityIterations of the impostor
  53835. * @param impostor impostor to set velocity iterations on
  53836. * @param velocityIterations velocityIterations value
  53837. */
  53838. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53839. /**
  53840. * Gets positionIterations of the impostor
  53841. * @param impostor impostor to get position iterations from
  53842. * @returns positionIterations value
  53843. */
  53844. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53845. /**
  53846. * Sets positionIterations of the impostor
  53847. * @param impostor impostor to set position on
  53848. * @param positionIterations positionIterations value
  53849. */
  53850. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53851. /**
  53852. * Append an anchor to a cloth object
  53853. * @param impostor is the cloth impostor to add anchor to
  53854. * @param otherImpostor is the rigid impostor to anchor to
  53855. * @param width ratio across width from 0 to 1
  53856. * @param height ratio up height from 0 to 1
  53857. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53858. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53859. */
  53860. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53861. /**
  53862. * Append an hook to a rope object
  53863. * @param impostor is the rope impostor to add hook to
  53864. * @param otherImpostor is the rigid impostor to hook to
  53865. * @param length ratio along the rope from 0 to 1
  53866. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53867. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53868. */
  53869. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53870. /**
  53871. * Sleeps the physics body and stops it from being active
  53872. * @param impostor impostor to sleep
  53873. */
  53874. sleepBody(impostor: PhysicsImpostor): void;
  53875. /**
  53876. * Activates the physics body
  53877. * @param impostor impostor to activate
  53878. */
  53879. wakeUpBody(impostor: PhysicsImpostor): void;
  53880. /**
  53881. * Updates the distance parameters of the joint
  53882. * @param joint joint to update
  53883. * @param maxDistance maximum distance of the joint
  53884. * @param minDistance minimum distance of the joint
  53885. */
  53886. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53887. /**
  53888. * Sets a motor on the joint
  53889. * @param joint joint to set motor on
  53890. * @param speed speed of the motor
  53891. * @param maxForce maximum force of the motor
  53892. * @param motorIndex index of the motor
  53893. */
  53894. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53895. /**
  53896. * Sets the motors limit
  53897. * @param joint joint to set limit on
  53898. * @param upperLimit upper limit
  53899. * @param lowerLimit lower limit
  53900. */
  53901. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53902. /**
  53903. * Syncs the position and rotation of a mesh with the impostor
  53904. * @param mesh mesh to sync
  53905. * @param impostor impostor to update the mesh with
  53906. */
  53907. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53908. /**
  53909. * Gets the radius of the impostor
  53910. * @param impostor impostor to get radius from
  53911. * @returns the radius
  53912. */
  53913. getRadius(impostor: PhysicsImpostor): number;
  53914. /**
  53915. * Gets the box size of the impostor
  53916. * @param impostor impostor to get box size from
  53917. * @param result the resulting box size
  53918. */
  53919. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53920. /**
  53921. * Disposes of the impostor
  53922. */
  53923. dispose(): void;
  53924. /**
  53925. * Does a raycast in the physics world
  53926. * @param from when should the ray start?
  53927. * @param to when should the ray end?
  53928. * @returns PhysicsRaycastResult
  53929. */
  53930. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53931. }
  53932. }
  53933. declare module "babylonjs/Probes/reflectionProbe" {
  53934. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53935. import { Vector3 } from "babylonjs/Maths/math.vector";
  53936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53937. import { Nullable } from "babylonjs/types";
  53938. import { Scene } from "babylonjs/scene";
  53939. module "babylonjs/abstractScene" {
  53940. interface AbstractScene {
  53941. /**
  53942. * The list of reflection probes added to the scene
  53943. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53944. */
  53945. reflectionProbes: Array<ReflectionProbe>;
  53946. /**
  53947. * Removes the given reflection probe from this scene.
  53948. * @param toRemove The reflection probe to remove
  53949. * @returns The index of the removed reflection probe
  53950. */
  53951. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53952. /**
  53953. * Adds the given reflection probe to this scene.
  53954. * @param newReflectionProbe The reflection probe to add
  53955. */
  53956. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53957. }
  53958. }
  53959. /**
  53960. * Class used to generate realtime reflection / refraction cube textures
  53961. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53962. */
  53963. export class ReflectionProbe {
  53964. /** defines the name of the probe */
  53965. name: string;
  53966. private _scene;
  53967. private _renderTargetTexture;
  53968. private _projectionMatrix;
  53969. private _viewMatrix;
  53970. private _target;
  53971. private _add;
  53972. private _attachedMesh;
  53973. private _invertYAxis;
  53974. /** Gets or sets probe position (center of the cube map) */
  53975. position: Vector3;
  53976. /**
  53977. * Creates a new reflection probe
  53978. * @param name defines the name of the probe
  53979. * @param size defines the texture resolution (for each face)
  53980. * @param scene defines the hosting scene
  53981. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53982. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53983. */
  53984. constructor(
  53985. /** defines the name of the probe */
  53986. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53987. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53988. samples: number;
  53989. /** Gets or sets the refresh rate to use (on every frame by default) */
  53990. refreshRate: number;
  53991. /**
  53992. * Gets the hosting scene
  53993. * @returns a Scene
  53994. */
  53995. getScene(): Scene;
  53996. /** Gets the internal CubeTexture used to render to */
  53997. readonly cubeTexture: RenderTargetTexture;
  53998. /** Gets the list of meshes to render */
  53999. readonly renderList: Nullable<AbstractMesh[]>;
  54000. /**
  54001. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54002. * @param mesh defines the mesh to attach to
  54003. */
  54004. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54005. /**
  54006. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54007. * @param renderingGroupId The rendering group id corresponding to its index
  54008. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54009. */
  54010. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54011. /**
  54012. * Clean all associated resources
  54013. */
  54014. dispose(): void;
  54015. /**
  54016. * Converts the reflection probe information to a readable string for debug purpose.
  54017. * @param fullDetails Supports for multiple levels of logging within scene loading
  54018. * @returns the human readable reflection probe info
  54019. */
  54020. toString(fullDetails?: boolean): string;
  54021. /**
  54022. * Get the class name of the relfection probe.
  54023. * @returns "ReflectionProbe"
  54024. */
  54025. getClassName(): string;
  54026. /**
  54027. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54028. * @returns The JSON representation of the texture
  54029. */
  54030. serialize(): any;
  54031. /**
  54032. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54033. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54034. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54035. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54036. * @returns The parsed reflection probe if successful
  54037. */
  54038. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54039. }
  54040. }
  54041. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54042. /** @hidden */
  54043. export var _BabylonLoaderRegistered: boolean;
  54044. }
  54045. declare module "babylonjs/Loading/Plugins/index" {
  54046. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54047. }
  54048. declare module "babylonjs/Loading/index" {
  54049. export * from "babylonjs/Loading/loadingScreen";
  54050. export * from "babylonjs/Loading/Plugins/index";
  54051. export * from "babylonjs/Loading/sceneLoader";
  54052. export * from "babylonjs/Loading/sceneLoaderFlags";
  54053. }
  54054. declare module "babylonjs/Materials/Background/index" {
  54055. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54056. }
  54057. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54058. import { Scene } from "babylonjs/scene";
  54059. import { Color3 } from "babylonjs/Maths/math.color";
  54060. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54062. /**
  54063. * The Physically based simple base material of BJS.
  54064. *
  54065. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54066. * It is used as the base class for both the specGloss and metalRough conventions.
  54067. */
  54068. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54069. /**
  54070. * Number of Simultaneous lights allowed on the material.
  54071. */
  54072. maxSimultaneousLights: number;
  54073. /**
  54074. * If sets to true, disables all the lights affecting the material.
  54075. */
  54076. disableLighting: boolean;
  54077. /**
  54078. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54079. */
  54080. environmentTexture: BaseTexture;
  54081. /**
  54082. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54083. */
  54084. invertNormalMapX: boolean;
  54085. /**
  54086. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54087. */
  54088. invertNormalMapY: boolean;
  54089. /**
  54090. * Normal map used in the model.
  54091. */
  54092. normalTexture: BaseTexture;
  54093. /**
  54094. * Emissivie color used to self-illuminate the model.
  54095. */
  54096. emissiveColor: Color3;
  54097. /**
  54098. * Emissivie texture used to self-illuminate the model.
  54099. */
  54100. emissiveTexture: BaseTexture;
  54101. /**
  54102. * Occlusion Channel Strenght.
  54103. */
  54104. occlusionStrength: number;
  54105. /**
  54106. * Occlusion Texture of the material (adding extra occlusion effects).
  54107. */
  54108. occlusionTexture: BaseTexture;
  54109. /**
  54110. * Defines the alpha limits in alpha test mode.
  54111. */
  54112. alphaCutOff: number;
  54113. /**
  54114. * Gets the current double sided mode.
  54115. */
  54116. /**
  54117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54118. */
  54119. doubleSided: boolean;
  54120. /**
  54121. * Stores the pre-calculated light information of a mesh in a texture.
  54122. */
  54123. lightmapTexture: BaseTexture;
  54124. /**
  54125. * If true, the light map contains occlusion information instead of lighting info.
  54126. */
  54127. useLightmapAsShadowmap: boolean;
  54128. /**
  54129. * Instantiates a new PBRMaterial instance.
  54130. *
  54131. * @param name The material name
  54132. * @param scene The scene the material will be use in.
  54133. */
  54134. constructor(name: string, scene: Scene);
  54135. getClassName(): string;
  54136. }
  54137. }
  54138. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54139. import { Scene } from "babylonjs/scene";
  54140. import { Color3 } from "babylonjs/Maths/math.color";
  54141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54142. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54143. /**
  54144. * The PBR material of BJS following the metal roughness convention.
  54145. *
  54146. * This fits to the PBR convention in the GLTF definition:
  54147. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54148. */
  54149. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54150. /**
  54151. * The base color has two different interpretations depending on the value of metalness.
  54152. * When the material is a metal, the base color is the specific measured reflectance value
  54153. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54154. * of the material.
  54155. */
  54156. baseColor: Color3;
  54157. /**
  54158. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54159. * well as opacity information in the alpha channel.
  54160. */
  54161. baseTexture: BaseTexture;
  54162. /**
  54163. * Specifies the metallic scalar value of the material.
  54164. * Can also be used to scale the metalness values of the metallic texture.
  54165. */
  54166. metallic: number;
  54167. /**
  54168. * Specifies the roughness scalar value of the material.
  54169. * Can also be used to scale the roughness values of the metallic texture.
  54170. */
  54171. roughness: number;
  54172. /**
  54173. * Texture containing both the metallic value in the B channel and the
  54174. * roughness value in the G channel to keep better precision.
  54175. */
  54176. metallicRoughnessTexture: BaseTexture;
  54177. /**
  54178. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54179. *
  54180. * @param name The material name
  54181. * @param scene The scene the material will be use in.
  54182. */
  54183. constructor(name: string, scene: Scene);
  54184. /**
  54185. * Return the currrent class name of the material.
  54186. */
  54187. getClassName(): string;
  54188. /**
  54189. * Makes a duplicate of the current material.
  54190. * @param name - name to use for the new material.
  54191. */
  54192. clone(name: string): PBRMetallicRoughnessMaterial;
  54193. /**
  54194. * Serialize the material to a parsable JSON object.
  54195. */
  54196. serialize(): any;
  54197. /**
  54198. * Parses a JSON object correponding to the serialize function.
  54199. */
  54200. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54201. }
  54202. }
  54203. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54204. import { Scene } from "babylonjs/scene";
  54205. import { Color3 } from "babylonjs/Maths/math.color";
  54206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54207. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54208. /**
  54209. * The PBR material of BJS following the specular glossiness convention.
  54210. *
  54211. * This fits to the PBR convention in the GLTF definition:
  54212. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54213. */
  54214. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54215. /**
  54216. * Specifies the diffuse color of the material.
  54217. */
  54218. diffuseColor: Color3;
  54219. /**
  54220. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54221. * channel.
  54222. */
  54223. diffuseTexture: BaseTexture;
  54224. /**
  54225. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54226. */
  54227. specularColor: Color3;
  54228. /**
  54229. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54230. */
  54231. glossiness: number;
  54232. /**
  54233. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54234. */
  54235. specularGlossinessTexture: BaseTexture;
  54236. /**
  54237. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54238. *
  54239. * @param name The material name
  54240. * @param scene The scene the material will be use in.
  54241. */
  54242. constructor(name: string, scene: Scene);
  54243. /**
  54244. * Return the currrent class name of the material.
  54245. */
  54246. getClassName(): string;
  54247. /**
  54248. * Makes a duplicate of the current material.
  54249. * @param name - name to use for the new material.
  54250. */
  54251. clone(name: string): PBRSpecularGlossinessMaterial;
  54252. /**
  54253. * Serialize the material to a parsable JSON object.
  54254. */
  54255. serialize(): any;
  54256. /**
  54257. * Parses a JSON object correponding to the serialize function.
  54258. */
  54259. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54260. }
  54261. }
  54262. declare module "babylonjs/Materials/PBR/index" {
  54263. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54264. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54265. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54266. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54267. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54268. }
  54269. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54270. import { Nullable } from "babylonjs/types";
  54271. import { Scene } from "babylonjs/scene";
  54272. import { Matrix } from "babylonjs/Maths/math.vector";
  54273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54274. /**
  54275. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54276. * It can help converting any input color in a desired output one. This can then be used to create effects
  54277. * from sepia, black and white to sixties or futuristic rendering...
  54278. *
  54279. * The only supported format is currently 3dl.
  54280. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54281. */
  54282. export class ColorGradingTexture extends BaseTexture {
  54283. /**
  54284. * The current texture matrix. (will always be identity in color grading texture)
  54285. */
  54286. private _textureMatrix;
  54287. /**
  54288. * The texture URL.
  54289. */
  54290. url: string;
  54291. /**
  54292. * Empty line regex stored for GC.
  54293. */
  54294. private static _noneEmptyLineRegex;
  54295. private _engine;
  54296. /**
  54297. * Instantiates a ColorGradingTexture from the following parameters.
  54298. *
  54299. * @param url The location of the color gradind data (currently only supporting 3dl)
  54300. * @param scene The scene the texture will be used in
  54301. */
  54302. constructor(url: string, scene: Scene);
  54303. /**
  54304. * Returns the texture matrix used in most of the material.
  54305. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54306. */
  54307. getTextureMatrix(): Matrix;
  54308. /**
  54309. * Occurs when the file being loaded is a .3dl LUT file.
  54310. */
  54311. private load3dlTexture;
  54312. /**
  54313. * Starts the loading process of the texture.
  54314. */
  54315. private loadTexture;
  54316. /**
  54317. * Clones the color gradind texture.
  54318. */
  54319. clone(): ColorGradingTexture;
  54320. /**
  54321. * Called during delayed load for textures.
  54322. */
  54323. delayLoad(): void;
  54324. /**
  54325. * Parses a color grading texture serialized by Babylon.
  54326. * @param parsedTexture The texture information being parsedTexture
  54327. * @param scene The scene to load the texture in
  54328. * @param rootUrl The root url of the data assets to load
  54329. * @return A color gradind texture
  54330. */
  54331. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54332. /**
  54333. * Serializes the LUT texture to json format.
  54334. */
  54335. serialize(): any;
  54336. }
  54337. }
  54338. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54340. import { Scene } from "babylonjs/scene";
  54341. import { Nullable } from "babylonjs/types";
  54342. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54343. /**
  54344. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54345. */
  54346. export class EquiRectangularCubeTexture extends BaseTexture {
  54347. /** The six faces of the cube. */
  54348. private static _FacesMapping;
  54349. private _noMipmap;
  54350. private _onLoad;
  54351. private _onError;
  54352. /** The size of the cubemap. */
  54353. private _size;
  54354. /** The buffer of the image. */
  54355. private _buffer;
  54356. /** The width of the input image. */
  54357. private _width;
  54358. /** The height of the input image. */
  54359. private _height;
  54360. /** The URL to the image. */
  54361. url: string;
  54362. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54363. coordinatesMode: number;
  54364. /**
  54365. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54366. * @param url The location of the image
  54367. * @param scene The scene the texture will be used in
  54368. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54369. * @param noMipmap Forces to not generate the mipmap if true
  54370. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54371. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54372. * @param onLoad — defines a callback called when texture is loaded
  54373. * @param onError — defines a callback called if there is an error
  54374. */
  54375. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54376. /**
  54377. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54378. */
  54379. private loadImage;
  54380. /**
  54381. * Convert the image buffer into a cubemap and create a CubeTexture.
  54382. */
  54383. private loadTexture;
  54384. /**
  54385. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54386. * @param buffer The ArrayBuffer that should be converted.
  54387. * @returns The buffer as Float32Array.
  54388. */
  54389. private getFloat32ArrayFromArrayBuffer;
  54390. /**
  54391. * Get the current class name of the texture useful for serialization or dynamic coding.
  54392. * @returns "EquiRectangularCubeTexture"
  54393. */
  54394. getClassName(): string;
  54395. /**
  54396. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54397. * @returns A clone of the current EquiRectangularCubeTexture.
  54398. */
  54399. clone(): EquiRectangularCubeTexture;
  54400. }
  54401. }
  54402. declare module "babylonjs/Misc/tga" {
  54403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54404. /**
  54405. * Based on jsTGALoader - Javascript loader for TGA file
  54406. * By Vincent Thibault
  54407. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54408. */
  54409. export class TGATools {
  54410. private static _TYPE_INDEXED;
  54411. private static _TYPE_RGB;
  54412. private static _TYPE_GREY;
  54413. private static _TYPE_RLE_INDEXED;
  54414. private static _TYPE_RLE_RGB;
  54415. private static _TYPE_RLE_GREY;
  54416. private static _ORIGIN_MASK;
  54417. private static _ORIGIN_SHIFT;
  54418. private static _ORIGIN_BL;
  54419. private static _ORIGIN_BR;
  54420. private static _ORIGIN_UL;
  54421. private static _ORIGIN_UR;
  54422. /**
  54423. * Gets the header of a TGA file
  54424. * @param data defines the TGA data
  54425. * @returns the header
  54426. */
  54427. static GetTGAHeader(data: Uint8Array): any;
  54428. /**
  54429. * Uploads TGA content to a Babylon Texture
  54430. * @hidden
  54431. */
  54432. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54433. /** @hidden */
  54434. 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;
  54435. /** @hidden */
  54436. 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;
  54437. /** @hidden */
  54438. 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;
  54439. /** @hidden */
  54440. 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;
  54441. /** @hidden */
  54442. 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;
  54443. /** @hidden */
  54444. 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;
  54445. }
  54446. }
  54447. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54448. import { Nullable } from "babylonjs/types";
  54449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54450. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54451. /**
  54452. * Implementation of the TGA Texture Loader.
  54453. * @hidden
  54454. */
  54455. export class _TGATextureLoader implements IInternalTextureLoader {
  54456. /**
  54457. * Defines wether the loader supports cascade loading the different faces.
  54458. */
  54459. readonly supportCascades: boolean;
  54460. /**
  54461. * This returns if the loader support the current file information.
  54462. * @param extension defines the file extension of the file being loaded
  54463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54464. * @param fallback defines the fallback internal texture if any
  54465. * @param isBase64 defines whether the texture is encoded as a base64
  54466. * @param isBuffer defines whether the texture data are stored as a buffer
  54467. * @returns true if the loader can load the specified file
  54468. */
  54469. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54470. /**
  54471. * Transform the url before loading if required.
  54472. * @param rootUrl the url of the texture
  54473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54474. * @returns the transformed texture
  54475. */
  54476. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54477. /**
  54478. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54479. * @param rootUrl the url of the texture
  54480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54481. * @returns the fallback texture
  54482. */
  54483. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54484. /**
  54485. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54486. * @param data contains the texture data
  54487. * @param texture defines the BabylonJS internal texture
  54488. * @param createPolynomials will be true if polynomials have been requested
  54489. * @param onLoad defines the callback to trigger once the texture is ready
  54490. * @param onError defines the callback to trigger in case of error
  54491. */
  54492. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54493. /**
  54494. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54495. * @param data contains the texture data
  54496. * @param texture defines the BabylonJS internal texture
  54497. * @param callback defines the method to call once ready to upload
  54498. */
  54499. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54500. }
  54501. }
  54502. declare module "babylonjs/Misc/basis" {
  54503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54504. /**
  54505. * Info about the .basis files
  54506. */
  54507. class BasisFileInfo {
  54508. /**
  54509. * If the file has alpha
  54510. */
  54511. hasAlpha: boolean;
  54512. /**
  54513. * Info about each image of the basis file
  54514. */
  54515. images: Array<{
  54516. levels: Array<{
  54517. width: number;
  54518. height: number;
  54519. transcodedPixels: ArrayBufferView;
  54520. }>;
  54521. }>;
  54522. }
  54523. /**
  54524. * Result of transcoding a basis file
  54525. */
  54526. class TranscodeResult {
  54527. /**
  54528. * Info about the .basis file
  54529. */
  54530. fileInfo: BasisFileInfo;
  54531. /**
  54532. * Format to use when loading the file
  54533. */
  54534. format: number;
  54535. }
  54536. /**
  54537. * Configuration options for the Basis transcoder
  54538. */
  54539. export class BasisTranscodeConfiguration {
  54540. /**
  54541. * Supported compression formats used to determine the supported output format of the transcoder
  54542. */
  54543. supportedCompressionFormats?: {
  54544. /**
  54545. * etc1 compression format
  54546. */
  54547. etc1?: boolean;
  54548. /**
  54549. * s3tc compression format
  54550. */
  54551. s3tc?: boolean;
  54552. /**
  54553. * pvrtc compression format
  54554. */
  54555. pvrtc?: boolean;
  54556. /**
  54557. * etc2 compression format
  54558. */
  54559. etc2?: boolean;
  54560. };
  54561. /**
  54562. * If mipmap levels should be loaded for transcoded images (Default: true)
  54563. */
  54564. loadMipmapLevels?: boolean;
  54565. /**
  54566. * Index of a single image to load (Default: all images)
  54567. */
  54568. loadSingleImage?: number;
  54569. }
  54570. /**
  54571. * Used to load .Basis files
  54572. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54573. */
  54574. export class BasisTools {
  54575. private static _IgnoreSupportedFormats;
  54576. /**
  54577. * URL to use when loading the basis transcoder
  54578. */
  54579. static JSModuleURL: string;
  54580. /**
  54581. * URL to use when loading the wasm module for the transcoder
  54582. */
  54583. static WasmModuleURL: string;
  54584. /**
  54585. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54586. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54587. * @returns internal format corresponding to the Basis format
  54588. */
  54589. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54590. private static _WorkerPromise;
  54591. private static _Worker;
  54592. private static _actionId;
  54593. private static _CreateWorkerAsync;
  54594. /**
  54595. * Transcodes a loaded image file to compressed pixel data
  54596. * @param imageData image data to transcode
  54597. * @param config configuration options for the transcoding
  54598. * @returns a promise resulting in the transcoded image
  54599. */
  54600. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54601. /**
  54602. * Loads a texture from the transcode result
  54603. * @param texture texture load to
  54604. * @param transcodeResult the result of transcoding the basis file to load from
  54605. */
  54606. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54607. }
  54608. }
  54609. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54610. import { Nullable } from "babylonjs/types";
  54611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54612. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54613. /**
  54614. * Loader for .basis file format
  54615. */
  54616. export class _BasisTextureLoader implements IInternalTextureLoader {
  54617. /**
  54618. * Defines whether the loader supports cascade loading the different faces.
  54619. */
  54620. readonly supportCascades: boolean;
  54621. /**
  54622. * This returns if the loader support the current file information.
  54623. * @param extension defines the file extension of the file being loaded
  54624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54625. * @param fallback defines the fallback internal texture if any
  54626. * @param isBase64 defines whether the texture is encoded as a base64
  54627. * @param isBuffer defines whether the texture data are stored as a buffer
  54628. * @returns true if the loader can load the specified file
  54629. */
  54630. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54631. /**
  54632. * Transform the url before loading if required.
  54633. * @param rootUrl the url of the texture
  54634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54635. * @returns the transformed texture
  54636. */
  54637. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54638. /**
  54639. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54640. * @param rootUrl the url of the texture
  54641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54642. * @returns the fallback texture
  54643. */
  54644. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54645. /**
  54646. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54647. * @param data contains the texture data
  54648. * @param texture defines the BabylonJS internal texture
  54649. * @param createPolynomials will be true if polynomials have been requested
  54650. * @param onLoad defines the callback to trigger once the texture is ready
  54651. * @param onError defines the callback to trigger in case of error
  54652. */
  54653. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54654. /**
  54655. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54656. * @param data contains the texture data
  54657. * @param texture defines the BabylonJS internal texture
  54658. * @param callback defines the method to call once ready to upload
  54659. */
  54660. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54661. }
  54662. }
  54663. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54664. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54665. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54666. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54667. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54668. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54669. }
  54670. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54671. import { Scene } from "babylonjs/scene";
  54672. import { Texture } from "babylonjs/Materials/Textures/texture";
  54673. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54674. /**
  54675. * 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.
  54676. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54678. */
  54679. export class CustomProceduralTexture extends ProceduralTexture {
  54680. private _animate;
  54681. private _time;
  54682. private _config;
  54683. private _texturePath;
  54684. /**
  54685. * Instantiates a new Custom Procedural Texture.
  54686. * 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.
  54687. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54688. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54689. * @param name Define the name of the texture
  54690. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54691. * @param size Define the size of the texture to create
  54692. * @param scene Define the scene the texture belongs to
  54693. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54694. * @param generateMipMaps Define if the texture should creates mip maps or not
  54695. */
  54696. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54697. private _loadJson;
  54698. /**
  54699. * Is the texture ready to be used ? (rendered at least once)
  54700. * @returns true if ready, otherwise, false.
  54701. */
  54702. isReady(): boolean;
  54703. /**
  54704. * Render the texture to its associated render target.
  54705. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54706. */
  54707. render(useCameraPostProcess?: boolean): void;
  54708. /**
  54709. * Update the list of dependant textures samplers in the shader.
  54710. */
  54711. updateTextures(): void;
  54712. /**
  54713. * Update the uniform values of the procedural texture in the shader.
  54714. */
  54715. updateShaderUniforms(): void;
  54716. /**
  54717. * Define if the texture animates or not.
  54718. */
  54719. animate: boolean;
  54720. }
  54721. }
  54722. declare module "babylonjs/Shaders/noise.fragment" {
  54723. /** @hidden */
  54724. export var noisePixelShader: {
  54725. name: string;
  54726. shader: string;
  54727. };
  54728. }
  54729. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54730. import { Nullable } from "babylonjs/types";
  54731. import { Scene } from "babylonjs/scene";
  54732. import { Texture } from "babylonjs/Materials/Textures/texture";
  54733. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54734. import "babylonjs/Shaders/noise.fragment";
  54735. /**
  54736. * Class used to generate noise procedural textures
  54737. */
  54738. export class NoiseProceduralTexture extends ProceduralTexture {
  54739. private _time;
  54740. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54741. brightness: number;
  54742. /** Defines the number of octaves to process */
  54743. octaves: number;
  54744. /** Defines the level of persistence (0.8 by default) */
  54745. persistence: number;
  54746. /** Gets or sets animation speed factor (default is 1) */
  54747. animationSpeedFactor: number;
  54748. /**
  54749. * Creates a new NoiseProceduralTexture
  54750. * @param name defines the name fo the texture
  54751. * @param size defines the size of the texture (default is 256)
  54752. * @param scene defines the hosting scene
  54753. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54754. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54755. */
  54756. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54757. private _updateShaderUniforms;
  54758. protected _getDefines(): string;
  54759. /** Generate the current state of the procedural texture */
  54760. render(useCameraPostProcess?: boolean): void;
  54761. /**
  54762. * Serializes this noise procedural texture
  54763. * @returns a serialized noise procedural texture object
  54764. */
  54765. serialize(): any;
  54766. /**
  54767. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54768. * @param parsedTexture defines parsed texture data
  54769. * @param scene defines the current scene
  54770. * @param rootUrl defines the root URL containing noise procedural texture information
  54771. * @returns a parsed NoiseProceduralTexture
  54772. */
  54773. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54774. }
  54775. }
  54776. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54777. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54778. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54779. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54780. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54781. }
  54782. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54783. import { Nullable } from "babylonjs/types";
  54784. import { Scene } from "babylonjs/scene";
  54785. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54786. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54787. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54788. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54789. /**
  54790. * Raw cube texture where the raw buffers are passed in
  54791. */
  54792. export class RawCubeTexture extends CubeTexture {
  54793. /**
  54794. * Creates a cube texture where the raw buffers are passed in.
  54795. * @param scene defines the scene the texture is attached to
  54796. * @param data defines the array of data to use to create each face
  54797. * @param size defines the size of the textures
  54798. * @param format defines the format of the data
  54799. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54800. * @param generateMipMaps defines if the engine should generate the mip levels
  54801. * @param invertY defines if data must be stored with Y axis inverted
  54802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54803. * @param compression defines the compression used (null by default)
  54804. */
  54805. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54806. /**
  54807. * Updates the raw cube texture.
  54808. * @param data defines the data to store
  54809. * @param format defines the data format
  54810. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54811. * @param invertY defines if data must be stored with Y axis inverted
  54812. * @param compression defines the compression used (null by default)
  54813. * @param level defines which level of the texture to update
  54814. */
  54815. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54816. /**
  54817. * Updates a raw cube texture with RGBD encoded data.
  54818. * @param data defines the array of data [mipmap][face] to use to create each face
  54819. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54820. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54821. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54822. * @returns a promsie that resolves when the operation is complete
  54823. */
  54824. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54825. /**
  54826. * Clones the raw cube texture.
  54827. * @return a new cube texture
  54828. */
  54829. clone(): CubeTexture;
  54830. /** @hidden */
  54831. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54832. }
  54833. }
  54834. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54835. import { Scene } from "babylonjs/scene";
  54836. import { Texture } from "babylonjs/Materials/Textures/texture";
  54837. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54838. /**
  54839. * Class used to store 3D textures containing user data
  54840. */
  54841. export class RawTexture3D extends Texture {
  54842. /** Gets or sets the texture format to use */
  54843. format: number;
  54844. private _engine;
  54845. /**
  54846. * Create a new RawTexture3D
  54847. * @param data defines the data of the texture
  54848. * @param width defines the width of the texture
  54849. * @param height defines the height of the texture
  54850. * @param depth defines the depth of the texture
  54851. * @param format defines the texture format to use
  54852. * @param scene defines the hosting scene
  54853. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54854. * @param invertY defines if texture must be stored with Y axis inverted
  54855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54856. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54857. */
  54858. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54859. /** Gets or sets the texture format to use */
  54860. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54861. /**
  54862. * Update the texture with new data
  54863. * @param data defines the data to store in the texture
  54864. */
  54865. update(data: ArrayBufferView): void;
  54866. }
  54867. }
  54868. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54869. import { Scene } from "babylonjs/scene";
  54870. import { Plane } from "babylonjs/Maths/math.plane";
  54871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54872. /**
  54873. * Creates a refraction texture used by refraction channel of the standard material.
  54874. * It is like a mirror but to see through a material.
  54875. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54876. */
  54877. export class RefractionTexture extends RenderTargetTexture {
  54878. /**
  54879. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54880. * 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.
  54881. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54882. */
  54883. refractionPlane: Plane;
  54884. /**
  54885. * Define how deep under the surface we should see.
  54886. */
  54887. depth: number;
  54888. /**
  54889. * Creates a refraction texture used by refraction channel of the standard material.
  54890. * It is like a mirror but to see through a material.
  54891. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54892. * @param name Define the texture name
  54893. * @param size Define the size of the underlying texture
  54894. * @param scene Define the scene the refraction belongs to
  54895. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54896. */
  54897. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54898. /**
  54899. * Clone the refraction texture.
  54900. * @returns the cloned texture
  54901. */
  54902. clone(): RefractionTexture;
  54903. /**
  54904. * Serialize the texture to a JSON representation you could use in Parse later on
  54905. * @returns the serialized JSON representation
  54906. */
  54907. serialize(): any;
  54908. }
  54909. }
  54910. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54911. import { Nullable } from "babylonjs/types";
  54912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54913. import { Matrix } from "babylonjs/Maths/math.vector";
  54914. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54915. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54916. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54917. import { Scene } from "babylonjs/scene";
  54918. /**
  54919. * Defines the options related to the creation of an HtmlElementTexture
  54920. */
  54921. export interface IHtmlElementTextureOptions {
  54922. /**
  54923. * Defines wether mip maps should be created or not.
  54924. */
  54925. generateMipMaps?: boolean;
  54926. /**
  54927. * Defines the sampling mode of the texture.
  54928. */
  54929. samplingMode?: number;
  54930. /**
  54931. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54932. */
  54933. engine: Nullable<ThinEngine>;
  54934. /**
  54935. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54936. */
  54937. scene: Nullable<Scene>;
  54938. }
  54939. /**
  54940. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54941. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54942. * is automatically managed.
  54943. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54944. * in your application.
  54945. *
  54946. * As the update is not automatic, you need to call them manually.
  54947. */
  54948. export class HtmlElementTexture extends BaseTexture {
  54949. /**
  54950. * The texture URL.
  54951. */
  54952. element: HTMLVideoElement | HTMLCanvasElement;
  54953. private static readonly DefaultOptions;
  54954. private _textureMatrix;
  54955. private _engine;
  54956. private _isVideo;
  54957. private _generateMipMaps;
  54958. private _samplingMode;
  54959. /**
  54960. * Instantiates a HtmlElementTexture from the following parameters.
  54961. *
  54962. * @param name Defines the name of the texture
  54963. * @param element Defines the video or canvas the texture is filled with
  54964. * @param options Defines the other none mandatory texture creation options
  54965. */
  54966. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54967. private _createInternalTexture;
  54968. /**
  54969. * Returns the texture matrix used in most of the material.
  54970. */
  54971. getTextureMatrix(): Matrix;
  54972. /**
  54973. * Updates the content of the texture.
  54974. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54975. */
  54976. update(invertY?: Nullable<boolean>): void;
  54977. }
  54978. }
  54979. declare module "babylonjs/Materials/Textures/index" {
  54980. export * from "babylonjs/Materials/Textures/baseTexture";
  54981. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54982. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54983. export * from "babylonjs/Materials/Textures/cubeTexture";
  54984. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54985. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54986. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54987. export * from "babylonjs/Materials/Textures/internalTexture";
  54988. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54989. export * from "babylonjs/Materials/Textures/Loaders/index";
  54990. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54991. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54992. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54993. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54994. export * from "babylonjs/Materials/Textures/rawTexture";
  54995. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54996. export * from "babylonjs/Materials/Textures/refractionTexture";
  54997. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54998. export * from "babylonjs/Materials/Textures/texture";
  54999. export * from "babylonjs/Materials/Textures/videoTexture";
  55000. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55001. }
  55002. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55003. /**
  55004. * Enum used to define the target of a block
  55005. */
  55006. export enum NodeMaterialBlockTargets {
  55007. /** Vertex shader */
  55008. Vertex = 1,
  55009. /** Fragment shader */
  55010. Fragment = 2,
  55011. /** Neutral */
  55012. Neutral = 4,
  55013. /** Vertex and Fragment */
  55014. VertexAndFragment = 3
  55015. }
  55016. }
  55017. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55018. /**
  55019. * Defines the kind of connection point for node based material
  55020. */
  55021. export enum NodeMaterialBlockConnectionPointTypes {
  55022. /** Float */
  55023. Float = 1,
  55024. /** Int */
  55025. Int = 2,
  55026. /** Vector2 */
  55027. Vector2 = 4,
  55028. /** Vector3 */
  55029. Vector3 = 8,
  55030. /** Vector4 */
  55031. Vector4 = 16,
  55032. /** Color3 */
  55033. Color3 = 32,
  55034. /** Color4 */
  55035. Color4 = 64,
  55036. /** Matrix */
  55037. Matrix = 128,
  55038. /** Detect type based on connection */
  55039. AutoDetect = 1024,
  55040. /** Output type that will be defined by input type */
  55041. BasedOnInput = 2048
  55042. }
  55043. }
  55044. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55045. /**
  55046. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55047. */
  55048. export enum NodeMaterialBlockConnectionPointMode {
  55049. /** Value is an uniform */
  55050. Uniform = 0,
  55051. /** Value is a mesh attribute */
  55052. Attribute = 1,
  55053. /** Value is a varying between vertex and fragment shaders */
  55054. Varying = 2,
  55055. /** Mode is undefined */
  55056. Undefined = 3
  55057. }
  55058. }
  55059. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55060. /**
  55061. * Enum used to define system values e.g. values automatically provided by the system
  55062. */
  55063. export enum NodeMaterialSystemValues {
  55064. /** World */
  55065. World = 1,
  55066. /** View */
  55067. View = 2,
  55068. /** Projection */
  55069. Projection = 3,
  55070. /** ViewProjection */
  55071. ViewProjection = 4,
  55072. /** WorldView */
  55073. WorldView = 5,
  55074. /** WorldViewProjection */
  55075. WorldViewProjection = 6,
  55076. /** CameraPosition */
  55077. CameraPosition = 7,
  55078. /** Fog Color */
  55079. FogColor = 8,
  55080. /** Delta time */
  55081. DeltaTime = 9
  55082. }
  55083. }
  55084. declare module "babylonjs/Materials/Node/Enums/index" {
  55085. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55086. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55087. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55088. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55089. }
  55090. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55092. /**
  55093. * Root class for all node material optimizers
  55094. */
  55095. export class NodeMaterialOptimizer {
  55096. /**
  55097. * Function used to optimize a NodeMaterial graph
  55098. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55099. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55100. */
  55101. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55102. }
  55103. }
  55104. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55108. import { Scene } from "babylonjs/scene";
  55109. /**
  55110. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55111. */
  55112. export class TransformBlock extends NodeMaterialBlock {
  55113. /**
  55114. * Defines the value to use to complement W value to transform it to a Vector4
  55115. */
  55116. complementW: number;
  55117. /**
  55118. * Defines the value to use to complement z value to transform it to a Vector4
  55119. */
  55120. complementZ: number;
  55121. /**
  55122. * Creates a new TransformBlock
  55123. * @param name defines the block name
  55124. */
  55125. constructor(name: string);
  55126. /**
  55127. * Gets the current class name
  55128. * @returns the class name
  55129. */
  55130. getClassName(): string;
  55131. /**
  55132. * Gets the vector input
  55133. */
  55134. readonly vector: NodeMaterialConnectionPoint;
  55135. /**
  55136. * Gets the output component
  55137. */
  55138. readonly output: NodeMaterialConnectionPoint;
  55139. /**
  55140. * Gets the matrix transform input
  55141. */
  55142. readonly transform: NodeMaterialConnectionPoint;
  55143. protected _buildBlock(state: NodeMaterialBuildState): this;
  55144. serialize(): any;
  55145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55146. protected _dumpPropertiesCode(): string;
  55147. }
  55148. }
  55149. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55153. /**
  55154. * Block used to output the vertex position
  55155. */
  55156. export class VertexOutputBlock extends NodeMaterialBlock {
  55157. /**
  55158. * Creates a new VertexOutputBlock
  55159. * @param name defines the block name
  55160. */
  55161. constructor(name: string);
  55162. /**
  55163. * Gets the current class name
  55164. * @returns the class name
  55165. */
  55166. getClassName(): string;
  55167. /**
  55168. * Gets the vector input component
  55169. */
  55170. readonly vector: NodeMaterialConnectionPoint;
  55171. protected _buildBlock(state: NodeMaterialBuildState): this;
  55172. }
  55173. }
  55174. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55178. /**
  55179. * Block used to output the final color
  55180. */
  55181. export class FragmentOutputBlock extends NodeMaterialBlock {
  55182. /**
  55183. * Create a new FragmentOutputBlock
  55184. * @param name defines the block name
  55185. */
  55186. constructor(name: string);
  55187. /**
  55188. * Gets the current class name
  55189. * @returns the class name
  55190. */
  55191. getClassName(): string;
  55192. /**
  55193. * Gets the rgba input component
  55194. */
  55195. readonly rgba: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the rgb input component
  55198. */
  55199. readonly rgb: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the a input component
  55202. */
  55203. readonly a: NodeMaterialConnectionPoint;
  55204. protected _buildBlock(state: NodeMaterialBuildState): this;
  55205. }
  55206. }
  55207. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55213. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55214. import { Effect } from "babylonjs/Materials/effect";
  55215. import { Mesh } from "babylonjs/Meshes/mesh";
  55216. import { Nullable } from "babylonjs/types";
  55217. import { Scene } from "babylonjs/scene";
  55218. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55219. /**
  55220. * Block used to read a reflection texture from a sampler
  55221. */
  55222. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55223. private _define3DName;
  55224. private _defineCubicName;
  55225. private _defineExplicitName;
  55226. private _defineProjectionName;
  55227. private _defineLocalCubicName;
  55228. private _defineSphericalName;
  55229. private _definePlanarName;
  55230. private _defineEquirectangularName;
  55231. private _defineMirroredEquirectangularFixedName;
  55232. private _defineEquirectangularFixedName;
  55233. private _defineSkyboxName;
  55234. private _cubeSamplerName;
  55235. private _2DSamplerName;
  55236. private _positionUVWName;
  55237. private _directionWName;
  55238. private _reflectionCoordsName;
  55239. private _reflection2DCoordsName;
  55240. private _reflectionColorName;
  55241. private _reflectionMatrixName;
  55242. /**
  55243. * Gets or sets the texture associated with the node
  55244. */
  55245. texture: Nullable<BaseTexture>;
  55246. /**
  55247. * Create a new TextureBlock
  55248. * @param name defines the block name
  55249. */
  55250. constructor(name: string);
  55251. /**
  55252. * Gets the current class name
  55253. * @returns the class name
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Gets the world position input component
  55258. */
  55259. readonly position: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the world position input component
  55262. */
  55263. readonly worldPosition: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the world normal input component
  55266. */
  55267. readonly worldNormal: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the world input component
  55270. */
  55271. readonly world: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the camera (or eye) position component
  55274. */
  55275. readonly cameraPosition: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the view input component
  55278. */
  55279. readonly view: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the rgb output component
  55282. */
  55283. readonly rgb: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the r output component
  55286. */
  55287. readonly r: NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the g output component
  55290. */
  55291. readonly g: NodeMaterialConnectionPoint;
  55292. /**
  55293. * Gets the b output component
  55294. */
  55295. readonly b: NodeMaterialConnectionPoint;
  55296. autoConfigure(material: NodeMaterial): void;
  55297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55298. isReady(): boolean;
  55299. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55300. private _injectVertexCode;
  55301. private _writeOutput;
  55302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55303. serialize(): any;
  55304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55305. }
  55306. }
  55307. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55309. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55310. import { Scene } from "babylonjs/scene";
  55311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55312. import { Matrix } from "babylonjs/Maths/math.vector";
  55313. import { Mesh } from "babylonjs/Meshes/mesh";
  55314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55315. import { Observable } from "babylonjs/Misc/observable";
  55316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55317. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55318. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55319. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55320. import { Nullable } from "babylonjs/types";
  55321. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55322. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55323. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55324. /**
  55325. * Interface used to configure the node material editor
  55326. */
  55327. export interface INodeMaterialEditorOptions {
  55328. /** Define the URl to load node editor script */
  55329. editorURL?: string;
  55330. }
  55331. /** @hidden */
  55332. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55333. /** BONES */
  55334. NUM_BONE_INFLUENCERS: number;
  55335. BonesPerMesh: number;
  55336. BONETEXTURE: boolean;
  55337. /** MORPH TARGETS */
  55338. MORPHTARGETS: boolean;
  55339. MORPHTARGETS_NORMAL: boolean;
  55340. MORPHTARGETS_TANGENT: boolean;
  55341. MORPHTARGETS_UV: boolean;
  55342. NUM_MORPH_INFLUENCERS: number;
  55343. /** IMAGE PROCESSING */
  55344. IMAGEPROCESSING: boolean;
  55345. VIGNETTE: boolean;
  55346. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55347. VIGNETTEBLENDMODEOPAQUE: boolean;
  55348. TONEMAPPING: boolean;
  55349. TONEMAPPING_ACES: boolean;
  55350. CONTRAST: boolean;
  55351. EXPOSURE: boolean;
  55352. COLORCURVES: boolean;
  55353. COLORGRADING: boolean;
  55354. COLORGRADING3D: boolean;
  55355. SAMPLER3DGREENDEPTH: boolean;
  55356. SAMPLER3DBGRMAP: boolean;
  55357. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55358. /** MISC. */
  55359. BUMPDIRECTUV: number;
  55360. constructor();
  55361. setValue(name: string, value: boolean): void;
  55362. }
  55363. /**
  55364. * Class used to configure NodeMaterial
  55365. */
  55366. export interface INodeMaterialOptions {
  55367. /**
  55368. * Defines if blocks should emit comments
  55369. */
  55370. emitComments: boolean;
  55371. }
  55372. /**
  55373. * Class used to create a node based material built by assembling shader blocks
  55374. */
  55375. export class NodeMaterial extends PushMaterial {
  55376. private static _BuildIdGenerator;
  55377. private _options;
  55378. private _vertexCompilationState;
  55379. private _fragmentCompilationState;
  55380. private _sharedData;
  55381. private _buildId;
  55382. private _buildWasSuccessful;
  55383. private _cachedWorldViewMatrix;
  55384. private _cachedWorldViewProjectionMatrix;
  55385. private _optimizers;
  55386. private _animationFrame;
  55387. /** Define the URl to load node editor script */
  55388. static EditorURL: string;
  55389. private BJSNODEMATERIALEDITOR;
  55390. /** Get the inspector from bundle or global */
  55391. private _getGlobalNodeMaterialEditor;
  55392. /**
  55393. * 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)
  55394. */
  55395. ignoreAlpha: boolean;
  55396. /**
  55397. * Defines the maximum number of lights that can be used in the material
  55398. */
  55399. maxSimultaneousLights: number;
  55400. /**
  55401. * Observable raised when the material is built
  55402. */
  55403. onBuildObservable: Observable<NodeMaterial>;
  55404. /**
  55405. * Gets or sets the root nodes of the material vertex shader
  55406. */
  55407. _vertexOutputNodes: NodeMaterialBlock[];
  55408. /**
  55409. * Gets or sets the root nodes of the material fragment (pixel) shader
  55410. */
  55411. _fragmentOutputNodes: NodeMaterialBlock[];
  55412. /** Gets or sets options to control the node material overall behavior */
  55413. options: INodeMaterialOptions;
  55414. /**
  55415. * Default configuration related to image processing available in the standard Material.
  55416. */
  55417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55418. /**
  55419. * Gets the image processing configuration used either in this material.
  55420. */
  55421. /**
  55422. * Sets the Default image processing configuration used either in the this material.
  55423. *
  55424. * If sets to null, the scene one is in use.
  55425. */
  55426. imageProcessingConfiguration: ImageProcessingConfiguration;
  55427. /**
  55428. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55429. */
  55430. attachedBlocks: NodeMaterialBlock[];
  55431. /**
  55432. * Create a new node based material
  55433. * @param name defines the material name
  55434. * @param scene defines the hosting scene
  55435. * @param options defines creation option
  55436. */
  55437. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55438. /**
  55439. * Gets the current class name of the material e.g. "NodeMaterial"
  55440. * @returns the class name
  55441. */
  55442. getClassName(): string;
  55443. /**
  55444. * Keep track of the image processing observer to allow dispose and replace.
  55445. */
  55446. private _imageProcessingObserver;
  55447. /**
  55448. * Attaches a new image processing configuration to the Standard Material.
  55449. * @param configuration
  55450. */
  55451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55452. /**
  55453. * Get a block by its name
  55454. * @param name defines the name of the block to retrieve
  55455. * @returns the required block or null if not found
  55456. */
  55457. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55458. /**
  55459. * Get a block by its name
  55460. * @param predicate defines the predicate used to find the good candidate
  55461. * @returns the required block or null if not found
  55462. */
  55463. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55464. /**
  55465. * Get an input block by its name
  55466. * @param predicate defines the predicate used to find the good candidate
  55467. * @returns the required input block or null if not found
  55468. */
  55469. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55470. /**
  55471. * Gets the list of input blocks attached to this material
  55472. * @returns an array of InputBlocks
  55473. */
  55474. getInputBlocks(): InputBlock[];
  55475. /**
  55476. * Adds a new optimizer to the list of optimizers
  55477. * @param optimizer defines the optimizers to add
  55478. * @returns the current material
  55479. */
  55480. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55481. /**
  55482. * Remove an optimizer from the list of optimizers
  55483. * @param optimizer defines the optimizers to remove
  55484. * @returns the current material
  55485. */
  55486. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55487. /**
  55488. * Add a new block to the list of output nodes
  55489. * @param node defines the node to add
  55490. * @returns the current material
  55491. */
  55492. addOutputNode(node: NodeMaterialBlock): this;
  55493. /**
  55494. * Remove a block from the list of root nodes
  55495. * @param node defines the node to remove
  55496. * @returns the current material
  55497. */
  55498. removeOutputNode(node: NodeMaterialBlock): this;
  55499. private _addVertexOutputNode;
  55500. private _removeVertexOutputNode;
  55501. private _addFragmentOutputNode;
  55502. private _removeFragmentOutputNode;
  55503. /**
  55504. * Specifies if the material will require alpha blending
  55505. * @returns a boolean specifying if alpha blending is needed
  55506. */
  55507. needAlphaBlending(): boolean;
  55508. /**
  55509. * Specifies if this material should be rendered in alpha test mode
  55510. * @returns a boolean specifying if an alpha test is needed.
  55511. */
  55512. needAlphaTesting(): boolean;
  55513. private _initializeBlock;
  55514. private _resetDualBlocks;
  55515. /**
  55516. * Build the material and generates the inner effect
  55517. * @param verbose defines if the build should log activity
  55518. */
  55519. build(verbose?: boolean): void;
  55520. /**
  55521. * Runs an otpimization phase to try to improve the shader code
  55522. */
  55523. optimize(): void;
  55524. private _prepareDefinesForAttributes;
  55525. /**
  55526. * Get if the submesh is ready to be used and all its information available.
  55527. * Child classes can use it to update shaders
  55528. * @param mesh defines the mesh to check
  55529. * @param subMesh defines which submesh to check
  55530. * @param useInstances specifies that instances should be used
  55531. * @returns a boolean indicating that the submesh is ready or not
  55532. */
  55533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55534. /**
  55535. * Get a string representing the shaders built by the current node graph
  55536. */
  55537. readonly compiledShaders: string;
  55538. /**
  55539. * Binds the world matrix to the material
  55540. * @param world defines the world transformation matrix
  55541. */
  55542. bindOnlyWorldMatrix(world: Matrix): void;
  55543. /**
  55544. * Binds the submesh to this material by preparing the effect and shader to draw
  55545. * @param world defines the world transformation matrix
  55546. * @param mesh defines the mesh containing the submesh
  55547. * @param subMesh defines the submesh to bind the material to
  55548. */
  55549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55550. /**
  55551. * Gets the active textures from the material
  55552. * @returns an array of textures
  55553. */
  55554. getActiveTextures(): BaseTexture[];
  55555. /**
  55556. * Gets the list of texture blocks
  55557. * @returns an array of texture blocks
  55558. */
  55559. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55560. /**
  55561. * Specifies if the material uses a texture
  55562. * @param texture defines the texture to check against the material
  55563. * @returns a boolean specifying if the material uses the texture
  55564. */
  55565. hasTexture(texture: BaseTexture): boolean;
  55566. /**
  55567. * Disposes the material
  55568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55570. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55571. */
  55572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55573. /** Creates the node editor window. */
  55574. private _createNodeEditor;
  55575. /**
  55576. * Launch the node material editor
  55577. * @param config Define the configuration of the editor
  55578. * @return a promise fulfilled when the node editor is visible
  55579. */
  55580. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55581. /**
  55582. * Clear the current material
  55583. */
  55584. clear(): void;
  55585. /**
  55586. * Clear the current material and set it to a default state
  55587. */
  55588. setToDefault(): void;
  55589. /**
  55590. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55591. * @param url defines the url to load from
  55592. * @returns a promise that will fullfil when the material is fully loaded
  55593. */
  55594. loadAsync(url: string): Promise<unknown>;
  55595. private _gatherBlocks;
  55596. /**
  55597. * Generate a string containing the code declaration required to create an equivalent of this material
  55598. * @returns a string
  55599. */
  55600. generateCode(): string;
  55601. /**
  55602. * Serializes this material in a JSON representation
  55603. * @returns the serialized material object
  55604. */
  55605. serialize(): any;
  55606. private _restoreConnections;
  55607. /**
  55608. * Clear the current graph and load a new one from a serialization object
  55609. * @param source defines the JSON representation of the material
  55610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55611. */
  55612. loadFromSerialization(source: any, rootUrl?: string): void;
  55613. /**
  55614. * Creates a node material from parsed material data
  55615. * @param source defines the JSON representation of the material
  55616. * @param scene defines the hosting scene
  55617. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55618. * @returns a new node material
  55619. */
  55620. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55621. /**
  55622. * Creates a new node material set to default basic configuration
  55623. * @param name defines the name of the material
  55624. * @param scene defines the hosting scene
  55625. * @returns a new NodeMaterial
  55626. */
  55627. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55628. }
  55629. }
  55630. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55633. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55636. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55637. import { Effect } from "babylonjs/Materials/effect";
  55638. import { Mesh } from "babylonjs/Meshes/mesh";
  55639. import { Nullable } from "babylonjs/types";
  55640. import { Texture } from "babylonjs/Materials/Textures/texture";
  55641. import { Scene } from "babylonjs/scene";
  55642. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55643. /**
  55644. * Block used to read a texture from a sampler
  55645. */
  55646. export class TextureBlock extends NodeMaterialBlock {
  55647. private _defineName;
  55648. private _linearDefineName;
  55649. private _samplerName;
  55650. private _transformedUVName;
  55651. private _textureTransformName;
  55652. private _textureInfoName;
  55653. private _mainUVName;
  55654. private _mainUVDefineName;
  55655. /**
  55656. * Gets or sets the texture associated with the node
  55657. */
  55658. texture: Nullable<Texture>;
  55659. /**
  55660. * Create a new TextureBlock
  55661. * @param name defines the block name
  55662. */
  55663. constructor(name: string);
  55664. /**
  55665. * Gets the current class name
  55666. * @returns the class name
  55667. */
  55668. getClassName(): string;
  55669. /**
  55670. * Gets the uv input component
  55671. */
  55672. readonly uv: NodeMaterialConnectionPoint;
  55673. /**
  55674. * Gets the rgba output component
  55675. */
  55676. readonly rgba: NodeMaterialConnectionPoint;
  55677. /**
  55678. * Gets the rgb output component
  55679. */
  55680. readonly rgb: NodeMaterialConnectionPoint;
  55681. /**
  55682. * Gets the r output component
  55683. */
  55684. readonly r: NodeMaterialConnectionPoint;
  55685. /**
  55686. * Gets the g output component
  55687. */
  55688. readonly g: NodeMaterialConnectionPoint;
  55689. /**
  55690. * Gets the b output component
  55691. */
  55692. readonly b: NodeMaterialConnectionPoint;
  55693. /**
  55694. * Gets the a output component
  55695. */
  55696. readonly a: NodeMaterialConnectionPoint;
  55697. readonly target: NodeMaterialBlockTargets;
  55698. autoConfigure(material: NodeMaterial): void;
  55699. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55700. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55701. isReady(): boolean;
  55702. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55703. private readonly _isMixed;
  55704. private _injectVertexCode;
  55705. private _writeOutput;
  55706. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55707. protected _dumpPropertiesCode(): string;
  55708. serialize(): any;
  55709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55710. }
  55711. }
  55712. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55715. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55716. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55717. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55718. import { Scene } from "babylonjs/scene";
  55719. /**
  55720. * Class used to store shared data between 2 NodeMaterialBuildState
  55721. */
  55722. export class NodeMaterialBuildStateSharedData {
  55723. /**
  55724. * Gets the list of emitted varyings
  55725. */
  55726. temps: string[];
  55727. /**
  55728. * Gets the list of emitted varyings
  55729. */
  55730. varyings: string[];
  55731. /**
  55732. * Gets the varying declaration string
  55733. */
  55734. varyingDeclaration: string;
  55735. /**
  55736. * Input blocks
  55737. */
  55738. inputBlocks: InputBlock[];
  55739. /**
  55740. * Input blocks
  55741. */
  55742. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55743. /**
  55744. * Bindable blocks (Blocks that need to set data to the effect)
  55745. */
  55746. bindableBlocks: NodeMaterialBlock[];
  55747. /**
  55748. * List of blocks that can provide a compilation fallback
  55749. */
  55750. blocksWithFallbacks: NodeMaterialBlock[];
  55751. /**
  55752. * List of blocks that can provide a define update
  55753. */
  55754. blocksWithDefines: NodeMaterialBlock[];
  55755. /**
  55756. * List of blocks that can provide a repeatable content
  55757. */
  55758. repeatableContentBlocks: NodeMaterialBlock[];
  55759. /**
  55760. * List of blocks that can provide a dynamic list of uniforms
  55761. */
  55762. dynamicUniformBlocks: NodeMaterialBlock[];
  55763. /**
  55764. * List of blocks that can block the isReady function for the material
  55765. */
  55766. blockingBlocks: NodeMaterialBlock[];
  55767. /**
  55768. * Gets the list of animated inputs
  55769. */
  55770. animatedInputs: InputBlock[];
  55771. /**
  55772. * Build Id used to avoid multiple recompilations
  55773. */
  55774. buildId: number;
  55775. /** List of emitted variables */
  55776. variableNames: {
  55777. [key: string]: number;
  55778. };
  55779. /** List of emitted defines */
  55780. defineNames: {
  55781. [key: string]: number;
  55782. };
  55783. /** Should emit comments? */
  55784. emitComments: boolean;
  55785. /** Emit build activity */
  55786. verbose: boolean;
  55787. /** Gets or sets the hosting scene */
  55788. scene: Scene;
  55789. /**
  55790. * Gets the compilation hints emitted at compilation time
  55791. */
  55792. hints: {
  55793. needWorldViewMatrix: boolean;
  55794. needWorldViewProjectionMatrix: boolean;
  55795. needAlphaBlending: boolean;
  55796. needAlphaTesting: boolean;
  55797. };
  55798. /**
  55799. * List of compilation checks
  55800. */
  55801. checks: {
  55802. emitVertex: boolean;
  55803. emitFragment: boolean;
  55804. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55805. };
  55806. /** Creates a new shared data */
  55807. constructor();
  55808. /**
  55809. * Emits console errors and exceptions if there is a failing check
  55810. */
  55811. emitErrors(): void;
  55812. }
  55813. }
  55814. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55815. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55816. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55817. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55818. /**
  55819. * Class used to store node based material build state
  55820. */
  55821. export class NodeMaterialBuildState {
  55822. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55823. supportUniformBuffers: boolean;
  55824. /**
  55825. * Gets the list of emitted attributes
  55826. */
  55827. attributes: string[];
  55828. /**
  55829. * Gets the list of emitted uniforms
  55830. */
  55831. uniforms: string[];
  55832. /**
  55833. * Gets the list of emitted constants
  55834. */
  55835. constants: string[];
  55836. /**
  55837. * Gets the list of emitted samplers
  55838. */
  55839. samplers: string[];
  55840. /**
  55841. * Gets the list of emitted functions
  55842. */
  55843. functions: {
  55844. [key: string]: string;
  55845. };
  55846. /**
  55847. * Gets the list of emitted extensions
  55848. */
  55849. extensions: {
  55850. [key: string]: string;
  55851. };
  55852. /**
  55853. * Gets the target of the compilation state
  55854. */
  55855. target: NodeMaterialBlockTargets;
  55856. /**
  55857. * Gets the list of emitted counters
  55858. */
  55859. counters: {
  55860. [key: string]: number;
  55861. };
  55862. /**
  55863. * Shared data between multiple NodeMaterialBuildState instances
  55864. */
  55865. sharedData: NodeMaterialBuildStateSharedData;
  55866. /** @hidden */
  55867. _vertexState: NodeMaterialBuildState;
  55868. /** @hidden */
  55869. _attributeDeclaration: string;
  55870. /** @hidden */
  55871. _uniformDeclaration: string;
  55872. /** @hidden */
  55873. _constantDeclaration: string;
  55874. /** @hidden */
  55875. _samplerDeclaration: string;
  55876. /** @hidden */
  55877. _varyingTransfer: string;
  55878. private _repeatableContentAnchorIndex;
  55879. /** @hidden */
  55880. _builtCompilationString: string;
  55881. /**
  55882. * Gets the emitted compilation strings
  55883. */
  55884. compilationString: string;
  55885. /**
  55886. * Finalize the compilation strings
  55887. * @param state defines the current compilation state
  55888. */
  55889. finalize(state: NodeMaterialBuildState): void;
  55890. /** @hidden */
  55891. readonly _repeatableContentAnchor: string;
  55892. /** @hidden */
  55893. _getFreeVariableName(prefix: string): string;
  55894. /** @hidden */
  55895. _getFreeDefineName(prefix: string): string;
  55896. /** @hidden */
  55897. _excludeVariableName(name: string): void;
  55898. /** @hidden */
  55899. _emit2DSampler(name: string): void;
  55900. /** @hidden */
  55901. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55902. /** @hidden */
  55903. _emitExtension(name: string, extension: string): void;
  55904. /** @hidden */
  55905. _emitFunction(name: string, code: string, comments: string): void;
  55906. /** @hidden */
  55907. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55908. replaceStrings?: {
  55909. search: RegExp;
  55910. replace: string;
  55911. }[];
  55912. repeatKey?: string;
  55913. }): string;
  55914. /** @hidden */
  55915. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55916. repeatKey?: string;
  55917. removeAttributes?: boolean;
  55918. removeUniforms?: boolean;
  55919. removeVaryings?: boolean;
  55920. removeIfDef?: boolean;
  55921. replaceStrings?: {
  55922. search: RegExp;
  55923. replace: string;
  55924. }[];
  55925. }, storeKey?: string): void;
  55926. /** @hidden */
  55927. _registerTempVariable(name: string): boolean;
  55928. /** @hidden */
  55929. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55930. /** @hidden */
  55931. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55932. /** @hidden */
  55933. _emitFloat(value: number): string;
  55934. }
  55935. }
  55936. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55937. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55939. import { Nullable } from "babylonjs/types";
  55940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55941. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55942. import { Effect } from "babylonjs/Materials/effect";
  55943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55944. import { Mesh } from "babylonjs/Meshes/mesh";
  55945. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55946. import { Scene } from "babylonjs/scene";
  55947. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55948. /**
  55949. * Defines a block that can be used inside a node based material
  55950. */
  55951. export class NodeMaterialBlock {
  55952. private _buildId;
  55953. private _buildTarget;
  55954. private _target;
  55955. private _isFinalMerger;
  55956. private _isInput;
  55957. /** @hidden */
  55958. _codeVariableName: string;
  55959. /** @hidden */
  55960. _inputs: NodeMaterialConnectionPoint[];
  55961. /** @hidden */
  55962. _outputs: NodeMaterialConnectionPoint[];
  55963. /** @hidden */
  55964. _preparationId: number;
  55965. /**
  55966. * Gets or sets the name of the block
  55967. */
  55968. name: string;
  55969. /**
  55970. * Gets or sets the unique id of the node
  55971. */
  55972. uniqueId: number;
  55973. /**
  55974. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55975. */
  55976. readonly isFinalMerger: boolean;
  55977. /**
  55978. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55979. */
  55980. readonly isInput: boolean;
  55981. /**
  55982. * Gets or sets the build Id
  55983. */
  55984. buildId: number;
  55985. /**
  55986. * Gets or sets the target of the block
  55987. */
  55988. target: NodeMaterialBlockTargets;
  55989. /**
  55990. * Gets the list of input points
  55991. */
  55992. readonly inputs: NodeMaterialConnectionPoint[];
  55993. /** Gets the list of output points */
  55994. readonly outputs: NodeMaterialConnectionPoint[];
  55995. /**
  55996. * Find an input by its name
  55997. * @param name defines the name of the input to look for
  55998. * @returns the input or null if not found
  55999. */
  56000. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56001. /**
  56002. * Find an output by its name
  56003. * @param name defines the name of the outputto look for
  56004. * @returns the output or null if not found
  56005. */
  56006. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56007. /**
  56008. * Creates a new NodeMaterialBlock
  56009. * @param name defines the block name
  56010. * @param target defines the target of that block (Vertex by default)
  56011. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56012. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56013. */
  56014. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56015. /**
  56016. * Initialize the block and prepare the context for build
  56017. * @param state defines the state that will be used for the build
  56018. */
  56019. initialize(state: NodeMaterialBuildState): void;
  56020. /**
  56021. * Bind data to effect. Will only be called for blocks with isBindable === true
  56022. * @param effect defines the effect to bind data to
  56023. * @param nodeMaterial defines the hosting NodeMaterial
  56024. * @param mesh defines the mesh that will be rendered
  56025. */
  56026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56027. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56028. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56029. protected _writeFloat(value: number): string;
  56030. /**
  56031. * Gets the current class name e.g. "NodeMaterialBlock"
  56032. * @returns the class name
  56033. */
  56034. getClassName(): string;
  56035. /**
  56036. * Register a new input. Must be called inside a block constructor
  56037. * @param name defines the connection point name
  56038. * @param type defines the connection point type
  56039. * @param isOptional defines a boolean indicating that this input can be omitted
  56040. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56041. * @returns the current block
  56042. */
  56043. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56044. /**
  56045. * Register a new output. Must be called inside a block constructor
  56046. * @param name defines the connection point name
  56047. * @param type defines the connection point type
  56048. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56049. * @returns the current block
  56050. */
  56051. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56052. /**
  56053. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56054. * @param forOutput defines an optional connection point to check compatibility with
  56055. * @returns the first available input or null
  56056. */
  56057. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56058. /**
  56059. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56060. * @param forBlock defines an optional block to check compatibility with
  56061. * @returns the first available input or null
  56062. */
  56063. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56064. /**
  56065. * Gets the sibling of the given output
  56066. * @param current defines the current output
  56067. * @returns the next output in the list or null
  56068. */
  56069. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56070. /**
  56071. * Connect current block with another block
  56072. * @param other defines the block to connect with
  56073. * @param options define the various options to help pick the right connections
  56074. * @returns the current block
  56075. */
  56076. connectTo(other: NodeMaterialBlock, options?: {
  56077. input?: string;
  56078. output?: string;
  56079. outputSwizzle?: string;
  56080. }): this | undefined;
  56081. protected _buildBlock(state: NodeMaterialBuildState): void;
  56082. /**
  56083. * Add uniforms, samplers and uniform buffers at compilation time
  56084. * @param state defines the state to update
  56085. * @param nodeMaterial defines the node material requesting the update
  56086. * @param defines defines the material defines to update
  56087. * @param uniformBuffers defines the list of uniform buffer names
  56088. */
  56089. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56090. /**
  56091. * Add potential fallbacks if shader compilation fails
  56092. * @param mesh defines the mesh to be rendered
  56093. * @param fallbacks defines the current prioritized list of fallbacks
  56094. */
  56095. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56096. /**
  56097. * Initialize defines for shader compilation
  56098. * @param mesh defines the mesh to be rendered
  56099. * @param nodeMaterial defines the node material requesting the update
  56100. * @param defines defines the material defines to update
  56101. * @param useInstances specifies that instances should be used
  56102. */
  56103. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56104. /**
  56105. * Update defines for shader compilation
  56106. * @param mesh defines the mesh to be rendered
  56107. * @param nodeMaterial defines the node material requesting the update
  56108. * @param defines defines the material defines to update
  56109. * @param useInstances specifies that instances should be used
  56110. */
  56111. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56112. /**
  56113. * Lets the block try to connect some inputs automatically
  56114. * @param material defines the hosting NodeMaterial
  56115. */
  56116. autoConfigure(material: NodeMaterial): void;
  56117. /**
  56118. * Function called when a block is declared as repeatable content generator
  56119. * @param vertexShaderState defines the current compilation state for the vertex shader
  56120. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56121. * @param mesh defines the mesh to be rendered
  56122. * @param defines defines the material defines to update
  56123. */
  56124. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56125. /**
  56126. * Checks if the block is ready
  56127. * @param mesh defines the mesh to be rendered
  56128. * @param nodeMaterial defines the node material requesting the update
  56129. * @param defines defines the material defines to update
  56130. * @param useInstances specifies that instances should be used
  56131. * @returns true if the block is ready
  56132. */
  56133. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56134. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56135. private _processBuild;
  56136. /**
  56137. * Compile the current node and generate the shader code
  56138. * @param state defines the current compilation state (uniforms, samplers, current string)
  56139. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56140. * @returns true if already built
  56141. */
  56142. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56143. protected _inputRename(name: string): string;
  56144. protected _outputRename(name: string): string;
  56145. protected _dumpPropertiesCode(): string;
  56146. /** @hidden */
  56147. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56148. /**
  56149. * Clone the current block to a new identical block
  56150. * @param scene defines the hosting scene
  56151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56152. * @returns a copy of the current block
  56153. */
  56154. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56155. /**
  56156. * Serializes this block in a JSON representation
  56157. * @returns the serialized block object
  56158. */
  56159. serialize(): any;
  56160. /** @hidden */
  56161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56162. }
  56163. }
  56164. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56165. /**
  56166. * Enum defining the type of animations supported by InputBlock
  56167. */
  56168. export enum AnimatedInputBlockTypes {
  56169. /** No animation */
  56170. None = 0,
  56171. /** Time based animation. Will only work for floats */
  56172. Time = 1
  56173. }
  56174. }
  56175. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56177. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56178. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56179. import { Nullable } from "babylonjs/types";
  56180. import { Effect } from "babylonjs/Materials/effect";
  56181. import { Matrix } from "babylonjs/Maths/math.vector";
  56182. import { Scene } from "babylonjs/scene";
  56183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56185. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56186. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56187. /**
  56188. * Block used to expose an input value
  56189. */
  56190. export class InputBlock extends NodeMaterialBlock {
  56191. private _mode;
  56192. private _associatedVariableName;
  56193. private _storedValue;
  56194. private _valueCallback;
  56195. private _type;
  56196. private _animationType;
  56197. /** Gets or set a value used to limit the range of float values */
  56198. min: number;
  56199. /** Gets or set a value used to limit the range of float values */
  56200. max: number;
  56201. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56202. matrixMode: number;
  56203. /** @hidden */
  56204. _systemValue: Nullable<NodeMaterialSystemValues>;
  56205. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56206. visibleInInspector: boolean;
  56207. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56208. isConstant: boolean;
  56209. /**
  56210. * Gets or sets the connection point type (default is float)
  56211. */
  56212. readonly type: NodeMaterialBlockConnectionPointTypes;
  56213. /**
  56214. * Creates a new InputBlock
  56215. * @param name defines the block name
  56216. * @param target defines the target of that block (Vertex by default)
  56217. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56218. */
  56219. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56220. /**
  56221. * Gets the output component
  56222. */
  56223. readonly output: NodeMaterialConnectionPoint;
  56224. /**
  56225. * Set the source of this connection point to a vertex attribute
  56226. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56227. * @returns the current connection point
  56228. */
  56229. setAsAttribute(attributeName?: string): InputBlock;
  56230. /**
  56231. * Set the source of this connection point to a system value
  56232. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56233. * @returns the current connection point
  56234. */
  56235. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56236. /**
  56237. * Gets or sets the value of that point.
  56238. * Please note that this value will be ignored if valueCallback is defined
  56239. */
  56240. value: any;
  56241. /**
  56242. * Gets or sets a callback used to get the value of that point.
  56243. * Please note that setting this value will force the connection point to ignore the value property
  56244. */
  56245. valueCallback: () => any;
  56246. /**
  56247. * Gets or sets the associated variable name in the shader
  56248. */
  56249. associatedVariableName: string;
  56250. /** Gets or sets the type of animation applied to the input */
  56251. animationType: AnimatedInputBlockTypes;
  56252. /**
  56253. * Gets a boolean indicating that this connection point not defined yet
  56254. */
  56255. readonly isUndefined: boolean;
  56256. /**
  56257. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56258. * In this case the connection point name must be the name of the uniform to use.
  56259. * Can only be set on inputs
  56260. */
  56261. isUniform: boolean;
  56262. /**
  56263. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56264. * In this case the connection point name must be the name of the attribute to use
  56265. * Can only be set on inputs
  56266. */
  56267. isAttribute: boolean;
  56268. /**
  56269. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56270. * Can only be set on exit points
  56271. */
  56272. isVarying: boolean;
  56273. /**
  56274. * Gets a boolean indicating that the current connection point is a system value
  56275. */
  56276. readonly isSystemValue: boolean;
  56277. /**
  56278. * Gets or sets the current well known value or null if not defined as a system value
  56279. */
  56280. systemValue: Nullable<NodeMaterialSystemValues>;
  56281. /**
  56282. * Gets the current class name
  56283. * @returns the class name
  56284. */
  56285. getClassName(): string;
  56286. /**
  56287. * Animate the input if animationType !== None
  56288. * @param scene defines the rendering scene
  56289. */
  56290. animate(scene: Scene): void;
  56291. private _emitDefine;
  56292. initialize(state: NodeMaterialBuildState): void;
  56293. /**
  56294. * Set the input block to its default value (based on its type)
  56295. */
  56296. setDefaultValue(): void;
  56297. private _emitConstant;
  56298. private _emit;
  56299. /** @hidden */
  56300. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56301. /** @hidden */
  56302. _transmit(effect: Effect, scene: Scene): void;
  56303. protected _buildBlock(state: NodeMaterialBuildState): void;
  56304. protected _dumpPropertiesCode(): string;
  56305. serialize(): any;
  56306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56307. }
  56308. }
  56309. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56310. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56311. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56312. import { Nullable } from "babylonjs/types";
  56313. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56315. /**
  56316. * Defines a connection point for a block
  56317. */
  56318. export class NodeMaterialConnectionPoint {
  56319. /** @hidden */
  56320. _ownerBlock: NodeMaterialBlock;
  56321. /** @hidden */
  56322. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56323. private _endpoints;
  56324. private _associatedVariableName;
  56325. /** @hidden */
  56326. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56327. /** @hidden */
  56328. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56329. private _type;
  56330. /** @hidden */
  56331. _enforceAssociatedVariableName: boolean;
  56332. /**
  56333. * Gets or sets the additional types supported by this connection point
  56334. */
  56335. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56336. /**
  56337. * Gets or sets the additional types excluded by this connection point
  56338. */
  56339. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56340. /**
  56341. * Gets or sets the associated variable name in the shader
  56342. */
  56343. associatedVariableName: string;
  56344. /**
  56345. * Gets or sets the connection point type (default is float)
  56346. */
  56347. type: NodeMaterialBlockConnectionPointTypes;
  56348. /**
  56349. * Gets or sets the connection point name
  56350. */
  56351. name: string;
  56352. /**
  56353. * Gets or sets a boolean indicating that this connection point can be omitted
  56354. */
  56355. isOptional: boolean;
  56356. /**
  56357. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56358. */
  56359. define: string;
  56360. /** Gets or sets the target of that connection point */
  56361. target: NodeMaterialBlockTargets;
  56362. /**
  56363. * Gets a boolean indicating that the current point is connected
  56364. */
  56365. readonly isConnected: boolean;
  56366. /**
  56367. * Gets a boolean indicating that the current point is connected to an input block
  56368. */
  56369. readonly isConnectedToInputBlock: boolean;
  56370. /**
  56371. * Gets a the connected input block (if any)
  56372. */
  56373. readonly connectInputBlock: Nullable<InputBlock>;
  56374. /** Get the other side of the connection (if any) */
  56375. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56376. /** Get the block that owns this connection point */
  56377. readonly ownerBlock: NodeMaterialBlock;
  56378. /** Get the block connected on the other side of this connection (if any) */
  56379. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56380. /** Get the block connected on the endpoints of this connection (if any) */
  56381. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56382. /** Gets the list of connected endpoints */
  56383. readonly endpoints: NodeMaterialConnectionPoint[];
  56384. /** Gets a boolean indicating if that output point is connected to at least one input */
  56385. readonly hasEndpoints: boolean;
  56386. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56387. readonly isConnectedInVertexShader: boolean;
  56388. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56389. readonly isConnectedInFragmentShader: boolean;
  56390. /**
  56391. * Creates a new connection point
  56392. * @param name defines the connection point name
  56393. * @param ownerBlock defines the block hosting this connection point
  56394. */
  56395. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56396. /**
  56397. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56398. * @returns the class name
  56399. */
  56400. getClassName(): string;
  56401. /**
  56402. * Gets an boolean indicating if the current point can be connected to another point
  56403. * @param connectionPoint defines the other connection point
  56404. * @returns true if the connection is possible
  56405. */
  56406. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56407. /**
  56408. * Connect this point to another connection point
  56409. * @param connectionPoint defines the other connection point
  56410. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56411. * @returns the current connection point
  56412. */
  56413. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56414. /**
  56415. * Disconnect this point from one of his endpoint
  56416. * @param endpoint defines the other connection point
  56417. * @returns the current connection point
  56418. */
  56419. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56420. /**
  56421. * Serializes this point in a JSON representation
  56422. * @returns the serialized point object
  56423. */
  56424. serialize(): any;
  56425. }
  56426. }
  56427. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56431. import { Mesh } from "babylonjs/Meshes/mesh";
  56432. import { Effect } from "babylonjs/Materials/effect";
  56433. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56434. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56435. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56436. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56437. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56438. /**
  56439. * Block used to add support for vertex skinning (bones)
  56440. */
  56441. export class BonesBlock extends NodeMaterialBlock {
  56442. /**
  56443. * Creates a new BonesBlock
  56444. * @param name defines the block name
  56445. */
  56446. constructor(name: string);
  56447. /**
  56448. * Initialize the block and prepare the context for build
  56449. * @param state defines the state that will be used for the build
  56450. */
  56451. initialize(state: NodeMaterialBuildState): void;
  56452. /**
  56453. * Gets the current class name
  56454. * @returns the class name
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Gets the matrix indices input component
  56459. */
  56460. readonly matricesIndices: NodeMaterialConnectionPoint;
  56461. /**
  56462. * Gets the matrix weights input component
  56463. */
  56464. readonly matricesWeights: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the extra matrix indices input component
  56467. */
  56468. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the extra matrix weights input component
  56471. */
  56472. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56473. /**
  56474. * Gets the world input component
  56475. */
  56476. readonly world: NodeMaterialConnectionPoint;
  56477. /**
  56478. * Gets the output component
  56479. */
  56480. readonly output: NodeMaterialConnectionPoint;
  56481. autoConfigure(material: NodeMaterial): void;
  56482. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56483. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56485. protected _buildBlock(state: NodeMaterialBuildState): this;
  56486. }
  56487. }
  56488. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56493. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56494. /**
  56495. * Block used to add support for instances
  56496. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56497. */
  56498. export class InstancesBlock extends NodeMaterialBlock {
  56499. /**
  56500. * Creates a new InstancesBlock
  56501. * @param name defines the block name
  56502. */
  56503. constructor(name: string);
  56504. /**
  56505. * Gets the current class name
  56506. * @returns the class name
  56507. */
  56508. getClassName(): string;
  56509. /**
  56510. * Gets the first world row input component
  56511. */
  56512. readonly world0: NodeMaterialConnectionPoint;
  56513. /**
  56514. * Gets the second world row input component
  56515. */
  56516. readonly world1: NodeMaterialConnectionPoint;
  56517. /**
  56518. * Gets the third world row input component
  56519. */
  56520. readonly world2: NodeMaterialConnectionPoint;
  56521. /**
  56522. * Gets the forth world row input component
  56523. */
  56524. readonly world3: NodeMaterialConnectionPoint;
  56525. /**
  56526. * Gets the world input component
  56527. */
  56528. readonly world: NodeMaterialConnectionPoint;
  56529. /**
  56530. * Gets the output component
  56531. */
  56532. readonly output: NodeMaterialConnectionPoint;
  56533. autoConfigure(material: NodeMaterial): void;
  56534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56535. protected _buildBlock(state: NodeMaterialBuildState): this;
  56536. }
  56537. }
  56538. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56543. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56544. import { Effect } from "babylonjs/Materials/effect";
  56545. import { Mesh } from "babylonjs/Meshes/mesh";
  56546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56548. /**
  56549. * Block used to add morph targets support to vertex shader
  56550. */
  56551. export class MorphTargetsBlock extends NodeMaterialBlock {
  56552. private _repeatableContentAnchor;
  56553. private _repeatebleContentGenerated;
  56554. /**
  56555. * Create a new MorphTargetsBlock
  56556. * @param name defines the block name
  56557. */
  56558. constructor(name: string);
  56559. /**
  56560. * Gets the current class name
  56561. * @returns the class name
  56562. */
  56563. getClassName(): string;
  56564. /**
  56565. * Gets the position input component
  56566. */
  56567. readonly position: NodeMaterialConnectionPoint;
  56568. /**
  56569. * Gets the normal input component
  56570. */
  56571. readonly normal: NodeMaterialConnectionPoint;
  56572. /**
  56573. * Gets the tangent input component
  56574. */
  56575. readonly tangent: NodeMaterialConnectionPoint;
  56576. /**
  56577. * Gets the tangent input component
  56578. */
  56579. readonly uv: NodeMaterialConnectionPoint;
  56580. /**
  56581. * Gets the position output component
  56582. */
  56583. readonly positionOutput: NodeMaterialConnectionPoint;
  56584. /**
  56585. * Gets the normal output component
  56586. */
  56587. readonly normalOutput: NodeMaterialConnectionPoint;
  56588. /**
  56589. * Gets the tangent output component
  56590. */
  56591. readonly tangentOutput: NodeMaterialConnectionPoint;
  56592. /**
  56593. * Gets the tangent output component
  56594. */
  56595. readonly uvOutput: NodeMaterialConnectionPoint;
  56596. initialize(state: NodeMaterialBuildState): void;
  56597. autoConfigure(material: NodeMaterial): void;
  56598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56600. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56601. protected _buildBlock(state: NodeMaterialBuildState): this;
  56602. }
  56603. }
  56604. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56607. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56608. import { Nullable } from "babylonjs/types";
  56609. import { Scene } from "babylonjs/scene";
  56610. import { Effect } from "babylonjs/Materials/effect";
  56611. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56612. import { Mesh } from "babylonjs/Meshes/mesh";
  56613. import { Light } from "babylonjs/Lights/light";
  56614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56615. /**
  56616. * Block used to get data information from a light
  56617. */
  56618. export class LightInformationBlock extends NodeMaterialBlock {
  56619. private _lightDataUniformName;
  56620. private _lightColorUniformName;
  56621. private _lightTypeDefineName;
  56622. /**
  56623. * Gets or sets the light associated with this block
  56624. */
  56625. light: Nullable<Light>;
  56626. /**
  56627. * Creates a new LightInformationBlock
  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 world position input component
  56638. */
  56639. readonly worldPosition: NodeMaterialConnectionPoint;
  56640. /**
  56641. * Gets the direction output component
  56642. */
  56643. readonly direction: NodeMaterialConnectionPoint;
  56644. /**
  56645. * Gets the direction output component
  56646. */
  56647. readonly color: NodeMaterialConnectionPoint;
  56648. /**
  56649. * Gets the direction output component
  56650. */
  56651. readonly intensity: NodeMaterialConnectionPoint;
  56652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this;
  56655. serialize(): any;
  56656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56657. }
  56658. }
  56659. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56660. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56661. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56662. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56663. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56664. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56665. }
  56666. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56671. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56672. import { Effect } from "babylonjs/Materials/effect";
  56673. import { Mesh } from "babylonjs/Meshes/mesh";
  56674. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56675. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56676. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56677. /**
  56678. * Block used to add image processing support to fragment shader
  56679. */
  56680. export class ImageProcessingBlock extends NodeMaterialBlock {
  56681. /**
  56682. * Create a new ImageProcessingBlock
  56683. * @param name defines the block name
  56684. */
  56685. constructor(name: string);
  56686. /**
  56687. * Gets the current class name
  56688. * @returns the class name
  56689. */
  56690. getClassName(): string;
  56691. /**
  56692. * Gets the color input component
  56693. */
  56694. readonly color: NodeMaterialConnectionPoint;
  56695. /**
  56696. * Gets the output component
  56697. */
  56698. readonly output: NodeMaterialConnectionPoint;
  56699. /**
  56700. * Initialize the block and prepare the context for build
  56701. * @param state defines the state that will be used for the build
  56702. */
  56703. initialize(state: NodeMaterialBuildState): void;
  56704. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56707. protected _buildBlock(state: NodeMaterialBuildState): this;
  56708. }
  56709. }
  56710. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56714. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56716. import { Effect } from "babylonjs/Materials/effect";
  56717. import { Mesh } from "babylonjs/Meshes/mesh";
  56718. import { Scene } from "babylonjs/scene";
  56719. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56720. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56721. /**
  56722. * Block used to pertub normals based on a normal map
  56723. */
  56724. export class PerturbNormalBlock extends NodeMaterialBlock {
  56725. private _tangentSpaceParameterName;
  56726. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56727. invertX: boolean;
  56728. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56729. invertY: boolean;
  56730. /**
  56731. * Create a new PerturbNormalBlock
  56732. * @param name defines the block name
  56733. */
  56734. constructor(name: string);
  56735. /**
  56736. * Gets the current class name
  56737. * @returns the class name
  56738. */
  56739. getClassName(): string;
  56740. /**
  56741. * Gets the world position input component
  56742. */
  56743. readonly worldPosition: NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the world normal input component
  56746. */
  56747. readonly worldNormal: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the uv input component
  56750. */
  56751. readonly uv: NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the normal map color input component
  56754. */
  56755. readonly normalMapColor: NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the strength input component
  56758. */
  56759. readonly strength: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the output component
  56762. */
  56763. readonly output: NodeMaterialConnectionPoint;
  56764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56766. autoConfigure(material: NodeMaterial): void;
  56767. protected _buildBlock(state: NodeMaterialBuildState): this;
  56768. protected _dumpPropertiesCode(): string;
  56769. serialize(): any;
  56770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56771. }
  56772. }
  56773. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56777. /**
  56778. * Block used to discard a pixel if a value is smaller than a cutoff
  56779. */
  56780. export class DiscardBlock extends NodeMaterialBlock {
  56781. /**
  56782. * Create a new DiscardBlock
  56783. * @param name defines the block name
  56784. */
  56785. constructor(name: string);
  56786. /**
  56787. * Gets the current class name
  56788. * @returns the class name
  56789. */
  56790. getClassName(): string;
  56791. /**
  56792. * Gets the color input component
  56793. */
  56794. readonly value: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the cutoff input component
  56797. */
  56798. readonly cutoff: NodeMaterialConnectionPoint;
  56799. protected _buildBlock(state: NodeMaterialBuildState): this;
  56800. }
  56801. }
  56802. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56803. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56804. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56805. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56806. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56807. }
  56808. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56811. import { Mesh } from "babylonjs/Meshes/mesh";
  56812. import { Effect } from "babylonjs/Materials/effect";
  56813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56816. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56817. /**
  56818. * Block used to add support for scene fog
  56819. */
  56820. export class FogBlock extends NodeMaterialBlock {
  56821. private _fogDistanceName;
  56822. private _fogParameters;
  56823. /**
  56824. * Create a new FogBlock
  56825. * @param name defines the block name
  56826. */
  56827. constructor(name: string);
  56828. /**
  56829. * Gets the current class name
  56830. * @returns the class name
  56831. */
  56832. getClassName(): string;
  56833. /**
  56834. * Gets the world position input component
  56835. */
  56836. readonly worldPosition: NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the view input component
  56839. */
  56840. readonly view: NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the color input component
  56843. */
  56844. readonly input: NodeMaterialConnectionPoint;
  56845. /**
  56846. * Gets the fog color input component
  56847. */
  56848. readonly fogColor: NodeMaterialConnectionPoint;
  56849. /**
  56850. * Gets the output component
  56851. */
  56852. readonly output: NodeMaterialConnectionPoint;
  56853. autoConfigure(material: NodeMaterial): void;
  56854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56855. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56856. protected _buildBlock(state: NodeMaterialBuildState): this;
  56857. }
  56858. }
  56859. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56865. import { Effect } from "babylonjs/Materials/effect";
  56866. import { Mesh } from "babylonjs/Meshes/mesh";
  56867. import { Light } from "babylonjs/Lights/light";
  56868. import { Nullable } from "babylonjs/types";
  56869. import { Scene } from "babylonjs/scene";
  56870. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56871. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56872. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56874. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56875. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56876. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56877. /**
  56878. * Block used to add light in the fragment shader
  56879. */
  56880. export class LightBlock extends NodeMaterialBlock {
  56881. private _lightId;
  56882. /**
  56883. * Gets or sets the light associated with this block
  56884. */
  56885. light: Nullable<Light>;
  56886. /**
  56887. * Create a new LightBlock
  56888. * @param name defines the block name
  56889. */
  56890. constructor(name: string);
  56891. /**
  56892. * Gets the current class name
  56893. * @returns the class name
  56894. */
  56895. getClassName(): string;
  56896. /**
  56897. * Gets the world position input component
  56898. */
  56899. readonly worldPosition: NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the world normal input component
  56902. */
  56903. readonly worldNormal: NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the camera (or eye) position component
  56906. */
  56907. readonly cameraPosition: NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the glossiness component
  56910. */
  56911. readonly glossiness: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the glossinness power component
  56914. */
  56915. readonly glossPower: NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the diffuse color component
  56918. */
  56919. readonly diffuseColor: NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the specular color component
  56922. */
  56923. readonly specularColor: NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the diffuse output component
  56926. */
  56927. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56928. /**
  56929. * Gets the specular output component
  56930. */
  56931. readonly specularOutput: NodeMaterialConnectionPoint;
  56932. autoConfigure(material: NodeMaterial): void;
  56933. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56934. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56935. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56936. private _injectVertexCode;
  56937. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56938. serialize(): any;
  56939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56940. }
  56941. }
  56942. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56943. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56944. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56945. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56946. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56947. }
  56948. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56949. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56950. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56951. }
  56952. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56956. /**
  56957. * Block used to multiply 2 values
  56958. */
  56959. export class MultiplyBlock extends NodeMaterialBlock {
  56960. /**
  56961. * Creates a new MultiplyBlock
  56962. * @param name defines the block name
  56963. */
  56964. constructor(name: string);
  56965. /**
  56966. * Gets the current class name
  56967. * @returns the class name
  56968. */
  56969. getClassName(): string;
  56970. /**
  56971. * Gets the left operand input component
  56972. */
  56973. readonly left: NodeMaterialConnectionPoint;
  56974. /**
  56975. * Gets the right operand input component
  56976. */
  56977. readonly right: NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the output component
  56980. */
  56981. readonly output: NodeMaterialConnectionPoint;
  56982. protected _buildBlock(state: NodeMaterialBuildState): this;
  56983. }
  56984. }
  56985. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56989. /**
  56990. * Block used to add 2 vectors
  56991. */
  56992. export class AddBlock extends NodeMaterialBlock {
  56993. /**
  56994. * Creates a new AddBlock
  56995. * @param name defines the block name
  56996. */
  56997. constructor(name: string);
  56998. /**
  56999. * Gets the current class name
  57000. * @returns the class name
  57001. */
  57002. getClassName(): string;
  57003. /**
  57004. * Gets the left operand input component
  57005. */
  57006. readonly left: NodeMaterialConnectionPoint;
  57007. /**
  57008. * Gets the right operand input component
  57009. */
  57010. readonly right: 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/scaleBlock" {
  57019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57022. /**
  57023. * Block used to scale a vector by a float
  57024. */
  57025. export class ScaleBlock extends NodeMaterialBlock {
  57026. /**
  57027. * Creates a new ScaleBlock
  57028. * @param name defines the block name
  57029. */
  57030. constructor(name: string);
  57031. /**
  57032. * Gets the current class name
  57033. * @returns the class name
  57034. */
  57035. getClassName(): string;
  57036. /**
  57037. * Gets the input component
  57038. */
  57039. readonly input: NodeMaterialConnectionPoint;
  57040. /**
  57041. * Gets the factor input component
  57042. */
  57043. readonly factor: NodeMaterialConnectionPoint;
  57044. /**
  57045. * Gets the output component
  57046. */
  57047. readonly output: NodeMaterialConnectionPoint;
  57048. protected _buildBlock(state: NodeMaterialBuildState): this;
  57049. }
  57050. }
  57051. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57055. import { Scene } from "babylonjs/scene";
  57056. /**
  57057. * Block used to clamp a float
  57058. */
  57059. export class ClampBlock extends NodeMaterialBlock {
  57060. /** Gets or sets the minimum range */
  57061. minimum: number;
  57062. /** Gets or sets the maximum range */
  57063. maximum: number;
  57064. /**
  57065. * Creates a new ClampBlock
  57066. * @param name defines the block name
  57067. */
  57068. constructor(name: string);
  57069. /**
  57070. * Gets the current class name
  57071. * @returns the class name
  57072. */
  57073. getClassName(): string;
  57074. /**
  57075. * Gets the value input component
  57076. */
  57077. readonly value: NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the output component
  57080. */
  57081. readonly output: NodeMaterialConnectionPoint;
  57082. protected _buildBlock(state: NodeMaterialBuildState): this;
  57083. protected _dumpPropertiesCode(): string;
  57084. serialize(): any;
  57085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57086. }
  57087. }
  57088. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57092. /**
  57093. * Block used to apply a cross product between 2 vectors
  57094. */
  57095. export class CrossBlock extends NodeMaterialBlock {
  57096. /**
  57097. * Creates a new CrossBlock
  57098. * @param name defines the block name
  57099. */
  57100. constructor(name: string);
  57101. /**
  57102. * Gets the current class name
  57103. * @returns the class name
  57104. */
  57105. getClassName(): string;
  57106. /**
  57107. * Gets the left operand input component
  57108. */
  57109. readonly left: NodeMaterialConnectionPoint;
  57110. /**
  57111. * Gets the right operand input component
  57112. */
  57113. readonly right: NodeMaterialConnectionPoint;
  57114. /**
  57115. * Gets the output component
  57116. */
  57117. readonly output: NodeMaterialConnectionPoint;
  57118. protected _buildBlock(state: NodeMaterialBuildState): this;
  57119. }
  57120. }
  57121. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57125. /**
  57126. * Block used to apply a dot product between 2 vectors
  57127. */
  57128. export class DotBlock extends NodeMaterialBlock {
  57129. /**
  57130. * Creates a new DotBlock
  57131. * @param name defines the block name
  57132. */
  57133. constructor(name: string);
  57134. /**
  57135. * Gets the current class name
  57136. * @returns the class name
  57137. */
  57138. getClassName(): string;
  57139. /**
  57140. * Gets the left operand input component
  57141. */
  57142. readonly left: NodeMaterialConnectionPoint;
  57143. /**
  57144. * Gets the right operand input component
  57145. */
  57146. readonly right: NodeMaterialConnectionPoint;
  57147. /**
  57148. * Gets the output component
  57149. */
  57150. readonly output: NodeMaterialConnectionPoint;
  57151. protected _buildBlock(state: NodeMaterialBuildState): this;
  57152. }
  57153. }
  57154. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57158. import { Vector2 } from "babylonjs/Maths/math.vector";
  57159. import { Scene } from "babylonjs/scene";
  57160. /**
  57161. * Block used to remap a float from a range to a new one
  57162. */
  57163. export class RemapBlock extends NodeMaterialBlock {
  57164. /**
  57165. * Gets or sets the source range
  57166. */
  57167. sourceRange: Vector2;
  57168. /**
  57169. * Gets or sets the target range
  57170. */
  57171. targetRange: Vector2;
  57172. /**
  57173. * Creates a new RemapBlock
  57174. * @param name defines the block name
  57175. */
  57176. constructor(name: string);
  57177. /**
  57178. * Gets the current class name
  57179. * @returns the class name
  57180. */
  57181. getClassName(): string;
  57182. /**
  57183. * Gets the input component
  57184. */
  57185. readonly input: NodeMaterialConnectionPoint;
  57186. /**
  57187. * Gets the source min input component
  57188. */
  57189. readonly sourceMin: NodeMaterialConnectionPoint;
  57190. /**
  57191. * Gets the source max input component
  57192. */
  57193. readonly sourceMax: NodeMaterialConnectionPoint;
  57194. /**
  57195. * Gets the target min input component
  57196. */
  57197. readonly targetMin: NodeMaterialConnectionPoint;
  57198. /**
  57199. * Gets the target max input component
  57200. */
  57201. readonly targetMax: NodeMaterialConnectionPoint;
  57202. /**
  57203. * Gets the output component
  57204. */
  57205. readonly output: NodeMaterialConnectionPoint;
  57206. protected _buildBlock(state: NodeMaterialBuildState): this;
  57207. protected _dumpPropertiesCode(): string;
  57208. serialize(): any;
  57209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57210. }
  57211. }
  57212. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57216. /**
  57217. * Block used to normalize a vector
  57218. */
  57219. export class NormalizeBlock extends NodeMaterialBlock {
  57220. /**
  57221. * Creates a new NormalizeBlock
  57222. * @param name defines the block name
  57223. */
  57224. constructor(name: string);
  57225. /**
  57226. * Gets the current class name
  57227. * @returns the class name
  57228. */
  57229. getClassName(): string;
  57230. /**
  57231. * Gets the input component
  57232. */
  57233. readonly input: NodeMaterialConnectionPoint;
  57234. /**
  57235. * Gets the output component
  57236. */
  57237. readonly output: NodeMaterialConnectionPoint;
  57238. protected _buildBlock(state: NodeMaterialBuildState): this;
  57239. }
  57240. }
  57241. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57245. import { Scene } from "babylonjs/scene";
  57246. /**
  57247. * Operations supported by the Trigonometry block
  57248. */
  57249. export enum TrigonometryBlockOperations {
  57250. /** Cos */
  57251. Cos = 0,
  57252. /** Sin */
  57253. Sin = 1,
  57254. /** Abs */
  57255. Abs = 2,
  57256. /** Exp */
  57257. Exp = 3,
  57258. /** Exp2 */
  57259. Exp2 = 4,
  57260. /** Round */
  57261. Round = 5,
  57262. /** Floor */
  57263. Floor = 6,
  57264. /** Ceiling */
  57265. Ceiling = 7,
  57266. /** Square root */
  57267. Sqrt = 8,
  57268. /** Log */
  57269. Log = 9,
  57270. /** Tangent */
  57271. Tan = 10,
  57272. /** Arc tangent */
  57273. ArcTan = 11,
  57274. /** Arc cosinus */
  57275. ArcCos = 12,
  57276. /** Arc sinus */
  57277. ArcSin = 13,
  57278. /** Fraction */
  57279. Fract = 14,
  57280. /** Sign */
  57281. Sign = 15,
  57282. /** To radians (from degrees) */
  57283. Radians = 16,
  57284. /** To degrees (from radians) */
  57285. Degrees = 17
  57286. }
  57287. /**
  57288. * Block used to apply trigonometry operation to floats
  57289. */
  57290. export class TrigonometryBlock extends NodeMaterialBlock {
  57291. /**
  57292. * Gets or sets the operation applied by the block
  57293. */
  57294. operation: TrigonometryBlockOperations;
  57295. /**
  57296. * Creates a new TrigonometryBlock
  57297. * @param name defines the block name
  57298. */
  57299. constructor(name: string);
  57300. /**
  57301. * Gets the current class name
  57302. * @returns the class name
  57303. */
  57304. getClassName(): string;
  57305. /**
  57306. * Gets the input component
  57307. */
  57308. readonly input: NodeMaterialConnectionPoint;
  57309. /**
  57310. * Gets the output component
  57311. */
  57312. readonly output: NodeMaterialConnectionPoint;
  57313. protected _buildBlock(state: NodeMaterialBuildState): this;
  57314. serialize(): any;
  57315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57316. }
  57317. }
  57318. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57322. /**
  57323. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57324. */
  57325. export class ColorMergerBlock extends NodeMaterialBlock {
  57326. /**
  57327. * Create a new ColorMergerBlock
  57328. * @param name defines the block name
  57329. */
  57330. constructor(name: string);
  57331. /**
  57332. * Gets the current class name
  57333. * @returns the class name
  57334. */
  57335. getClassName(): string;
  57336. /**
  57337. * Gets the r component (input)
  57338. */
  57339. readonly r: NodeMaterialConnectionPoint;
  57340. /**
  57341. * Gets the g component (input)
  57342. */
  57343. readonly g: NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the b component (input)
  57346. */
  57347. readonly b: NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the a component (input)
  57350. */
  57351. readonly a: NodeMaterialConnectionPoint;
  57352. /**
  57353. * Gets the rgba component (output)
  57354. */
  57355. readonly rgba: NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the rgb component (output)
  57358. */
  57359. readonly rgb: NodeMaterialConnectionPoint;
  57360. protected _buildBlock(state: NodeMaterialBuildState): this;
  57361. }
  57362. }
  57363. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57367. /**
  57368. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57369. */
  57370. export class VectorMergerBlock extends NodeMaterialBlock {
  57371. /**
  57372. * Create a new VectorMergerBlock
  57373. * @param name defines the block name
  57374. */
  57375. constructor(name: string);
  57376. /**
  57377. * Gets the current class name
  57378. * @returns the class name
  57379. */
  57380. getClassName(): string;
  57381. /**
  57382. * Gets the x component (input)
  57383. */
  57384. readonly x: NodeMaterialConnectionPoint;
  57385. /**
  57386. * Gets the y component (input)
  57387. */
  57388. readonly y: NodeMaterialConnectionPoint;
  57389. /**
  57390. * Gets the z component (input)
  57391. */
  57392. readonly z: NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the w component (input)
  57395. */
  57396. readonly w: NodeMaterialConnectionPoint;
  57397. /**
  57398. * Gets the xyzw component (output)
  57399. */
  57400. readonly xyzw: NodeMaterialConnectionPoint;
  57401. /**
  57402. * Gets the xyz component (output)
  57403. */
  57404. readonly xyz: NodeMaterialConnectionPoint;
  57405. /**
  57406. * Gets the xy component (output)
  57407. */
  57408. readonly xy: NodeMaterialConnectionPoint;
  57409. protected _buildBlock(state: NodeMaterialBuildState): this;
  57410. }
  57411. }
  57412. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57416. /**
  57417. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57418. */
  57419. export class ColorSplitterBlock extends NodeMaterialBlock {
  57420. /**
  57421. * Create a new ColorSplitterBlock
  57422. * @param name defines the block name
  57423. */
  57424. constructor(name: string);
  57425. /**
  57426. * Gets the current class name
  57427. * @returns the class name
  57428. */
  57429. getClassName(): string;
  57430. /**
  57431. * Gets the rgba component (input)
  57432. */
  57433. readonly rgba: NodeMaterialConnectionPoint;
  57434. /**
  57435. * Gets the rgb component (input)
  57436. */
  57437. readonly rgbIn: NodeMaterialConnectionPoint;
  57438. /**
  57439. * Gets the rgb component (output)
  57440. */
  57441. readonly rgbOut: NodeMaterialConnectionPoint;
  57442. /**
  57443. * Gets the r component (output)
  57444. */
  57445. readonly r: NodeMaterialConnectionPoint;
  57446. /**
  57447. * Gets the g component (output)
  57448. */
  57449. readonly g: NodeMaterialConnectionPoint;
  57450. /**
  57451. * Gets the b component (output)
  57452. */
  57453. readonly b: NodeMaterialConnectionPoint;
  57454. /**
  57455. * Gets the a component (output)
  57456. */
  57457. readonly a: NodeMaterialConnectionPoint;
  57458. protected _inputRename(name: string): string;
  57459. protected _outputRename(name: string): string;
  57460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57461. }
  57462. }
  57463. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57467. /**
  57468. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57469. */
  57470. export class VectorSplitterBlock extends NodeMaterialBlock {
  57471. /**
  57472. * Create a new VectorSplitterBlock
  57473. * @param name defines the block name
  57474. */
  57475. constructor(name: string);
  57476. /**
  57477. * Gets the current class name
  57478. * @returns the class name
  57479. */
  57480. getClassName(): string;
  57481. /**
  57482. * Gets the xyzw component (input)
  57483. */
  57484. readonly xyzw: NodeMaterialConnectionPoint;
  57485. /**
  57486. * Gets the xyz component (input)
  57487. */
  57488. readonly xyzIn: NodeMaterialConnectionPoint;
  57489. /**
  57490. * Gets the xy component (input)
  57491. */
  57492. readonly xyIn: NodeMaterialConnectionPoint;
  57493. /**
  57494. * Gets the xyz component (output)
  57495. */
  57496. readonly xyzOut: NodeMaterialConnectionPoint;
  57497. /**
  57498. * Gets the xy component (output)
  57499. */
  57500. readonly xyOut: NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the x component (output)
  57503. */
  57504. readonly x: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the y component (output)
  57507. */
  57508. readonly y: NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the z component (output)
  57511. */
  57512. readonly z: NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the w component (output)
  57515. */
  57516. readonly w: NodeMaterialConnectionPoint;
  57517. protected _inputRename(name: string): string;
  57518. protected _outputRename(name: string): string;
  57519. protected _buildBlock(state: NodeMaterialBuildState): this;
  57520. }
  57521. }
  57522. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57526. /**
  57527. * Block used to lerp between 2 values
  57528. */
  57529. export class LerpBlock extends NodeMaterialBlock {
  57530. /**
  57531. * Creates a new LerpBlock
  57532. * @param name defines the block name
  57533. */
  57534. constructor(name: string);
  57535. /**
  57536. * Gets the current class name
  57537. * @returns the class name
  57538. */
  57539. getClassName(): string;
  57540. /**
  57541. * Gets the left operand input component
  57542. */
  57543. readonly left: NodeMaterialConnectionPoint;
  57544. /**
  57545. * Gets the right operand input component
  57546. */
  57547. readonly right: NodeMaterialConnectionPoint;
  57548. /**
  57549. * Gets the gradient operand input component
  57550. */
  57551. readonly gradient: NodeMaterialConnectionPoint;
  57552. /**
  57553. * Gets the output component
  57554. */
  57555. readonly output: NodeMaterialConnectionPoint;
  57556. protected _buildBlock(state: NodeMaterialBuildState): this;
  57557. }
  57558. }
  57559. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57563. /**
  57564. * Block used to divide 2 vectors
  57565. */
  57566. export class DivideBlock extends NodeMaterialBlock {
  57567. /**
  57568. * Creates a new DivideBlock
  57569. * @param name defines the block name
  57570. */
  57571. constructor(name: string);
  57572. /**
  57573. * Gets the current class name
  57574. * @returns the class name
  57575. */
  57576. getClassName(): string;
  57577. /**
  57578. * Gets the left operand input component
  57579. */
  57580. readonly left: NodeMaterialConnectionPoint;
  57581. /**
  57582. * Gets the right operand input component
  57583. */
  57584. readonly right: NodeMaterialConnectionPoint;
  57585. /**
  57586. * Gets the output component
  57587. */
  57588. readonly output: NodeMaterialConnectionPoint;
  57589. protected _buildBlock(state: NodeMaterialBuildState): this;
  57590. }
  57591. }
  57592. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57596. /**
  57597. * Block used to subtract 2 vectors
  57598. */
  57599. export class SubtractBlock extends NodeMaterialBlock {
  57600. /**
  57601. * Creates a new SubtractBlock
  57602. * @param name defines the block name
  57603. */
  57604. constructor(name: string);
  57605. /**
  57606. * Gets the current class name
  57607. * @returns the class name
  57608. */
  57609. getClassName(): string;
  57610. /**
  57611. * Gets the left operand input component
  57612. */
  57613. readonly left: NodeMaterialConnectionPoint;
  57614. /**
  57615. * Gets the right operand input component
  57616. */
  57617. readonly right: NodeMaterialConnectionPoint;
  57618. /**
  57619. * Gets the output component
  57620. */
  57621. readonly output: NodeMaterialConnectionPoint;
  57622. protected _buildBlock(state: NodeMaterialBuildState): this;
  57623. }
  57624. }
  57625. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57629. /**
  57630. * Block used to step a value
  57631. */
  57632. export class StepBlock extends NodeMaterialBlock {
  57633. /**
  57634. * Creates a new StepBlock
  57635. * @param name defines the block name
  57636. */
  57637. constructor(name: string);
  57638. /**
  57639. * Gets the current class name
  57640. * @returns the class name
  57641. */
  57642. getClassName(): string;
  57643. /**
  57644. * Gets the value operand input component
  57645. */
  57646. readonly value: NodeMaterialConnectionPoint;
  57647. /**
  57648. * Gets the edge operand input component
  57649. */
  57650. readonly edge: NodeMaterialConnectionPoint;
  57651. /**
  57652. * Gets the output component
  57653. */
  57654. readonly output: NodeMaterialConnectionPoint;
  57655. protected _buildBlock(state: NodeMaterialBuildState): this;
  57656. }
  57657. }
  57658. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57662. /**
  57663. * Block used to get the opposite (1 - x) of a value
  57664. */
  57665. export class OneMinusBlock extends NodeMaterialBlock {
  57666. /**
  57667. * Creates a new OneMinusBlock
  57668. * @param name defines the block name
  57669. */
  57670. constructor(name: string);
  57671. /**
  57672. * Gets the current class name
  57673. * @returns the class name
  57674. */
  57675. getClassName(): string;
  57676. /**
  57677. * Gets the input component
  57678. */
  57679. readonly input: NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the output component
  57682. */
  57683. readonly output: NodeMaterialConnectionPoint;
  57684. protected _buildBlock(state: NodeMaterialBuildState): this;
  57685. }
  57686. }
  57687. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57691. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57692. /**
  57693. * Block used to get the view direction
  57694. */
  57695. export class ViewDirectionBlock extends NodeMaterialBlock {
  57696. /**
  57697. * Creates a new ViewDirectionBlock
  57698. * @param name defines the block name
  57699. */
  57700. constructor(name: string);
  57701. /**
  57702. * Gets the current class name
  57703. * @returns the class name
  57704. */
  57705. getClassName(): string;
  57706. /**
  57707. * Gets the world position component
  57708. */
  57709. readonly worldPosition: NodeMaterialConnectionPoint;
  57710. /**
  57711. * Gets the camera position component
  57712. */
  57713. readonly cameraPosition: NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the output component
  57716. */
  57717. readonly output: NodeMaterialConnectionPoint;
  57718. autoConfigure(material: NodeMaterial): void;
  57719. protected _buildBlock(state: NodeMaterialBuildState): this;
  57720. }
  57721. }
  57722. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57726. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57727. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57728. /**
  57729. * Block used to compute fresnel value
  57730. */
  57731. export class FresnelBlock extends NodeMaterialBlock {
  57732. /**
  57733. * Create a new FresnelBlock
  57734. * @param name defines the block name
  57735. */
  57736. constructor(name: string);
  57737. /**
  57738. * Gets the current class name
  57739. * @returns the class name
  57740. */
  57741. getClassName(): string;
  57742. /**
  57743. * Gets the world normal input component
  57744. */
  57745. readonly worldNormal: NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the view direction input component
  57748. */
  57749. readonly viewDirection: NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the bias input component
  57752. */
  57753. readonly bias: NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the camera (or eye) position component
  57756. */
  57757. readonly power: NodeMaterialConnectionPoint;
  57758. /**
  57759. * Gets the fresnel output component
  57760. */
  57761. readonly fresnel: NodeMaterialConnectionPoint;
  57762. autoConfigure(material: NodeMaterial): void;
  57763. protected _buildBlock(state: NodeMaterialBuildState): this;
  57764. }
  57765. }
  57766. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57770. /**
  57771. * Block used to get the max of 2 values
  57772. */
  57773. export class MaxBlock extends NodeMaterialBlock {
  57774. /**
  57775. * Creates a new MaxBlock
  57776. * @param name defines the block name
  57777. */
  57778. constructor(name: string);
  57779. /**
  57780. * Gets the current class name
  57781. * @returns the class name
  57782. */
  57783. getClassName(): string;
  57784. /**
  57785. * Gets the left operand input component
  57786. */
  57787. readonly left: NodeMaterialConnectionPoint;
  57788. /**
  57789. * Gets the right operand input component
  57790. */
  57791. readonly right: NodeMaterialConnectionPoint;
  57792. /**
  57793. * Gets the output component
  57794. */
  57795. readonly output: NodeMaterialConnectionPoint;
  57796. protected _buildBlock(state: NodeMaterialBuildState): this;
  57797. }
  57798. }
  57799. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57803. /**
  57804. * Block used to get the min of 2 values
  57805. */
  57806. export class MinBlock extends NodeMaterialBlock {
  57807. /**
  57808. * Creates a new MinBlock
  57809. * @param name defines the block name
  57810. */
  57811. constructor(name: string);
  57812. /**
  57813. * Gets the current class name
  57814. * @returns the class name
  57815. */
  57816. getClassName(): string;
  57817. /**
  57818. * Gets the left operand input component
  57819. */
  57820. readonly left: NodeMaterialConnectionPoint;
  57821. /**
  57822. * Gets the right operand input component
  57823. */
  57824. readonly right: NodeMaterialConnectionPoint;
  57825. /**
  57826. * Gets the output component
  57827. */
  57828. readonly output: NodeMaterialConnectionPoint;
  57829. protected _buildBlock(state: NodeMaterialBuildState): this;
  57830. }
  57831. }
  57832. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57836. /**
  57837. * Block used to get the distance between 2 values
  57838. */
  57839. export class DistanceBlock extends NodeMaterialBlock {
  57840. /**
  57841. * Creates a new DistanceBlock
  57842. * @param name defines the block name
  57843. */
  57844. constructor(name: string);
  57845. /**
  57846. * Gets the current class name
  57847. * @returns the class name
  57848. */
  57849. getClassName(): string;
  57850. /**
  57851. * Gets the left operand input component
  57852. */
  57853. readonly left: NodeMaterialConnectionPoint;
  57854. /**
  57855. * Gets the right operand input component
  57856. */
  57857. readonly right: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the output component
  57860. */
  57861. readonly output: NodeMaterialConnectionPoint;
  57862. protected _buildBlock(state: NodeMaterialBuildState): this;
  57863. }
  57864. }
  57865. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57869. /**
  57870. * Block used to get the length of a vector
  57871. */
  57872. export class LengthBlock extends NodeMaterialBlock {
  57873. /**
  57874. * Creates a new LengthBlock
  57875. * @param name defines the block name
  57876. */
  57877. constructor(name: string);
  57878. /**
  57879. * Gets the current class name
  57880. * @returns the class name
  57881. */
  57882. getClassName(): string;
  57883. /**
  57884. * Gets the value input component
  57885. */
  57886. readonly value: NodeMaterialConnectionPoint;
  57887. /**
  57888. * Gets the output component
  57889. */
  57890. readonly output: NodeMaterialConnectionPoint;
  57891. protected _buildBlock(state: NodeMaterialBuildState): this;
  57892. }
  57893. }
  57894. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57895. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57898. /**
  57899. * Block used to get negative version of a value (i.e. x * -1)
  57900. */
  57901. export class NegateBlock extends NodeMaterialBlock {
  57902. /**
  57903. * Creates a new NegateBlock
  57904. * @param name defines the block name
  57905. */
  57906. constructor(name: string);
  57907. /**
  57908. * Gets the current class name
  57909. * @returns the class name
  57910. */
  57911. getClassName(): string;
  57912. /**
  57913. * Gets the value input component
  57914. */
  57915. readonly value: NodeMaterialConnectionPoint;
  57916. /**
  57917. * Gets the output component
  57918. */
  57919. readonly output: NodeMaterialConnectionPoint;
  57920. protected _buildBlock(state: NodeMaterialBuildState): this;
  57921. }
  57922. }
  57923. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57927. /**
  57928. * Block used to get the value of the first parameter raised to the power of the second
  57929. */
  57930. export class PowBlock extends NodeMaterialBlock {
  57931. /**
  57932. * Creates a new PowBlock
  57933. * @param name defines the block name
  57934. */
  57935. constructor(name: string);
  57936. /**
  57937. * Gets the current class name
  57938. * @returns the class name
  57939. */
  57940. getClassName(): string;
  57941. /**
  57942. * Gets the value operand input component
  57943. */
  57944. readonly value: NodeMaterialConnectionPoint;
  57945. /**
  57946. * Gets the power operand input component
  57947. */
  57948. readonly power: NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the output component
  57951. */
  57952. readonly output: NodeMaterialConnectionPoint;
  57953. protected _buildBlock(state: NodeMaterialBuildState): this;
  57954. }
  57955. }
  57956. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57961. /**
  57962. * Block used to get a random number
  57963. */
  57964. export class RandomNumberBlock extends NodeMaterialBlock {
  57965. /**
  57966. * Creates a new RandomNumberBlock
  57967. * @param name defines the block name
  57968. */
  57969. constructor(name: string);
  57970. /**
  57971. * Gets the current class name
  57972. * @returns the class name
  57973. */
  57974. getClassName(): string;
  57975. /**
  57976. * Gets the seed input component
  57977. */
  57978. readonly seed: NodeMaterialConnectionPoint;
  57979. /**
  57980. * Gets the output component
  57981. */
  57982. readonly output: NodeMaterialConnectionPoint;
  57983. protected _buildBlock(state: NodeMaterialBuildState): this;
  57984. }
  57985. }
  57986. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57990. /**
  57991. * Block used to compute arc tangent of 2 values
  57992. */
  57993. export class ArcTan2Block extends NodeMaterialBlock {
  57994. /**
  57995. * Creates a new ArcTan2Block
  57996. * @param name defines the block name
  57997. */
  57998. constructor(name: string);
  57999. /**
  58000. * Gets the current class name
  58001. * @returns the class name
  58002. */
  58003. getClassName(): string;
  58004. /**
  58005. * Gets the x operand input component
  58006. */
  58007. readonly x: NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the y operand input component
  58010. */
  58011. readonly y: NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the output component
  58014. */
  58015. readonly output: NodeMaterialConnectionPoint;
  58016. protected _buildBlock(state: NodeMaterialBuildState): this;
  58017. }
  58018. }
  58019. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58023. /**
  58024. * Block used to smooth step a value
  58025. */
  58026. export class SmoothStepBlock extends NodeMaterialBlock {
  58027. /**
  58028. * Creates a new SmoothStepBlock
  58029. * @param name defines the block name
  58030. */
  58031. constructor(name: string);
  58032. /**
  58033. * Gets the current class name
  58034. * @returns the class name
  58035. */
  58036. getClassName(): string;
  58037. /**
  58038. * Gets the value operand input component
  58039. */
  58040. readonly value: NodeMaterialConnectionPoint;
  58041. /**
  58042. * Gets the first edge operand input component
  58043. */
  58044. readonly edge0: NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the second edge operand input component
  58047. */
  58048. readonly edge1: NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the output component
  58051. */
  58052. readonly output: NodeMaterialConnectionPoint;
  58053. protected _buildBlock(state: NodeMaterialBuildState): this;
  58054. }
  58055. }
  58056. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58060. /**
  58061. * Block used to get the reciprocal (1 / x) of a value
  58062. */
  58063. export class ReciprocalBlock extends NodeMaterialBlock {
  58064. /**
  58065. * Creates a new ReciprocalBlock
  58066. * @param name defines the block name
  58067. */
  58068. constructor(name: string);
  58069. /**
  58070. * Gets the current class name
  58071. * @returns the class name
  58072. */
  58073. getClassName(): string;
  58074. /**
  58075. * Gets the input component
  58076. */
  58077. readonly input: NodeMaterialConnectionPoint;
  58078. /**
  58079. * Gets the output component
  58080. */
  58081. readonly output: NodeMaterialConnectionPoint;
  58082. protected _buildBlock(state: NodeMaterialBuildState): this;
  58083. }
  58084. }
  58085. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58089. /**
  58090. * Block used to replace a color by another one
  58091. */
  58092. export class ReplaceColorBlock extends NodeMaterialBlock {
  58093. /**
  58094. * Creates a new ReplaceColorBlock
  58095. * @param name defines the block name
  58096. */
  58097. constructor(name: string);
  58098. /**
  58099. * Gets the current class name
  58100. * @returns the class name
  58101. */
  58102. getClassName(): string;
  58103. /**
  58104. * Gets the value input component
  58105. */
  58106. readonly value: NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the reference input component
  58109. */
  58110. readonly reference: NodeMaterialConnectionPoint;
  58111. /**
  58112. * Gets the distance input component
  58113. */
  58114. readonly distance: NodeMaterialConnectionPoint;
  58115. /**
  58116. * Gets the replacement input component
  58117. */
  58118. readonly replacement: NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the output component
  58121. */
  58122. readonly output: NodeMaterialConnectionPoint;
  58123. protected _buildBlock(state: NodeMaterialBuildState): this;
  58124. }
  58125. }
  58126. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58130. /**
  58131. * Block used to posterize a value
  58132. * @see https://en.wikipedia.org/wiki/Posterization
  58133. */
  58134. export class PosterizeBlock extends NodeMaterialBlock {
  58135. /**
  58136. * Creates a new PosterizeBlock
  58137. * @param name defines the block name
  58138. */
  58139. constructor(name: string);
  58140. /**
  58141. * Gets the current class name
  58142. * @returns the class name
  58143. */
  58144. getClassName(): string;
  58145. /**
  58146. * Gets the value input component
  58147. */
  58148. readonly value: NodeMaterialConnectionPoint;
  58149. /**
  58150. * Gets the steps input component
  58151. */
  58152. readonly steps: NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the output component
  58155. */
  58156. readonly output: NodeMaterialConnectionPoint;
  58157. protected _buildBlock(state: NodeMaterialBuildState): this;
  58158. }
  58159. }
  58160. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58164. import { Scene } from "babylonjs/scene";
  58165. /**
  58166. * Operations supported by the Wave block
  58167. */
  58168. export enum WaveBlockKind {
  58169. /** SawTooth */
  58170. SawTooth = 0,
  58171. /** Square */
  58172. Square = 1,
  58173. /** Triangle */
  58174. Triangle = 2
  58175. }
  58176. /**
  58177. * Block used to apply wave operation to floats
  58178. */
  58179. export class WaveBlock extends NodeMaterialBlock {
  58180. /**
  58181. * Gets or sets the kibnd of wave to be applied by the block
  58182. */
  58183. kind: WaveBlockKind;
  58184. /**
  58185. * Creates a new WaveBlock
  58186. * @param name defines the block name
  58187. */
  58188. constructor(name: string);
  58189. /**
  58190. * Gets the current class name
  58191. * @returns the class name
  58192. */
  58193. getClassName(): string;
  58194. /**
  58195. * Gets the input component
  58196. */
  58197. readonly input: NodeMaterialConnectionPoint;
  58198. /**
  58199. * Gets the output component
  58200. */
  58201. readonly output: NodeMaterialConnectionPoint;
  58202. protected _buildBlock(state: NodeMaterialBuildState): this;
  58203. serialize(): any;
  58204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58205. }
  58206. }
  58207. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58211. import { Color3 } from "babylonjs/Maths/math.color";
  58212. import { Scene } from "babylonjs/scene";
  58213. /**
  58214. * Class used to store a color step for the GradientBlock
  58215. */
  58216. export class GradientBlockColorStep {
  58217. /**
  58218. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58219. */
  58220. step: number;
  58221. /**
  58222. * Gets or sets the color associated with this step
  58223. */
  58224. color: Color3;
  58225. /**
  58226. * Creates a new GradientBlockColorStep
  58227. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58228. * @param color defines the color associated with this step
  58229. */
  58230. constructor(
  58231. /**
  58232. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58233. */
  58234. step: number,
  58235. /**
  58236. * Gets or sets the color associated with this step
  58237. */
  58238. color: Color3);
  58239. }
  58240. /**
  58241. * Block used to return a color from a gradient based on an input value between 0 and 1
  58242. */
  58243. export class GradientBlock extends NodeMaterialBlock {
  58244. /**
  58245. * Gets or sets the list of color steps
  58246. */
  58247. colorSteps: GradientBlockColorStep[];
  58248. /**
  58249. * Creates a new GradientBlock
  58250. * @param name defines the block name
  58251. */
  58252. constructor(name: string);
  58253. /**
  58254. * Gets the current class name
  58255. * @returns the class name
  58256. */
  58257. getClassName(): string;
  58258. /**
  58259. * Gets the gradient input component
  58260. */
  58261. readonly gradient: NodeMaterialConnectionPoint;
  58262. /**
  58263. * Gets the output component
  58264. */
  58265. readonly output: NodeMaterialConnectionPoint;
  58266. private _writeColorConstant;
  58267. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58268. serialize(): any;
  58269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58270. protected _dumpPropertiesCode(): string;
  58271. }
  58272. }
  58273. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58277. /**
  58278. * Block used to normalize lerp between 2 values
  58279. */
  58280. export class NLerpBlock extends NodeMaterialBlock {
  58281. /**
  58282. * Creates a new NLerpBlock
  58283. * @param name defines the block name
  58284. */
  58285. constructor(name: string);
  58286. /**
  58287. * Gets the current class name
  58288. * @returns the class name
  58289. */
  58290. getClassName(): string;
  58291. /**
  58292. * Gets the left operand input component
  58293. */
  58294. readonly left: NodeMaterialConnectionPoint;
  58295. /**
  58296. * Gets the right operand input component
  58297. */
  58298. readonly right: NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the gradient operand input component
  58301. */
  58302. readonly gradient: NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the output component
  58305. */
  58306. readonly output: NodeMaterialConnectionPoint;
  58307. protected _buildBlock(state: NodeMaterialBuildState): this;
  58308. }
  58309. }
  58310. declare module "babylonjs/Materials/Node/Blocks/index" {
  58311. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58312. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58313. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58314. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58315. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58316. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58325. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58332. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58333. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58334. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58335. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58336. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58337. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58338. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58339. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58340. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58341. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58342. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58343. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58344. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58345. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58346. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58347. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58348. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58349. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58350. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58351. }
  58352. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58353. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58354. }
  58355. declare module "babylonjs/Materials/Node/index" {
  58356. export * from "babylonjs/Materials/Node/Enums/index";
  58357. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58358. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58359. export * from "babylonjs/Materials/Node/nodeMaterial";
  58360. export * from "babylonjs/Materials/Node/Blocks/index";
  58361. export * from "babylonjs/Materials/Node/Optimizers/index";
  58362. }
  58363. declare module "babylonjs/Materials/effectRenderer" {
  58364. import { Nullable } from "babylonjs/types";
  58365. import { Texture } from "babylonjs/Materials/Textures/texture";
  58366. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58367. import { Viewport } from "babylonjs/Maths/math.viewport";
  58368. import { Observable } from "babylonjs/Misc/observable";
  58369. import { Effect } from "babylonjs/Materials/effect";
  58370. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58371. import "babylonjs/Shaders/postprocess.vertex";
  58372. /**
  58373. * Effect Render Options
  58374. */
  58375. export interface IEffectRendererOptions {
  58376. /**
  58377. * Defines the vertices positions.
  58378. */
  58379. positions?: number[];
  58380. /**
  58381. * Defines the indices.
  58382. */
  58383. indices?: number[];
  58384. }
  58385. /**
  58386. * Helper class to render one or more effects
  58387. */
  58388. export class EffectRenderer {
  58389. private engine;
  58390. private static _DefaultOptions;
  58391. private _vertexBuffers;
  58392. private _indexBuffer;
  58393. private _ringBufferIndex;
  58394. private _ringScreenBuffer;
  58395. private _fullscreenViewport;
  58396. private _getNextFrameBuffer;
  58397. /**
  58398. * Creates an effect renderer
  58399. * @param engine the engine to use for rendering
  58400. * @param options defines the options of the effect renderer
  58401. */
  58402. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58403. /**
  58404. * Sets the current viewport in normalized coordinates 0-1
  58405. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58406. */
  58407. setViewport(viewport?: Viewport): void;
  58408. /**
  58409. * Binds the embedded attributes buffer to the effect.
  58410. * @param effect Defines the effect to bind the attributes for
  58411. */
  58412. bindBuffers(effect: Effect): void;
  58413. /**
  58414. * Sets the current effect wrapper to use during draw.
  58415. * The effect needs to be ready before calling this api.
  58416. * This also sets the default full screen position attribute.
  58417. * @param effectWrapper Defines the effect to draw with
  58418. */
  58419. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58420. /**
  58421. * Draws a full screen quad.
  58422. */
  58423. draw(): void;
  58424. /**
  58425. * renders one or more effects to a specified texture
  58426. * @param effectWrappers list of effects to renderer
  58427. * @param outputTexture texture to draw to, if null it will render to the screen
  58428. */
  58429. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58430. /**
  58431. * Disposes of the effect renderer
  58432. */
  58433. dispose(): void;
  58434. }
  58435. /**
  58436. * Options to create an EffectWrapper
  58437. */
  58438. interface EffectWrapperCreationOptions {
  58439. /**
  58440. * Engine to use to create the effect
  58441. */
  58442. engine: ThinEngine;
  58443. /**
  58444. * Fragment shader for the effect
  58445. */
  58446. fragmentShader: string;
  58447. /**
  58448. * Vertex shader for the effect
  58449. */
  58450. vertexShader?: string;
  58451. /**
  58452. * Attributes to use in the shader
  58453. */
  58454. attributeNames?: Array<string>;
  58455. /**
  58456. * Uniforms to use in the shader
  58457. */
  58458. uniformNames?: Array<string>;
  58459. /**
  58460. * Texture sampler names to use in the shader
  58461. */
  58462. samplerNames?: Array<string>;
  58463. /**
  58464. * The friendly name of the effect displayed in Spector.
  58465. */
  58466. name?: string;
  58467. }
  58468. /**
  58469. * Wraps an effect to be used for rendering
  58470. */
  58471. export class EffectWrapper {
  58472. /**
  58473. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58474. */
  58475. onApplyObservable: Observable<{}>;
  58476. /**
  58477. * The underlying effect
  58478. */
  58479. effect: Effect;
  58480. /**
  58481. * Creates an effect to be renderer
  58482. * @param creationOptions options to create the effect
  58483. */
  58484. constructor(creationOptions: EffectWrapperCreationOptions);
  58485. /**
  58486. * Disposes of the effect wrapper
  58487. */
  58488. dispose(): void;
  58489. }
  58490. }
  58491. declare module "babylonjs/Materials/index" {
  58492. export * from "babylonjs/Materials/Background/index";
  58493. export * from "babylonjs/Materials/colorCurves";
  58494. export * from "babylonjs/Materials/iEffectFallbacks";
  58495. export * from "babylonjs/Materials/effectFallbacks";
  58496. export * from "babylonjs/Materials/effect";
  58497. export * from "babylonjs/Materials/fresnelParameters";
  58498. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58499. export * from "babylonjs/Materials/material";
  58500. export * from "babylonjs/Materials/materialDefines";
  58501. export * from "babylonjs/Materials/materialHelper";
  58502. export * from "babylonjs/Materials/multiMaterial";
  58503. export * from "babylonjs/Materials/PBR/index";
  58504. export * from "babylonjs/Materials/pushMaterial";
  58505. export * from "babylonjs/Materials/shaderMaterial";
  58506. export * from "babylonjs/Materials/standardMaterial";
  58507. export * from "babylonjs/Materials/Textures/index";
  58508. export * from "babylonjs/Materials/uniformBuffer";
  58509. export * from "babylonjs/Materials/materialFlags";
  58510. export * from "babylonjs/Materials/Node/index";
  58511. export * from "babylonjs/Materials/effectRenderer";
  58512. }
  58513. declare module "babylonjs/Maths/index" {
  58514. export * from "babylonjs/Maths/math.scalar";
  58515. export * from "babylonjs/Maths/math";
  58516. export * from "babylonjs/Maths/sphericalPolynomial";
  58517. }
  58518. declare module "babylonjs/Misc/workerPool" {
  58519. import { IDisposable } from "babylonjs/scene";
  58520. /**
  58521. * Helper class to push actions to a pool of workers.
  58522. */
  58523. export class WorkerPool implements IDisposable {
  58524. private _workerInfos;
  58525. private _pendingActions;
  58526. /**
  58527. * Constructor
  58528. * @param workers Array of workers to use for actions
  58529. */
  58530. constructor(workers: Array<Worker>);
  58531. /**
  58532. * Terminates all workers and clears any pending actions.
  58533. */
  58534. dispose(): void;
  58535. /**
  58536. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58537. * pended until a worker has completed its action.
  58538. * @param action The action to perform. Call onComplete when the action is complete.
  58539. */
  58540. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58541. private _execute;
  58542. }
  58543. }
  58544. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58545. import { IDisposable } from "babylonjs/scene";
  58546. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58547. /**
  58548. * Configuration for Draco compression
  58549. */
  58550. export interface IDracoCompressionConfiguration {
  58551. /**
  58552. * Configuration for the decoder.
  58553. */
  58554. decoder: {
  58555. /**
  58556. * The url to the WebAssembly module.
  58557. */
  58558. wasmUrl?: string;
  58559. /**
  58560. * The url to the WebAssembly binary.
  58561. */
  58562. wasmBinaryUrl?: string;
  58563. /**
  58564. * The url to the fallback JavaScript module.
  58565. */
  58566. fallbackUrl?: string;
  58567. };
  58568. }
  58569. /**
  58570. * Draco compression (https://google.github.io/draco/)
  58571. *
  58572. * This class wraps the Draco module.
  58573. *
  58574. * **Encoder**
  58575. *
  58576. * The encoder is not currently implemented.
  58577. *
  58578. * **Decoder**
  58579. *
  58580. * 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.
  58581. *
  58582. * To update the configuration, use the following code:
  58583. * ```javascript
  58584. * DracoCompression.Configuration = {
  58585. * decoder: {
  58586. * wasmUrl: "<url to the WebAssembly library>",
  58587. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58588. * fallbackUrl: "<url to the fallback JavaScript library>",
  58589. * }
  58590. * };
  58591. * ```
  58592. *
  58593. * 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.
  58594. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58595. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58596. *
  58597. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58598. * ```javascript
  58599. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58600. * ```
  58601. *
  58602. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58603. */
  58604. export class DracoCompression implements IDisposable {
  58605. private _workerPoolPromise?;
  58606. private _decoderModulePromise?;
  58607. /**
  58608. * The configuration. Defaults to the following urls:
  58609. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58610. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58611. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58612. */
  58613. static Configuration: IDracoCompressionConfiguration;
  58614. /**
  58615. * Returns true if the decoder configuration is available.
  58616. */
  58617. static readonly DecoderAvailable: boolean;
  58618. /**
  58619. * Default number of workers to create when creating the draco compression object.
  58620. */
  58621. static DefaultNumWorkers: number;
  58622. private static GetDefaultNumWorkers;
  58623. private static _Default;
  58624. /**
  58625. * Default instance for the draco compression object.
  58626. */
  58627. static readonly Default: DracoCompression;
  58628. /**
  58629. * Constructor
  58630. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58631. */
  58632. constructor(numWorkers?: number);
  58633. /**
  58634. * Stop all async operations and release resources.
  58635. */
  58636. dispose(): void;
  58637. /**
  58638. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58639. * @returns a promise that resolves when ready
  58640. */
  58641. whenReadyAsync(): Promise<void>;
  58642. /**
  58643. * Decode Draco compressed mesh data to vertex data.
  58644. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58645. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58646. * @returns A promise that resolves with the decoded vertex data
  58647. */
  58648. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58649. [kind: string]: number;
  58650. }): Promise<VertexData>;
  58651. }
  58652. }
  58653. declare module "babylonjs/Meshes/Compression/index" {
  58654. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58655. }
  58656. declare module "babylonjs/Meshes/csg" {
  58657. import { Nullable } from "babylonjs/types";
  58658. import { Scene } from "babylonjs/scene";
  58659. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58660. import { Mesh } from "babylonjs/Meshes/mesh";
  58661. import { Material } from "babylonjs/Materials/material";
  58662. /**
  58663. * Class for building Constructive Solid Geometry
  58664. */
  58665. export class CSG {
  58666. private polygons;
  58667. /**
  58668. * The world matrix
  58669. */
  58670. matrix: Matrix;
  58671. /**
  58672. * Stores the position
  58673. */
  58674. position: Vector3;
  58675. /**
  58676. * Stores the rotation
  58677. */
  58678. rotation: Vector3;
  58679. /**
  58680. * Stores the rotation quaternion
  58681. */
  58682. rotationQuaternion: Nullable<Quaternion>;
  58683. /**
  58684. * Stores the scaling vector
  58685. */
  58686. scaling: Vector3;
  58687. /**
  58688. * Convert the Mesh to CSG
  58689. * @param mesh The Mesh to convert to CSG
  58690. * @returns A new CSG from the Mesh
  58691. */
  58692. static FromMesh(mesh: Mesh): CSG;
  58693. /**
  58694. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58695. * @param polygons Polygons used to construct a CSG solid
  58696. */
  58697. private static FromPolygons;
  58698. /**
  58699. * Clones, or makes a deep copy, of the CSG
  58700. * @returns A new CSG
  58701. */
  58702. clone(): CSG;
  58703. /**
  58704. * Unions this CSG with another CSG
  58705. * @param csg The CSG to union against this CSG
  58706. * @returns The unioned CSG
  58707. */
  58708. union(csg: CSG): CSG;
  58709. /**
  58710. * Unions this CSG with another CSG in place
  58711. * @param csg The CSG to union against this CSG
  58712. */
  58713. unionInPlace(csg: CSG): void;
  58714. /**
  58715. * Subtracts this CSG with another CSG
  58716. * @param csg The CSG to subtract against this CSG
  58717. * @returns A new CSG
  58718. */
  58719. subtract(csg: CSG): CSG;
  58720. /**
  58721. * Subtracts this CSG with another CSG in place
  58722. * @param csg The CSG to subtact against this CSG
  58723. */
  58724. subtractInPlace(csg: CSG): void;
  58725. /**
  58726. * Intersect this CSG with another CSG
  58727. * @param csg The CSG to intersect against this CSG
  58728. * @returns A new CSG
  58729. */
  58730. intersect(csg: CSG): CSG;
  58731. /**
  58732. * Intersects this CSG with another CSG in place
  58733. * @param csg The CSG to intersect against this CSG
  58734. */
  58735. intersectInPlace(csg: CSG): void;
  58736. /**
  58737. * Return a new CSG solid with solid and empty space switched. This solid is
  58738. * not modified.
  58739. * @returns A new CSG solid with solid and empty space switched
  58740. */
  58741. inverse(): CSG;
  58742. /**
  58743. * Inverses the CSG in place
  58744. */
  58745. inverseInPlace(): void;
  58746. /**
  58747. * This is used to keep meshes transformations so they can be restored
  58748. * when we build back a Babylon Mesh
  58749. * NB : All CSG operations are performed in world coordinates
  58750. * @param csg The CSG to copy the transform attributes from
  58751. * @returns This CSG
  58752. */
  58753. copyTransformAttributes(csg: CSG): CSG;
  58754. /**
  58755. * Build Raw mesh from CSG
  58756. * Coordinates here are in world space
  58757. * @param name The name of the mesh geometry
  58758. * @param scene The Scene
  58759. * @param keepSubMeshes Specifies if the submeshes should be kept
  58760. * @returns A new Mesh
  58761. */
  58762. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58763. /**
  58764. * Build Mesh from CSG taking material and transforms into account
  58765. * @param name The name of the Mesh
  58766. * @param material The material of the Mesh
  58767. * @param scene The Scene
  58768. * @param keepSubMeshes Specifies if submeshes should be kept
  58769. * @returns The new Mesh
  58770. */
  58771. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58772. }
  58773. }
  58774. declare module "babylonjs/Meshes/trailMesh" {
  58775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58776. import { Mesh } from "babylonjs/Meshes/mesh";
  58777. import { Scene } from "babylonjs/scene";
  58778. /**
  58779. * Class used to create a trail following a mesh
  58780. */
  58781. export class TrailMesh extends Mesh {
  58782. private _generator;
  58783. private _autoStart;
  58784. private _running;
  58785. private _diameter;
  58786. private _length;
  58787. private _sectionPolygonPointsCount;
  58788. private _sectionVectors;
  58789. private _sectionNormalVectors;
  58790. private _beforeRenderObserver;
  58791. /**
  58792. * @constructor
  58793. * @param name The value used by scene.getMeshByName() to do a lookup.
  58794. * @param generator The mesh to generate a trail.
  58795. * @param scene The scene to add this mesh to.
  58796. * @param diameter Diameter of trailing mesh. Default is 1.
  58797. * @param length Length of trailing mesh. Default is 60.
  58798. * @param autoStart Automatically start trailing mesh. Default true.
  58799. */
  58800. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58801. /**
  58802. * "TrailMesh"
  58803. * @returns "TrailMesh"
  58804. */
  58805. getClassName(): string;
  58806. private _createMesh;
  58807. /**
  58808. * Start trailing mesh.
  58809. */
  58810. start(): void;
  58811. /**
  58812. * Stop trailing mesh.
  58813. */
  58814. stop(): void;
  58815. /**
  58816. * Update trailing mesh geometry.
  58817. */
  58818. update(): void;
  58819. /**
  58820. * Returns a new TrailMesh object.
  58821. * @param name is a string, the name given to the new mesh
  58822. * @param newGenerator use new generator object for cloned trail mesh
  58823. * @returns a new mesh
  58824. */
  58825. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58826. /**
  58827. * Serializes this trail mesh
  58828. * @param serializationObject object to write serialization to
  58829. */
  58830. serialize(serializationObject: any): void;
  58831. /**
  58832. * Parses a serialized trail mesh
  58833. * @param parsedMesh the serialized mesh
  58834. * @param scene the scene to create the trail mesh in
  58835. * @returns the created trail mesh
  58836. */
  58837. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58838. }
  58839. }
  58840. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58841. import { Nullable } from "babylonjs/types";
  58842. import { Scene } from "babylonjs/scene";
  58843. import { Vector4 } from "babylonjs/Maths/math.vector";
  58844. import { Color4 } from "babylonjs/Maths/math.color";
  58845. import { Mesh } from "babylonjs/Meshes/mesh";
  58846. /**
  58847. * Class containing static functions to help procedurally build meshes
  58848. */
  58849. export class TiledBoxBuilder {
  58850. /**
  58851. * Creates a box mesh
  58852. * 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)
  58853. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58857. * @param name defines the name of the mesh
  58858. * @param options defines the options used to create the mesh
  58859. * @param scene defines the hosting scene
  58860. * @returns the box mesh
  58861. */
  58862. static CreateTiledBox(name: string, options: {
  58863. pattern?: number;
  58864. width?: number;
  58865. height?: number;
  58866. depth?: number;
  58867. tileSize?: number;
  58868. tileWidth?: number;
  58869. tileHeight?: number;
  58870. alignHorizontal?: number;
  58871. alignVertical?: number;
  58872. faceUV?: Vector4[];
  58873. faceColors?: Color4[];
  58874. sideOrientation?: number;
  58875. updatable?: boolean;
  58876. }, scene?: Nullable<Scene>): Mesh;
  58877. }
  58878. }
  58879. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58880. import { Vector4 } from "babylonjs/Maths/math.vector";
  58881. import { Mesh } from "babylonjs/Meshes/mesh";
  58882. /**
  58883. * Class containing static functions to help procedurally build meshes
  58884. */
  58885. export class TorusKnotBuilder {
  58886. /**
  58887. * Creates a torus knot mesh
  58888. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58889. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58890. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58891. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58895. * @param name defines the name of the mesh
  58896. * @param options defines the options used to create the mesh
  58897. * @param scene defines the hosting scene
  58898. * @returns the torus knot mesh
  58899. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58900. */
  58901. static CreateTorusKnot(name: string, options: {
  58902. radius?: number;
  58903. tube?: number;
  58904. radialSegments?: number;
  58905. tubularSegments?: number;
  58906. p?: number;
  58907. q?: number;
  58908. updatable?: boolean;
  58909. sideOrientation?: number;
  58910. frontUVs?: Vector4;
  58911. backUVs?: Vector4;
  58912. }, scene: any): Mesh;
  58913. }
  58914. }
  58915. declare module "babylonjs/Meshes/polygonMesh" {
  58916. import { Scene } from "babylonjs/scene";
  58917. import { Vector2 } from "babylonjs/Maths/math.vector";
  58918. import { Mesh } from "babylonjs/Meshes/mesh";
  58919. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58920. import { Path2 } from "babylonjs/Maths/math.path";
  58921. /**
  58922. * Polygon
  58923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58924. */
  58925. export class Polygon {
  58926. /**
  58927. * Creates a rectangle
  58928. * @param xmin bottom X coord
  58929. * @param ymin bottom Y coord
  58930. * @param xmax top X coord
  58931. * @param ymax top Y coord
  58932. * @returns points that make the resulting rectation
  58933. */
  58934. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58935. /**
  58936. * Creates a circle
  58937. * @param radius radius of circle
  58938. * @param cx scale in x
  58939. * @param cy scale in y
  58940. * @param numberOfSides number of sides that make up the circle
  58941. * @returns points that make the resulting circle
  58942. */
  58943. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58944. /**
  58945. * Creates a polygon from input string
  58946. * @param input Input polygon data
  58947. * @returns the parsed points
  58948. */
  58949. static Parse(input: string): Vector2[];
  58950. /**
  58951. * Starts building a polygon from x and y coordinates
  58952. * @param x x coordinate
  58953. * @param y y coordinate
  58954. * @returns the started path2
  58955. */
  58956. static StartingAt(x: number, y: number): Path2;
  58957. }
  58958. /**
  58959. * Builds a polygon
  58960. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58961. */
  58962. export class PolygonMeshBuilder {
  58963. private _points;
  58964. private _outlinepoints;
  58965. private _holes;
  58966. private _name;
  58967. private _scene;
  58968. private _epoints;
  58969. private _eholes;
  58970. private _addToepoint;
  58971. /**
  58972. * Babylon reference to the earcut plugin.
  58973. */
  58974. bjsEarcut: any;
  58975. /**
  58976. * Creates a PolygonMeshBuilder
  58977. * @param name name of the builder
  58978. * @param contours Path of the polygon
  58979. * @param scene scene to add to when creating the mesh
  58980. * @param earcutInjection can be used to inject your own earcut reference
  58981. */
  58982. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58983. /**
  58984. * Adds a whole within the polygon
  58985. * @param hole Array of points defining the hole
  58986. * @returns this
  58987. */
  58988. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58989. /**
  58990. * Creates the polygon
  58991. * @param updatable If the mesh should be updatable
  58992. * @param depth The depth of the mesh created
  58993. * @returns the created mesh
  58994. */
  58995. build(updatable?: boolean, depth?: number): Mesh;
  58996. /**
  58997. * Creates the polygon
  58998. * @param depth The depth of the mesh created
  58999. * @returns the created VertexData
  59000. */
  59001. buildVertexData(depth?: number): VertexData;
  59002. /**
  59003. * Adds a side to the polygon
  59004. * @param positions points that make the polygon
  59005. * @param normals normals of the polygon
  59006. * @param uvs uvs of the polygon
  59007. * @param indices indices of the polygon
  59008. * @param bounds bounds of the polygon
  59009. * @param points points of the polygon
  59010. * @param depth depth of the polygon
  59011. * @param flip flip of the polygon
  59012. */
  59013. private addSide;
  59014. }
  59015. }
  59016. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59017. import { Scene } from "babylonjs/scene";
  59018. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59019. import { Color4 } from "babylonjs/Maths/math.color";
  59020. import { Mesh } from "babylonjs/Meshes/mesh";
  59021. import { Nullable } from "babylonjs/types";
  59022. /**
  59023. * Class containing static functions to help procedurally build meshes
  59024. */
  59025. export class PolygonBuilder {
  59026. /**
  59027. * Creates a polygon mesh
  59028. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59029. * * 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
  59030. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59033. * * Remember you can only change the shape positions, not their number when updating a polygon
  59034. * @param name defines the name of the mesh
  59035. * @param options defines the options used to create the mesh
  59036. * @param scene defines the hosting scene
  59037. * @param earcutInjection can be used to inject your own earcut reference
  59038. * @returns the polygon mesh
  59039. */
  59040. static CreatePolygon(name: string, options: {
  59041. shape: Vector3[];
  59042. holes?: Vector3[][];
  59043. depth?: number;
  59044. faceUV?: Vector4[];
  59045. faceColors?: Color4[];
  59046. updatable?: boolean;
  59047. sideOrientation?: number;
  59048. frontUVs?: Vector4;
  59049. backUVs?: Vector4;
  59050. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59051. /**
  59052. * Creates an extruded polygon mesh, with depth in the Y direction.
  59053. * * 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)
  59054. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59055. * @param name defines the name of the mesh
  59056. * @param options defines the options used to create the mesh
  59057. * @param scene defines the hosting scene
  59058. * @param earcutInjection can be used to inject your own earcut reference
  59059. * @returns the polygon mesh
  59060. */
  59061. static ExtrudePolygon(name: string, options: {
  59062. shape: Vector3[];
  59063. holes?: Vector3[][];
  59064. depth?: number;
  59065. faceUV?: Vector4[];
  59066. faceColors?: Color4[];
  59067. updatable?: boolean;
  59068. sideOrientation?: number;
  59069. frontUVs?: Vector4;
  59070. backUVs?: Vector4;
  59071. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59072. }
  59073. }
  59074. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59075. import { Scene } from "babylonjs/scene";
  59076. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59077. import { Mesh } from "babylonjs/Meshes/mesh";
  59078. import { Nullable } from "babylonjs/types";
  59079. /**
  59080. * Class containing static functions to help procedurally build meshes
  59081. */
  59082. export class LatheBuilder {
  59083. /**
  59084. * Creates lathe mesh.
  59085. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59086. * * 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
  59087. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59088. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59089. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59090. * * 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
  59091. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59092. * * 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
  59093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59097. * @param name defines the name of the mesh
  59098. * @param options defines the options used to create the mesh
  59099. * @param scene defines the hosting scene
  59100. * @returns the lathe mesh
  59101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59102. */
  59103. static CreateLathe(name: string, options: {
  59104. shape: Vector3[];
  59105. radius?: number;
  59106. tessellation?: number;
  59107. clip?: number;
  59108. arc?: number;
  59109. closed?: boolean;
  59110. updatable?: boolean;
  59111. sideOrientation?: number;
  59112. frontUVs?: Vector4;
  59113. backUVs?: Vector4;
  59114. cap?: number;
  59115. invertUV?: boolean;
  59116. }, scene?: Nullable<Scene>): Mesh;
  59117. }
  59118. }
  59119. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59120. import { Nullable } from "babylonjs/types";
  59121. import { Scene } from "babylonjs/scene";
  59122. import { Vector4 } from "babylonjs/Maths/math.vector";
  59123. import { Mesh } from "babylonjs/Meshes/mesh";
  59124. /**
  59125. * Class containing static functions to help procedurally build meshes
  59126. */
  59127. export class TiledPlaneBuilder {
  59128. /**
  59129. * Creates a tiled plane mesh
  59130. * * The parameter `pattern` will, depending on value, do nothing or
  59131. * * * flip (reflect about central vertical) alternate tiles across and up
  59132. * * * flip every tile on alternate rows
  59133. * * * rotate (180 degs) alternate tiles across and up
  59134. * * * rotate every tile on alternate rows
  59135. * * * flip and rotate alternate tiles across and up
  59136. * * * flip and rotate every tile on alternate rows
  59137. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59138. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59141. * * 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)
  59142. * * 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)
  59143. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59144. * @param name defines the name of the mesh
  59145. * @param options defines the options used to create the mesh
  59146. * @param scene defines the hosting scene
  59147. * @returns the box mesh
  59148. */
  59149. static CreateTiledPlane(name: string, options: {
  59150. pattern?: number;
  59151. tileSize?: number;
  59152. tileWidth?: number;
  59153. tileHeight?: number;
  59154. size?: number;
  59155. width?: number;
  59156. height?: number;
  59157. alignHorizontal?: number;
  59158. alignVertical?: number;
  59159. sideOrientation?: number;
  59160. frontUVs?: Vector4;
  59161. backUVs?: Vector4;
  59162. updatable?: boolean;
  59163. }, scene?: Nullable<Scene>): Mesh;
  59164. }
  59165. }
  59166. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59167. import { Nullable } from "babylonjs/types";
  59168. import { Scene } from "babylonjs/scene";
  59169. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59170. import { Mesh } from "babylonjs/Meshes/mesh";
  59171. /**
  59172. * Class containing static functions to help procedurally build meshes
  59173. */
  59174. export class TubeBuilder {
  59175. /**
  59176. * Creates a tube mesh.
  59177. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59178. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59179. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59180. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59181. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59182. * * 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)
  59183. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59184. * * 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
  59185. * * 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
  59186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59190. * @param name defines the name of the mesh
  59191. * @param options defines the options used to create the mesh
  59192. * @param scene defines the hosting scene
  59193. * @returns the tube mesh
  59194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59195. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59196. */
  59197. static CreateTube(name: string, options: {
  59198. path: Vector3[];
  59199. radius?: number;
  59200. tessellation?: number;
  59201. radiusFunction?: {
  59202. (i: number, distance: number): number;
  59203. };
  59204. cap?: number;
  59205. arc?: number;
  59206. updatable?: boolean;
  59207. sideOrientation?: number;
  59208. frontUVs?: Vector4;
  59209. backUVs?: Vector4;
  59210. instance?: Mesh;
  59211. invertUV?: boolean;
  59212. }, scene?: Nullable<Scene>): Mesh;
  59213. }
  59214. }
  59215. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59216. import { Scene } from "babylonjs/scene";
  59217. import { Vector4 } from "babylonjs/Maths/math.vector";
  59218. import { Mesh } from "babylonjs/Meshes/mesh";
  59219. import { Nullable } from "babylonjs/types";
  59220. /**
  59221. * Class containing static functions to help procedurally build meshes
  59222. */
  59223. export class IcoSphereBuilder {
  59224. /**
  59225. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59226. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59227. * * 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`)
  59228. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59229. * * 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
  59230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59233. * @param name defines the name of the mesh
  59234. * @param options defines the options used to create the mesh
  59235. * @param scene defines the hosting scene
  59236. * @returns the icosahedron mesh
  59237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59238. */
  59239. static CreateIcoSphere(name: string, options: {
  59240. radius?: number;
  59241. radiusX?: number;
  59242. radiusY?: number;
  59243. radiusZ?: number;
  59244. flat?: boolean;
  59245. subdivisions?: number;
  59246. sideOrientation?: number;
  59247. frontUVs?: Vector4;
  59248. backUVs?: Vector4;
  59249. updatable?: boolean;
  59250. }, scene?: Nullable<Scene>): Mesh;
  59251. }
  59252. }
  59253. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59254. import { Vector3 } from "babylonjs/Maths/math.vector";
  59255. import { Mesh } from "babylonjs/Meshes/mesh";
  59256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59257. /**
  59258. * Class containing static functions to help procedurally build meshes
  59259. */
  59260. export class DecalBuilder {
  59261. /**
  59262. * Creates a decal mesh.
  59263. * 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
  59264. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59265. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59266. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59267. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59268. * @param name defines the name of the mesh
  59269. * @param sourceMesh defines the mesh where the decal must be applied
  59270. * @param options defines the options used to create the mesh
  59271. * @param scene defines the hosting scene
  59272. * @returns the decal mesh
  59273. * @see https://doc.babylonjs.com/how_to/decals
  59274. */
  59275. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59276. position?: Vector3;
  59277. normal?: Vector3;
  59278. size?: Vector3;
  59279. angle?: number;
  59280. }): Mesh;
  59281. }
  59282. }
  59283. declare module "babylonjs/Meshes/meshBuilder" {
  59284. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59285. import { Nullable } from "babylonjs/types";
  59286. import { Scene } from "babylonjs/scene";
  59287. import { Mesh } from "babylonjs/Meshes/mesh";
  59288. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59289. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59291. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59292. import { Plane } from "babylonjs/Maths/math.plane";
  59293. /**
  59294. * Class containing static functions to help procedurally build meshes
  59295. */
  59296. export class MeshBuilder {
  59297. /**
  59298. * Creates a box mesh
  59299. * * The parameter `size` sets the size (float) of each box side (default 1)
  59300. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59301. * * 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)
  59302. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59306. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59307. * @param name defines the name of the mesh
  59308. * @param options defines the options used to create the mesh
  59309. * @param scene defines the hosting scene
  59310. * @returns the box mesh
  59311. */
  59312. static CreateBox(name: string, options: {
  59313. size?: number;
  59314. width?: number;
  59315. height?: number;
  59316. depth?: number;
  59317. faceUV?: Vector4[];
  59318. faceColors?: Color4[];
  59319. sideOrientation?: number;
  59320. frontUVs?: Vector4;
  59321. backUVs?: Vector4;
  59322. updatable?: boolean;
  59323. }, scene?: Nullable<Scene>): Mesh;
  59324. /**
  59325. * Creates a tiled box mesh
  59326. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59328. * @param name defines the name of the mesh
  59329. * @param options defines the options used to create the mesh
  59330. * @param scene defines the hosting scene
  59331. * @returns the tiled box mesh
  59332. */
  59333. static CreateTiledBox(name: string, options: {
  59334. pattern?: number;
  59335. size?: number;
  59336. width?: number;
  59337. height?: number;
  59338. depth: number;
  59339. tileSize?: number;
  59340. tileWidth?: number;
  59341. tileHeight?: number;
  59342. faceUV?: Vector4[];
  59343. faceColors?: Color4[];
  59344. alignHorizontal?: number;
  59345. alignVertical?: number;
  59346. sideOrientation?: number;
  59347. updatable?: boolean;
  59348. }, scene?: Nullable<Scene>): Mesh;
  59349. /**
  59350. * Creates a sphere mesh
  59351. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59352. * * 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`)
  59353. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59354. * * 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
  59355. * * 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)
  59356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59359. * @param name defines the name of the mesh
  59360. * @param options defines the options used to create the mesh
  59361. * @param scene defines the hosting scene
  59362. * @returns the sphere mesh
  59363. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59364. */
  59365. static CreateSphere(name: string, options: {
  59366. segments?: number;
  59367. diameter?: number;
  59368. diameterX?: number;
  59369. diameterY?: number;
  59370. diameterZ?: number;
  59371. arc?: number;
  59372. slice?: number;
  59373. sideOrientation?: number;
  59374. frontUVs?: Vector4;
  59375. backUVs?: Vector4;
  59376. updatable?: boolean;
  59377. }, scene?: Nullable<Scene>): Mesh;
  59378. /**
  59379. * Creates a plane polygonal mesh. By default, this is a disc
  59380. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59381. * * 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
  59382. * * 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
  59383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59386. * @param name defines the name of the mesh
  59387. * @param options defines the options used to create the mesh
  59388. * @param scene defines the hosting scene
  59389. * @returns the plane polygonal mesh
  59390. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59391. */
  59392. static CreateDisc(name: string, options: {
  59393. radius?: number;
  59394. tessellation?: number;
  59395. arc?: number;
  59396. updatable?: boolean;
  59397. sideOrientation?: number;
  59398. frontUVs?: Vector4;
  59399. backUVs?: Vector4;
  59400. }, scene?: Nullable<Scene>): Mesh;
  59401. /**
  59402. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59403. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59404. * * 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`)
  59405. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59406. * * 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
  59407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59410. * @param name defines the name of the mesh
  59411. * @param options defines the options used to create the mesh
  59412. * @param scene defines the hosting scene
  59413. * @returns the icosahedron mesh
  59414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59415. */
  59416. static CreateIcoSphere(name: string, options: {
  59417. radius?: number;
  59418. radiusX?: number;
  59419. radiusY?: number;
  59420. radiusZ?: number;
  59421. flat?: boolean;
  59422. subdivisions?: number;
  59423. sideOrientation?: number;
  59424. frontUVs?: Vector4;
  59425. backUVs?: Vector4;
  59426. updatable?: boolean;
  59427. }, scene?: Nullable<Scene>): Mesh;
  59428. /**
  59429. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59430. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59431. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59432. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59433. * * 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
  59434. * * 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
  59435. * * 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
  59436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59439. * * 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
  59440. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59441. * * 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
  59442. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59444. * @param name defines the name of the mesh
  59445. * @param options defines the options used to create the mesh
  59446. * @param scene defines the hosting scene
  59447. * @returns the ribbon mesh
  59448. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59450. */
  59451. static CreateRibbon(name: string, options: {
  59452. pathArray: Vector3[][];
  59453. closeArray?: boolean;
  59454. closePath?: boolean;
  59455. offset?: number;
  59456. updatable?: boolean;
  59457. sideOrientation?: number;
  59458. frontUVs?: Vector4;
  59459. backUVs?: Vector4;
  59460. instance?: Mesh;
  59461. invertUV?: boolean;
  59462. uvs?: Vector2[];
  59463. colors?: Color4[];
  59464. }, scene?: Nullable<Scene>): Mesh;
  59465. /**
  59466. * Creates a cylinder or a cone mesh
  59467. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59468. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59469. * * 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.
  59470. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59471. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59472. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59473. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59474. * * 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).
  59475. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59476. * * 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).
  59477. * * 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
  59478. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59479. * * 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
  59480. * * 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.
  59481. * * If `enclose` is false, a ring surface is one element.
  59482. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59483. * * 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
  59484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59487. * @param name defines the name of the mesh
  59488. * @param options defines the options used to create the mesh
  59489. * @param scene defines the hosting scene
  59490. * @returns the cylinder mesh
  59491. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59492. */
  59493. static CreateCylinder(name: string, options: {
  59494. height?: number;
  59495. diameterTop?: number;
  59496. diameterBottom?: number;
  59497. diameter?: number;
  59498. tessellation?: number;
  59499. subdivisions?: number;
  59500. arc?: number;
  59501. faceColors?: Color4[];
  59502. faceUV?: Vector4[];
  59503. updatable?: boolean;
  59504. hasRings?: boolean;
  59505. enclose?: boolean;
  59506. cap?: number;
  59507. sideOrientation?: number;
  59508. frontUVs?: Vector4;
  59509. backUVs?: Vector4;
  59510. }, scene?: Nullable<Scene>): Mesh;
  59511. /**
  59512. * Creates a torus mesh
  59513. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59514. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59515. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59519. * @param name defines the name of the mesh
  59520. * @param options defines the options used to create the mesh
  59521. * @param scene defines the hosting scene
  59522. * @returns the torus mesh
  59523. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59524. */
  59525. static CreateTorus(name: string, options: {
  59526. diameter?: number;
  59527. thickness?: number;
  59528. tessellation?: number;
  59529. updatable?: boolean;
  59530. sideOrientation?: number;
  59531. frontUVs?: Vector4;
  59532. backUVs?: Vector4;
  59533. }, scene?: Nullable<Scene>): Mesh;
  59534. /**
  59535. * Creates a torus knot mesh
  59536. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59537. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59538. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59539. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59543. * @param name defines the name of the mesh
  59544. * @param options defines the options used to create the mesh
  59545. * @param scene defines the hosting scene
  59546. * @returns the torus knot mesh
  59547. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59548. */
  59549. static CreateTorusKnot(name: string, options: {
  59550. radius?: number;
  59551. tube?: number;
  59552. radialSegments?: number;
  59553. tubularSegments?: number;
  59554. p?: number;
  59555. q?: number;
  59556. updatable?: boolean;
  59557. sideOrientation?: number;
  59558. frontUVs?: Vector4;
  59559. backUVs?: Vector4;
  59560. }, scene?: Nullable<Scene>): Mesh;
  59561. /**
  59562. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59563. * * 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
  59564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59565. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59566. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59567. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59568. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59569. * * 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
  59570. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59573. * @param name defines the name of the new line system
  59574. * @param options defines the options used to create the line system
  59575. * @param scene defines the hosting scene
  59576. * @returns a new line system mesh
  59577. */
  59578. static CreateLineSystem(name: string, options: {
  59579. lines: Vector3[][];
  59580. updatable?: boolean;
  59581. instance?: Nullable<LinesMesh>;
  59582. colors?: Nullable<Color4[][]>;
  59583. useVertexAlpha?: boolean;
  59584. }, scene: Nullable<Scene>): LinesMesh;
  59585. /**
  59586. * Creates a line mesh
  59587. * 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
  59588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59589. * * The parameter `points` is an array successive Vector3
  59590. * * 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
  59591. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59592. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59593. * * When updating an instance, remember that only point positions can change, not the number of points
  59594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59596. * @param name defines the name of the new line system
  59597. * @param options defines the options used to create the line system
  59598. * @param scene defines the hosting scene
  59599. * @returns a new line mesh
  59600. */
  59601. static CreateLines(name: string, options: {
  59602. points: Vector3[];
  59603. updatable?: boolean;
  59604. instance?: Nullable<LinesMesh>;
  59605. colors?: Color4[];
  59606. useVertexAlpha?: boolean;
  59607. }, scene?: Nullable<Scene>): LinesMesh;
  59608. /**
  59609. * Creates a dashed line mesh
  59610. * * 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
  59611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59612. * * The parameter `points` is an array successive Vector3
  59613. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59614. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59615. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59616. * * 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
  59617. * * When updating an instance, remember that only point positions can change, not the number of points
  59618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59619. * @param name defines the name of the mesh
  59620. * @param options defines the options used to create the mesh
  59621. * @param scene defines the hosting scene
  59622. * @returns the dashed line mesh
  59623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59624. */
  59625. static CreateDashedLines(name: string, options: {
  59626. points: Vector3[];
  59627. dashSize?: number;
  59628. gapSize?: number;
  59629. dashNb?: number;
  59630. updatable?: boolean;
  59631. instance?: LinesMesh;
  59632. }, scene?: Nullable<Scene>): LinesMesh;
  59633. /**
  59634. * 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.
  59635. * * 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.
  59636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59637. * * 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.
  59638. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59639. * * 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
  59640. * * 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
  59641. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59644. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59646. * @param name defines the name of the mesh
  59647. * @param options defines the options used to create the mesh
  59648. * @param scene defines the hosting scene
  59649. * @returns the extruded shape mesh
  59650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59652. */
  59653. static ExtrudeShape(name: string, options: {
  59654. shape: Vector3[];
  59655. path: Vector3[];
  59656. scale?: number;
  59657. rotation?: number;
  59658. cap?: number;
  59659. updatable?: boolean;
  59660. sideOrientation?: number;
  59661. frontUVs?: Vector4;
  59662. backUVs?: Vector4;
  59663. instance?: Mesh;
  59664. invertUV?: boolean;
  59665. }, scene?: Nullable<Scene>): Mesh;
  59666. /**
  59667. * Creates an custom extruded shape mesh.
  59668. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59669. * * 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.
  59670. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59671. * * 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
  59672. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59673. * * 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
  59674. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59675. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59676. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59677. * * 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
  59678. * * 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
  59679. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59684. * @param name defines the name of the mesh
  59685. * @param options defines the options used to create the mesh
  59686. * @param scene defines the hosting scene
  59687. * @returns the custom extruded shape mesh
  59688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59691. */
  59692. static ExtrudeShapeCustom(name: string, options: {
  59693. shape: Vector3[];
  59694. path: Vector3[];
  59695. scaleFunction?: any;
  59696. rotationFunction?: any;
  59697. ribbonCloseArray?: boolean;
  59698. ribbonClosePath?: boolean;
  59699. cap?: number;
  59700. updatable?: boolean;
  59701. sideOrientation?: number;
  59702. frontUVs?: Vector4;
  59703. backUVs?: Vector4;
  59704. instance?: Mesh;
  59705. invertUV?: boolean;
  59706. }, scene?: Nullable<Scene>): Mesh;
  59707. /**
  59708. * Creates lathe mesh.
  59709. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59710. * * 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
  59711. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59712. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59713. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59714. * * 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
  59715. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59716. * * 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
  59717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59721. * @param name defines the name of the mesh
  59722. * @param options defines the options used to create the mesh
  59723. * @param scene defines the hosting scene
  59724. * @returns the lathe mesh
  59725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59726. */
  59727. static CreateLathe(name: string, options: {
  59728. shape: Vector3[];
  59729. radius?: number;
  59730. tessellation?: number;
  59731. clip?: number;
  59732. arc?: number;
  59733. closed?: boolean;
  59734. updatable?: boolean;
  59735. sideOrientation?: number;
  59736. frontUVs?: Vector4;
  59737. backUVs?: Vector4;
  59738. cap?: number;
  59739. invertUV?: boolean;
  59740. }, scene?: Nullable<Scene>): Mesh;
  59741. /**
  59742. * Creates a tiled plane mesh
  59743. * * You can set a limited pattern arrangement with the tiles
  59744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59747. * @param name defines the name of the mesh
  59748. * @param options defines the options used to create the mesh
  59749. * @param scene defines the hosting scene
  59750. * @returns the plane mesh
  59751. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59752. */
  59753. static CreateTiledPlane(name: string, options: {
  59754. pattern?: number;
  59755. tileSize?: number;
  59756. tileWidth?: number;
  59757. tileHeight?: number;
  59758. size?: number;
  59759. width?: number;
  59760. height?: number;
  59761. alignHorizontal?: number;
  59762. alignVertical?: number;
  59763. sideOrientation?: number;
  59764. frontUVs?: Vector4;
  59765. backUVs?: Vector4;
  59766. updatable?: boolean;
  59767. }, scene?: Nullable<Scene>): Mesh;
  59768. /**
  59769. * Creates a plane mesh
  59770. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59771. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59772. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59776. * @param name defines the name of the mesh
  59777. * @param options defines the options used to create the mesh
  59778. * @param scene defines the hosting scene
  59779. * @returns the plane mesh
  59780. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59781. */
  59782. static CreatePlane(name: string, options: {
  59783. size?: number;
  59784. width?: number;
  59785. height?: number;
  59786. sideOrientation?: number;
  59787. frontUVs?: Vector4;
  59788. backUVs?: Vector4;
  59789. updatable?: boolean;
  59790. sourcePlane?: Plane;
  59791. }, scene?: Nullable<Scene>): Mesh;
  59792. /**
  59793. * Creates a ground mesh
  59794. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59795. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59797. * @param name defines the name of the mesh
  59798. * @param options defines the options used to create the mesh
  59799. * @param scene defines the hosting scene
  59800. * @returns the ground mesh
  59801. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59802. */
  59803. static CreateGround(name: string, options: {
  59804. width?: number;
  59805. height?: number;
  59806. subdivisions?: number;
  59807. subdivisionsX?: number;
  59808. subdivisionsY?: number;
  59809. updatable?: boolean;
  59810. }, scene?: Nullable<Scene>): Mesh;
  59811. /**
  59812. * Creates a tiled ground mesh
  59813. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59814. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59815. * * 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
  59816. * * 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
  59817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59818. * @param name defines the name of the mesh
  59819. * @param options defines the options used to create the mesh
  59820. * @param scene defines the hosting scene
  59821. * @returns the tiled ground mesh
  59822. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59823. */
  59824. static CreateTiledGround(name: string, options: {
  59825. xmin: number;
  59826. zmin: number;
  59827. xmax: number;
  59828. zmax: number;
  59829. subdivisions?: {
  59830. w: number;
  59831. h: number;
  59832. };
  59833. precision?: {
  59834. w: number;
  59835. h: number;
  59836. };
  59837. updatable?: boolean;
  59838. }, scene?: Nullable<Scene>): Mesh;
  59839. /**
  59840. * Creates a ground mesh from a height map
  59841. * * The parameter `url` sets the URL of the height map image resource.
  59842. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59843. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59844. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59845. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59846. * * 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.
  59847. * * 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).
  59848. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59850. * @param name defines the name of the mesh
  59851. * @param url defines the url to the height map
  59852. * @param options defines the options used to create the mesh
  59853. * @param scene defines the hosting scene
  59854. * @returns the ground mesh
  59855. * @see https://doc.babylonjs.com/babylon101/height_map
  59856. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59857. */
  59858. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59859. width?: number;
  59860. height?: number;
  59861. subdivisions?: number;
  59862. minHeight?: number;
  59863. maxHeight?: number;
  59864. colorFilter?: Color3;
  59865. alphaFilter?: number;
  59866. updatable?: boolean;
  59867. onReady?: (mesh: GroundMesh) => void;
  59868. }, scene?: Nullable<Scene>): GroundMesh;
  59869. /**
  59870. * Creates a polygon mesh
  59871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59872. * * 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
  59873. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59876. * * Remember you can only change the shape positions, not their number when updating a polygon
  59877. * @param name defines the name of the mesh
  59878. * @param options defines the options used to create the mesh
  59879. * @param scene defines the hosting scene
  59880. * @param earcutInjection can be used to inject your own earcut reference
  59881. * @returns the polygon mesh
  59882. */
  59883. static CreatePolygon(name: string, options: {
  59884. shape: Vector3[];
  59885. holes?: Vector3[][];
  59886. depth?: number;
  59887. faceUV?: Vector4[];
  59888. faceColors?: Color4[];
  59889. updatable?: boolean;
  59890. sideOrientation?: number;
  59891. frontUVs?: Vector4;
  59892. backUVs?: Vector4;
  59893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59894. /**
  59895. * Creates an extruded polygon mesh, with depth in the Y direction.
  59896. * * 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)
  59897. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59898. * @param name defines the name of the mesh
  59899. * @param options defines the options used to create the mesh
  59900. * @param scene defines the hosting scene
  59901. * @param earcutInjection can be used to inject your own earcut reference
  59902. * @returns the polygon mesh
  59903. */
  59904. static ExtrudePolygon(name: string, options: {
  59905. shape: Vector3[];
  59906. holes?: Vector3[][];
  59907. depth?: number;
  59908. faceUV?: Vector4[];
  59909. faceColors?: Color4[];
  59910. updatable?: boolean;
  59911. sideOrientation?: number;
  59912. frontUVs?: Vector4;
  59913. backUVs?: Vector4;
  59914. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59915. /**
  59916. * Creates a tube mesh.
  59917. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59918. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59919. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59920. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59921. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59922. * * 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)
  59923. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59924. * * 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
  59925. * * 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
  59926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59930. * @param name defines the name of the mesh
  59931. * @param options defines the options used to create the mesh
  59932. * @param scene defines the hosting scene
  59933. * @returns the tube mesh
  59934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59935. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59936. */
  59937. static CreateTube(name: string, options: {
  59938. path: Vector3[];
  59939. radius?: number;
  59940. tessellation?: number;
  59941. radiusFunction?: {
  59942. (i: number, distance: number): number;
  59943. };
  59944. cap?: number;
  59945. arc?: number;
  59946. updatable?: boolean;
  59947. sideOrientation?: number;
  59948. frontUVs?: Vector4;
  59949. backUVs?: Vector4;
  59950. instance?: Mesh;
  59951. invertUV?: boolean;
  59952. }, scene?: Nullable<Scene>): Mesh;
  59953. /**
  59954. * Creates a polyhedron mesh
  59955. * * 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
  59956. * * The parameter `size` (positive float, default 1) sets the polygon size
  59957. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59958. * * 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`
  59959. * * 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
  59960. * * 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)`)
  59961. * * 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
  59962. * * 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
  59963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59966. * @param name defines the name of the mesh
  59967. * @param options defines the options used to create the mesh
  59968. * @param scene defines the hosting scene
  59969. * @returns the polyhedron mesh
  59970. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59971. */
  59972. static CreatePolyhedron(name: string, options: {
  59973. type?: number;
  59974. size?: number;
  59975. sizeX?: number;
  59976. sizeY?: number;
  59977. sizeZ?: number;
  59978. custom?: any;
  59979. faceUV?: Vector4[];
  59980. faceColors?: Color4[];
  59981. flat?: boolean;
  59982. updatable?: boolean;
  59983. sideOrientation?: number;
  59984. frontUVs?: Vector4;
  59985. backUVs?: Vector4;
  59986. }, scene?: Nullable<Scene>): Mesh;
  59987. /**
  59988. * Creates a decal mesh.
  59989. * 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
  59990. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59991. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59992. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59993. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59994. * @param name defines the name of the mesh
  59995. * @param sourceMesh defines the mesh where the decal must be applied
  59996. * @param options defines the options used to create the mesh
  59997. * @param scene defines the hosting scene
  59998. * @returns the decal mesh
  59999. * @see https://doc.babylonjs.com/how_to/decals
  60000. */
  60001. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60002. position?: Vector3;
  60003. normal?: Vector3;
  60004. size?: Vector3;
  60005. angle?: number;
  60006. }): Mesh;
  60007. }
  60008. }
  60009. declare module "babylonjs/Meshes/meshSimplification" {
  60010. import { Mesh } from "babylonjs/Meshes/mesh";
  60011. /**
  60012. * A simplifier interface for future simplification implementations
  60013. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60014. */
  60015. export interface ISimplifier {
  60016. /**
  60017. * Simplification of a given mesh according to the given settings.
  60018. * Since this requires computation, it is assumed that the function runs async.
  60019. * @param settings The settings of the simplification, including quality and distance
  60020. * @param successCallback A callback that will be called after the mesh was simplified.
  60021. * @param errorCallback in case of an error, this callback will be called. optional.
  60022. */
  60023. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60024. }
  60025. /**
  60026. * Expected simplification settings.
  60027. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60028. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60029. */
  60030. export interface ISimplificationSettings {
  60031. /**
  60032. * Gets or sets the expected quality
  60033. */
  60034. quality: number;
  60035. /**
  60036. * Gets or sets the distance when this optimized version should be used
  60037. */
  60038. distance: number;
  60039. /**
  60040. * Gets an already optimized mesh
  60041. */
  60042. optimizeMesh?: boolean;
  60043. }
  60044. /**
  60045. * Class used to specify simplification options
  60046. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60047. */
  60048. export class SimplificationSettings implements ISimplificationSettings {
  60049. /** expected quality */
  60050. quality: number;
  60051. /** distance when this optimized version should be used */
  60052. distance: number;
  60053. /** already optimized mesh */
  60054. optimizeMesh?: boolean | undefined;
  60055. /**
  60056. * Creates a SimplificationSettings
  60057. * @param quality expected quality
  60058. * @param distance distance when this optimized version should be used
  60059. * @param optimizeMesh already optimized mesh
  60060. */
  60061. constructor(
  60062. /** expected quality */
  60063. quality: number,
  60064. /** distance when this optimized version should be used */
  60065. distance: number,
  60066. /** already optimized mesh */
  60067. optimizeMesh?: boolean | undefined);
  60068. }
  60069. /**
  60070. * Interface used to define a simplification task
  60071. */
  60072. export interface ISimplificationTask {
  60073. /**
  60074. * Array of settings
  60075. */
  60076. settings: Array<ISimplificationSettings>;
  60077. /**
  60078. * Simplification type
  60079. */
  60080. simplificationType: SimplificationType;
  60081. /**
  60082. * Mesh to simplify
  60083. */
  60084. mesh: Mesh;
  60085. /**
  60086. * Callback called on success
  60087. */
  60088. successCallback?: () => void;
  60089. /**
  60090. * Defines if parallel processing can be used
  60091. */
  60092. parallelProcessing: boolean;
  60093. }
  60094. /**
  60095. * Queue used to order the simplification tasks
  60096. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60097. */
  60098. export class SimplificationQueue {
  60099. private _simplificationArray;
  60100. /**
  60101. * Gets a boolean indicating that the process is still running
  60102. */
  60103. running: boolean;
  60104. /**
  60105. * Creates a new queue
  60106. */
  60107. constructor();
  60108. /**
  60109. * Adds a new simplification task
  60110. * @param task defines a task to add
  60111. */
  60112. addTask(task: ISimplificationTask): void;
  60113. /**
  60114. * Execute next task
  60115. */
  60116. executeNext(): void;
  60117. /**
  60118. * Execute a simplification task
  60119. * @param task defines the task to run
  60120. */
  60121. runSimplification(task: ISimplificationTask): void;
  60122. private getSimplifier;
  60123. }
  60124. /**
  60125. * The implemented types of simplification
  60126. * At the moment only Quadratic Error Decimation is implemented
  60127. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60128. */
  60129. export enum SimplificationType {
  60130. /** Quadratic error decimation */
  60131. QUADRATIC = 0
  60132. }
  60133. }
  60134. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60135. import { Scene } from "babylonjs/scene";
  60136. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60137. import { ISceneComponent } from "babylonjs/sceneComponent";
  60138. module "babylonjs/scene" {
  60139. interface Scene {
  60140. /** @hidden (Backing field) */
  60141. _simplificationQueue: SimplificationQueue;
  60142. /**
  60143. * Gets or sets the simplification queue attached to the scene
  60144. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60145. */
  60146. simplificationQueue: SimplificationQueue;
  60147. }
  60148. }
  60149. module "babylonjs/Meshes/mesh" {
  60150. interface Mesh {
  60151. /**
  60152. * Simplify the mesh according to the given array of settings.
  60153. * Function will return immediately and will simplify async
  60154. * @param settings a collection of simplification settings
  60155. * @param parallelProcessing should all levels calculate parallel or one after the other
  60156. * @param simplificationType the type of simplification to run
  60157. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60158. * @returns the current mesh
  60159. */
  60160. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60161. }
  60162. }
  60163. /**
  60164. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60165. * created in a scene
  60166. */
  60167. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60168. /**
  60169. * The component name helpfull to identify the component in the list of scene components.
  60170. */
  60171. readonly name: string;
  60172. /**
  60173. * The scene the component belongs to.
  60174. */
  60175. scene: Scene;
  60176. /**
  60177. * Creates a new instance of the component for the given scene
  60178. * @param scene Defines the scene to register the component in
  60179. */
  60180. constructor(scene: Scene);
  60181. /**
  60182. * Registers the component in a given scene
  60183. */
  60184. register(): void;
  60185. /**
  60186. * Rebuilds the elements related to this component in case of
  60187. * context lost for instance.
  60188. */
  60189. rebuild(): void;
  60190. /**
  60191. * Disposes the component and the associated ressources
  60192. */
  60193. dispose(): void;
  60194. private _beforeCameraUpdate;
  60195. }
  60196. }
  60197. declare module "babylonjs/Meshes/Builders/index" {
  60198. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60199. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60200. export * from "babylonjs/Meshes/Builders/discBuilder";
  60201. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60202. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60203. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60204. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60205. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60206. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60207. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60208. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60209. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60210. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60211. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60212. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60213. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60214. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60215. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60216. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60217. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60218. }
  60219. declare module "babylonjs/Meshes/index" {
  60220. export * from "babylonjs/Meshes/abstractMesh";
  60221. export * from "babylonjs/Meshes/buffer";
  60222. export * from "babylonjs/Meshes/Compression/index";
  60223. export * from "babylonjs/Meshes/csg";
  60224. export * from "babylonjs/Meshes/geometry";
  60225. export * from "babylonjs/Meshes/groundMesh";
  60226. export * from "babylonjs/Meshes/trailMesh";
  60227. export * from "babylonjs/Meshes/instancedMesh";
  60228. export * from "babylonjs/Meshes/linesMesh";
  60229. export * from "babylonjs/Meshes/mesh";
  60230. export * from "babylonjs/Meshes/mesh.vertexData";
  60231. export * from "babylonjs/Meshes/meshBuilder";
  60232. export * from "babylonjs/Meshes/meshSimplification";
  60233. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60234. export * from "babylonjs/Meshes/polygonMesh";
  60235. export * from "babylonjs/Meshes/subMesh";
  60236. export * from "babylonjs/Meshes/meshLODLevel";
  60237. export * from "babylonjs/Meshes/transformNode";
  60238. export * from "babylonjs/Meshes/Builders/index";
  60239. export * from "babylonjs/Meshes/dataBuffer";
  60240. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60241. }
  60242. declare module "babylonjs/Morph/index" {
  60243. export * from "babylonjs/Morph/morphTarget";
  60244. export * from "babylonjs/Morph/morphTargetManager";
  60245. }
  60246. declare module "babylonjs/Navigation/INavigationEngine" {
  60247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60248. import { Vector3 } from "babylonjs/Maths/math";
  60249. import { Mesh } from "babylonjs/Meshes/mesh";
  60250. import { Scene } from "babylonjs/scene";
  60251. /**
  60252. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60253. */
  60254. export interface INavigationEnginePlugin {
  60255. /**
  60256. * plugin name
  60257. */
  60258. name: string;
  60259. /**
  60260. * Creates a navigation mesh
  60261. * @param meshes array of all the geometry used to compute the navigatio mesh
  60262. * @param parameters bunch of parameters used to filter geometry
  60263. */
  60264. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60265. /**
  60266. * Create a navigation mesh debug mesh
  60267. * @param scene is where the mesh will be added
  60268. * @returns debug display mesh
  60269. */
  60270. createDebugNavMesh(scene: Scene): Mesh;
  60271. /**
  60272. * Get a navigation mesh constrained position, closest to the parameter position
  60273. * @param position world position
  60274. * @returns the closest point to position constrained by the navigation mesh
  60275. */
  60276. getClosestPoint(position: Vector3): Vector3;
  60277. /**
  60278. * Get a navigation mesh constrained position, within a particular radius
  60279. * @param position world position
  60280. * @param maxRadius the maximum distance to the constrained world position
  60281. * @returns the closest point to position constrained by the navigation mesh
  60282. */
  60283. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60284. /**
  60285. * Compute the final position from a segment made of destination-position
  60286. * @param position world position
  60287. * @param destination world position
  60288. * @returns the resulting point along the navmesh
  60289. */
  60290. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60291. /**
  60292. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60293. * @param start world position
  60294. * @param end world position
  60295. * @returns array containing world position composing the path
  60296. */
  60297. computePath(start: Vector3, end: Vector3): Vector3[];
  60298. /**
  60299. * If this plugin is supported
  60300. * @returns true if plugin is supported
  60301. */
  60302. isSupported(): boolean;
  60303. /**
  60304. * Create a new Crowd so you can add agents
  60305. * @param maxAgents the maximum agent count in the crowd
  60306. * @param maxAgentRadius the maximum radius an agent can have
  60307. * @param scene to attach the crowd to
  60308. * @returns the crowd you can add agents to
  60309. */
  60310. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60311. /**
  60312. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60313. * The queries will try to find a solution within those bounds
  60314. * default is (1,1,1)
  60315. * @param extent x,y,z value that define the extent around the queries point of reference
  60316. */
  60317. setDefaultQueryExtent(extent: Vector3): void;
  60318. /**
  60319. * Get the Bounding box extent specified by setDefaultQueryExtent
  60320. * @returns the box extent values
  60321. */
  60322. getDefaultQueryExtent(): Vector3;
  60323. /**
  60324. * Release all resources
  60325. */
  60326. dispose(): void;
  60327. }
  60328. /**
  60329. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60330. */
  60331. export interface ICrowd {
  60332. /**
  60333. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60334. * You can attach anything to that node. The node position is updated in the scene update tick.
  60335. * @param pos world position that will be constrained by the navigation mesh
  60336. * @param parameters agent parameters
  60337. * @param transform hooked to the agent that will be update by the scene
  60338. * @returns agent index
  60339. */
  60340. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60341. /**
  60342. * Returns the agent position in world space
  60343. * @param index agent index returned by addAgent
  60344. * @returns world space position
  60345. */
  60346. getAgentPosition(index: number): Vector3;
  60347. /**
  60348. * Gets the agent velocity in world space
  60349. * @param index agent index returned by addAgent
  60350. * @returns world space velocity
  60351. */
  60352. getAgentVelocity(index: number): Vector3;
  60353. /**
  60354. * remove a particular agent previously created
  60355. * @param index agent index returned by addAgent
  60356. */
  60357. removeAgent(index: number): void;
  60358. /**
  60359. * get the list of all agents attached to this crowd
  60360. * @returns list of agent indices
  60361. */
  60362. getAgents(): number[];
  60363. /**
  60364. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60365. * @param deltaTime in seconds
  60366. */
  60367. update(deltaTime: number): void;
  60368. /**
  60369. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60370. * @param index agent index returned by addAgent
  60371. * @param destination targeted world position
  60372. */
  60373. agentGoto(index: number, destination: Vector3): void;
  60374. /**
  60375. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60376. * The queries will try to find a solution within those bounds
  60377. * default is (1,1,1)
  60378. * @param extent x,y,z value that define the extent around the queries point of reference
  60379. */
  60380. setDefaultQueryExtent(extent: Vector3): void;
  60381. /**
  60382. * Get the Bounding box extent specified by setDefaultQueryExtent
  60383. * @returns the box extent values
  60384. */
  60385. getDefaultQueryExtent(): Vector3;
  60386. /**
  60387. * Release all resources
  60388. */
  60389. dispose(): void;
  60390. }
  60391. /**
  60392. * Configures an agent
  60393. */
  60394. export interface IAgentParameters {
  60395. /**
  60396. * Agent radius. [Limit: >= 0]
  60397. */
  60398. radius: number;
  60399. /**
  60400. * Agent height. [Limit: > 0]
  60401. */
  60402. height: number;
  60403. /**
  60404. * Maximum allowed acceleration. [Limit: >= 0]
  60405. */
  60406. maxAcceleration: number;
  60407. /**
  60408. * Maximum allowed speed. [Limit: >= 0]
  60409. */
  60410. maxSpeed: number;
  60411. /**
  60412. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60413. */
  60414. collisionQueryRange: number;
  60415. /**
  60416. * The path visibility optimization range. [Limit: > 0]
  60417. */
  60418. pathOptimizationRange: number;
  60419. /**
  60420. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60421. */
  60422. separationWeight: number;
  60423. }
  60424. /**
  60425. * Configures the navigation mesh creation
  60426. */
  60427. export interface INavMeshParameters {
  60428. /**
  60429. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60430. */
  60431. cs: number;
  60432. /**
  60433. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60434. */
  60435. ch: number;
  60436. /**
  60437. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60438. */
  60439. walkableSlopeAngle: number;
  60440. /**
  60441. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60442. * be considered walkable. [Limit: >= 3] [Units: vx]
  60443. */
  60444. walkableHeight: number;
  60445. /**
  60446. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60447. */
  60448. walkableClimb: number;
  60449. /**
  60450. * The distance to erode/shrink the walkable area of the heightfield away from
  60451. * obstructions. [Limit: >=0] [Units: vx]
  60452. */
  60453. walkableRadius: number;
  60454. /**
  60455. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60456. */
  60457. maxEdgeLen: number;
  60458. /**
  60459. * The maximum distance a simplfied contour's border edges should deviate
  60460. * the original raw contour. [Limit: >=0] [Units: vx]
  60461. */
  60462. maxSimplificationError: number;
  60463. /**
  60464. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60465. */
  60466. minRegionArea: number;
  60467. /**
  60468. * Any regions with a span count smaller than this value will, if possible,
  60469. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60470. */
  60471. mergeRegionArea: number;
  60472. /**
  60473. * The maximum number of vertices allowed for polygons generated during the
  60474. * contour to polygon conversion process. [Limit: >= 3]
  60475. */
  60476. maxVertsPerPoly: number;
  60477. /**
  60478. * Sets the sampling distance to use when generating the detail mesh.
  60479. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60480. */
  60481. detailSampleDist: number;
  60482. /**
  60483. * The maximum distance the detail mesh surface should deviate from heightfield
  60484. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60485. */
  60486. detailSampleMaxError: number;
  60487. }
  60488. }
  60489. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60490. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60491. import { Mesh } from "babylonjs/Meshes/mesh";
  60492. import { Scene } from "babylonjs/scene";
  60493. import { Vector3 } from "babylonjs/Maths/math";
  60494. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60495. /**
  60496. * RecastJS navigation plugin
  60497. */
  60498. export class RecastJSPlugin implements INavigationEnginePlugin {
  60499. /**
  60500. * Reference to the Recast library
  60501. */
  60502. bjsRECAST: any;
  60503. /**
  60504. * plugin name
  60505. */
  60506. name: string;
  60507. /**
  60508. * the first navmesh created. We might extend this to support multiple navmeshes
  60509. */
  60510. navMesh: any;
  60511. /**
  60512. * Initializes the recastJS plugin
  60513. * @param recastInjection can be used to inject your own recast reference
  60514. */
  60515. constructor(recastInjection?: any);
  60516. /**
  60517. * Creates a navigation mesh
  60518. * @param meshes array of all the geometry used to compute the navigatio mesh
  60519. * @param parameters bunch of parameters used to filter geometry
  60520. */
  60521. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60522. /**
  60523. * Create a navigation mesh debug mesh
  60524. * @param scene is where the mesh will be added
  60525. * @returns debug display mesh
  60526. */
  60527. createDebugNavMesh(scene: Scene): Mesh;
  60528. /**
  60529. * Get a navigation mesh constrained position, closest to the parameter position
  60530. * @param position world position
  60531. * @returns the closest point to position constrained by the navigation mesh
  60532. */
  60533. getClosestPoint(position: Vector3): Vector3;
  60534. /**
  60535. * Get a navigation mesh constrained position, within a particular radius
  60536. * @param position world position
  60537. * @param maxRadius the maximum distance to the constrained world position
  60538. * @returns the closest point to position constrained by the navigation mesh
  60539. */
  60540. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60541. /**
  60542. * Compute the final position from a segment made of destination-position
  60543. * @param position world position
  60544. * @param destination world position
  60545. * @returns the resulting point along the navmesh
  60546. */
  60547. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60548. /**
  60549. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60550. * @param start world position
  60551. * @param end world position
  60552. * @returns array containing world position composing the path
  60553. */
  60554. computePath(start: Vector3, end: Vector3): Vector3[];
  60555. /**
  60556. * Create a new Crowd so you can add agents
  60557. * @param maxAgents the maximum agent count in the crowd
  60558. * @param maxAgentRadius the maximum radius an agent can have
  60559. * @param scene to attach the crowd to
  60560. * @returns the crowd you can add agents to
  60561. */
  60562. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60563. /**
  60564. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60565. * The queries will try to find a solution within those bounds
  60566. * default is (1,1,1)
  60567. * @param extent x,y,z value that define the extent around the queries point of reference
  60568. */
  60569. setDefaultQueryExtent(extent: Vector3): void;
  60570. /**
  60571. * Get the Bounding box extent specified by setDefaultQueryExtent
  60572. * @returns the box extent values
  60573. */
  60574. getDefaultQueryExtent(): Vector3;
  60575. /**
  60576. * Disposes
  60577. */
  60578. dispose(): void;
  60579. /**
  60580. * If this plugin is supported
  60581. * @returns true if plugin is supported
  60582. */
  60583. isSupported(): boolean;
  60584. }
  60585. /**
  60586. * Recast detour crowd implementation
  60587. */
  60588. export class RecastJSCrowd implements ICrowd {
  60589. /**
  60590. * Recast/detour plugin
  60591. */
  60592. bjsRECASTPlugin: RecastJSPlugin;
  60593. /**
  60594. * Link to the detour crowd
  60595. */
  60596. recastCrowd: any;
  60597. /**
  60598. * One transform per agent
  60599. */
  60600. transforms: TransformNode[];
  60601. /**
  60602. * All agents created
  60603. */
  60604. agents: number[];
  60605. /**
  60606. * Link to the scene is kept to unregister the crowd from the scene
  60607. */
  60608. private _scene;
  60609. /**
  60610. * Observer for crowd updates
  60611. */
  60612. private _onBeforeAnimationsObserver;
  60613. /**
  60614. * Constructor
  60615. * @param plugin recastJS plugin
  60616. * @param maxAgents the maximum agent count in the crowd
  60617. * @param maxAgentRadius the maximum radius an agent can have
  60618. * @param scene to attach the crowd to
  60619. * @returns the crowd you can add agents to
  60620. */
  60621. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60622. /**
  60623. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60624. * You can attach anything to that node. The node position is updated in the scene update tick.
  60625. * @param pos world position that will be constrained by the navigation mesh
  60626. * @param parameters agent parameters
  60627. * @param transform hooked to the agent that will be update by the scene
  60628. * @returns agent index
  60629. */
  60630. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60631. /**
  60632. * Returns the agent position in world space
  60633. * @param index agent index returned by addAgent
  60634. * @returns world space position
  60635. */
  60636. getAgentPosition(index: number): Vector3;
  60637. /**
  60638. * Returns the agent velocity in world space
  60639. * @param index agent index returned by addAgent
  60640. * @returns world space velocity
  60641. */
  60642. getAgentVelocity(index: number): Vector3;
  60643. /**
  60644. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60645. * @param index agent index returned by addAgent
  60646. * @param destination targeted world position
  60647. */
  60648. agentGoto(index: number, destination: Vector3): void;
  60649. /**
  60650. * remove a particular agent previously created
  60651. * @param index agent index returned by addAgent
  60652. */
  60653. removeAgent(index: number): void;
  60654. /**
  60655. * get the list of all agents attached to this crowd
  60656. * @returns list of agent indices
  60657. */
  60658. getAgents(): number[];
  60659. /**
  60660. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60661. * @param deltaTime in seconds
  60662. */
  60663. update(deltaTime: number): void;
  60664. /**
  60665. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60666. * The queries will try to find a solution within those bounds
  60667. * default is (1,1,1)
  60668. * @param extent x,y,z value that define the extent around the queries point of reference
  60669. */
  60670. setDefaultQueryExtent(extent: Vector3): void;
  60671. /**
  60672. * Get the Bounding box extent specified by setDefaultQueryExtent
  60673. * @returns the box extent values
  60674. */
  60675. getDefaultQueryExtent(): Vector3;
  60676. /**
  60677. * Release all resources
  60678. */
  60679. dispose(): void;
  60680. }
  60681. }
  60682. declare module "babylonjs/Navigation/Plugins/index" {
  60683. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60684. }
  60685. declare module "babylonjs/Navigation/index" {
  60686. export * from "babylonjs/Navigation/INavigationEngine";
  60687. export * from "babylonjs/Navigation/Plugins/index";
  60688. }
  60689. declare module "babylonjs/Offline/database" {
  60690. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60691. /**
  60692. * Class used to enable access to IndexedDB
  60693. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60694. */
  60695. export class Database implements IOfflineProvider {
  60696. private _callbackManifestChecked;
  60697. private _currentSceneUrl;
  60698. private _db;
  60699. private _enableSceneOffline;
  60700. private _enableTexturesOffline;
  60701. private _manifestVersionFound;
  60702. private _mustUpdateRessources;
  60703. private _hasReachedQuota;
  60704. private _isSupported;
  60705. private _idbFactory;
  60706. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60707. private static IsUASupportingBlobStorage;
  60708. /**
  60709. * Gets a boolean indicating if Database storate is enabled (off by default)
  60710. */
  60711. static IDBStorageEnabled: boolean;
  60712. /**
  60713. * Gets a boolean indicating if scene must be saved in the database
  60714. */
  60715. readonly enableSceneOffline: boolean;
  60716. /**
  60717. * Gets a boolean indicating if textures must be saved in the database
  60718. */
  60719. readonly enableTexturesOffline: boolean;
  60720. /**
  60721. * Creates a new Database
  60722. * @param urlToScene defines the url to load the scene
  60723. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60724. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60725. */
  60726. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60727. private static _ParseURL;
  60728. private static _ReturnFullUrlLocation;
  60729. private _checkManifestFile;
  60730. /**
  60731. * Open the database and make it available
  60732. * @param successCallback defines the callback to call on success
  60733. * @param errorCallback defines the callback to call on error
  60734. */
  60735. open(successCallback: () => void, errorCallback: () => void): void;
  60736. /**
  60737. * Loads an image from the database
  60738. * @param url defines the url to load from
  60739. * @param image defines the target DOM image
  60740. */
  60741. loadImage(url: string, image: HTMLImageElement): void;
  60742. private _loadImageFromDBAsync;
  60743. private _saveImageIntoDBAsync;
  60744. private _checkVersionFromDB;
  60745. private _loadVersionFromDBAsync;
  60746. private _saveVersionIntoDBAsync;
  60747. /**
  60748. * Loads a file from database
  60749. * @param url defines the URL to load from
  60750. * @param sceneLoaded defines a callback to call on success
  60751. * @param progressCallBack defines a callback to call when progress changed
  60752. * @param errorCallback defines a callback to call on error
  60753. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60754. */
  60755. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60756. private _loadFileAsync;
  60757. private _saveFileAsync;
  60758. /**
  60759. * Validates if xhr data is correct
  60760. * @param xhr defines the request to validate
  60761. * @param dataType defines the expected data type
  60762. * @returns true if data is correct
  60763. */
  60764. private static _ValidateXHRData;
  60765. }
  60766. }
  60767. declare module "babylonjs/Offline/index" {
  60768. export * from "babylonjs/Offline/database";
  60769. export * from "babylonjs/Offline/IOfflineProvider";
  60770. }
  60771. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60772. /** @hidden */
  60773. export var gpuUpdateParticlesPixelShader: {
  60774. name: string;
  60775. shader: string;
  60776. };
  60777. }
  60778. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60779. /** @hidden */
  60780. export var gpuUpdateParticlesVertexShader: {
  60781. name: string;
  60782. shader: string;
  60783. };
  60784. }
  60785. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60786. /** @hidden */
  60787. export var clipPlaneFragmentDeclaration2: {
  60788. name: string;
  60789. shader: string;
  60790. };
  60791. }
  60792. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60793. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60794. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60795. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60796. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60797. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60798. /** @hidden */
  60799. export var gpuRenderParticlesPixelShader: {
  60800. name: string;
  60801. shader: string;
  60802. };
  60803. }
  60804. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60805. /** @hidden */
  60806. export var clipPlaneVertexDeclaration2: {
  60807. name: string;
  60808. shader: string;
  60809. };
  60810. }
  60811. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60812. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60813. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60814. /** @hidden */
  60815. export var gpuRenderParticlesVertexShader: {
  60816. name: string;
  60817. shader: string;
  60818. };
  60819. }
  60820. declare module "babylonjs/Particles/gpuParticleSystem" {
  60821. import { Nullable } from "babylonjs/types";
  60822. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60823. import { Observable } from "babylonjs/Misc/observable";
  60824. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60825. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60826. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60827. import { Scene, IDisposable } from "babylonjs/scene";
  60828. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60829. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60830. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60831. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60832. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60833. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60834. /**
  60835. * This represents a GPU particle system in Babylon
  60836. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60837. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60838. */
  60839. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60840. /**
  60841. * The layer mask we are rendering the particles through.
  60842. */
  60843. layerMask: number;
  60844. private _capacity;
  60845. private _activeCount;
  60846. private _currentActiveCount;
  60847. private _accumulatedCount;
  60848. private _renderEffect;
  60849. private _updateEffect;
  60850. private _buffer0;
  60851. private _buffer1;
  60852. private _spriteBuffer;
  60853. private _updateVAO;
  60854. private _renderVAO;
  60855. private _targetIndex;
  60856. private _sourceBuffer;
  60857. private _targetBuffer;
  60858. private _engine;
  60859. private _currentRenderId;
  60860. private _started;
  60861. private _stopped;
  60862. private _timeDelta;
  60863. private _randomTexture;
  60864. private _randomTexture2;
  60865. private _attributesStrideSize;
  60866. private _updateEffectOptions;
  60867. private _randomTextureSize;
  60868. private _actualFrame;
  60869. private readonly _rawTextureWidth;
  60870. /**
  60871. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60872. */
  60873. static readonly IsSupported: boolean;
  60874. /**
  60875. * An event triggered when the system is disposed.
  60876. */
  60877. onDisposeObservable: Observable<GPUParticleSystem>;
  60878. /**
  60879. * Gets the maximum number of particles active at the same time.
  60880. * @returns The max number of active particles.
  60881. */
  60882. getCapacity(): number;
  60883. /**
  60884. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60885. * to override the particles.
  60886. */
  60887. forceDepthWrite: boolean;
  60888. /**
  60889. * Gets or set the number of active particles
  60890. */
  60891. activeParticleCount: number;
  60892. private _preWarmDone;
  60893. /**
  60894. * Is this system ready to be used/rendered
  60895. * @return true if the system is ready
  60896. */
  60897. isReady(): boolean;
  60898. /**
  60899. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60900. * @returns True if it has been started, otherwise false.
  60901. */
  60902. isStarted(): boolean;
  60903. /**
  60904. * Starts the particle system and begins to emit
  60905. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60906. */
  60907. start(delay?: number): void;
  60908. /**
  60909. * Stops the particle system.
  60910. */
  60911. stop(): void;
  60912. /**
  60913. * Remove all active particles
  60914. */
  60915. reset(): void;
  60916. /**
  60917. * Returns the string "GPUParticleSystem"
  60918. * @returns a string containing the class name
  60919. */
  60920. getClassName(): string;
  60921. private _colorGradientsTexture;
  60922. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60923. /**
  60924. * Adds a new color gradient
  60925. * @param gradient defines the gradient to use (between 0 and 1)
  60926. * @param color1 defines the color to affect to the specified gradient
  60927. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60928. * @returns the current particle system
  60929. */
  60930. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60931. /**
  60932. * Remove a specific color gradient
  60933. * @param gradient defines the gradient to remove
  60934. * @returns the current particle system
  60935. */
  60936. removeColorGradient(gradient: number): GPUParticleSystem;
  60937. private _angularSpeedGradientsTexture;
  60938. private _sizeGradientsTexture;
  60939. private _velocityGradientsTexture;
  60940. private _limitVelocityGradientsTexture;
  60941. private _dragGradientsTexture;
  60942. private _addFactorGradient;
  60943. /**
  60944. * Adds a new size gradient
  60945. * @param gradient defines the gradient to use (between 0 and 1)
  60946. * @param factor defines the size factor to affect to the specified gradient
  60947. * @returns the current particle system
  60948. */
  60949. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60950. /**
  60951. * Remove a specific size gradient
  60952. * @param gradient defines the gradient to remove
  60953. * @returns the current particle system
  60954. */
  60955. removeSizeGradient(gradient: number): GPUParticleSystem;
  60956. /**
  60957. * Adds a new angular speed gradient
  60958. * @param gradient defines the gradient to use (between 0 and 1)
  60959. * @param factor defines the angular speed to affect to the specified gradient
  60960. * @returns the current particle system
  60961. */
  60962. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60963. /**
  60964. * Remove a specific angular speed gradient
  60965. * @param gradient defines the gradient to remove
  60966. * @returns the current particle system
  60967. */
  60968. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60969. /**
  60970. * Adds a new velocity gradient
  60971. * @param gradient defines the gradient to use (between 0 and 1)
  60972. * @param factor defines the velocity to affect to the specified gradient
  60973. * @returns the current particle system
  60974. */
  60975. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60976. /**
  60977. * Remove a specific velocity gradient
  60978. * @param gradient defines the gradient to remove
  60979. * @returns the current particle system
  60980. */
  60981. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60982. /**
  60983. * Adds a new limit velocity gradient
  60984. * @param gradient defines the gradient to use (between 0 and 1)
  60985. * @param factor defines the limit velocity value to affect to the specified gradient
  60986. * @returns the current particle system
  60987. */
  60988. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60989. /**
  60990. * Remove a specific limit velocity gradient
  60991. * @param gradient defines the gradient to remove
  60992. * @returns the current particle system
  60993. */
  60994. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60995. /**
  60996. * Adds a new drag gradient
  60997. * @param gradient defines the gradient to use (between 0 and 1)
  60998. * @param factor defines the drag value to affect to the specified gradient
  60999. * @returns the current particle system
  61000. */
  61001. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61002. /**
  61003. * Remove a specific drag gradient
  61004. * @param gradient defines the gradient to remove
  61005. * @returns the current particle system
  61006. */
  61007. removeDragGradient(gradient: number): GPUParticleSystem;
  61008. /**
  61009. * Not supported by GPUParticleSystem
  61010. * @param gradient defines the gradient to use (between 0 and 1)
  61011. * @param factor defines the emit rate value to affect to the specified gradient
  61012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61013. * @returns the current particle system
  61014. */
  61015. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61016. /**
  61017. * Not supported by GPUParticleSystem
  61018. * @param gradient defines the gradient to remove
  61019. * @returns the current particle system
  61020. */
  61021. removeEmitRateGradient(gradient: number): IParticleSystem;
  61022. /**
  61023. * Not supported by GPUParticleSystem
  61024. * @param gradient defines the gradient to use (between 0 and 1)
  61025. * @param factor defines the start size value to affect to the specified gradient
  61026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61027. * @returns the current particle system
  61028. */
  61029. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61030. /**
  61031. * Not supported by GPUParticleSystem
  61032. * @param gradient defines the gradient to remove
  61033. * @returns the current particle system
  61034. */
  61035. removeStartSizeGradient(gradient: number): IParticleSystem;
  61036. /**
  61037. * Not supported by GPUParticleSystem
  61038. * @param gradient defines the gradient to use (between 0 and 1)
  61039. * @param min defines the color remap minimal range
  61040. * @param max defines the color remap maximal range
  61041. * @returns the current particle system
  61042. */
  61043. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61044. /**
  61045. * Not supported by GPUParticleSystem
  61046. * @param gradient defines the gradient to remove
  61047. * @returns the current particle system
  61048. */
  61049. removeColorRemapGradient(): IParticleSystem;
  61050. /**
  61051. * Not supported by GPUParticleSystem
  61052. * @param gradient defines the gradient to use (between 0 and 1)
  61053. * @param min defines the alpha remap minimal range
  61054. * @param max defines the alpha remap maximal range
  61055. * @returns the current particle system
  61056. */
  61057. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61058. /**
  61059. * Not supported by GPUParticleSystem
  61060. * @param gradient defines the gradient to remove
  61061. * @returns the current particle system
  61062. */
  61063. removeAlphaRemapGradient(): IParticleSystem;
  61064. /**
  61065. * Not supported by GPUParticleSystem
  61066. * @param gradient defines the gradient to use (between 0 and 1)
  61067. * @param color defines the color to affect to the specified gradient
  61068. * @returns the current particle system
  61069. */
  61070. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61071. /**
  61072. * Not supported by GPUParticleSystem
  61073. * @param gradient defines the gradient to remove
  61074. * @returns the current particle system
  61075. */
  61076. removeRampGradient(): IParticleSystem;
  61077. /**
  61078. * Not supported by GPUParticleSystem
  61079. * @returns the list of ramp gradients
  61080. */
  61081. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61082. /**
  61083. * Not supported by GPUParticleSystem
  61084. * Gets or sets a boolean indicating that ramp gradients must be used
  61085. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61086. */
  61087. useRampGradients: boolean;
  61088. /**
  61089. * Not supported by GPUParticleSystem
  61090. * @param gradient defines the gradient to use (between 0 and 1)
  61091. * @param factor defines the life time factor to affect to the specified gradient
  61092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61093. * @returns the current particle system
  61094. */
  61095. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61096. /**
  61097. * Not supported by GPUParticleSystem
  61098. * @param gradient defines the gradient to remove
  61099. * @returns the current particle system
  61100. */
  61101. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61102. /**
  61103. * Instantiates a GPU particle system.
  61104. * 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.
  61105. * @param name The name of the particle system
  61106. * @param options The options used to create the system
  61107. * @param scene The scene the particle system belongs to
  61108. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61109. */
  61110. constructor(name: string, options: Partial<{
  61111. capacity: number;
  61112. randomTextureSize: number;
  61113. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61114. protected _reset(): void;
  61115. private _createUpdateVAO;
  61116. private _createRenderVAO;
  61117. private _initialize;
  61118. /** @hidden */
  61119. _recreateUpdateEffect(): void;
  61120. /** @hidden */
  61121. _recreateRenderEffect(): void;
  61122. /**
  61123. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61124. * @param preWarm defines if we are in the pre-warmimg phase
  61125. */
  61126. animate(preWarm?: boolean): void;
  61127. private _createFactorGradientTexture;
  61128. private _createSizeGradientTexture;
  61129. private _createAngularSpeedGradientTexture;
  61130. private _createVelocityGradientTexture;
  61131. private _createLimitVelocityGradientTexture;
  61132. private _createDragGradientTexture;
  61133. private _createColorGradientTexture;
  61134. /**
  61135. * Renders the particle system in its current state
  61136. * @param preWarm defines if the system should only update the particles but not render them
  61137. * @returns the current number of particles
  61138. */
  61139. render(preWarm?: boolean): number;
  61140. /**
  61141. * Rebuilds the particle system
  61142. */
  61143. rebuild(): void;
  61144. private _releaseBuffers;
  61145. private _releaseVAOs;
  61146. /**
  61147. * Disposes the particle system and free the associated resources
  61148. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61149. */
  61150. dispose(disposeTexture?: boolean): void;
  61151. /**
  61152. * Clones the particle system.
  61153. * @param name The name of the cloned object
  61154. * @param newEmitter The new emitter to use
  61155. * @returns the cloned particle system
  61156. */
  61157. clone(name: string, newEmitter: any): GPUParticleSystem;
  61158. /**
  61159. * Serializes the particle system to a JSON object.
  61160. * @returns the JSON object
  61161. */
  61162. serialize(): any;
  61163. /**
  61164. * Parses a JSON object to create a GPU particle system.
  61165. * @param parsedParticleSystem The JSON object to parse
  61166. * @param scene The scene to create the particle system in
  61167. * @param rootUrl The root url to use to load external dependencies like texture
  61168. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61169. * @returns the parsed GPU particle system
  61170. */
  61171. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61172. }
  61173. }
  61174. declare module "babylonjs/Particles/particleSystemSet" {
  61175. import { Nullable } from "babylonjs/types";
  61176. import { Color3 } from "babylonjs/Maths/math.color";
  61177. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61179. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61180. import { Scene, IDisposable } from "babylonjs/scene";
  61181. /**
  61182. * Represents a set of particle systems working together to create a specific effect
  61183. */
  61184. export class ParticleSystemSet implements IDisposable {
  61185. private _emitterCreationOptions;
  61186. private _emitterNode;
  61187. /**
  61188. * Gets the particle system list
  61189. */
  61190. systems: IParticleSystem[];
  61191. /**
  61192. * Gets the emitter node used with this set
  61193. */
  61194. readonly emitterNode: Nullable<TransformNode>;
  61195. /**
  61196. * Creates a new emitter mesh as a sphere
  61197. * @param options defines the options used to create the sphere
  61198. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61199. * @param scene defines the hosting scene
  61200. */
  61201. setEmitterAsSphere(options: {
  61202. diameter: number;
  61203. segments: number;
  61204. color: Color3;
  61205. }, renderingGroupId: number, scene: Scene): void;
  61206. /**
  61207. * Starts all particle systems of the set
  61208. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61209. */
  61210. start(emitter?: AbstractMesh): void;
  61211. /**
  61212. * Release all associated resources
  61213. */
  61214. dispose(): void;
  61215. /**
  61216. * Serialize the set into a JSON compatible object
  61217. * @returns a JSON compatible representation of the set
  61218. */
  61219. serialize(): any;
  61220. /**
  61221. * Parse a new ParticleSystemSet from a serialized source
  61222. * @param data defines a JSON compatible representation of the set
  61223. * @param scene defines the hosting scene
  61224. * @param gpu defines if we want GPU particles or CPU particles
  61225. * @returns a new ParticleSystemSet
  61226. */
  61227. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61228. }
  61229. }
  61230. declare module "babylonjs/Particles/particleHelper" {
  61231. import { Nullable } from "babylonjs/types";
  61232. import { Scene } from "babylonjs/scene";
  61233. import { Vector3 } from "babylonjs/Maths/math.vector";
  61234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61235. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61236. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61237. /**
  61238. * This class is made for on one-liner static method to help creating particle system set.
  61239. */
  61240. export class ParticleHelper {
  61241. /**
  61242. * Gets or sets base Assets URL
  61243. */
  61244. static BaseAssetsUrl: string;
  61245. /**
  61246. * Create a default particle system that you can tweak
  61247. * @param emitter defines the emitter to use
  61248. * @param capacity defines the system capacity (default is 500 particles)
  61249. * @param scene defines the hosting scene
  61250. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61251. * @returns the new Particle system
  61252. */
  61253. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61254. /**
  61255. * This is the main static method (one-liner) of this helper to create different particle systems
  61256. * @param type This string represents the type to the particle system to create
  61257. * @param scene The scene where the particle system should live
  61258. * @param gpu If the system will use gpu
  61259. * @returns the ParticleSystemSet created
  61260. */
  61261. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61262. /**
  61263. * Static function used to export a particle system to a ParticleSystemSet variable.
  61264. * Please note that the emitter shape is not exported
  61265. * @param systems defines the particle systems to export
  61266. * @returns the created particle system set
  61267. */
  61268. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61269. }
  61270. }
  61271. declare module "babylonjs/Particles/particleSystemComponent" {
  61272. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61273. import { Effect } from "babylonjs/Materials/effect";
  61274. import "babylonjs/Shaders/particles.vertex";
  61275. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61276. module "babylonjs/Engines/engine" {
  61277. interface Engine {
  61278. /**
  61279. * Create an effect to use with particle systems.
  61280. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61281. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61282. * @param uniformsNames defines a list of attribute names
  61283. * @param samplers defines an array of string used to represent textures
  61284. * @param defines defines the string containing the defines to use to compile the shaders
  61285. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61286. * @param onCompiled defines a function to call when the effect creation is successful
  61287. * @param onError defines a function to call when the effect creation has failed
  61288. * @returns the new Effect
  61289. */
  61290. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61291. }
  61292. }
  61293. module "babylonjs/Meshes/mesh" {
  61294. interface Mesh {
  61295. /**
  61296. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61297. * @returns an array of IParticleSystem
  61298. */
  61299. getEmittedParticleSystems(): IParticleSystem[];
  61300. /**
  61301. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61302. * @returns an array of IParticleSystem
  61303. */
  61304. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61305. }
  61306. }
  61307. /**
  61308. * @hidden
  61309. */
  61310. export var _IDoNeedToBeInTheBuild: number;
  61311. }
  61312. declare module "babylonjs/Particles/pointsCloudSystem" {
  61313. import { Color4 } from "babylonjs/Maths/math";
  61314. import { Mesh } from "babylonjs/Meshes/mesh";
  61315. import { Scene, IDisposable } from "babylonjs/scene";
  61316. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61317. /** Defines the 4 color options */
  61318. export enum PointColor {
  61319. /** color value */
  61320. Color = 2,
  61321. /** uv value */
  61322. UV = 1,
  61323. /** random value */
  61324. Random = 0,
  61325. /** stated value */
  61326. Stated = 3
  61327. }
  61328. /**
  61329. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61330. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61331. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61332. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61333. *
  61334. * Full documentation here : TO BE ENTERED
  61335. */
  61336. export class PointsCloudSystem implements IDisposable {
  61337. /**
  61338. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61339. * Example : var p = SPS.particles[i];
  61340. */
  61341. particles: CloudPoint[];
  61342. /**
  61343. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61344. */
  61345. nbParticles: number;
  61346. /**
  61347. * This a counter for your own usage. It's not set by any SPS functions.
  61348. */
  61349. counter: number;
  61350. /**
  61351. * The PCS name. This name is also given to the underlying mesh.
  61352. */
  61353. name: string;
  61354. /**
  61355. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61356. */
  61357. mesh: Mesh;
  61358. /**
  61359. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61360. * Please read :
  61361. */
  61362. vars: any;
  61363. /**
  61364. * @hidden
  61365. */
  61366. _size: number;
  61367. private _scene;
  61368. private _promises;
  61369. private _positions;
  61370. private _indices;
  61371. private _normals;
  61372. private _colors;
  61373. private _uvs;
  61374. private _indices32;
  61375. private _positions32;
  61376. private _colors32;
  61377. private _uvs32;
  61378. private _updatable;
  61379. private _isVisibilityBoxLocked;
  61380. private _alwaysVisible;
  61381. private _groups;
  61382. private _groupCounter;
  61383. private _computeParticleColor;
  61384. private _computeParticleTexture;
  61385. private _computeParticleRotation;
  61386. private _computeBoundingBox;
  61387. private _isReady;
  61388. /**
  61389. * Creates a PCS (Points Cloud System) object
  61390. * @param name (String) is the PCS name, this will be the underlying mesh name
  61391. * @param pointSize (number) is the size for each point
  61392. * @param scene (Scene) is the scene in which the PCS is added
  61393. * @param options defines the options of the PCS e.g.
  61394. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61395. */
  61396. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61397. updatable?: boolean;
  61398. });
  61399. /**
  61400. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61401. * If no points were added to the PCS, the returned mesh is just a single point.
  61402. * @returns a promise for the created mesh
  61403. */
  61404. buildMeshAsync(): Promise<Mesh>;
  61405. /**
  61406. * @hidden
  61407. */
  61408. private _buildMesh;
  61409. private _addParticle;
  61410. private _randomUnitVector;
  61411. private _getColorIndicesForCoord;
  61412. private _setPointsColorOrUV;
  61413. private _colorFromTexture;
  61414. private _calculateDensity;
  61415. /**
  61416. * Adds points to the PCS in random positions within a unit sphere
  61417. * @param nb (positive integer) the number of particles to be created from this model
  61418. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61419. * @returns the number of groups in the system
  61420. */
  61421. addPoints(nb: number, pointFunction?: any): number;
  61422. /**
  61423. * Adds points to the PCS from the surface of the model shape
  61424. * @param mesh is any Mesh object that will be used as a surface model for the points
  61425. * @param nb (positive integer) the number of particles to be created from this model
  61426. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61427. * @param color (color3) to be used when colorWith is stated
  61428. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61429. * @returns the number of groups in the system
  61430. */
  61431. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61432. /**
  61433. * Adds points to the PCS inside the model shape
  61434. * @param mesh is any Mesh object that will be used as a surface model for the points
  61435. * @param nb (positive integer) the number of particles to be created from this model
  61436. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61437. * @param color (color4) to be used when colorWith is stated
  61438. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61439. * @returns the number of groups in the system
  61440. */
  61441. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61442. /**
  61443. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61444. * This method calls `updateParticle()` for each particle of the SPS.
  61445. * For an animated SPS, it is usually called within the render loop.
  61446. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61447. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61448. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61449. * @returns the PCS.
  61450. */
  61451. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61452. /**
  61453. * Disposes the PCS.
  61454. */
  61455. dispose(): void;
  61456. /**
  61457. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61458. * doc :
  61459. * @returns the PCS.
  61460. */
  61461. refreshVisibleSize(): PointsCloudSystem;
  61462. /**
  61463. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61464. * @param size the size (float) of the visibility box
  61465. * note : this doesn't lock the PCS mesh bounding box.
  61466. * doc :
  61467. */
  61468. setVisibilityBox(size: number): void;
  61469. /**
  61470. * Gets whether the PCS is always visible or not
  61471. * doc :
  61472. */
  61473. /**
  61474. * Sets the PCS as always visible or not
  61475. * doc :
  61476. */
  61477. isAlwaysVisible: boolean;
  61478. /**
  61479. * Tells to `setParticles()` to compute the particle rotations or not
  61480. * Default value : false. The PCS is faster when it's set to false
  61481. * Note : particle rotations are only applied to parent particles
  61482. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61483. */
  61484. computeParticleRotation: boolean;
  61485. /**
  61486. * Tells to `setParticles()` to compute the particle colors or not.
  61487. * Default value : true. The PCS is faster when it's set to false.
  61488. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61489. */
  61490. /**
  61491. * Gets if `setParticles()` computes the particle colors or not.
  61492. * Default value : false. The PCS is faster when it's set to false.
  61493. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61494. */
  61495. computeParticleColor: boolean;
  61496. /**
  61497. * Gets if `setParticles()` computes the particle textures or not.
  61498. * Default value : false. The PCS is faster when it's set to false.
  61499. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61500. */
  61501. computeParticleTexture: boolean;
  61502. /**
  61503. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61504. */
  61505. /**
  61506. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61507. */
  61508. computeBoundingBox: boolean;
  61509. /**
  61510. * This function does nothing. It may be overwritten to set all the particle first values.
  61511. * The PCS doesn't call this function, you may have to call it by your own.
  61512. * doc :
  61513. */
  61514. initParticles(): void;
  61515. /**
  61516. * This function does nothing. It may be overwritten to recycle a particle
  61517. * The PCS doesn't call this function, you can to call it
  61518. * doc :
  61519. * @param particle The particle to recycle
  61520. * @returns the recycled particle
  61521. */
  61522. recycleParticle(particle: CloudPoint): CloudPoint;
  61523. /**
  61524. * Updates a particle : this function should be overwritten by the user.
  61525. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61526. * doc :
  61527. * @example : just set a particle position or velocity and recycle conditions
  61528. * @param particle The particle to update
  61529. * @returns the updated particle
  61530. */
  61531. updateParticle(particle: CloudPoint): CloudPoint;
  61532. /**
  61533. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61534. * This does nothing and may be overwritten by the user.
  61535. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61536. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61537. * @param update the boolean update value actually passed to setParticles()
  61538. */
  61539. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61540. /**
  61541. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61542. * This will be passed three parameters.
  61543. * This does nothing and may be overwritten by the user.
  61544. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61545. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61546. * @param update the boolean update value actually passed to setParticles()
  61547. */
  61548. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61549. }
  61550. }
  61551. declare module "babylonjs/Particles/cloudPoint" {
  61552. import { Nullable } from "babylonjs/types";
  61553. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61554. import { Mesh } from "babylonjs/Meshes/mesh";
  61555. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61556. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61557. /**
  61558. * Represents one particle of a points cloud system.
  61559. */
  61560. export class CloudPoint {
  61561. /**
  61562. * particle global index
  61563. */
  61564. idx: number;
  61565. /**
  61566. * The color of the particle
  61567. */
  61568. color: Nullable<Color4>;
  61569. /**
  61570. * The world space position of the particle.
  61571. */
  61572. position: Vector3;
  61573. /**
  61574. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61575. */
  61576. rotation: Vector3;
  61577. /**
  61578. * The world space rotation quaternion of the particle.
  61579. */
  61580. rotationQuaternion: Nullable<Quaternion>;
  61581. /**
  61582. * The uv of the particle.
  61583. */
  61584. uv: Nullable<Vector2>;
  61585. /**
  61586. * The current speed of the particle.
  61587. */
  61588. velocity: Vector3;
  61589. /**
  61590. * The pivot point in the particle local space.
  61591. */
  61592. pivot: Vector3;
  61593. /**
  61594. * Must the particle be translated from its pivot point in its local space ?
  61595. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61596. * Default : false
  61597. */
  61598. translateFromPivot: boolean;
  61599. /**
  61600. * Index of this particle in the global "positions" array (Internal use)
  61601. * @hidden
  61602. */
  61603. _pos: number;
  61604. /**
  61605. * @hidden Index of this particle in the global "indices" array (Internal use)
  61606. */
  61607. _ind: number;
  61608. /**
  61609. * Group this particle belongs to
  61610. */
  61611. _group: PointsGroup;
  61612. /**
  61613. * Group id of this particle
  61614. */
  61615. groupId: number;
  61616. /**
  61617. * Index of the particle in its group id (Internal use)
  61618. */
  61619. idxInGroup: number;
  61620. /**
  61621. * @hidden Particle BoundingInfo object (Internal use)
  61622. */
  61623. _boundingInfo: BoundingInfo;
  61624. /**
  61625. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61626. */
  61627. _pcs: PointsCloudSystem;
  61628. /**
  61629. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61630. */
  61631. _stillInvisible: boolean;
  61632. /**
  61633. * @hidden Last computed particle rotation matrix
  61634. */
  61635. _rotationMatrix: number[];
  61636. /**
  61637. * Parent particle Id, if any.
  61638. * Default null.
  61639. */
  61640. parentId: Nullable<number>;
  61641. /**
  61642. * @hidden Internal global position in the PCS.
  61643. */
  61644. _globalPosition: Vector3;
  61645. /**
  61646. * Creates a Point Cloud object.
  61647. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61648. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61649. * @param group (PointsGroup) is the group the particle belongs to
  61650. * @param groupId (integer) is the group identifier in the PCS.
  61651. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61652. * @param pcs defines the PCS it is associated to
  61653. */
  61654. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61655. /**
  61656. * get point size
  61657. */
  61658. /**
  61659. * Set point size
  61660. */
  61661. size: Vector3;
  61662. /**
  61663. * Legacy support, changed quaternion to rotationQuaternion
  61664. */
  61665. /**
  61666. * Legacy support, changed quaternion to rotationQuaternion
  61667. */
  61668. quaternion: Nullable<Quaternion>;
  61669. /**
  61670. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  61671. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  61672. * @param target is the object (point or mesh) what the intersection is computed against.
  61673. * @returns true if it intersects
  61674. */
  61675. intersectsMesh(target: Mesh | CloudPoint): boolean;
  61676. /**
  61677. * get the rotation matrix of the particle
  61678. * @hidden
  61679. */
  61680. getRotationMatrix(m: Matrix): void;
  61681. }
  61682. /**
  61683. * Represents a group of points in a points cloud system
  61684. * * PCS internal tool, don't use it manually.
  61685. */
  61686. export class PointsGroup {
  61687. /**
  61688. * The group id
  61689. * @hidden
  61690. */
  61691. groupID: number;
  61692. /**
  61693. * image data for group (internal use)
  61694. * @hidden
  61695. */
  61696. _groupImageData: Nullable<ArrayBufferView>;
  61697. /**
  61698. * Image Width (internal use)
  61699. * @hidden
  61700. */
  61701. _groupImgWidth: number;
  61702. /**
  61703. * Image Height (internal use)
  61704. * @hidden
  61705. */
  61706. _groupImgHeight: number;
  61707. /**
  61708. * Custom position function (internal use)
  61709. * @hidden
  61710. */
  61711. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61712. /**
  61713. * density per facet for surface points
  61714. * @hidden
  61715. */
  61716. _groupDensity: number[];
  61717. /**
  61718. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61719. * PCS internal tool, don't use it manually.
  61720. * @hidden
  61721. */
  61722. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61723. }
  61724. }
  61725. declare module "babylonjs/Particles/index" {
  61726. export * from "babylonjs/Particles/baseParticleSystem";
  61727. export * from "babylonjs/Particles/EmitterTypes/index";
  61728. export * from "babylonjs/Particles/gpuParticleSystem";
  61729. export * from "babylonjs/Particles/IParticleSystem";
  61730. export * from "babylonjs/Particles/particle";
  61731. export * from "babylonjs/Particles/particleHelper";
  61732. export * from "babylonjs/Particles/particleSystem";
  61733. export * from "babylonjs/Particles/particleSystemComponent";
  61734. export * from "babylonjs/Particles/particleSystemSet";
  61735. export * from "babylonjs/Particles/solidParticle";
  61736. export * from "babylonjs/Particles/solidParticleSystem";
  61737. export * from "babylonjs/Particles/cloudPoint";
  61738. export * from "babylonjs/Particles/pointsCloudSystem";
  61739. export * from "babylonjs/Particles/subEmitter";
  61740. }
  61741. declare module "babylonjs/Physics/physicsEngineComponent" {
  61742. import { Nullable } from "babylonjs/types";
  61743. import { Observable, Observer } from "babylonjs/Misc/observable";
  61744. import { Vector3 } from "babylonjs/Maths/math.vector";
  61745. import { Mesh } from "babylonjs/Meshes/mesh";
  61746. import { ISceneComponent } from "babylonjs/sceneComponent";
  61747. import { Scene } from "babylonjs/scene";
  61748. import { Node } from "babylonjs/node";
  61749. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61750. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61751. module "babylonjs/scene" {
  61752. interface Scene {
  61753. /** @hidden (Backing field) */
  61754. _physicsEngine: Nullable<IPhysicsEngine>;
  61755. /**
  61756. * Gets the current physics engine
  61757. * @returns a IPhysicsEngine or null if none attached
  61758. */
  61759. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61760. /**
  61761. * Enables physics to the current scene
  61762. * @param gravity defines the scene's gravity for the physics engine
  61763. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61764. * @return a boolean indicating if the physics engine was initialized
  61765. */
  61766. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61767. /**
  61768. * Disables and disposes the physics engine associated with the scene
  61769. */
  61770. disablePhysicsEngine(): void;
  61771. /**
  61772. * Gets a boolean indicating if there is an active physics engine
  61773. * @returns a boolean indicating if there is an active physics engine
  61774. */
  61775. isPhysicsEnabled(): boolean;
  61776. /**
  61777. * Deletes a physics compound impostor
  61778. * @param compound defines the compound to delete
  61779. */
  61780. deleteCompoundImpostor(compound: any): void;
  61781. /**
  61782. * An event triggered when physic simulation is about to be run
  61783. */
  61784. onBeforePhysicsObservable: Observable<Scene>;
  61785. /**
  61786. * An event triggered when physic simulation has been done
  61787. */
  61788. onAfterPhysicsObservable: Observable<Scene>;
  61789. }
  61790. }
  61791. module "babylonjs/Meshes/abstractMesh" {
  61792. interface AbstractMesh {
  61793. /** @hidden */
  61794. _physicsImpostor: Nullable<PhysicsImpostor>;
  61795. /**
  61796. * Gets or sets impostor used for physic simulation
  61797. * @see http://doc.babylonjs.com/features/physics_engine
  61798. */
  61799. physicsImpostor: Nullable<PhysicsImpostor>;
  61800. /**
  61801. * Gets the current physics impostor
  61802. * @see http://doc.babylonjs.com/features/physics_engine
  61803. * @returns a physics impostor or null
  61804. */
  61805. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61806. /** Apply a physic impulse to the mesh
  61807. * @param force defines the force to apply
  61808. * @param contactPoint defines where to apply the force
  61809. * @returns the current mesh
  61810. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61811. */
  61812. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61813. /**
  61814. * Creates a physic joint between two meshes
  61815. * @param otherMesh defines the other mesh to use
  61816. * @param pivot1 defines the pivot to use on this mesh
  61817. * @param pivot2 defines the pivot to use on the other mesh
  61818. * @param options defines additional options (can be plugin dependent)
  61819. * @returns the current mesh
  61820. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61821. */
  61822. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61823. /** @hidden */
  61824. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61825. }
  61826. }
  61827. /**
  61828. * Defines the physics engine scene component responsible to manage a physics engine
  61829. */
  61830. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61831. /**
  61832. * The component name helpful to identify the component in the list of scene components.
  61833. */
  61834. readonly name: string;
  61835. /**
  61836. * The scene the component belongs to.
  61837. */
  61838. scene: Scene;
  61839. /**
  61840. * Creates a new instance of the component for the given scene
  61841. * @param scene Defines the scene to register the component in
  61842. */
  61843. constructor(scene: Scene);
  61844. /**
  61845. * Registers the component in a given scene
  61846. */
  61847. register(): void;
  61848. /**
  61849. * Rebuilds the elements related to this component in case of
  61850. * context lost for instance.
  61851. */
  61852. rebuild(): void;
  61853. /**
  61854. * Disposes the component and the associated ressources
  61855. */
  61856. dispose(): void;
  61857. }
  61858. }
  61859. declare module "babylonjs/Physics/physicsHelper" {
  61860. import { Nullable } from "babylonjs/types";
  61861. import { Vector3 } from "babylonjs/Maths/math.vector";
  61862. import { Mesh } from "babylonjs/Meshes/mesh";
  61863. import { Scene } from "babylonjs/scene";
  61864. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61865. /**
  61866. * A helper for physics simulations
  61867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61868. */
  61869. export class PhysicsHelper {
  61870. private _scene;
  61871. private _physicsEngine;
  61872. /**
  61873. * Initializes the Physics helper
  61874. * @param scene Babylon.js scene
  61875. */
  61876. constructor(scene: Scene);
  61877. /**
  61878. * Applies a radial explosion impulse
  61879. * @param origin the origin of the explosion
  61880. * @param radiusOrEventOptions the radius or the options of radial explosion
  61881. * @param strength the explosion strength
  61882. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61883. * @returns A physics radial explosion event, or null
  61884. */
  61885. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61886. /**
  61887. * Applies a radial explosion force
  61888. * @param origin the origin of the explosion
  61889. * @param radiusOrEventOptions the radius or the options of radial explosion
  61890. * @param strength the explosion strength
  61891. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61892. * @returns A physics radial explosion event, or null
  61893. */
  61894. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61895. /**
  61896. * Creates a gravitational field
  61897. * @param origin the origin of the explosion
  61898. * @param radiusOrEventOptions the radius or the options of radial explosion
  61899. * @param strength the explosion strength
  61900. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61901. * @returns A physics gravitational field event, or null
  61902. */
  61903. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61904. /**
  61905. * Creates a physics updraft event
  61906. * @param origin the origin of the updraft
  61907. * @param radiusOrEventOptions the radius or the options of the updraft
  61908. * @param strength the strength of the updraft
  61909. * @param height the height of the updraft
  61910. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61911. * @returns A physics updraft event, or null
  61912. */
  61913. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61914. /**
  61915. * Creates a physics vortex event
  61916. * @param origin the of the vortex
  61917. * @param radiusOrEventOptions the radius or the options of the vortex
  61918. * @param strength the strength of the vortex
  61919. * @param height the height of the vortex
  61920. * @returns a Physics vortex event, or null
  61921. * A physics vortex event or null
  61922. */
  61923. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61924. }
  61925. /**
  61926. * Represents a physics radial explosion event
  61927. */
  61928. class PhysicsRadialExplosionEvent {
  61929. private _scene;
  61930. private _options;
  61931. private _sphere;
  61932. private _dataFetched;
  61933. /**
  61934. * Initializes a radial explosioin event
  61935. * @param _scene BabylonJS scene
  61936. * @param _options The options for the vortex event
  61937. */
  61938. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61939. /**
  61940. * Returns the data related to the radial explosion event (sphere).
  61941. * @returns The radial explosion event data
  61942. */
  61943. getData(): PhysicsRadialExplosionEventData;
  61944. /**
  61945. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61946. * @param impostor A physics imposter
  61947. * @param origin the origin of the explosion
  61948. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61949. */
  61950. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61951. /**
  61952. * Triggers affecterd impostors callbacks
  61953. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61954. */
  61955. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61956. /**
  61957. * Disposes the sphere.
  61958. * @param force Specifies if the sphere should be disposed by force
  61959. */
  61960. dispose(force?: boolean): void;
  61961. /*** Helpers ***/
  61962. private _prepareSphere;
  61963. private _intersectsWithSphere;
  61964. }
  61965. /**
  61966. * Represents a gravitational field event
  61967. */
  61968. class PhysicsGravitationalFieldEvent {
  61969. private _physicsHelper;
  61970. private _scene;
  61971. private _origin;
  61972. private _options;
  61973. private _tickCallback;
  61974. private _sphere;
  61975. private _dataFetched;
  61976. /**
  61977. * Initializes the physics gravitational field event
  61978. * @param _physicsHelper A physics helper
  61979. * @param _scene BabylonJS scene
  61980. * @param _origin The origin position of the gravitational field event
  61981. * @param _options The options for the vortex event
  61982. */
  61983. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61984. /**
  61985. * Returns the data related to the gravitational field event (sphere).
  61986. * @returns A gravitational field event
  61987. */
  61988. getData(): PhysicsGravitationalFieldEventData;
  61989. /**
  61990. * Enables the gravitational field.
  61991. */
  61992. enable(): void;
  61993. /**
  61994. * Disables the gravitational field.
  61995. */
  61996. disable(): void;
  61997. /**
  61998. * Disposes the sphere.
  61999. * @param force The force to dispose from the gravitational field event
  62000. */
  62001. dispose(force?: boolean): void;
  62002. private _tick;
  62003. }
  62004. /**
  62005. * Represents a physics updraft event
  62006. */
  62007. class PhysicsUpdraftEvent {
  62008. private _scene;
  62009. private _origin;
  62010. private _options;
  62011. private _physicsEngine;
  62012. private _originTop;
  62013. private _originDirection;
  62014. private _tickCallback;
  62015. private _cylinder;
  62016. private _cylinderPosition;
  62017. private _dataFetched;
  62018. /**
  62019. * Initializes the physics updraft event
  62020. * @param _scene BabylonJS scene
  62021. * @param _origin The origin position of the updraft
  62022. * @param _options The options for the updraft event
  62023. */
  62024. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62025. /**
  62026. * Returns the data related to the updraft event (cylinder).
  62027. * @returns A physics updraft event
  62028. */
  62029. getData(): PhysicsUpdraftEventData;
  62030. /**
  62031. * Enables the updraft.
  62032. */
  62033. enable(): void;
  62034. /**
  62035. * Disables the updraft.
  62036. */
  62037. disable(): void;
  62038. /**
  62039. * Disposes the cylinder.
  62040. * @param force Specifies if the updraft should be disposed by force
  62041. */
  62042. dispose(force?: boolean): void;
  62043. private getImpostorHitData;
  62044. private _tick;
  62045. /*** Helpers ***/
  62046. private _prepareCylinder;
  62047. private _intersectsWithCylinder;
  62048. }
  62049. /**
  62050. * Represents a physics vortex event
  62051. */
  62052. class PhysicsVortexEvent {
  62053. private _scene;
  62054. private _origin;
  62055. private _options;
  62056. private _physicsEngine;
  62057. private _originTop;
  62058. private _tickCallback;
  62059. private _cylinder;
  62060. private _cylinderPosition;
  62061. private _dataFetched;
  62062. /**
  62063. * Initializes the physics vortex event
  62064. * @param _scene The BabylonJS scene
  62065. * @param _origin The origin position of the vortex
  62066. * @param _options The options for the vortex event
  62067. */
  62068. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62069. /**
  62070. * Returns the data related to the vortex event (cylinder).
  62071. * @returns The physics vortex event data
  62072. */
  62073. getData(): PhysicsVortexEventData;
  62074. /**
  62075. * Enables the vortex.
  62076. */
  62077. enable(): void;
  62078. /**
  62079. * Disables the cortex.
  62080. */
  62081. disable(): void;
  62082. /**
  62083. * Disposes the sphere.
  62084. * @param force
  62085. */
  62086. dispose(force?: boolean): void;
  62087. private getImpostorHitData;
  62088. private _tick;
  62089. /*** Helpers ***/
  62090. private _prepareCylinder;
  62091. private _intersectsWithCylinder;
  62092. }
  62093. /**
  62094. * Options fot the radial explosion event
  62095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62096. */
  62097. export class PhysicsRadialExplosionEventOptions {
  62098. /**
  62099. * The radius of the sphere for the radial explosion.
  62100. */
  62101. radius: number;
  62102. /**
  62103. * The strenth of the explosion.
  62104. */
  62105. strength: number;
  62106. /**
  62107. * The strenght of the force in correspondence to the distance of the affected object
  62108. */
  62109. falloff: PhysicsRadialImpulseFalloff;
  62110. /**
  62111. * Sphere options for the radial explosion.
  62112. */
  62113. sphere: {
  62114. segments: number;
  62115. diameter: number;
  62116. };
  62117. /**
  62118. * Sphere options for the radial explosion.
  62119. */
  62120. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62121. }
  62122. /**
  62123. * Options fot the updraft event
  62124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62125. */
  62126. export class PhysicsUpdraftEventOptions {
  62127. /**
  62128. * The radius of the cylinder for the vortex
  62129. */
  62130. radius: number;
  62131. /**
  62132. * The strenth of the updraft.
  62133. */
  62134. strength: number;
  62135. /**
  62136. * The height of the cylinder for the updraft.
  62137. */
  62138. height: number;
  62139. /**
  62140. * The mode for the the updraft.
  62141. */
  62142. updraftMode: PhysicsUpdraftMode;
  62143. }
  62144. /**
  62145. * Options fot the vortex event
  62146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62147. */
  62148. export class PhysicsVortexEventOptions {
  62149. /**
  62150. * The radius of the cylinder for the vortex
  62151. */
  62152. radius: number;
  62153. /**
  62154. * The strenth of the vortex.
  62155. */
  62156. strength: number;
  62157. /**
  62158. * The height of the cylinder for the vortex.
  62159. */
  62160. height: number;
  62161. /**
  62162. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62163. */
  62164. centripetalForceThreshold: number;
  62165. /**
  62166. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62167. */
  62168. centripetalForceMultiplier: number;
  62169. /**
  62170. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62171. */
  62172. centrifugalForceMultiplier: number;
  62173. /**
  62174. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62175. */
  62176. updraftForceMultiplier: number;
  62177. }
  62178. /**
  62179. * The strenght of the force in correspondence to the distance of the affected object
  62180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62181. */
  62182. export enum PhysicsRadialImpulseFalloff {
  62183. /** Defines that impulse is constant in strength across it's whole radius */
  62184. Constant = 0,
  62185. /** Defines that impulse gets weaker if it's further from the origin */
  62186. Linear = 1
  62187. }
  62188. /**
  62189. * The strength of the force in correspondence to the distance of the affected object
  62190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62191. */
  62192. export enum PhysicsUpdraftMode {
  62193. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62194. Center = 0,
  62195. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62196. Perpendicular = 1
  62197. }
  62198. /**
  62199. * Interface for a physics hit data
  62200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62201. */
  62202. export interface PhysicsHitData {
  62203. /**
  62204. * The force applied at the contact point
  62205. */
  62206. force: Vector3;
  62207. /**
  62208. * The contact point
  62209. */
  62210. contactPoint: Vector3;
  62211. /**
  62212. * The distance from the origin to the contact point
  62213. */
  62214. distanceFromOrigin: number;
  62215. }
  62216. /**
  62217. * Interface for radial explosion event data
  62218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62219. */
  62220. export interface PhysicsRadialExplosionEventData {
  62221. /**
  62222. * A sphere used for the radial explosion event
  62223. */
  62224. sphere: Mesh;
  62225. }
  62226. /**
  62227. * Interface for gravitational field event data
  62228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62229. */
  62230. export interface PhysicsGravitationalFieldEventData {
  62231. /**
  62232. * A sphere mesh used for the gravitational field event
  62233. */
  62234. sphere: Mesh;
  62235. }
  62236. /**
  62237. * Interface for updraft event data
  62238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62239. */
  62240. export interface PhysicsUpdraftEventData {
  62241. /**
  62242. * A cylinder used for the updraft event
  62243. */
  62244. cylinder: Mesh;
  62245. }
  62246. /**
  62247. * Interface for vortex event data
  62248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62249. */
  62250. export interface PhysicsVortexEventData {
  62251. /**
  62252. * A cylinder used for the vortex event
  62253. */
  62254. cylinder: Mesh;
  62255. }
  62256. /**
  62257. * Interface for an affected physics impostor
  62258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62259. */
  62260. export interface PhysicsAffectedImpostorWithData {
  62261. /**
  62262. * The impostor affected by the effect
  62263. */
  62264. impostor: PhysicsImpostor;
  62265. /**
  62266. * The data about the hit/horce from the explosion
  62267. */
  62268. hitData: PhysicsHitData;
  62269. }
  62270. }
  62271. declare module "babylonjs/Physics/Plugins/index" {
  62272. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62273. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62274. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62275. }
  62276. declare module "babylonjs/Physics/index" {
  62277. export * from "babylonjs/Physics/IPhysicsEngine";
  62278. export * from "babylonjs/Physics/physicsEngine";
  62279. export * from "babylonjs/Physics/physicsEngineComponent";
  62280. export * from "babylonjs/Physics/physicsHelper";
  62281. export * from "babylonjs/Physics/physicsImpostor";
  62282. export * from "babylonjs/Physics/physicsJoint";
  62283. export * from "babylonjs/Physics/Plugins/index";
  62284. }
  62285. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62286. /** @hidden */
  62287. export var blackAndWhitePixelShader: {
  62288. name: string;
  62289. shader: string;
  62290. };
  62291. }
  62292. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62294. import { Camera } from "babylonjs/Cameras/camera";
  62295. import { Engine } from "babylonjs/Engines/engine";
  62296. import "babylonjs/Shaders/blackAndWhite.fragment";
  62297. /**
  62298. * Post process used to render in black and white
  62299. */
  62300. export class BlackAndWhitePostProcess extends PostProcess {
  62301. /**
  62302. * Linear about to convert he result to black and white (default: 1)
  62303. */
  62304. degree: number;
  62305. /**
  62306. * Creates a black and white post process
  62307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62308. * @param name The name of the effect.
  62309. * @param options The required width/height ratio to downsize to before computing the render pass.
  62310. * @param camera The camera to apply the render pass to.
  62311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62312. * @param engine The engine which the post process will be applied. (default: current engine)
  62313. * @param reusable If the post process can be reused on the same frame. (default: false)
  62314. */
  62315. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62316. }
  62317. }
  62318. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62319. import { Nullable } from "babylonjs/types";
  62320. import { Camera } from "babylonjs/Cameras/camera";
  62321. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62322. import { Engine } from "babylonjs/Engines/engine";
  62323. /**
  62324. * This represents a set of one or more post processes in Babylon.
  62325. * A post process can be used to apply a shader to a texture after it is rendered.
  62326. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62327. */
  62328. export class PostProcessRenderEffect {
  62329. private _postProcesses;
  62330. private _getPostProcesses;
  62331. private _singleInstance;
  62332. private _cameras;
  62333. private _indicesForCamera;
  62334. /**
  62335. * Name of the effect
  62336. * @hidden
  62337. */
  62338. _name: string;
  62339. /**
  62340. * Instantiates a post process render effect.
  62341. * A post process can be used to apply a shader to a texture after it is rendered.
  62342. * @param engine The engine the effect is tied to
  62343. * @param name The name of the effect
  62344. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62345. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62346. */
  62347. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62348. /**
  62349. * Checks if all the post processes in the effect are supported.
  62350. */
  62351. readonly isSupported: boolean;
  62352. /**
  62353. * Updates the current state of the effect
  62354. * @hidden
  62355. */
  62356. _update(): void;
  62357. /**
  62358. * Attaches the effect on cameras
  62359. * @param cameras The camera to attach to.
  62360. * @hidden
  62361. */
  62362. _attachCameras(cameras: Camera): void;
  62363. /**
  62364. * Attaches the effect on cameras
  62365. * @param cameras The camera to attach to.
  62366. * @hidden
  62367. */
  62368. _attachCameras(cameras: Camera[]): void;
  62369. /**
  62370. * Detaches the effect on cameras
  62371. * @param cameras The camera to detatch from.
  62372. * @hidden
  62373. */
  62374. _detachCameras(cameras: Camera): void;
  62375. /**
  62376. * Detatches the effect on cameras
  62377. * @param cameras The camera to detatch from.
  62378. * @hidden
  62379. */
  62380. _detachCameras(cameras: Camera[]): void;
  62381. /**
  62382. * Enables the effect on given cameras
  62383. * @param cameras The camera to enable.
  62384. * @hidden
  62385. */
  62386. _enable(cameras: Camera): void;
  62387. /**
  62388. * Enables the effect on given cameras
  62389. * @param cameras The camera to enable.
  62390. * @hidden
  62391. */
  62392. _enable(cameras: Nullable<Camera[]>): void;
  62393. /**
  62394. * Disables the effect on the given cameras
  62395. * @param cameras The camera to disable.
  62396. * @hidden
  62397. */
  62398. _disable(cameras: Camera): void;
  62399. /**
  62400. * Disables the effect on the given cameras
  62401. * @param cameras The camera to disable.
  62402. * @hidden
  62403. */
  62404. _disable(cameras: Nullable<Camera[]>): void;
  62405. /**
  62406. * Gets a list of the post processes contained in the effect.
  62407. * @param camera The camera to get the post processes on.
  62408. * @returns The list of the post processes in the effect.
  62409. */
  62410. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62411. }
  62412. }
  62413. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62414. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62415. /** @hidden */
  62416. export var extractHighlightsPixelShader: {
  62417. name: string;
  62418. shader: string;
  62419. };
  62420. }
  62421. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62422. import { Nullable } from "babylonjs/types";
  62423. import { Camera } from "babylonjs/Cameras/camera";
  62424. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62425. import { Engine } from "babylonjs/Engines/engine";
  62426. import "babylonjs/Shaders/extractHighlights.fragment";
  62427. /**
  62428. * 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.
  62429. */
  62430. export class ExtractHighlightsPostProcess extends PostProcess {
  62431. /**
  62432. * The luminance threshold, pixels below this value will be set to black.
  62433. */
  62434. threshold: number;
  62435. /** @hidden */
  62436. _exposure: number;
  62437. /**
  62438. * Post process which has the input texture to be used when performing highlight extraction
  62439. * @hidden
  62440. */
  62441. _inputPostProcess: Nullable<PostProcess>;
  62442. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62443. }
  62444. }
  62445. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62446. /** @hidden */
  62447. export var bloomMergePixelShader: {
  62448. name: string;
  62449. shader: string;
  62450. };
  62451. }
  62452. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62454. import { Nullable } from "babylonjs/types";
  62455. import { Engine } from "babylonjs/Engines/engine";
  62456. import { Camera } from "babylonjs/Cameras/camera";
  62457. import "babylonjs/Shaders/bloomMerge.fragment";
  62458. /**
  62459. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62460. */
  62461. export class BloomMergePostProcess extends PostProcess {
  62462. /** Weight of the bloom to be added to the original input. */
  62463. weight: number;
  62464. /**
  62465. * Creates a new instance of @see BloomMergePostProcess
  62466. * @param name The name of the effect.
  62467. * @param originalFromInput Post process which's input will be used for the merge.
  62468. * @param blurred Blurred highlights post process which's output will be used.
  62469. * @param weight Weight of the bloom to be added to the original input.
  62470. * @param options The required width/height ratio to downsize to before computing the render pass.
  62471. * @param camera The camera to apply the render pass to.
  62472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62473. * @param engine The engine which the post process will be applied. (default: current engine)
  62474. * @param reusable If the post process can be reused on the same frame. (default: false)
  62475. * @param textureType Type of textures used when performing the post process. (default: 0)
  62476. * @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)
  62477. */
  62478. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62479. /** Weight of the bloom to be added to the original input. */
  62480. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62481. }
  62482. }
  62483. declare module "babylonjs/PostProcesses/bloomEffect" {
  62484. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62485. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62486. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62487. import { Camera } from "babylonjs/Cameras/camera";
  62488. import { Scene } from "babylonjs/scene";
  62489. /**
  62490. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62491. */
  62492. export class BloomEffect extends PostProcessRenderEffect {
  62493. private bloomScale;
  62494. /**
  62495. * @hidden Internal
  62496. */
  62497. _effects: Array<PostProcess>;
  62498. /**
  62499. * @hidden Internal
  62500. */
  62501. _downscale: ExtractHighlightsPostProcess;
  62502. private _blurX;
  62503. private _blurY;
  62504. private _merge;
  62505. /**
  62506. * The luminance threshold to find bright areas of the image to bloom.
  62507. */
  62508. threshold: number;
  62509. /**
  62510. * The strength of the bloom.
  62511. */
  62512. weight: number;
  62513. /**
  62514. * Specifies the size of the bloom blur kernel, relative to the final output size
  62515. */
  62516. kernel: number;
  62517. /**
  62518. * Creates a new instance of @see BloomEffect
  62519. * @param scene The scene the effect belongs to.
  62520. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62521. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62522. * @param bloomWeight The the strength of bloom.
  62523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62524. * @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)
  62525. */
  62526. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62527. /**
  62528. * Disposes each of the internal effects for a given camera.
  62529. * @param camera The camera to dispose the effect on.
  62530. */
  62531. disposeEffects(camera: Camera): void;
  62532. /**
  62533. * @hidden Internal
  62534. */
  62535. _updateEffects(): void;
  62536. /**
  62537. * Internal
  62538. * @returns if all the contained post processes are ready.
  62539. * @hidden
  62540. */
  62541. _isReady(): boolean;
  62542. }
  62543. }
  62544. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62545. /** @hidden */
  62546. export var chromaticAberrationPixelShader: {
  62547. name: string;
  62548. shader: string;
  62549. };
  62550. }
  62551. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62552. import { Vector2 } from "babylonjs/Maths/math.vector";
  62553. import { Nullable } from "babylonjs/types";
  62554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62555. import { Camera } from "babylonjs/Cameras/camera";
  62556. import { Engine } from "babylonjs/Engines/engine";
  62557. import "babylonjs/Shaders/chromaticAberration.fragment";
  62558. /**
  62559. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62560. */
  62561. export class ChromaticAberrationPostProcess extends PostProcess {
  62562. /**
  62563. * The amount of seperation of rgb channels (default: 30)
  62564. */
  62565. aberrationAmount: number;
  62566. /**
  62567. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62568. */
  62569. radialIntensity: number;
  62570. /**
  62571. * 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))
  62572. */
  62573. direction: Vector2;
  62574. /**
  62575. * 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))
  62576. */
  62577. centerPosition: Vector2;
  62578. /**
  62579. * Creates a new instance ChromaticAberrationPostProcess
  62580. * @param name The name of the effect.
  62581. * @param screenWidth The width of the screen to apply the effect on.
  62582. * @param screenHeight The height of the screen to apply the effect on.
  62583. * @param options The required width/height ratio to downsize to before computing the render pass.
  62584. * @param camera The camera to apply the render pass to.
  62585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62586. * @param engine The engine which the post process will be applied. (default: current engine)
  62587. * @param reusable If the post process can be reused on the same frame. (default: false)
  62588. * @param textureType Type of textures used when performing the post process. (default: 0)
  62589. * @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)
  62590. */
  62591. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62592. }
  62593. }
  62594. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62595. /** @hidden */
  62596. export var circleOfConfusionPixelShader: {
  62597. name: string;
  62598. shader: string;
  62599. };
  62600. }
  62601. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62602. import { Nullable } from "babylonjs/types";
  62603. import { Engine } from "babylonjs/Engines/engine";
  62604. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62605. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62606. import { Camera } from "babylonjs/Cameras/camera";
  62607. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62608. /**
  62609. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62610. */
  62611. export class CircleOfConfusionPostProcess extends PostProcess {
  62612. /**
  62613. * 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.
  62614. */
  62615. lensSize: number;
  62616. /**
  62617. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62618. */
  62619. fStop: number;
  62620. /**
  62621. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62622. */
  62623. focusDistance: number;
  62624. /**
  62625. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62626. */
  62627. focalLength: number;
  62628. private _depthTexture;
  62629. /**
  62630. * Creates a new instance CircleOfConfusionPostProcess
  62631. * @param name The name of the effect.
  62632. * @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.
  62633. * @param options The required width/height ratio to downsize to before computing the render pass.
  62634. * @param camera The camera to apply the render pass to.
  62635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62636. * @param engine The engine which the post process will be applied. (default: current engine)
  62637. * @param reusable If the post process can be reused on the same frame. (default: false)
  62638. * @param textureType Type of textures used when performing the post process. (default: 0)
  62639. * @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)
  62640. */
  62641. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62642. /**
  62643. * 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.
  62644. */
  62645. depthTexture: RenderTargetTexture;
  62646. }
  62647. }
  62648. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62649. /** @hidden */
  62650. export var colorCorrectionPixelShader: {
  62651. name: string;
  62652. shader: string;
  62653. };
  62654. }
  62655. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62657. import { Engine } from "babylonjs/Engines/engine";
  62658. import { Camera } from "babylonjs/Cameras/camera";
  62659. import "babylonjs/Shaders/colorCorrection.fragment";
  62660. /**
  62661. *
  62662. * This post-process allows the modification of rendered colors by using
  62663. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62664. *
  62665. * The object needs to be provided an url to a texture containing the color
  62666. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62667. * Use an image editing software to tweak the LUT to match your needs.
  62668. *
  62669. * For an example of a color LUT, see here:
  62670. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62671. * For explanations on color grading, see here:
  62672. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62673. *
  62674. */
  62675. export class ColorCorrectionPostProcess extends PostProcess {
  62676. private _colorTableTexture;
  62677. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62678. }
  62679. }
  62680. declare module "babylonjs/Shaders/convolution.fragment" {
  62681. /** @hidden */
  62682. export var convolutionPixelShader: {
  62683. name: string;
  62684. shader: string;
  62685. };
  62686. }
  62687. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62689. import { Nullable } from "babylonjs/types";
  62690. import { Camera } from "babylonjs/Cameras/camera";
  62691. import { Engine } from "babylonjs/Engines/engine";
  62692. import "babylonjs/Shaders/convolution.fragment";
  62693. /**
  62694. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62695. * input texture to perform effects such as edge detection or sharpening
  62696. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62697. */
  62698. export class ConvolutionPostProcess extends PostProcess {
  62699. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62700. kernel: number[];
  62701. /**
  62702. * Creates a new instance ConvolutionPostProcess
  62703. * @param name The name of the effect.
  62704. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62705. * @param options The required width/height ratio to downsize to before computing the render pass.
  62706. * @param camera The camera to apply the render pass to.
  62707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62708. * @param engine The engine which the post process will be applied. (default: current engine)
  62709. * @param reusable If the post process can be reused on the same frame. (default: false)
  62710. * @param textureType Type of textures used when performing the post process. (default: 0)
  62711. */
  62712. constructor(name: string,
  62713. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62714. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62715. /**
  62716. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62717. */
  62718. static EdgeDetect0Kernel: number[];
  62719. /**
  62720. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62721. */
  62722. static EdgeDetect1Kernel: number[];
  62723. /**
  62724. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62725. */
  62726. static EdgeDetect2Kernel: number[];
  62727. /**
  62728. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62729. */
  62730. static SharpenKernel: number[];
  62731. /**
  62732. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62733. */
  62734. static EmbossKernel: number[];
  62735. /**
  62736. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62737. */
  62738. static GaussianKernel: number[];
  62739. }
  62740. }
  62741. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62742. import { Nullable } from "babylonjs/types";
  62743. import { Vector2 } from "babylonjs/Maths/math.vector";
  62744. import { Camera } from "babylonjs/Cameras/camera";
  62745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62746. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62747. import { Engine } from "babylonjs/Engines/engine";
  62748. import { Scene } from "babylonjs/scene";
  62749. /**
  62750. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62751. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62752. * based on samples that have a large difference in distance than the center pixel.
  62753. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62754. */
  62755. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62756. direction: Vector2;
  62757. /**
  62758. * Creates a new instance CircleOfConfusionPostProcess
  62759. * @param name The name of the effect.
  62760. * @param scene The scene the effect belongs to.
  62761. * @param direction The direction the blur should be applied.
  62762. * @param kernel The size of the kernel used to blur.
  62763. * @param options The required width/height ratio to downsize to before computing the render pass.
  62764. * @param camera The camera to apply the render pass to.
  62765. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62766. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62768. * @param engine The engine which the post process will be applied. (default: current engine)
  62769. * @param reusable If the post process can be reused on the same frame. (default: false)
  62770. * @param textureType Type of textures used when performing the post process. (default: 0)
  62771. * @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)
  62772. */
  62773. 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);
  62774. }
  62775. }
  62776. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62777. /** @hidden */
  62778. export var depthOfFieldMergePixelShader: {
  62779. name: string;
  62780. shader: string;
  62781. };
  62782. }
  62783. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62784. import { Nullable } from "babylonjs/types";
  62785. import { Camera } from "babylonjs/Cameras/camera";
  62786. import { Effect } from "babylonjs/Materials/effect";
  62787. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62788. import { Engine } from "babylonjs/Engines/engine";
  62789. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62790. /**
  62791. * Options to be set when merging outputs from the default pipeline.
  62792. */
  62793. export class DepthOfFieldMergePostProcessOptions {
  62794. /**
  62795. * The original image to merge on top of
  62796. */
  62797. originalFromInput: PostProcess;
  62798. /**
  62799. * Parameters to perform the merge of the depth of field effect
  62800. */
  62801. depthOfField?: {
  62802. circleOfConfusion: PostProcess;
  62803. blurSteps: Array<PostProcess>;
  62804. };
  62805. /**
  62806. * Parameters to perform the merge of bloom effect
  62807. */
  62808. bloom?: {
  62809. blurred: PostProcess;
  62810. weight: number;
  62811. };
  62812. }
  62813. /**
  62814. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62815. */
  62816. export class DepthOfFieldMergePostProcess extends PostProcess {
  62817. private blurSteps;
  62818. /**
  62819. * Creates a new instance of DepthOfFieldMergePostProcess
  62820. * @param name The name of the effect.
  62821. * @param originalFromInput Post process which's input will be used for the merge.
  62822. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62823. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62824. * @param options The required width/height ratio to downsize to before computing the render pass.
  62825. * @param camera The camera to apply the render pass to.
  62826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62827. * @param engine The engine which the post process will be applied. (default: current engine)
  62828. * @param reusable If the post process can be reused on the same frame. (default: false)
  62829. * @param textureType Type of textures used when performing the post process. (default: 0)
  62830. * @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)
  62831. */
  62832. 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);
  62833. /**
  62834. * Updates the effect with the current post process compile time values and recompiles the shader.
  62835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62838. * @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
  62839. * @param onCompiled Called when the shader has been compiled.
  62840. * @param onError Called if there is an error when compiling a shader.
  62841. */
  62842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62843. }
  62844. }
  62845. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62846. import { Nullable } from "babylonjs/types";
  62847. import { Camera } from "babylonjs/Cameras/camera";
  62848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62849. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62850. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62851. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62852. import { Scene } from "babylonjs/scene";
  62853. /**
  62854. * Specifies the level of max blur that should be applied when using the depth of field effect
  62855. */
  62856. export enum DepthOfFieldEffectBlurLevel {
  62857. /**
  62858. * Subtle blur
  62859. */
  62860. Low = 0,
  62861. /**
  62862. * Medium blur
  62863. */
  62864. Medium = 1,
  62865. /**
  62866. * Large blur
  62867. */
  62868. High = 2
  62869. }
  62870. /**
  62871. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62872. */
  62873. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62874. private _circleOfConfusion;
  62875. /**
  62876. * @hidden Internal, blurs from high to low
  62877. */
  62878. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62879. private _depthOfFieldBlurY;
  62880. private _dofMerge;
  62881. /**
  62882. * @hidden Internal post processes in depth of field effect
  62883. */
  62884. _effects: Array<PostProcess>;
  62885. /**
  62886. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62887. */
  62888. focalLength: number;
  62889. /**
  62890. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62891. */
  62892. fStop: number;
  62893. /**
  62894. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62895. */
  62896. focusDistance: number;
  62897. /**
  62898. * 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.
  62899. */
  62900. lensSize: number;
  62901. /**
  62902. * Creates a new instance DepthOfFieldEffect
  62903. * @param scene The scene the effect belongs to.
  62904. * @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.
  62905. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62906. * @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)
  62907. */
  62908. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62909. /**
  62910. * Get the current class name of the current effet
  62911. * @returns "DepthOfFieldEffect"
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * 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.
  62916. */
  62917. depthTexture: RenderTargetTexture;
  62918. /**
  62919. * Disposes each of the internal effects for a given camera.
  62920. * @param camera The camera to dispose the effect on.
  62921. */
  62922. disposeEffects(camera: Camera): void;
  62923. /**
  62924. * @hidden Internal
  62925. */
  62926. _updateEffects(): void;
  62927. /**
  62928. * Internal
  62929. * @returns if all the contained post processes are ready.
  62930. * @hidden
  62931. */
  62932. _isReady(): boolean;
  62933. }
  62934. }
  62935. declare module "babylonjs/Shaders/displayPass.fragment" {
  62936. /** @hidden */
  62937. export var displayPassPixelShader: {
  62938. name: string;
  62939. shader: string;
  62940. };
  62941. }
  62942. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62943. import { Nullable } from "babylonjs/types";
  62944. import { Camera } from "babylonjs/Cameras/camera";
  62945. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62946. import { Engine } from "babylonjs/Engines/engine";
  62947. import "babylonjs/Shaders/displayPass.fragment";
  62948. /**
  62949. * DisplayPassPostProcess which produces an output the same as it's input
  62950. */
  62951. export class DisplayPassPostProcess extends PostProcess {
  62952. /**
  62953. * Creates the DisplayPassPostProcess
  62954. * @param name The name of the effect.
  62955. * @param options The required width/height ratio to downsize to before computing the render pass.
  62956. * @param camera The camera to apply the render pass to.
  62957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62958. * @param engine The engine which the post process will be applied. (default: current engine)
  62959. * @param reusable If the post process can be reused on the same frame. (default: false)
  62960. */
  62961. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62962. }
  62963. }
  62964. declare module "babylonjs/Shaders/filter.fragment" {
  62965. /** @hidden */
  62966. export var filterPixelShader: {
  62967. name: string;
  62968. shader: string;
  62969. };
  62970. }
  62971. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62972. import { Nullable } from "babylonjs/types";
  62973. import { Matrix } from "babylonjs/Maths/math.vector";
  62974. import { Camera } from "babylonjs/Cameras/camera";
  62975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62976. import { Engine } from "babylonjs/Engines/engine";
  62977. import "babylonjs/Shaders/filter.fragment";
  62978. /**
  62979. * Applies a kernel filter to the image
  62980. */
  62981. export class FilterPostProcess extends PostProcess {
  62982. /** The matrix to be applied to the image */
  62983. kernelMatrix: Matrix;
  62984. /**
  62985. *
  62986. * @param name The name of the effect.
  62987. * @param kernelMatrix The matrix to be applied to the image
  62988. * @param options The required width/height ratio to downsize to before computing the render pass.
  62989. * @param camera The camera to apply the render pass to.
  62990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62991. * @param engine The engine which the post process will be applied. (default: current engine)
  62992. * @param reusable If the post process can be reused on the same frame. (default: false)
  62993. */
  62994. constructor(name: string,
  62995. /** The matrix to be applied to the image */
  62996. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62997. }
  62998. }
  62999. declare module "babylonjs/Shaders/fxaa.fragment" {
  63000. /** @hidden */
  63001. export var fxaaPixelShader: {
  63002. name: string;
  63003. shader: string;
  63004. };
  63005. }
  63006. declare module "babylonjs/Shaders/fxaa.vertex" {
  63007. /** @hidden */
  63008. export var fxaaVertexShader: {
  63009. name: string;
  63010. shader: string;
  63011. };
  63012. }
  63013. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63014. import { Nullable } from "babylonjs/types";
  63015. import { Camera } from "babylonjs/Cameras/camera";
  63016. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63017. import { Engine } from "babylonjs/Engines/engine";
  63018. import "babylonjs/Shaders/fxaa.fragment";
  63019. import "babylonjs/Shaders/fxaa.vertex";
  63020. /**
  63021. * Fxaa post process
  63022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63023. */
  63024. export class FxaaPostProcess extends PostProcess {
  63025. /** @hidden */
  63026. texelWidth: number;
  63027. /** @hidden */
  63028. texelHeight: number;
  63029. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63030. private _getDefines;
  63031. }
  63032. }
  63033. declare module "babylonjs/Shaders/grain.fragment" {
  63034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63035. /** @hidden */
  63036. export var grainPixelShader: {
  63037. name: string;
  63038. shader: string;
  63039. };
  63040. }
  63041. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63042. import { Nullable } from "babylonjs/types";
  63043. import { Camera } from "babylonjs/Cameras/camera";
  63044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63045. import { Engine } from "babylonjs/Engines/engine";
  63046. import "babylonjs/Shaders/grain.fragment";
  63047. /**
  63048. * The GrainPostProcess adds noise to the image at mid luminance levels
  63049. */
  63050. export class GrainPostProcess extends PostProcess {
  63051. /**
  63052. * The intensity of the grain added (default: 30)
  63053. */
  63054. intensity: number;
  63055. /**
  63056. * If the grain should be randomized on every frame
  63057. */
  63058. animated: boolean;
  63059. /**
  63060. * Creates a new instance of @see GrainPostProcess
  63061. * @param name The name of the effect.
  63062. * @param options The required width/height ratio to downsize to before computing the render pass.
  63063. * @param camera The camera to apply the render pass to.
  63064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63065. * @param engine The engine which the post process will be applied. (default: current engine)
  63066. * @param reusable If the post process can be reused on the same frame. (default: false)
  63067. * @param textureType Type of textures used when performing the post process. (default: 0)
  63068. * @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)
  63069. */
  63070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63071. }
  63072. }
  63073. declare module "babylonjs/Shaders/highlights.fragment" {
  63074. /** @hidden */
  63075. export var highlightsPixelShader: {
  63076. name: string;
  63077. shader: string;
  63078. };
  63079. }
  63080. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63081. import { Nullable } from "babylonjs/types";
  63082. import { Camera } from "babylonjs/Cameras/camera";
  63083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63084. import { Engine } from "babylonjs/Engines/engine";
  63085. import "babylonjs/Shaders/highlights.fragment";
  63086. /**
  63087. * Extracts highlights from the image
  63088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63089. */
  63090. export class HighlightsPostProcess extends PostProcess {
  63091. /**
  63092. * Extracts highlights from the image
  63093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63094. * @param name The name of the effect.
  63095. * @param options The required width/height ratio to downsize to before computing the render pass.
  63096. * @param camera The camera to apply the render pass to.
  63097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63098. * @param engine The engine which the post process will be applied. (default: current engine)
  63099. * @param reusable If the post process can be reused on the same frame. (default: false)
  63100. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63101. */
  63102. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63103. }
  63104. }
  63105. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63106. /** @hidden */
  63107. export var mrtFragmentDeclaration: {
  63108. name: string;
  63109. shader: string;
  63110. };
  63111. }
  63112. declare module "babylonjs/Shaders/geometry.fragment" {
  63113. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63114. /** @hidden */
  63115. export var geometryPixelShader: {
  63116. name: string;
  63117. shader: string;
  63118. };
  63119. }
  63120. declare module "babylonjs/Shaders/geometry.vertex" {
  63121. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63122. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63124. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63125. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63126. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63127. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63128. /** @hidden */
  63129. export var geometryVertexShader: {
  63130. name: string;
  63131. shader: string;
  63132. };
  63133. }
  63134. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63135. import { Matrix } from "babylonjs/Maths/math.vector";
  63136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63137. import { Mesh } from "babylonjs/Meshes/mesh";
  63138. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63139. import { Effect } from "babylonjs/Materials/effect";
  63140. import { Scene } from "babylonjs/scene";
  63141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63142. import "babylonjs/Shaders/geometry.fragment";
  63143. import "babylonjs/Shaders/geometry.vertex";
  63144. /** @hidden */
  63145. interface ISavedTransformationMatrix {
  63146. world: Matrix;
  63147. viewProjection: Matrix;
  63148. }
  63149. /**
  63150. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63151. */
  63152. export class GeometryBufferRenderer {
  63153. /**
  63154. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63155. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63156. */
  63157. static readonly POSITION_TEXTURE_TYPE: number;
  63158. /**
  63159. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63160. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63161. */
  63162. static readonly VELOCITY_TEXTURE_TYPE: number;
  63163. /**
  63164. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63165. * in order to compute objects velocities when enableVelocity is set to "true"
  63166. * @hidden
  63167. */
  63168. _previousTransformationMatrices: {
  63169. [index: number]: ISavedTransformationMatrix;
  63170. };
  63171. /**
  63172. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63173. * in order to compute objects velocities when enableVelocity is set to "true"
  63174. * @hidden
  63175. */
  63176. _previousBonesTransformationMatrices: {
  63177. [index: number]: Float32Array;
  63178. };
  63179. /**
  63180. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63181. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63182. */
  63183. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63184. private _scene;
  63185. private _multiRenderTarget;
  63186. private _ratio;
  63187. private _enablePosition;
  63188. private _enableVelocity;
  63189. private _positionIndex;
  63190. private _velocityIndex;
  63191. protected _effect: Effect;
  63192. protected _cachedDefines: string;
  63193. /**
  63194. * Set the render list (meshes to be rendered) used in the G buffer.
  63195. */
  63196. renderList: Mesh[];
  63197. /**
  63198. * Gets wether or not G buffer are supported by the running hardware.
  63199. * This requires draw buffer supports
  63200. */
  63201. readonly isSupported: boolean;
  63202. /**
  63203. * Returns the index of the given texture type in the G-Buffer textures array
  63204. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63205. * @returns the index of the given texture type in the G-Buffer textures array
  63206. */
  63207. getTextureIndex(textureType: number): number;
  63208. /**
  63209. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63210. */
  63211. /**
  63212. * Sets whether or not objects positions are enabled for the G buffer.
  63213. */
  63214. enablePosition: boolean;
  63215. /**
  63216. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63217. */
  63218. /**
  63219. * Sets wether or not objects velocities are enabled for the G buffer.
  63220. */
  63221. enableVelocity: boolean;
  63222. /**
  63223. * Gets the scene associated with the buffer.
  63224. */
  63225. readonly scene: Scene;
  63226. /**
  63227. * Gets the ratio used by the buffer during its creation.
  63228. * How big is the buffer related to the main canvas.
  63229. */
  63230. readonly ratio: number;
  63231. /** @hidden */
  63232. static _SceneComponentInitialization: (scene: Scene) => void;
  63233. /**
  63234. * Creates a new G Buffer for the scene
  63235. * @param scene The scene the buffer belongs to
  63236. * @param ratio How big is the buffer related to the main canvas.
  63237. */
  63238. constructor(scene: Scene, ratio?: number);
  63239. /**
  63240. * Checks wether everything is ready to render a submesh to the G buffer.
  63241. * @param subMesh the submesh to check readiness for
  63242. * @param useInstances is the mesh drawn using instance or not
  63243. * @returns true if ready otherwise false
  63244. */
  63245. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63246. /**
  63247. * Gets the current underlying G Buffer.
  63248. * @returns the buffer
  63249. */
  63250. getGBuffer(): MultiRenderTarget;
  63251. /**
  63252. * Gets the number of samples used to render the buffer (anti aliasing).
  63253. */
  63254. /**
  63255. * Sets the number of samples used to render the buffer (anti aliasing).
  63256. */
  63257. samples: number;
  63258. /**
  63259. * Disposes the renderer and frees up associated resources.
  63260. */
  63261. dispose(): void;
  63262. protected _createRenderTargets(): void;
  63263. private _copyBonesTransformationMatrices;
  63264. }
  63265. }
  63266. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63267. import { Nullable } from "babylonjs/types";
  63268. import { Scene } from "babylonjs/scene";
  63269. import { ISceneComponent } from "babylonjs/sceneComponent";
  63270. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63271. module "babylonjs/scene" {
  63272. interface Scene {
  63273. /** @hidden (Backing field) */
  63274. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63275. /**
  63276. * Gets or Sets the current geometry buffer associated to the scene.
  63277. */
  63278. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63279. /**
  63280. * Enables a GeometryBufferRender and associates it with the scene
  63281. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63282. * @returns the GeometryBufferRenderer
  63283. */
  63284. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63285. /**
  63286. * Disables the GeometryBufferRender associated with the scene
  63287. */
  63288. disableGeometryBufferRenderer(): void;
  63289. }
  63290. }
  63291. /**
  63292. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63293. * in several rendering techniques.
  63294. */
  63295. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63296. /**
  63297. * The component name helpful to identify the component in the list of scene components.
  63298. */
  63299. readonly name: string;
  63300. /**
  63301. * The scene the component belongs to.
  63302. */
  63303. scene: Scene;
  63304. /**
  63305. * Creates a new instance of the component for the given scene
  63306. * @param scene Defines the scene to register the component in
  63307. */
  63308. constructor(scene: Scene);
  63309. /**
  63310. * Registers the component in a given scene
  63311. */
  63312. register(): void;
  63313. /**
  63314. * Rebuilds the elements related to this component in case of
  63315. * context lost for instance.
  63316. */
  63317. rebuild(): void;
  63318. /**
  63319. * Disposes the component and the associated ressources
  63320. */
  63321. dispose(): void;
  63322. private _gatherRenderTargets;
  63323. }
  63324. }
  63325. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63326. /** @hidden */
  63327. export var motionBlurPixelShader: {
  63328. name: string;
  63329. shader: string;
  63330. };
  63331. }
  63332. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63333. import { Nullable } from "babylonjs/types";
  63334. import { Camera } from "babylonjs/Cameras/camera";
  63335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63336. import { Scene } from "babylonjs/scene";
  63337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63338. import "babylonjs/Animations/animatable";
  63339. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63340. import "babylonjs/Shaders/motionBlur.fragment";
  63341. import { Engine } from "babylonjs/Engines/engine";
  63342. /**
  63343. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63344. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63345. * As an example, all you have to do is to create the post-process:
  63346. * var mb = new BABYLON.MotionBlurPostProcess(
  63347. * 'mb', // The name of the effect.
  63348. * scene, // The scene containing the objects to blur according to their velocity.
  63349. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63350. * camera // The camera to apply the render pass to.
  63351. * );
  63352. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63353. */
  63354. export class MotionBlurPostProcess extends PostProcess {
  63355. /**
  63356. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63357. */
  63358. motionStrength: number;
  63359. /**
  63360. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63361. */
  63362. /**
  63363. * Sets the number of iterations to be used for motion blur quality
  63364. */
  63365. motionBlurSamples: number;
  63366. private _motionBlurSamples;
  63367. private _geometryBufferRenderer;
  63368. /**
  63369. * Creates a new instance MotionBlurPostProcess
  63370. * @param name The name of the effect.
  63371. * @param scene The scene containing the objects to blur according to their velocity.
  63372. * @param options The required width/height ratio to downsize to before computing the render pass.
  63373. * @param camera The camera to apply the render pass to.
  63374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63375. * @param engine The engine which the post process will be applied. (default: current engine)
  63376. * @param reusable If the post process can be reused on the same frame. (default: false)
  63377. * @param textureType Type of textures used when performing the post process. (default: 0)
  63378. * @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)
  63379. */
  63380. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63381. /**
  63382. * Excludes the given skinned mesh from computing bones velocities.
  63383. * 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.
  63384. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63385. */
  63386. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63387. /**
  63388. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63389. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63390. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63391. */
  63392. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63393. /**
  63394. * Disposes the post process.
  63395. * @param camera The camera to dispose the post process on.
  63396. */
  63397. dispose(camera?: Camera): void;
  63398. }
  63399. }
  63400. declare module "babylonjs/Shaders/refraction.fragment" {
  63401. /** @hidden */
  63402. export var refractionPixelShader: {
  63403. name: string;
  63404. shader: string;
  63405. };
  63406. }
  63407. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63408. import { Color3 } from "babylonjs/Maths/math.color";
  63409. import { Camera } from "babylonjs/Cameras/camera";
  63410. import { Texture } from "babylonjs/Materials/Textures/texture";
  63411. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63412. import { Engine } from "babylonjs/Engines/engine";
  63413. import "babylonjs/Shaders/refraction.fragment";
  63414. /**
  63415. * Post process which applies a refractin texture
  63416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63417. */
  63418. export class RefractionPostProcess extends PostProcess {
  63419. /** the base color of the refraction (used to taint the rendering) */
  63420. color: Color3;
  63421. /** simulated refraction depth */
  63422. depth: number;
  63423. /** the coefficient of the base color (0 to remove base color tainting) */
  63424. colorLevel: number;
  63425. private _refTexture;
  63426. private _ownRefractionTexture;
  63427. /**
  63428. * Gets or sets the refraction texture
  63429. * Please note that you are responsible for disposing the texture if you set it manually
  63430. */
  63431. refractionTexture: Texture;
  63432. /**
  63433. * Initializes the RefractionPostProcess
  63434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63435. * @param name The name of the effect.
  63436. * @param refractionTextureUrl Url of the refraction texture to use
  63437. * @param color the base color of the refraction (used to taint the rendering)
  63438. * @param depth simulated refraction depth
  63439. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63440. * @param camera The camera to apply the render pass to.
  63441. * @param options The required width/height ratio to downsize to before computing the render pass.
  63442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63443. * @param engine The engine which the post process will be applied. (default: current engine)
  63444. * @param reusable If the post process can be reused on the same frame. (default: false)
  63445. */
  63446. constructor(name: string, refractionTextureUrl: string,
  63447. /** the base color of the refraction (used to taint the rendering) */
  63448. color: Color3,
  63449. /** simulated refraction depth */
  63450. depth: number,
  63451. /** the coefficient of the base color (0 to remove base color tainting) */
  63452. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63453. /**
  63454. * Disposes of the post process
  63455. * @param camera Camera to dispose post process on
  63456. */
  63457. dispose(camera: Camera): void;
  63458. }
  63459. }
  63460. declare module "babylonjs/Shaders/sharpen.fragment" {
  63461. /** @hidden */
  63462. export var sharpenPixelShader: {
  63463. name: string;
  63464. shader: string;
  63465. };
  63466. }
  63467. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63468. import { Nullable } from "babylonjs/types";
  63469. import { Camera } from "babylonjs/Cameras/camera";
  63470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63471. import "babylonjs/Shaders/sharpen.fragment";
  63472. import { Engine } from "babylonjs/Engines/engine";
  63473. /**
  63474. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63475. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63476. */
  63477. export class SharpenPostProcess extends PostProcess {
  63478. /**
  63479. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63480. */
  63481. colorAmount: number;
  63482. /**
  63483. * How much sharpness should be applied (default: 0.3)
  63484. */
  63485. edgeAmount: number;
  63486. /**
  63487. * Creates a new instance ConvolutionPostProcess
  63488. * @param name The name of the effect.
  63489. * @param options The required width/height ratio to downsize to before computing the render pass.
  63490. * @param camera The camera to apply the render pass to.
  63491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63492. * @param engine The engine which the post process will be applied. (default: current engine)
  63493. * @param reusable If the post process can be reused on the same frame. (default: false)
  63494. * @param textureType Type of textures used when performing the post process. (default: 0)
  63495. * @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)
  63496. */
  63497. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63498. }
  63499. }
  63500. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63501. import { Nullable } from "babylonjs/types";
  63502. import { Camera } from "babylonjs/Cameras/camera";
  63503. import { Engine } from "babylonjs/Engines/engine";
  63504. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63505. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63506. /**
  63507. * PostProcessRenderPipeline
  63508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63509. */
  63510. export class PostProcessRenderPipeline {
  63511. private engine;
  63512. private _renderEffects;
  63513. private _renderEffectsForIsolatedPass;
  63514. /**
  63515. * List of inspectable custom properties (used by the Inspector)
  63516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63517. */
  63518. inspectableCustomProperties: IInspectable[];
  63519. /**
  63520. * @hidden
  63521. */
  63522. protected _cameras: Camera[];
  63523. /** @hidden */
  63524. _name: string;
  63525. /**
  63526. * Gets pipeline name
  63527. */
  63528. readonly name: string;
  63529. /**
  63530. * Initializes a PostProcessRenderPipeline
  63531. * @param engine engine to add the pipeline to
  63532. * @param name name of the pipeline
  63533. */
  63534. constructor(engine: Engine, name: string);
  63535. /**
  63536. * Gets the class name
  63537. * @returns "PostProcessRenderPipeline"
  63538. */
  63539. getClassName(): string;
  63540. /**
  63541. * If all the render effects in the pipeline are supported
  63542. */
  63543. readonly isSupported: boolean;
  63544. /**
  63545. * Adds an effect to the pipeline
  63546. * @param renderEffect the effect to add
  63547. */
  63548. addEffect(renderEffect: PostProcessRenderEffect): void;
  63549. /** @hidden */
  63550. _rebuild(): void;
  63551. /** @hidden */
  63552. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63553. /** @hidden */
  63554. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63555. /** @hidden */
  63556. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63557. /** @hidden */
  63558. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63559. /** @hidden */
  63560. _attachCameras(cameras: Camera, unique: boolean): void;
  63561. /** @hidden */
  63562. _attachCameras(cameras: Camera[], unique: boolean): void;
  63563. /** @hidden */
  63564. _detachCameras(cameras: Camera): void;
  63565. /** @hidden */
  63566. _detachCameras(cameras: Nullable<Camera[]>): void;
  63567. /** @hidden */
  63568. _update(): void;
  63569. /** @hidden */
  63570. _reset(): void;
  63571. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63572. /**
  63573. * Disposes of the pipeline
  63574. */
  63575. dispose(): void;
  63576. }
  63577. }
  63578. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63579. import { Camera } from "babylonjs/Cameras/camera";
  63580. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63581. /**
  63582. * PostProcessRenderPipelineManager class
  63583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63584. */
  63585. export class PostProcessRenderPipelineManager {
  63586. private _renderPipelines;
  63587. /**
  63588. * Initializes a PostProcessRenderPipelineManager
  63589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63590. */
  63591. constructor();
  63592. /**
  63593. * Gets the list of supported render pipelines
  63594. */
  63595. readonly supportedPipelines: PostProcessRenderPipeline[];
  63596. /**
  63597. * Adds a pipeline to the manager
  63598. * @param renderPipeline The pipeline to add
  63599. */
  63600. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63601. /**
  63602. * Attaches a camera to the pipeline
  63603. * @param renderPipelineName The name of the pipeline to attach to
  63604. * @param cameras the camera to attach
  63605. * @param unique if the camera can be attached multiple times to the pipeline
  63606. */
  63607. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63608. /**
  63609. * Detaches a camera from the pipeline
  63610. * @param renderPipelineName The name of the pipeline to detach from
  63611. * @param cameras the camera to detach
  63612. */
  63613. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63614. /**
  63615. * Enables an effect by name on a pipeline
  63616. * @param renderPipelineName the name of the pipeline to enable the effect in
  63617. * @param renderEffectName the name of the effect to enable
  63618. * @param cameras the cameras that the effect should be enabled on
  63619. */
  63620. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63621. /**
  63622. * Disables an effect by name on a pipeline
  63623. * @param renderPipelineName the name of the pipeline to disable the effect in
  63624. * @param renderEffectName the name of the effect to disable
  63625. * @param cameras the cameras that the effect should be disabled on
  63626. */
  63627. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63628. /**
  63629. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63630. */
  63631. update(): void;
  63632. /** @hidden */
  63633. _rebuild(): void;
  63634. /**
  63635. * Disposes of the manager and pipelines
  63636. */
  63637. dispose(): void;
  63638. }
  63639. }
  63640. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63641. import { ISceneComponent } from "babylonjs/sceneComponent";
  63642. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63643. import { Scene } from "babylonjs/scene";
  63644. module "babylonjs/scene" {
  63645. interface Scene {
  63646. /** @hidden (Backing field) */
  63647. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63648. /**
  63649. * Gets the postprocess render pipeline manager
  63650. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63651. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63652. */
  63653. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63654. }
  63655. }
  63656. /**
  63657. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63658. */
  63659. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63660. /**
  63661. * The component name helpfull to identify the component in the list of scene components.
  63662. */
  63663. readonly name: string;
  63664. /**
  63665. * The scene the component belongs to.
  63666. */
  63667. scene: Scene;
  63668. /**
  63669. * Creates a new instance of the component for the given scene
  63670. * @param scene Defines the scene to register the component in
  63671. */
  63672. constructor(scene: Scene);
  63673. /**
  63674. * Registers the component in a given scene
  63675. */
  63676. register(): void;
  63677. /**
  63678. * Rebuilds the elements related to this component in case of
  63679. * context lost for instance.
  63680. */
  63681. rebuild(): void;
  63682. /**
  63683. * Disposes the component and the associated ressources
  63684. */
  63685. dispose(): void;
  63686. private _gatherRenderTargets;
  63687. }
  63688. }
  63689. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63690. import { Nullable } from "babylonjs/types";
  63691. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63692. import { Camera } from "babylonjs/Cameras/camera";
  63693. import { IDisposable } from "babylonjs/scene";
  63694. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63695. import { Scene } from "babylonjs/scene";
  63696. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63697. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63698. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63699. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63700. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63701. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63702. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63703. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63704. import { Animation } from "babylonjs/Animations/animation";
  63705. /**
  63706. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63707. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63708. */
  63709. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63710. private _scene;
  63711. private _camerasToBeAttached;
  63712. /**
  63713. * ID of the sharpen post process,
  63714. */
  63715. private readonly SharpenPostProcessId;
  63716. /**
  63717. * @ignore
  63718. * ID of the image processing post process;
  63719. */
  63720. readonly ImageProcessingPostProcessId: string;
  63721. /**
  63722. * @ignore
  63723. * ID of the Fast Approximate Anti-Aliasing post process;
  63724. */
  63725. readonly FxaaPostProcessId: string;
  63726. /**
  63727. * ID of the chromatic aberration post process,
  63728. */
  63729. private readonly ChromaticAberrationPostProcessId;
  63730. /**
  63731. * ID of the grain post process
  63732. */
  63733. private readonly GrainPostProcessId;
  63734. /**
  63735. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63736. */
  63737. sharpen: SharpenPostProcess;
  63738. private _sharpenEffect;
  63739. private bloom;
  63740. /**
  63741. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63742. */
  63743. depthOfField: DepthOfFieldEffect;
  63744. /**
  63745. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63746. */
  63747. fxaa: FxaaPostProcess;
  63748. /**
  63749. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63750. */
  63751. imageProcessing: ImageProcessingPostProcess;
  63752. /**
  63753. * Chromatic aberration post process which will shift rgb colors in the image
  63754. */
  63755. chromaticAberration: ChromaticAberrationPostProcess;
  63756. private _chromaticAberrationEffect;
  63757. /**
  63758. * Grain post process which add noise to the image
  63759. */
  63760. grain: GrainPostProcess;
  63761. private _grainEffect;
  63762. /**
  63763. * Glow post process which adds a glow to emissive areas of the image
  63764. */
  63765. private _glowLayer;
  63766. /**
  63767. * Animations which can be used to tweak settings over a period of time
  63768. */
  63769. animations: Animation[];
  63770. private _imageProcessingConfigurationObserver;
  63771. private _sharpenEnabled;
  63772. private _bloomEnabled;
  63773. private _depthOfFieldEnabled;
  63774. private _depthOfFieldBlurLevel;
  63775. private _fxaaEnabled;
  63776. private _imageProcessingEnabled;
  63777. private _defaultPipelineTextureType;
  63778. private _bloomScale;
  63779. private _chromaticAberrationEnabled;
  63780. private _grainEnabled;
  63781. private _buildAllowed;
  63782. /**
  63783. * Gets active scene
  63784. */
  63785. readonly scene: Scene;
  63786. /**
  63787. * Enable or disable the sharpen process from the pipeline
  63788. */
  63789. sharpenEnabled: boolean;
  63790. private _resizeObserver;
  63791. private _hardwareScaleLevel;
  63792. private _bloomKernel;
  63793. /**
  63794. * Specifies the size of the bloom blur kernel, relative to the final output size
  63795. */
  63796. bloomKernel: number;
  63797. /**
  63798. * Specifies the weight of the bloom in the final rendering
  63799. */
  63800. private _bloomWeight;
  63801. /**
  63802. * Specifies the luma threshold for the area that will be blurred by the bloom
  63803. */
  63804. private _bloomThreshold;
  63805. private _hdr;
  63806. /**
  63807. * The strength of the bloom.
  63808. */
  63809. bloomWeight: number;
  63810. /**
  63811. * The strength of the bloom.
  63812. */
  63813. bloomThreshold: number;
  63814. /**
  63815. * The scale of the bloom, lower value will provide better performance.
  63816. */
  63817. bloomScale: number;
  63818. /**
  63819. * Enable or disable the bloom from the pipeline
  63820. */
  63821. bloomEnabled: boolean;
  63822. private _rebuildBloom;
  63823. /**
  63824. * If the depth of field is enabled.
  63825. */
  63826. depthOfFieldEnabled: boolean;
  63827. /**
  63828. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63829. */
  63830. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63831. /**
  63832. * If the anti aliasing is enabled.
  63833. */
  63834. fxaaEnabled: boolean;
  63835. private _samples;
  63836. /**
  63837. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63838. */
  63839. samples: number;
  63840. /**
  63841. * If image processing is enabled.
  63842. */
  63843. imageProcessingEnabled: boolean;
  63844. /**
  63845. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63846. */
  63847. glowLayerEnabled: boolean;
  63848. /**
  63849. * Gets the glow layer (or null if not defined)
  63850. */
  63851. readonly glowLayer: Nullable<GlowLayer>;
  63852. /**
  63853. * Enable or disable the chromaticAberration process from the pipeline
  63854. */
  63855. chromaticAberrationEnabled: boolean;
  63856. /**
  63857. * Enable or disable the grain process from the pipeline
  63858. */
  63859. grainEnabled: boolean;
  63860. /**
  63861. * @constructor
  63862. * @param name - The rendering pipeline name (default: "")
  63863. * @param hdr - If high dynamic range textures should be used (default: true)
  63864. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63865. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63866. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63867. */
  63868. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63869. /**
  63870. * Get the class name
  63871. * @returns "DefaultRenderingPipeline"
  63872. */
  63873. getClassName(): string;
  63874. /**
  63875. * Force the compilation of the entire pipeline.
  63876. */
  63877. prepare(): void;
  63878. private _hasCleared;
  63879. private _prevPostProcess;
  63880. private _prevPrevPostProcess;
  63881. private _setAutoClearAndTextureSharing;
  63882. private _depthOfFieldSceneObserver;
  63883. private _buildPipeline;
  63884. private _disposePostProcesses;
  63885. /**
  63886. * Adds a camera to the pipeline
  63887. * @param camera the camera to be added
  63888. */
  63889. addCamera(camera: Camera): void;
  63890. /**
  63891. * Removes a camera from the pipeline
  63892. * @param camera the camera to remove
  63893. */
  63894. removeCamera(camera: Camera): void;
  63895. /**
  63896. * Dispose of the pipeline and stop all post processes
  63897. */
  63898. dispose(): void;
  63899. /**
  63900. * Serialize the rendering pipeline (Used when exporting)
  63901. * @returns the serialized object
  63902. */
  63903. serialize(): any;
  63904. /**
  63905. * Parse the serialized pipeline
  63906. * @param source Source pipeline.
  63907. * @param scene The scene to load the pipeline to.
  63908. * @param rootUrl The URL of the serialized pipeline.
  63909. * @returns An instantiated pipeline from the serialized object.
  63910. */
  63911. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63912. }
  63913. }
  63914. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63915. /** @hidden */
  63916. export var lensHighlightsPixelShader: {
  63917. name: string;
  63918. shader: string;
  63919. };
  63920. }
  63921. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63922. /** @hidden */
  63923. export var depthOfFieldPixelShader: {
  63924. name: string;
  63925. shader: string;
  63926. };
  63927. }
  63928. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63929. import { Camera } from "babylonjs/Cameras/camera";
  63930. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63931. import { Scene } from "babylonjs/scene";
  63932. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63933. import "babylonjs/Shaders/chromaticAberration.fragment";
  63934. import "babylonjs/Shaders/lensHighlights.fragment";
  63935. import "babylonjs/Shaders/depthOfField.fragment";
  63936. /**
  63937. * BABYLON.JS Chromatic Aberration GLSL Shader
  63938. * Author: Olivier Guyot
  63939. * Separates very slightly R, G and B colors on the edges of the screen
  63940. * Inspired by Francois Tarlier & Martins Upitis
  63941. */
  63942. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63943. /**
  63944. * @ignore
  63945. * The chromatic aberration PostProcess id in the pipeline
  63946. */
  63947. LensChromaticAberrationEffect: string;
  63948. /**
  63949. * @ignore
  63950. * The highlights enhancing PostProcess id in the pipeline
  63951. */
  63952. HighlightsEnhancingEffect: string;
  63953. /**
  63954. * @ignore
  63955. * The depth-of-field PostProcess id in the pipeline
  63956. */
  63957. LensDepthOfFieldEffect: string;
  63958. private _scene;
  63959. private _depthTexture;
  63960. private _grainTexture;
  63961. private _chromaticAberrationPostProcess;
  63962. private _highlightsPostProcess;
  63963. private _depthOfFieldPostProcess;
  63964. private _edgeBlur;
  63965. private _grainAmount;
  63966. private _chromaticAberration;
  63967. private _distortion;
  63968. private _highlightsGain;
  63969. private _highlightsThreshold;
  63970. private _dofDistance;
  63971. private _dofAperture;
  63972. private _dofDarken;
  63973. private _dofPentagon;
  63974. private _blurNoise;
  63975. /**
  63976. * @constructor
  63977. *
  63978. * Effect parameters are as follow:
  63979. * {
  63980. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63981. * edge_blur: number; // from 0 to x (1 for realism)
  63982. * distortion: number; // from 0 to x (1 for realism)
  63983. * grain_amount: number; // from 0 to 1
  63984. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63985. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63986. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63987. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63988. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63989. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63990. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63991. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63992. * }
  63993. * Note: if an effect parameter is unset, effect is disabled
  63994. *
  63995. * @param name The rendering pipeline name
  63996. * @param parameters - An object containing all parameters (see above)
  63997. * @param scene The scene linked to this pipeline
  63998. * @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)
  63999. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64000. */
  64001. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64002. /**
  64003. * Get the class name
  64004. * @returns "LensRenderingPipeline"
  64005. */
  64006. getClassName(): string;
  64007. /**
  64008. * Gets associated scene
  64009. */
  64010. readonly scene: Scene;
  64011. /**
  64012. * Gets or sets the edge blur
  64013. */
  64014. edgeBlur: number;
  64015. /**
  64016. * Gets or sets the grain amount
  64017. */
  64018. grainAmount: number;
  64019. /**
  64020. * Gets or sets the chromatic aberration amount
  64021. */
  64022. chromaticAberration: number;
  64023. /**
  64024. * Gets or sets the depth of field aperture
  64025. */
  64026. dofAperture: number;
  64027. /**
  64028. * Gets or sets the edge distortion
  64029. */
  64030. edgeDistortion: number;
  64031. /**
  64032. * Gets or sets the depth of field distortion
  64033. */
  64034. dofDistortion: number;
  64035. /**
  64036. * Gets or sets the darken out of focus amount
  64037. */
  64038. darkenOutOfFocus: number;
  64039. /**
  64040. * Gets or sets a boolean indicating if blur noise is enabled
  64041. */
  64042. blurNoise: boolean;
  64043. /**
  64044. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64045. */
  64046. pentagonBokeh: boolean;
  64047. /**
  64048. * Gets or sets the highlight grain amount
  64049. */
  64050. highlightsGain: number;
  64051. /**
  64052. * Gets or sets the highlight threshold
  64053. */
  64054. highlightsThreshold: number;
  64055. /**
  64056. * Sets the amount of blur at the edges
  64057. * @param amount blur amount
  64058. */
  64059. setEdgeBlur(amount: number): void;
  64060. /**
  64061. * Sets edge blur to 0
  64062. */
  64063. disableEdgeBlur(): void;
  64064. /**
  64065. * Sets the amout of grain
  64066. * @param amount Amount of grain
  64067. */
  64068. setGrainAmount(amount: number): void;
  64069. /**
  64070. * Set grain amount to 0
  64071. */
  64072. disableGrain(): void;
  64073. /**
  64074. * Sets the chromatic aberration amount
  64075. * @param amount amount of chromatic aberration
  64076. */
  64077. setChromaticAberration(amount: number): void;
  64078. /**
  64079. * Sets chromatic aberration amount to 0
  64080. */
  64081. disableChromaticAberration(): void;
  64082. /**
  64083. * Sets the EdgeDistortion amount
  64084. * @param amount amount of EdgeDistortion
  64085. */
  64086. setEdgeDistortion(amount: number): void;
  64087. /**
  64088. * Sets edge distortion to 0
  64089. */
  64090. disableEdgeDistortion(): void;
  64091. /**
  64092. * Sets the FocusDistance amount
  64093. * @param amount amount of FocusDistance
  64094. */
  64095. setFocusDistance(amount: number): void;
  64096. /**
  64097. * Disables depth of field
  64098. */
  64099. disableDepthOfField(): void;
  64100. /**
  64101. * Sets the Aperture amount
  64102. * @param amount amount of Aperture
  64103. */
  64104. setAperture(amount: number): void;
  64105. /**
  64106. * Sets the DarkenOutOfFocus amount
  64107. * @param amount amount of DarkenOutOfFocus
  64108. */
  64109. setDarkenOutOfFocus(amount: number): void;
  64110. private _pentagonBokehIsEnabled;
  64111. /**
  64112. * Creates a pentagon bokeh effect
  64113. */
  64114. enablePentagonBokeh(): void;
  64115. /**
  64116. * Disables the pentagon bokeh effect
  64117. */
  64118. disablePentagonBokeh(): void;
  64119. /**
  64120. * Enables noise blur
  64121. */
  64122. enableNoiseBlur(): void;
  64123. /**
  64124. * Disables noise blur
  64125. */
  64126. disableNoiseBlur(): void;
  64127. /**
  64128. * Sets the HighlightsGain amount
  64129. * @param amount amount of HighlightsGain
  64130. */
  64131. setHighlightsGain(amount: number): void;
  64132. /**
  64133. * Sets the HighlightsThreshold amount
  64134. * @param amount amount of HighlightsThreshold
  64135. */
  64136. setHighlightsThreshold(amount: number): void;
  64137. /**
  64138. * Disables highlights
  64139. */
  64140. disableHighlights(): void;
  64141. /**
  64142. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64143. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64144. */
  64145. dispose(disableDepthRender?: boolean): void;
  64146. private _createChromaticAberrationPostProcess;
  64147. private _createHighlightsPostProcess;
  64148. private _createDepthOfFieldPostProcess;
  64149. private _createGrainTexture;
  64150. }
  64151. }
  64152. declare module "babylonjs/Shaders/ssao2.fragment" {
  64153. /** @hidden */
  64154. export var ssao2PixelShader: {
  64155. name: string;
  64156. shader: string;
  64157. };
  64158. }
  64159. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64160. /** @hidden */
  64161. export var ssaoCombinePixelShader: {
  64162. name: string;
  64163. shader: string;
  64164. };
  64165. }
  64166. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64167. import { Camera } from "babylonjs/Cameras/camera";
  64168. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64169. import { Scene } from "babylonjs/scene";
  64170. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64171. import "babylonjs/Shaders/ssao2.fragment";
  64172. import "babylonjs/Shaders/ssaoCombine.fragment";
  64173. /**
  64174. * Render pipeline to produce ssao effect
  64175. */
  64176. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64177. /**
  64178. * @ignore
  64179. * The PassPostProcess id in the pipeline that contains the original scene color
  64180. */
  64181. SSAOOriginalSceneColorEffect: string;
  64182. /**
  64183. * @ignore
  64184. * The SSAO PostProcess id in the pipeline
  64185. */
  64186. SSAORenderEffect: string;
  64187. /**
  64188. * @ignore
  64189. * The horizontal blur PostProcess id in the pipeline
  64190. */
  64191. SSAOBlurHRenderEffect: string;
  64192. /**
  64193. * @ignore
  64194. * The vertical blur PostProcess id in the pipeline
  64195. */
  64196. SSAOBlurVRenderEffect: string;
  64197. /**
  64198. * @ignore
  64199. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64200. */
  64201. SSAOCombineRenderEffect: string;
  64202. /**
  64203. * The output strength of the SSAO post-process. Default value is 1.0.
  64204. */
  64205. totalStrength: number;
  64206. /**
  64207. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64208. */
  64209. maxZ: number;
  64210. /**
  64211. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64212. */
  64213. minZAspect: number;
  64214. private _samples;
  64215. /**
  64216. * Number of samples used for the SSAO calculations. Default value is 8
  64217. */
  64218. samples: number;
  64219. private _textureSamples;
  64220. /**
  64221. * Number of samples to use for antialiasing
  64222. */
  64223. textureSamples: number;
  64224. /**
  64225. * Ratio object used for SSAO ratio and blur ratio
  64226. */
  64227. private _ratio;
  64228. /**
  64229. * Dynamically generated sphere sampler.
  64230. */
  64231. private _sampleSphere;
  64232. /**
  64233. * Blur filter offsets
  64234. */
  64235. private _samplerOffsets;
  64236. private _expensiveBlur;
  64237. /**
  64238. * If bilateral blur should be used
  64239. */
  64240. expensiveBlur: boolean;
  64241. /**
  64242. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64243. */
  64244. radius: number;
  64245. /**
  64246. * The base color of the SSAO post-process
  64247. * The final result is "base + ssao" between [0, 1]
  64248. */
  64249. base: number;
  64250. /**
  64251. * Support test.
  64252. */
  64253. static readonly IsSupported: boolean;
  64254. private _scene;
  64255. private _depthTexture;
  64256. private _normalTexture;
  64257. private _randomTexture;
  64258. private _originalColorPostProcess;
  64259. private _ssaoPostProcess;
  64260. private _blurHPostProcess;
  64261. private _blurVPostProcess;
  64262. private _ssaoCombinePostProcess;
  64263. private _firstUpdate;
  64264. /**
  64265. * Gets active scene
  64266. */
  64267. readonly scene: Scene;
  64268. /**
  64269. * @constructor
  64270. * @param name The rendering pipeline name
  64271. * @param scene The scene linked to this pipeline
  64272. * @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 }
  64273. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64274. */
  64275. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64276. /**
  64277. * Get the class name
  64278. * @returns "SSAO2RenderingPipeline"
  64279. */
  64280. getClassName(): string;
  64281. /**
  64282. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64283. */
  64284. dispose(disableGeometryBufferRenderer?: boolean): void;
  64285. private _createBlurPostProcess;
  64286. /** @hidden */
  64287. _rebuild(): void;
  64288. private _bits;
  64289. private _radicalInverse_VdC;
  64290. private _hammersley;
  64291. private _hemisphereSample_uniform;
  64292. private _generateHemisphere;
  64293. private _createSSAOPostProcess;
  64294. private _createSSAOCombinePostProcess;
  64295. private _createRandomTexture;
  64296. /**
  64297. * Serialize the rendering pipeline (Used when exporting)
  64298. * @returns the serialized object
  64299. */
  64300. serialize(): any;
  64301. /**
  64302. * Parse the serialized pipeline
  64303. * @param source Source pipeline.
  64304. * @param scene The scene to load the pipeline to.
  64305. * @param rootUrl The URL of the serialized pipeline.
  64306. * @returns An instantiated pipeline from the serialized object.
  64307. */
  64308. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64309. }
  64310. }
  64311. declare module "babylonjs/Shaders/ssao.fragment" {
  64312. /** @hidden */
  64313. export var ssaoPixelShader: {
  64314. name: string;
  64315. shader: string;
  64316. };
  64317. }
  64318. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64319. import { Camera } from "babylonjs/Cameras/camera";
  64320. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64321. import { Scene } from "babylonjs/scene";
  64322. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64323. import "babylonjs/Shaders/ssao.fragment";
  64324. import "babylonjs/Shaders/ssaoCombine.fragment";
  64325. /**
  64326. * Render pipeline to produce ssao effect
  64327. */
  64328. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64329. /**
  64330. * @ignore
  64331. * The PassPostProcess id in the pipeline that contains the original scene color
  64332. */
  64333. SSAOOriginalSceneColorEffect: string;
  64334. /**
  64335. * @ignore
  64336. * The SSAO PostProcess id in the pipeline
  64337. */
  64338. SSAORenderEffect: string;
  64339. /**
  64340. * @ignore
  64341. * The horizontal blur PostProcess id in the pipeline
  64342. */
  64343. SSAOBlurHRenderEffect: string;
  64344. /**
  64345. * @ignore
  64346. * The vertical blur PostProcess id in the pipeline
  64347. */
  64348. SSAOBlurVRenderEffect: string;
  64349. /**
  64350. * @ignore
  64351. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64352. */
  64353. SSAOCombineRenderEffect: string;
  64354. /**
  64355. * The output strength of the SSAO post-process. Default value is 1.0.
  64356. */
  64357. totalStrength: number;
  64358. /**
  64359. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64360. */
  64361. radius: number;
  64362. /**
  64363. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64364. * Must not be equal to fallOff and superior to fallOff.
  64365. * Default value is 0.0075
  64366. */
  64367. area: number;
  64368. /**
  64369. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64370. * Must not be equal to area and inferior to area.
  64371. * Default value is 0.000001
  64372. */
  64373. fallOff: number;
  64374. /**
  64375. * The base color of the SSAO post-process
  64376. * The final result is "base + ssao" between [0, 1]
  64377. */
  64378. base: number;
  64379. private _scene;
  64380. private _depthTexture;
  64381. private _randomTexture;
  64382. private _originalColorPostProcess;
  64383. private _ssaoPostProcess;
  64384. private _blurHPostProcess;
  64385. private _blurVPostProcess;
  64386. private _ssaoCombinePostProcess;
  64387. private _firstUpdate;
  64388. /**
  64389. * Gets active scene
  64390. */
  64391. readonly scene: Scene;
  64392. /**
  64393. * @constructor
  64394. * @param name - The rendering pipeline name
  64395. * @param scene - The scene linked to this pipeline
  64396. * @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 }
  64397. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64398. */
  64399. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64400. /**
  64401. * Get the class name
  64402. * @returns "SSAORenderingPipeline"
  64403. */
  64404. getClassName(): string;
  64405. /**
  64406. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64407. */
  64408. dispose(disableDepthRender?: boolean): void;
  64409. private _createBlurPostProcess;
  64410. /** @hidden */
  64411. _rebuild(): void;
  64412. private _createSSAOPostProcess;
  64413. private _createSSAOCombinePostProcess;
  64414. private _createRandomTexture;
  64415. }
  64416. }
  64417. declare module "babylonjs/Shaders/standard.fragment" {
  64418. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64419. /** @hidden */
  64420. export var standardPixelShader: {
  64421. name: string;
  64422. shader: string;
  64423. };
  64424. }
  64425. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64426. import { Nullable } from "babylonjs/types";
  64427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64428. import { Camera } from "babylonjs/Cameras/camera";
  64429. import { Texture } from "babylonjs/Materials/Textures/texture";
  64430. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64431. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64432. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64433. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64434. import { IDisposable } from "babylonjs/scene";
  64435. import { SpotLight } from "babylonjs/Lights/spotLight";
  64436. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64437. import { Scene } from "babylonjs/scene";
  64438. import { Animation } from "babylonjs/Animations/animation";
  64439. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64440. import "babylonjs/Shaders/standard.fragment";
  64441. /**
  64442. * Standard rendering pipeline
  64443. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64444. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64445. */
  64446. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64447. /**
  64448. * Public members
  64449. */
  64450. /**
  64451. * Post-process which contains the original scene color before the pipeline applies all the effects
  64452. */
  64453. originalPostProcess: Nullable<PostProcess>;
  64454. /**
  64455. * Post-process used to down scale an image x4
  64456. */
  64457. downSampleX4PostProcess: Nullable<PostProcess>;
  64458. /**
  64459. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64460. */
  64461. brightPassPostProcess: Nullable<PostProcess>;
  64462. /**
  64463. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64464. */
  64465. blurHPostProcesses: PostProcess[];
  64466. /**
  64467. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64468. */
  64469. blurVPostProcesses: PostProcess[];
  64470. /**
  64471. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64472. */
  64473. textureAdderPostProcess: Nullable<PostProcess>;
  64474. /**
  64475. * Post-process used to create volumetric lighting effect
  64476. */
  64477. volumetricLightPostProcess: Nullable<PostProcess>;
  64478. /**
  64479. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64480. */
  64481. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64482. /**
  64483. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64484. */
  64485. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64486. /**
  64487. * Post-process used to merge the volumetric light effect and the real scene color
  64488. */
  64489. volumetricLightMergePostProces: Nullable<PostProcess>;
  64490. /**
  64491. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64492. */
  64493. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64494. /**
  64495. * Base post-process used to calculate the average luminance of the final image for HDR
  64496. */
  64497. luminancePostProcess: Nullable<PostProcess>;
  64498. /**
  64499. * Post-processes used to create down sample post-processes in order to get
  64500. * the average luminance of the final image for HDR
  64501. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64502. */
  64503. luminanceDownSamplePostProcesses: PostProcess[];
  64504. /**
  64505. * Post-process used to create a HDR effect (light adaptation)
  64506. */
  64507. hdrPostProcess: Nullable<PostProcess>;
  64508. /**
  64509. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64510. */
  64511. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64512. /**
  64513. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64514. */
  64515. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64516. /**
  64517. * Post-process used to merge the final HDR post-process and the real scene color
  64518. */
  64519. hdrFinalPostProcess: Nullable<PostProcess>;
  64520. /**
  64521. * Post-process used to create a lens flare effect
  64522. */
  64523. lensFlarePostProcess: Nullable<PostProcess>;
  64524. /**
  64525. * Post-process that merges the result of the lens flare post-process and the real scene color
  64526. */
  64527. lensFlareComposePostProcess: Nullable<PostProcess>;
  64528. /**
  64529. * Post-process used to create a motion blur effect
  64530. */
  64531. motionBlurPostProcess: Nullable<PostProcess>;
  64532. /**
  64533. * Post-process used to create a depth of field effect
  64534. */
  64535. depthOfFieldPostProcess: Nullable<PostProcess>;
  64536. /**
  64537. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64538. */
  64539. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64540. /**
  64541. * Represents the brightness threshold in order to configure the illuminated surfaces
  64542. */
  64543. brightThreshold: number;
  64544. /**
  64545. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64546. */
  64547. blurWidth: number;
  64548. /**
  64549. * Sets if the blur for highlighted surfaces must be only horizontal
  64550. */
  64551. horizontalBlur: boolean;
  64552. /**
  64553. * Gets the overall exposure used by the pipeline
  64554. */
  64555. /**
  64556. * Sets the overall exposure used by the pipeline
  64557. */
  64558. exposure: number;
  64559. /**
  64560. * Texture used typically to simulate "dirty" on camera lens
  64561. */
  64562. lensTexture: Nullable<Texture>;
  64563. /**
  64564. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64565. */
  64566. volumetricLightCoefficient: number;
  64567. /**
  64568. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64569. */
  64570. volumetricLightPower: number;
  64571. /**
  64572. * Used the set the blur intensity to smooth the volumetric lights
  64573. */
  64574. volumetricLightBlurScale: number;
  64575. /**
  64576. * Light (spot or directional) used to generate the volumetric lights rays
  64577. * The source light must have a shadow generate so the pipeline can get its
  64578. * depth map
  64579. */
  64580. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64581. /**
  64582. * For eye adaptation, represents the minimum luminance the eye can see
  64583. */
  64584. hdrMinimumLuminance: number;
  64585. /**
  64586. * For eye adaptation, represents the decrease luminance speed
  64587. */
  64588. hdrDecreaseRate: number;
  64589. /**
  64590. * For eye adaptation, represents the increase luminance speed
  64591. */
  64592. hdrIncreaseRate: number;
  64593. /**
  64594. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64595. */
  64596. /**
  64597. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64598. */
  64599. hdrAutoExposure: boolean;
  64600. /**
  64601. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64602. */
  64603. lensColorTexture: Nullable<Texture>;
  64604. /**
  64605. * The overall strengh for the lens flare effect
  64606. */
  64607. lensFlareStrength: number;
  64608. /**
  64609. * Dispersion coefficient for lens flare ghosts
  64610. */
  64611. lensFlareGhostDispersal: number;
  64612. /**
  64613. * Main lens flare halo width
  64614. */
  64615. lensFlareHaloWidth: number;
  64616. /**
  64617. * Based on the lens distortion effect, defines how much the lens flare result
  64618. * is distorted
  64619. */
  64620. lensFlareDistortionStrength: number;
  64621. /**
  64622. * Configures the blur intensity used for for lens flare (halo)
  64623. */
  64624. lensFlareBlurWidth: number;
  64625. /**
  64626. * Lens star texture must be used to simulate rays on the flares and is available
  64627. * in the documentation
  64628. */
  64629. lensStarTexture: Nullable<Texture>;
  64630. /**
  64631. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64632. * flare effect by taking account of the dirt texture
  64633. */
  64634. lensFlareDirtTexture: Nullable<Texture>;
  64635. /**
  64636. * Represents the focal length for the depth of field effect
  64637. */
  64638. depthOfFieldDistance: number;
  64639. /**
  64640. * Represents the blur intensity for the blurred part of the depth of field effect
  64641. */
  64642. depthOfFieldBlurWidth: number;
  64643. /**
  64644. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64645. */
  64646. /**
  64647. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64648. */
  64649. motionStrength: number;
  64650. /**
  64651. * Gets wether or not the motion blur post-process is object based or screen based.
  64652. */
  64653. /**
  64654. * Sets wether or not the motion blur post-process should be object based or screen based
  64655. */
  64656. objectBasedMotionBlur: boolean;
  64657. /**
  64658. * List of animations for the pipeline (IAnimatable implementation)
  64659. */
  64660. animations: Animation[];
  64661. /**
  64662. * Private members
  64663. */
  64664. private _scene;
  64665. private _currentDepthOfFieldSource;
  64666. private _basePostProcess;
  64667. private _fixedExposure;
  64668. private _currentExposure;
  64669. private _hdrAutoExposure;
  64670. private _hdrCurrentLuminance;
  64671. private _motionStrength;
  64672. private _isObjectBasedMotionBlur;
  64673. private _floatTextureType;
  64674. private _camerasToBeAttached;
  64675. private _ratio;
  64676. private _bloomEnabled;
  64677. private _depthOfFieldEnabled;
  64678. private _vlsEnabled;
  64679. private _lensFlareEnabled;
  64680. private _hdrEnabled;
  64681. private _motionBlurEnabled;
  64682. private _fxaaEnabled;
  64683. private _motionBlurSamples;
  64684. private _volumetricLightStepsCount;
  64685. private _samples;
  64686. /**
  64687. * @ignore
  64688. * Specifies if the bloom pipeline is enabled
  64689. */
  64690. BloomEnabled: boolean;
  64691. /**
  64692. * @ignore
  64693. * Specifies if the depth of field pipeline is enabed
  64694. */
  64695. DepthOfFieldEnabled: boolean;
  64696. /**
  64697. * @ignore
  64698. * Specifies if the lens flare pipeline is enabed
  64699. */
  64700. LensFlareEnabled: boolean;
  64701. /**
  64702. * @ignore
  64703. * Specifies if the HDR pipeline is enabled
  64704. */
  64705. HDREnabled: boolean;
  64706. /**
  64707. * @ignore
  64708. * Specifies if the volumetric lights scattering effect is enabled
  64709. */
  64710. VLSEnabled: boolean;
  64711. /**
  64712. * @ignore
  64713. * Specifies if the motion blur effect is enabled
  64714. */
  64715. MotionBlurEnabled: boolean;
  64716. /**
  64717. * Specifies if anti-aliasing is enabled
  64718. */
  64719. fxaaEnabled: boolean;
  64720. /**
  64721. * Specifies the number of steps used to calculate the volumetric lights
  64722. * Typically in interval [50, 200]
  64723. */
  64724. volumetricLightStepsCount: number;
  64725. /**
  64726. * Specifies the number of samples used for the motion blur effect
  64727. * Typically in interval [16, 64]
  64728. */
  64729. motionBlurSamples: number;
  64730. /**
  64731. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64732. */
  64733. samples: number;
  64734. /**
  64735. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64736. * @constructor
  64737. * @param name The rendering pipeline name
  64738. * @param scene The scene linked to this pipeline
  64739. * @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)
  64740. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64741. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64742. */
  64743. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64744. private _buildPipeline;
  64745. private _createDownSampleX4PostProcess;
  64746. private _createBrightPassPostProcess;
  64747. private _createBlurPostProcesses;
  64748. private _createTextureAdderPostProcess;
  64749. private _createVolumetricLightPostProcess;
  64750. private _createLuminancePostProcesses;
  64751. private _createHdrPostProcess;
  64752. private _createLensFlarePostProcess;
  64753. private _createDepthOfFieldPostProcess;
  64754. private _createMotionBlurPostProcess;
  64755. private _getDepthTexture;
  64756. private _disposePostProcesses;
  64757. /**
  64758. * Dispose of the pipeline and stop all post processes
  64759. */
  64760. dispose(): void;
  64761. /**
  64762. * Serialize the rendering pipeline (Used when exporting)
  64763. * @returns the serialized object
  64764. */
  64765. serialize(): any;
  64766. /**
  64767. * Parse the serialized pipeline
  64768. * @param source Source pipeline.
  64769. * @param scene The scene to load the pipeline to.
  64770. * @param rootUrl The URL of the serialized pipeline.
  64771. * @returns An instantiated pipeline from the serialized object.
  64772. */
  64773. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64774. /**
  64775. * Luminance steps
  64776. */
  64777. static LuminanceSteps: number;
  64778. }
  64779. }
  64780. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64781. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64782. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64783. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64784. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64785. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64786. }
  64787. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64788. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64789. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64790. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64791. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64792. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64793. }
  64794. declare module "babylonjs/Shaders/tonemap.fragment" {
  64795. /** @hidden */
  64796. export var tonemapPixelShader: {
  64797. name: string;
  64798. shader: string;
  64799. };
  64800. }
  64801. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64802. import { Camera } from "babylonjs/Cameras/camera";
  64803. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64804. import "babylonjs/Shaders/tonemap.fragment";
  64805. import { Engine } from "babylonjs/Engines/engine";
  64806. /** Defines operator used for tonemapping */
  64807. export enum TonemappingOperator {
  64808. /** Hable */
  64809. Hable = 0,
  64810. /** Reinhard */
  64811. Reinhard = 1,
  64812. /** HejiDawson */
  64813. HejiDawson = 2,
  64814. /** Photographic */
  64815. Photographic = 3
  64816. }
  64817. /**
  64818. * Defines a post process to apply tone mapping
  64819. */
  64820. export class TonemapPostProcess extends PostProcess {
  64821. private _operator;
  64822. /** Defines the required exposure adjustement */
  64823. exposureAdjustment: number;
  64824. /**
  64825. * Creates a new TonemapPostProcess
  64826. * @param name defines the name of the postprocess
  64827. * @param _operator defines the operator to use
  64828. * @param exposureAdjustment defines the required exposure adjustement
  64829. * @param camera defines the camera to use (can be null)
  64830. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64831. * @param engine defines the hosting engine (can be ignore if camera is set)
  64832. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64833. */
  64834. constructor(name: string, _operator: TonemappingOperator,
  64835. /** Defines the required exposure adjustement */
  64836. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64837. }
  64838. }
  64839. declare module "babylonjs/Shaders/depth.vertex" {
  64840. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64843. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64844. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64845. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64846. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64847. /** @hidden */
  64848. export var depthVertexShader: {
  64849. name: string;
  64850. shader: string;
  64851. };
  64852. }
  64853. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64854. /** @hidden */
  64855. export var volumetricLightScatteringPixelShader: {
  64856. name: string;
  64857. shader: string;
  64858. };
  64859. }
  64860. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64861. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64864. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64866. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64867. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64868. /** @hidden */
  64869. export var volumetricLightScatteringPassVertexShader: {
  64870. name: string;
  64871. shader: string;
  64872. };
  64873. }
  64874. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64875. /** @hidden */
  64876. export var volumetricLightScatteringPassPixelShader: {
  64877. name: string;
  64878. shader: string;
  64879. };
  64880. }
  64881. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64882. import { Vector3 } from "babylonjs/Maths/math.vector";
  64883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64884. import { Mesh } from "babylonjs/Meshes/mesh";
  64885. import { Camera } from "babylonjs/Cameras/camera";
  64886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64888. import { Scene } from "babylonjs/scene";
  64889. import "babylonjs/Meshes/Builders/planeBuilder";
  64890. import "babylonjs/Shaders/depth.vertex";
  64891. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64892. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64893. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64894. import { Engine } from "babylonjs/Engines/engine";
  64895. /**
  64896. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64897. */
  64898. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64899. private _volumetricLightScatteringPass;
  64900. private _volumetricLightScatteringRTT;
  64901. private _viewPort;
  64902. private _screenCoordinates;
  64903. private _cachedDefines;
  64904. /**
  64905. * If not undefined, the mesh position is computed from the attached node position
  64906. */
  64907. attachedNode: {
  64908. position: Vector3;
  64909. };
  64910. /**
  64911. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64912. */
  64913. customMeshPosition: Vector3;
  64914. /**
  64915. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64916. */
  64917. useCustomMeshPosition: boolean;
  64918. /**
  64919. * If the post-process should inverse the light scattering direction
  64920. */
  64921. invert: boolean;
  64922. /**
  64923. * The internal mesh used by the post-process
  64924. */
  64925. mesh: Mesh;
  64926. /**
  64927. * @hidden
  64928. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64929. */
  64930. useDiffuseColor: boolean;
  64931. /**
  64932. * Array containing the excluded meshes not rendered in the internal pass
  64933. */
  64934. excludedMeshes: AbstractMesh[];
  64935. /**
  64936. * Controls the overall intensity of the post-process
  64937. */
  64938. exposure: number;
  64939. /**
  64940. * Dissipates each sample's contribution in range [0, 1]
  64941. */
  64942. decay: number;
  64943. /**
  64944. * Controls the overall intensity of each sample
  64945. */
  64946. weight: number;
  64947. /**
  64948. * Controls the density of each sample
  64949. */
  64950. density: number;
  64951. /**
  64952. * @constructor
  64953. * @param name The post-process name
  64954. * @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)
  64955. * @param camera The camera that the post-process will be attached to
  64956. * @param mesh The mesh used to create the light scattering
  64957. * @param samples The post-process quality, default 100
  64958. * @param samplingModeThe post-process filtering mode
  64959. * @param engine The babylon engine
  64960. * @param reusable If the post-process is reusable
  64961. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64962. */
  64963. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64964. /**
  64965. * Returns the string "VolumetricLightScatteringPostProcess"
  64966. * @returns "VolumetricLightScatteringPostProcess"
  64967. */
  64968. getClassName(): string;
  64969. private _isReady;
  64970. /**
  64971. * Sets the new light position for light scattering effect
  64972. * @param position The new custom light position
  64973. */
  64974. setCustomMeshPosition(position: Vector3): void;
  64975. /**
  64976. * Returns the light position for light scattering effect
  64977. * @return Vector3 The custom light position
  64978. */
  64979. getCustomMeshPosition(): Vector3;
  64980. /**
  64981. * Disposes the internal assets and detaches the post-process from the camera
  64982. */
  64983. dispose(camera: Camera): void;
  64984. /**
  64985. * Returns the render target texture used by the post-process
  64986. * @return the render target texture used by the post-process
  64987. */
  64988. getPass(): RenderTargetTexture;
  64989. private _meshExcluded;
  64990. private _createPass;
  64991. private _updateMeshScreenCoordinates;
  64992. /**
  64993. * Creates a default mesh for the Volumeric Light Scattering post-process
  64994. * @param name The mesh name
  64995. * @param scene The scene where to create the mesh
  64996. * @return the default mesh
  64997. */
  64998. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64999. }
  65000. }
  65001. declare module "babylonjs/PostProcesses/index" {
  65002. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65003. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65004. export * from "babylonjs/PostProcesses/bloomEffect";
  65005. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65006. export * from "babylonjs/PostProcesses/blurPostProcess";
  65007. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65008. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65009. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65010. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65011. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65012. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65013. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65014. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65015. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65016. export * from "babylonjs/PostProcesses/filterPostProcess";
  65017. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65018. export * from "babylonjs/PostProcesses/grainPostProcess";
  65019. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65020. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65021. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65022. export * from "babylonjs/PostProcesses/passPostProcess";
  65023. export * from "babylonjs/PostProcesses/postProcess";
  65024. export * from "babylonjs/PostProcesses/postProcessManager";
  65025. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65026. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65027. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65028. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65029. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65030. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65031. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65032. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65033. }
  65034. declare module "babylonjs/Probes/index" {
  65035. export * from "babylonjs/Probes/reflectionProbe";
  65036. }
  65037. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65038. import { Scene } from "babylonjs/scene";
  65039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65040. import { SmartArray } from "babylonjs/Misc/smartArray";
  65041. import { ISceneComponent } from "babylonjs/sceneComponent";
  65042. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65043. import "babylonjs/Meshes/Builders/boxBuilder";
  65044. import "babylonjs/Shaders/color.fragment";
  65045. import "babylonjs/Shaders/color.vertex";
  65046. import { Color3 } from "babylonjs/Maths/math.color";
  65047. module "babylonjs/scene" {
  65048. interface Scene {
  65049. /** @hidden (Backing field) */
  65050. _boundingBoxRenderer: BoundingBoxRenderer;
  65051. /** @hidden (Backing field) */
  65052. _forceShowBoundingBoxes: boolean;
  65053. /**
  65054. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65055. */
  65056. forceShowBoundingBoxes: boolean;
  65057. /**
  65058. * Gets the bounding box renderer associated with the scene
  65059. * @returns a BoundingBoxRenderer
  65060. */
  65061. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65062. }
  65063. }
  65064. module "babylonjs/Meshes/abstractMesh" {
  65065. interface AbstractMesh {
  65066. /** @hidden (Backing field) */
  65067. _showBoundingBox: boolean;
  65068. /**
  65069. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65070. */
  65071. showBoundingBox: boolean;
  65072. }
  65073. }
  65074. /**
  65075. * Component responsible of rendering the bounding box of the meshes in a scene.
  65076. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65077. */
  65078. export class BoundingBoxRenderer implements ISceneComponent {
  65079. /**
  65080. * The component name helpfull to identify the component in the list of scene components.
  65081. */
  65082. readonly name: string;
  65083. /**
  65084. * The scene the component belongs to.
  65085. */
  65086. scene: Scene;
  65087. /**
  65088. * Color of the bounding box lines placed in front of an object
  65089. */
  65090. frontColor: Color3;
  65091. /**
  65092. * Color of the bounding box lines placed behind an object
  65093. */
  65094. backColor: Color3;
  65095. /**
  65096. * Defines if the renderer should show the back lines or not
  65097. */
  65098. showBackLines: boolean;
  65099. /**
  65100. * @hidden
  65101. */
  65102. renderList: SmartArray<BoundingBox>;
  65103. private _colorShader;
  65104. private _vertexBuffers;
  65105. private _indexBuffer;
  65106. private _fillIndexBuffer;
  65107. private _fillIndexData;
  65108. /**
  65109. * Instantiates a new bounding box renderer in a scene.
  65110. * @param scene the scene the renderer renders in
  65111. */
  65112. constructor(scene: Scene);
  65113. /**
  65114. * Registers the component in a given scene
  65115. */
  65116. register(): void;
  65117. private _evaluateSubMesh;
  65118. private _activeMesh;
  65119. private _prepareRessources;
  65120. private _createIndexBuffer;
  65121. /**
  65122. * Rebuilds the elements related to this component in case of
  65123. * context lost for instance.
  65124. */
  65125. rebuild(): void;
  65126. /**
  65127. * @hidden
  65128. */
  65129. reset(): void;
  65130. /**
  65131. * Render the bounding boxes of a specific rendering group
  65132. * @param renderingGroupId defines the rendering group to render
  65133. */
  65134. render(renderingGroupId: number): void;
  65135. /**
  65136. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65137. * @param mesh Define the mesh to render the occlusion bounding box for
  65138. */
  65139. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65140. /**
  65141. * Dispose and release the resources attached to this renderer.
  65142. */
  65143. dispose(): void;
  65144. }
  65145. }
  65146. declare module "babylonjs/Shaders/depth.fragment" {
  65147. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65148. /** @hidden */
  65149. export var depthPixelShader: {
  65150. name: string;
  65151. shader: string;
  65152. };
  65153. }
  65154. declare module "babylonjs/Rendering/depthRenderer" {
  65155. import { Nullable } from "babylonjs/types";
  65156. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65157. import { Scene } from "babylonjs/scene";
  65158. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65159. import { Camera } from "babylonjs/Cameras/camera";
  65160. import "babylonjs/Shaders/depth.fragment";
  65161. import "babylonjs/Shaders/depth.vertex";
  65162. /**
  65163. * This represents a depth renderer in Babylon.
  65164. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65165. */
  65166. export class DepthRenderer {
  65167. private _scene;
  65168. private _depthMap;
  65169. private _effect;
  65170. private readonly _storeNonLinearDepth;
  65171. private readonly _clearColor;
  65172. /** Get if the depth renderer is using packed depth or not */
  65173. readonly isPacked: boolean;
  65174. private _cachedDefines;
  65175. private _camera;
  65176. /**
  65177. * Specifiess that the depth renderer will only be used within
  65178. * the camera it is created for.
  65179. * This can help forcing its rendering during the camera processing.
  65180. */
  65181. useOnlyInActiveCamera: boolean;
  65182. /** @hidden */
  65183. static _SceneComponentInitialization: (scene: Scene) => void;
  65184. /**
  65185. * Instantiates a depth renderer
  65186. * @param scene The scene the renderer belongs to
  65187. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65188. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65189. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65190. */
  65191. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65192. /**
  65193. * Creates the depth rendering effect and checks if the effect is ready.
  65194. * @param subMesh The submesh to be used to render the depth map of
  65195. * @param useInstances If multiple world instances should be used
  65196. * @returns if the depth renderer is ready to render the depth map
  65197. */
  65198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65199. /**
  65200. * Gets the texture which the depth map will be written to.
  65201. * @returns The depth map texture
  65202. */
  65203. getDepthMap(): RenderTargetTexture;
  65204. /**
  65205. * Disposes of the depth renderer.
  65206. */
  65207. dispose(): void;
  65208. }
  65209. }
  65210. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65211. import { Nullable } from "babylonjs/types";
  65212. import { Scene } from "babylonjs/scene";
  65213. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65214. import { Camera } from "babylonjs/Cameras/camera";
  65215. import { ISceneComponent } from "babylonjs/sceneComponent";
  65216. module "babylonjs/scene" {
  65217. interface Scene {
  65218. /** @hidden (Backing field) */
  65219. _depthRenderer: {
  65220. [id: string]: DepthRenderer;
  65221. };
  65222. /**
  65223. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65224. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65225. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65226. * @returns the created depth renderer
  65227. */
  65228. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65229. /**
  65230. * Disables a depth renderer for a given camera
  65231. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65232. */
  65233. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65234. }
  65235. }
  65236. /**
  65237. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65238. * in several rendering techniques.
  65239. */
  65240. export class DepthRendererSceneComponent implements ISceneComponent {
  65241. /**
  65242. * The component name helpfull to identify the component in the list of scene components.
  65243. */
  65244. readonly name: string;
  65245. /**
  65246. * The scene the component belongs to.
  65247. */
  65248. scene: Scene;
  65249. /**
  65250. * Creates a new instance of the component for the given scene
  65251. * @param scene Defines the scene to register the component in
  65252. */
  65253. constructor(scene: Scene);
  65254. /**
  65255. * Registers the component in a given scene
  65256. */
  65257. register(): void;
  65258. /**
  65259. * Rebuilds the elements related to this component in case of
  65260. * context lost for instance.
  65261. */
  65262. rebuild(): void;
  65263. /**
  65264. * Disposes the component and the associated ressources
  65265. */
  65266. dispose(): void;
  65267. private _gatherRenderTargets;
  65268. private _gatherActiveCameraRenderTargets;
  65269. }
  65270. }
  65271. declare module "babylonjs/Shaders/outline.fragment" {
  65272. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65273. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65274. /** @hidden */
  65275. export var outlinePixelShader: {
  65276. name: string;
  65277. shader: string;
  65278. };
  65279. }
  65280. declare module "babylonjs/Shaders/outline.vertex" {
  65281. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65283. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65284. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65285. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65287. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65288. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65289. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65290. /** @hidden */
  65291. export var outlineVertexShader: {
  65292. name: string;
  65293. shader: string;
  65294. };
  65295. }
  65296. declare module "babylonjs/Rendering/outlineRenderer" {
  65297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65298. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65299. import { Scene } from "babylonjs/scene";
  65300. import { ISceneComponent } from "babylonjs/sceneComponent";
  65301. import "babylonjs/Shaders/outline.fragment";
  65302. import "babylonjs/Shaders/outline.vertex";
  65303. module "babylonjs/scene" {
  65304. interface Scene {
  65305. /** @hidden */
  65306. _outlineRenderer: OutlineRenderer;
  65307. /**
  65308. * Gets the outline renderer associated with the scene
  65309. * @returns a OutlineRenderer
  65310. */
  65311. getOutlineRenderer(): OutlineRenderer;
  65312. }
  65313. }
  65314. module "babylonjs/Meshes/abstractMesh" {
  65315. interface AbstractMesh {
  65316. /** @hidden (Backing field) */
  65317. _renderOutline: boolean;
  65318. /**
  65319. * Gets or sets a boolean indicating if the outline must be rendered as well
  65320. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65321. */
  65322. renderOutline: boolean;
  65323. /** @hidden (Backing field) */
  65324. _renderOverlay: boolean;
  65325. /**
  65326. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65327. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65328. */
  65329. renderOverlay: boolean;
  65330. }
  65331. }
  65332. /**
  65333. * This class is responsible to draw bothe outline/overlay of meshes.
  65334. * It should not be used directly but through the available method on mesh.
  65335. */
  65336. export class OutlineRenderer implements ISceneComponent {
  65337. /**
  65338. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65339. */
  65340. private static _StencilReference;
  65341. /**
  65342. * The name of the component. Each component must have a unique name.
  65343. */
  65344. name: string;
  65345. /**
  65346. * The scene the component belongs to.
  65347. */
  65348. scene: Scene;
  65349. /**
  65350. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65351. */
  65352. zOffset: number;
  65353. private _engine;
  65354. private _effect;
  65355. private _cachedDefines;
  65356. private _savedDepthWrite;
  65357. /**
  65358. * Instantiates a new outline renderer. (There could be only one per scene).
  65359. * @param scene Defines the scene it belongs to
  65360. */
  65361. constructor(scene: Scene);
  65362. /**
  65363. * Register the component to one instance of a scene.
  65364. */
  65365. register(): void;
  65366. /**
  65367. * Rebuilds the elements related to this component in case of
  65368. * context lost for instance.
  65369. */
  65370. rebuild(): void;
  65371. /**
  65372. * Disposes the component and the associated ressources.
  65373. */
  65374. dispose(): void;
  65375. /**
  65376. * Renders the outline in the canvas.
  65377. * @param subMesh Defines the sumesh to render
  65378. * @param batch Defines the batch of meshes in case of instances
  65379. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65380. */
  65381. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65382. /**
  65383. * Returns whether or not the outline renderer is ready for a given submesh.
  65384. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65385. * @param subMesh Defines the submesh to check readyness for
  65386. * @param useInstances Defines wheter wee are trying to render instances or not
  65387. * @returns true if ready otherwise false
  65388. */
  65389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65390. private _beforeRenderingMesh;
  65391. private _afterRenderingMesh;
  65392. }
  65393. }
  65394. declare module "babylonjs/Rendering/index" {
  65395. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65396. export * from "babylonjs/Rendering/depthRenderer";
  65397. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65398. export * from "babylonjs/Rendering/edgesRenderer";
  65399. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65400. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65401. export * from "babylonjs/Rendering/outlineRenderer";
  65402. export * from "babylonjs/Rendering/renderingGroup";
  65403. export * from "babylonjs/Rendering/renderingManager";
  65404. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65405. }
  65406. declare module "babylonjs/Sprites/spritePackedManager" {
  65407. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65408. import { Scene } from "babylonjs/scene";
  65409. /**
  65410. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65411. * @see http://doc.babylonjs.com/babylon101/sprites
  65412. */
  65413. export class SpritePackedManager extends SpriteManager {
  65414. /** defines the packed manager's name */
  65415. name: string;
  65416. /**
  65417. * Creates a new sprite manager from a packed sprite sheet
  65418. * @param name defines the manager's name
  65419. * @param imgUrl defines the sprite sheet url
  65420. * @param capacity defines the maximum allowed number of sprites
  65421. * @param scene defines the hosting scene
  65422. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65423. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65424. * @param samplingMode defines the smapling mode to use with spritesheet
  65425. * @param fromPacked set to true; do not alter
  65426. */
  65427. constructor(
  65428. /** defines the packed manager's name */
  65429. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65430. }
  65431. }
  65432. declare module "babylonjs/Sprites/index" {
  65433. export * from "babylonjs/Sprites/sprite";
  65434. export * from "babylonjs/Sprites/spriteManager";
  65435. export * from "babylonjs/Sprites/spritePackedManager";
  65436. export * from "babylonjs/Sprites/spriteSceneComponent";
  65437. }
  65438. declare module "babylonjs/States/index" {
  65439. export * from "babylonjs/States/alphaCullingState";
  65440. export * from "babylonjs/States/depthCullingState";
  65441. export * from "babylonjs/States/stencilState";
  65442. }
  65443. declare module "babylonjs/Misc/assetsManager" {
  65444. import { Scene } from "babylonjs/scene";
  65445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65446. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65447. import { Skeleton } from "babylonjs/Bones/skeleton";
  65448. import { Observable } from "babylonjs/Misc/observable";
  65449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65450. import { Texture } from "babylonjs/Materials/Textures/texture";
  65451. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65452. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65453. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65454. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65455. /**
  65456. * Defines the list of states available for a task inside a AssetsManager
  65457. */
  65458. export enum AssetTaskState {
  65459. /**
  65460. * Initialization
  65461. */
  65462. INIT = 0,
  65463. /**
  65464. * Running
  65465. */
  65466. RUNNING = 1,
  65467. /**
  65468. * Done
  65469. */
  65470. DONE = 2,
  65471. /**
  65472. * Error
  65473. */
  65474. ERROR = 3
  65475. }
  65476. /**
  65477. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65478. */
  65479. export abstract class AbstractAssetTask {
  65480. /**
  65481. * Task name
  65482. */ name: string;
  65483. /**
  65484. * Callback called when the task is successful
  65485. */
  65486. onSuccess: (task: any) => void;
  65487. /**
  65488. * Callback called when the task is not successful
  65489. */
  65490. onError: (task: any, message?: string, exception?: any) => void;
  65491. /**
  65492. * Creates a new AssetsManager
  65493. * @param name defines the name of the task
  65494. */
  65495. constructor(
  65496. /**
  65497. * Task name
  65498. */ name: string);
  65499. private _isCompleted;
  65500. private _taskState;
  65501. private _errorObject;
  65502. /**
  65503. * Get if the task is completed
  65504. */
  65505. readonly isCompleted: boolean;
  65506. /**
  65507. * Gets the current state of the task
  65508. */
  65509. readonly taskState: AssetTaskState;
  65510. /**
  65511. * Gets the current error object (if task is in error)
  65512. */
  65513. readonly errorObject: {
  65514. message?: string;
  65515. exception?: any;
  65516. };
  65517. /**
  65518. * Internal only
  65519. * @hidden
  65520. */
  65521. _setErrorObject(message?: string, exception?: any): void;
  65522. /**
  65523. * Execute the current task
  65524. * @param scene defines the scene where you want your assets to be loaded
  65525. * @param onSuccess is a callback called when the task is successfully executed
  65526. * @param onError is a callback called if an error occurs
  65527. */
  65528. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65529. /**
  65530. * Execute the current task
  65531. * @param scene defines the scene where you want your assets to be loaded
  65532. * @param onSuccess is a callback called when the task is successfully executed
  65533. * @param onError is a callback called if an error occurs
  65534. */
  65535. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65536. /**
  65537. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65538. * This can be used with failed tasks that have the reason for failure fixed.
  65539. */
  65540. reset(): void;
  65541. private onErrorCallback;
  65542. private onDoneCallback;
  65543. }
  65544. /**
  65545. * Define the interface used by progress events raised during assets loading
  65546. */
  65547. export interface IAssetsProgressEvent {
  65548. /**
  65549. * Defines the number of remaining tasks to process
  65550. */
  65551. remainingCount: number;
  65552. /**
  65553. * Defines the total number of tasks
  65554. */
  65555. totalCount: number;
  65556. /**
  65557. * Defines the task that was just processed
  65558. */
  65559. task: AbstractAssetTask;
  65560. }
  65561. /**
  65562. * Class used to share progress information about assets loading
  65563. */
  65564. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65565. /**
  65566. * Defines the number of remaining tasks to process
  65567. */
  65568. remainingCount: number;
  65569. /**
  65570. * Defines the total number of tasks
  65571. */
  65572. totalCount: number;
  65573. /**
  65574. * Defines the task that was just processed
  65575. */
  65576. task: AbstractAssetTask;
  65577. /**
  65578. * Creates a AssetsProgressEvent
  65579. * @param remainingCount defines the number of remaining tasks to process
  65580. * @param totalCount defines the total number of tasks
  65581. * @param task defines the task that was just processed
  65582. */
  65583. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65584. }
  65585. /**
  65586. * Define a task used by AssetsManager to load meshes
  65587. */
  65588. export class MeshAssetTask extends AbstractAssetTask {
  65589. /**
  65590. * Defines the name of the task
  65591. */
  65592. name: string;
  65593. /**
  65594. * Defines the list of mesh's names you want to load
  65595. */
  65596. meshesNames: any;
  65597. /**
  65598. * Defines the root url to use as a base to load your meshes and associated resources
  65599. */
  65600. rootUrl: string;
  65601. /**
  65602. * Defines the filename of the scene to load from
  65603. */
  65604. sceneFilename: string;
  65605. /**
  65606. * Gets the list of loaded meshes
  65607. */
  65608. loadedMeshes: Array<AbstractMesh>;
  65609. /**
  65610. * Gets the list of loaded particle systems
  65611. */
  65612. loadedParticleSystems: Array<IParticleSystem>;
  65613. /**
  65614. * Gets the list of loaded skeletons
  65615. */
  65616. loadedSkeletons: Array<Skeleton>;
  65617. /**
  65618. * Gets the list of loaded animation groups
  65619. */
  65620. loadedAnimationGroups: Array<AnimationGroup>;
  65621. /**
  65622. * Callback called when the task is successful
  65623. */
  65624. onSuccess: (task: MeshAssetTask) => void;
  65625. /**
  65626. * Callback called when the task is successful
  65627. */
  65628. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65629. /**
  65630. * Creates a new MeshAssetTask
  65631. * @param name defines the name of the task
  65632. * @param meshesNames defines the list of mesh's names you want to load
  65633. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65634. * @param sceneFilename defines the filename of the scene to load from
  65635. */
  65636. constructor(
  65637. /**
  65638. * Defines the name of the task
  65639. */
  65640. name: string,
  65641. /**
  65642. * Defines the list of mesh's names you want to load
  65643. */
  65644. meshesNames: any,
  65645. /**
  65646. * Defines the root url to use as a base to load your meshes and associated resources
  65647. */
  65648. rootUrl: string,
  65649. /**
  65650. * Defines the filename of the scene to load from
  65651. */
  65652. sceneFilename: string);
  65653. /**
  65654. * Execute the current task
  65655. * @param scene defines the scene where you want your assets to be loaded
  65656. * @param onSuccess is a callback called when the task is successfully executed
  65657. * @param onError is a callback called if an error occurs
  65658. */
  65659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65660. }
  65661. /**
  65662. * Define a task used by AssetsManager to load text content
  65663. */
  65664. export class TextFileAssetTask extends AbstractAssetTask {
  65665. /**
  65666. * Defines the name of the task
  65667. */
  65668. name: string;
  65669. /**
  65670. * Defines the location of the file to load
  65671. */
  65672. url: string;
  65673. /**
  65674. * Gets the loaded text string
  65675. */
  65676. text: string;
  65677. /**
  65678. * Callback called when the task is successful
  65679. */
  65680. onSuccess: (task: TextFileAssetTask) => void;
  65681. /**
  65682. * Callback called when the task is successful
  65683. */
  65684. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65685. /**
  65686. * Creates a new TextFileAssetTask object
  65687. * @param name defines the name of the task
  65688. * @param url defines the location of the file to load
  65689. */
  65690. constructor(
  65691. /**
  65692. * Defines the name of the task
  65693. */
  65694. name: string,
  65695. /**
  65696. * Defines the location of the file to load
  65697. */
  65698. url: string);
  65699. /**
  65700. * Execute the current task
  65701. * @param scene defines the scene where you want your assets to be loaded
  65702. * @param onSuccess is a callback called when the task is successfully executed
  65703. * @param onError is a callback called if an error occurs
  65704. */
  65705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65706. }
  65707. /**
  65708. * Define a task used by AssetsManager to load binary data
  65709. */
  65710. export class BinaryFileAssetTask extends AbstractAssetTask {
  65711. /**
  65712. * Defines the name of the task
  65713. */
  65714. name: string;
  65715. /**
  65716. * Defines the location of the file to load
  65717. */
  65718. url: string;
  65719. /**
  65720. * Gets the lodaded data (as an array buffer)
  65721. */
  65722. data: ArrayBuffer;
  65723. /**
  65724. * Callback called when the task is successful
  65725. */
  65726. onSuccess: (task: BinaryFileAssetTask) => void;
  65727. /**
  65728. * Callback called when the task is successful
  65729. */
  65730. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65731. /**
  65732. * Creates a new BinaryFileAssetTask object
  65733. * @param name defines the name of the new task
  65734. * @param url defines the location of the file to load
  65735. */
  65736. constructor(
  65737. /**
  65738. * Defines the name of the task
  65739. */
  65740. name: string,
  65741. /**
  65742. * Defines the location of the file to load
  65743. */
  65744. url: string);
  65745. /**
  65746. * Execute the current task
  65747. * @param scene defines the scene where you want your assets to be loaded
  65748. * @param onSuccess is a callback called when the task is successfully executed
  65749. * @param onError is a callback called if an error occurs
  65750. */
  65751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65752. }
  65753. /**
  65754. * Define a task used by AssetsManager to load images
  65755. */
  65756. export class ImageAssetTask extends AbstractAssetTask {
  65757. /**
  65758. * Defines the name of the task
  65759. */
  65760. name: string;
  65761. /**
  65762. * Defines the location of the image to load
  65763. */
  65764. url: string;
  65765. /**
  65766. * Gets the loaded images
  65767. */
  65768. image: HTMLImageElement;
  65769. /**
  65770. * Callback called when the task is successful
  65771. */
  65772. onSuccess: (task: ImageAssetTask) => void;
  65773. /**
  65774. * Callback called when the task is successful
  65775. */
  65776. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65777. /**
  65778. * Creates a new ImageAssetTask
  65779. * @param name defines the name of the task
  65780. * @param url defines the location of the image to load
  65781. */
  65782. constructor(
  65783. /**
  65784. * Defines the name of the task
  65785. */
  65786. name: string,
  65787. /**
  65788. * Defines the location of the image to load
  65789. */
  65790. url: string);
  65791. /**
  65792. * Execute the current task
  65793. * @param scene defines the scene where you want your assets to be loaded
  65794. * @param onSuccess is a callback called when the task is successfully executed
  65795. * @param onError is a callback called if an error occurs
  65796. */
  65797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65798. }
  65799. /**
  65800. * Defines the interface used by texture loading tasks
  65801. */
  65802. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65803. /**
  65804. * Gets the loaded texture
  65805. */
  65806. texture: TEX;
  65807. }
  65808. /**
  65809. * Define a task used by AssetsManager to load 2D textures
  65810. */
  65811. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65812. /**
  65813. * Defines the name of the task
  65814. */
  65815. name: string;
  65816. /**
  65817. * Defines the location of the file to load
  65818. */
  65819. url: string;
  65820. /**
  65821. * Defines if mipmap should not be generated (default is false)
  65822. */
  65823. noMipmap?: boolean | undefined;
  65824. /**
  65825. * Defines if texture must be inverted on Y axis (default is false)
  65826. */
  65827. invertY?: boolean | undefined;
  65828. /**
  65829. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65830. */
  65831. samplingMode: number;
  65832. /**
  65833. * Gets the loaded texture
  65834. */
  65835. texture: Texture;
  65836. /**
  65837. * Callback called when the task is successful
  65838. */
  65839. onSuccess: (task: TextureAssetTask) => void;
  65840. /**
  65841. * Callback called when the task is successful
  65842. */
  65843. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65844. /**
  65845. * Creates a new TextureAssetTask object
  65846. * @param name defines the name of the task
  65847. * @param url defines the location of the file to load
  65848. * @param noMipmap defines if mipmap should not be generated (default is false)
  65849. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65850. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65851. */
  65852. constructor(
  65853. /**
  65854. * Defines the name of the task
  65855. */
  65856. name: string,
  65857. /**
  65858. * Defines the location of the file to load
  65859. */
  65860. url: string,
  65861. /**
  65862. * Defines if mipmap should not be generated (default is false)
  65863. */
  65864. noMipmap?: boolean | undefined,
  65865. /**
  65866. * Defines if texture must be inverted on Y axis (default is false)
  65867. */
  65868. invertY?: boolean | undefined,
  65869. /**
  65870. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65871. */
  65872. samplingMode?: number);
  65873. /**
  65874. * Execute the current task
  65875. * @param scene defines the scene where you want your assets to be loaded
  65876. * @param onSuccess is a callback called when the task is successfully executed
  65877. * @param onError is a callback called if an error occurs
  65878. */
  65879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65880. }
  65881. /**
  65882. * Define a task used by AssetsManager to load cube textures
  65883. */
  65884. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65885. /**
  65886. * Defines the name of the task
  65887. */
  65888. name: string;
  65889. /**
  65890. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65891. */
  65892. url: string;
  65893. /**
  65894. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65895. */
  65896. extensions?: string[] | undefined;
  65897. /**
  65898. * Defines if mipmaps should not be generated (default is false)
  65899. */
  65900. noMipmap?: boolean | undefined;
  65901. /**
  65902. * Defines the explicit list of files (undefined by default)
  65903. */
  65904. files?: string[] | undefined;
  65905. /**
  65906. * Gets the loaded texture
  65907. */
  65908. texture: CubeTexture;
  65909. /**
  65910. * Callback called when the task is successful
  65911. */
  65912. onSuccess: (task: CubeTextureAssetTask) => void;
  65913. /**
  65914. * Callback called when the task is successful
  65915. */
  65916. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65917. /**
  65918. * Creates a new CubeTextureAssetTask
  65919. * @param name defines the name of the task
  65920. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65921. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65922. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65923. * @param files defines the explicit list of files (undefined by default)
  65924. */
  65925. constructor(
  65926. /**
  65927. * Defines the name of the task
  65928. */
  65929. name: string,
  65930. /**
  65931. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65932. */
  65933. url: string,
  65934. /**
  65935. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65936. */
  65937. extensions?: string[] | undefined,
  65938. /**
  65939. * Defines if mipmaps should not be generated (default is false)
  65940. */
  65941. noMipmap?: boolean | undefined,
  65942. /**
  65943. * Defines the explicit list of files (undefined by default)
  65944. */
  65945. files?: string[] | undefined);
  65946. /**
  65947. * Execute the current task
  65948. * @param scene defines the scene where you want your assets to be loaded
  65949. * @param onSuccess is a callback called when the task is successfully executed
  65950. * @param onError is a callback called if an error occurs
  65951. */
  65952. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65953. }
  65954. /**
  65955. * Define a task used by AssetsManager to load HDR cube textures
  65956. */
  65957. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65958. /**
  65959. * Defines the name of the task
  65960. */
  65961. name: string;
  65962. /**
  65963. * Defines the location of the file to load
  65964. */
  65965. url: string;
  65966. /**
  65967. * Defines the desired size (the more it increases the longer the generation will be)
  65968. */
  65969. size: number;
  65970. /**
  65971. * Defines if mipmaps should not be generated (default is false)
  65972. */
  65973. noMipmap: boolean;
  65974. /**
  65975. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65976. */
  65977. generateHarmonics: boolean;
  65978. /**
  65979. * 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)
  65980. */
  65981. gammaSpace: boolean;
  65982. /**
  65983. * Internal Use Only
  65984. */
  65985. reserved: boolean;
  65986. /**
  65987. * Gets the loaded texture
  65988. */
  65989. texture: HDRCubeTexture;
  65990. /**
  65991. * Callback called when the task is successful
  65992. */
  65993. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65994. /**
  65995. * Callback called when the task is successful
  65996. */
  65997. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65998. /**
  65999. * Creates a new HDRCubeTextureAssetTask object
  66000. * @param name defines the name of the task
  66001. * @param url defines the location of the file to load
  66002. * @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.
  66003. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66004. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66005. * @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)
  66006. * @param reserved Internal use only
  66007. */
  66008. constructor(
  66009. /**
  66010. * Defines the name of the task
  66011. */
  66012. name: string,
  66013. /**
  66014. * Defines the location of the file to load
  66015. */
  66016. url: string,
  66017. /**
  66018. * Defines the desired size (the more it increases the longer the generation will be)
  66019. */
  66020. size: number,
  66021. /**
  66022. * Defines if mipmaps should not be generated (default is false)
  66023. */
  66024. noMipmap?: boolean,
  66025. /**
  66026. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66027. */
  66028. generateHarmonics?: boolean,
  66029. /**
  66030. * 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)
  66031. */
  66032. gammaSpace?: boolean,
  66033. /**
  66034. * Internal Use Only
  66035. */
  66036. reserved?: boolean);
  66037. /**
  66038. * Execute the current task
  66039. * @param scene defines the scene where you want your assets to be loaded
  66040. * @param onSuccess is a callback called when the task is successfully executed
  66041. * @param onError is a callback called if an error occurs
  66042. */
  66043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66044. }
  66045. /**
  66046. * Define a task used by AssetsManager to load Equirectangular cube textures
  66047. */
  66048. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66049. /**
  66050. * Defines the name of the task
  66051. */
  66052. name: string;
  66053. /**
  66054. * Defines the location of the file to load
  66055. */
  66056. url: string;
  66057. /**
  66058. * Defines the desired size (the more it increases the longer the generation will be)
  66059. */
  66060. size: number;
  66061. /**
  66062. * Defines if mipmaps should not be generated (default is false)
  66063. */
  66064. noMipmap: boolean;
  66065. /**
  66066. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66067. * but the standard material would require them in Gamma space) (default is true)
  66068. */
  66069. gammaSpace: boolean;
  66070. /**
  66071. * Gets the loaded texture
  66072. */
  66073. texture: EquiRectangularCubeTexture;
  66074. /**
  66075. * Callback called when the task is successful
  66076. */
  66077. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66078. /**
  66079. * Callback called when the task is successful
  66080. */
  66081. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66082. /**
  66083. * Creates a new EquiRectangularCubeTextureAssetTask object
  66084. * @param name defines the name of the task
  66085. * @param url defines the location of the file to load
  66086. * @param size defines the desired size (the more it increases the longer the generation will be)
  66087. * If the size is omitted this implies you are using a preprocessed cubemap.
  66088. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66089. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66090. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66091. * (default is true)
  66092. */
  66093. constructor(
  66094. /**
  66095. * Defines the name of the task
  66096. */
  66097. name: string,
  66098. /**
  66099. * Defines the location of the file to load
  66100. */
  66101. url: string,
  66102. /**
  66103. * Defines the desired size (the more it increases the longer the generation will be)
  66104. */
  66105. size: number,
  66106. /**
  66107. * Defines if mipmaps should not be generated (default is false)
  66108. */
  66109. noMipmap?: boolean,
  66110. /**
  66111. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66112. * but the standard material would require them in Gamma space) (default is true)
  66113. */
  66114. gammaSpace?: boolean);
  66115. /**
  66116. * Execute the current task
  66117. * @param scene defines the scene where you want your assets to be loaded
  66118. * @param onSuccess is a callback called when the task is successfully executed
  66119. * @param onError is a callback called if an error occurs
  66120. */
  66121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66122. }
  66123. /**
  66124. * This class can be used to easily import assets into a scene
  66125. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66126. */
  66127. export class AssetsManager {
  66128. private _scene;
  66129. private _isLoading;
  66130. protected _tasks: AbstractAssetTask[];
  66131. protected _waitingTasksCount: number;
  66132. protected _totalTasksCount: number;
  66133. /**
  66134. * Callback called when all tasks are processed
  66135. */
  66136. onFinish: (tasks: AbstractAssetTask[]) => void;
  66137. /**
  66138. * Callback called when a task is successful
  66139. */
  66140. onTaskSuccess: (task: AbstractAssetTask) => void;
  66141. /**
  66142. * Callback called when a task had an error
  66143. */
  66144. onTaskError: (task: AbstractAssetTask) => void;
  66145. /**
  66146. * Callback called when a task is done (whatever the result is)
  66147. */
  66148. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66149. /**
  66150. * Observable called when all tasks are processed
  66151. */
  66152. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66153. /**
  66154. * Observable called when a task had an error
  66155. */
  66156. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66157. /**
  66158. * Observable called when all tasks were executed
  66159. */
  66160. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66161. /**
  66162. * Observable called when a task is done (whatever the result is)
  66163. */
  66164. onProgressObservable: Observable<IAssetsProgressEvent>;
  66165. /**
  66166. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66168. */
  66169. useDefaultLoadingScreen: boolean;
  66170. /**
  66171. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66172. * when all assets have been downloaded.
  66173. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66174. */
  66175. autoHideLoadingUI: boolean;
  66176. /**
  66177. * Creates a new AssetsManager
  66178. * @param scene defines the scene to work on
  66179. */
  66180. constructor(scene: Scene);
  66181. /**
  66182. * Add a MeshAssetTask to the list of active tasks
  66183. * @param taskName defines the name of the new task
  66184. * @param meshesNames defines the name of meshes to load
  66185. * @param rootUrl defines the root url to use to locate files
  66186. * @param sceneFilename defines the filename of the scene file
  66187. * @returns a new MeshAssetTask object
  66188. */
  66189. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66190. /**
  66191. * Add a TextFileAssetTask to the list of active tasks
  66192. * @param taskName defines the name of the new task
  66193. * @param url defines the url of the file to load
  66194. * @returns a new TextFileAssetTask object
  66195. */
  66196. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66197. /**
  66198. * Add a BinaryFileAssetTask to the list of active tasks
  66199. * @param taskName defines the name of the new task
  66200. * @param url defines the url of the file to load
  66201. * @returns a new BinaryFileAssetTask object
  66202. */
  66203. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66204. /**
  66205. * Add a ImageAssetTask to the list of active tasks
  66206. * @param taskName defines the name of the new task
  66207. * @param url defines the url of the file to load
  66208. * @returns a new ImageAssetTask object
  66209. */
  66210. addImageTask(taskName: string, url: string): ImageAssetTask;
  66211. /**
  66212. * Add a TextureAssetTask to the list of active tasks
  66213. * @param taskName defines the name of the new task
  66214. * @param url defines the url of the file to load
  66215. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66216. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66217. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66218. * @returns a new TextureAssetTask object
  66219. */
  66220. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66221. /**
  66222. * Add a CubeTextureAssetTask to the list of active tasks
  66223. * @param taskName defines the name of the new task
  66224. * @param url defines the url of the file to load
  66225. * @param extensions defines the extension to use to load the cube map (can be null)
  66226. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66227. * @param files defines the list of files to load (can be null)
  66228. * @returns a new CubeTextureAssetTask object
  66229. */
  66230. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66231. /**
  66232. *
  66233. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66234. * @param taskName defines the name of the new task
  66235. * @param url defines the url of the file to load
  66236. * @param size defines the size you want for the cubemap (can be null)
  66237. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66238. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66239. * @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)
  66240. * @param reserved Internal use only
  66241. * @returns a new HDRCubeTextureAssetTask object
  66242. */
  66243. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66244. /**
  66245. *
  66246. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66247. * @param taskName defines the name of the new task
  66248. * @param url defines the url of the file to load
  66249. * @param size defines the size you want for the cubemap (can be null)
  66250. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66251. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66252. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66253. * @returns a new EquiRectangularCubeTextureAssetTask object
  66254. */
  66255. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66256. /**
  66257. * Remove a task from the assets manager.
  66258. * @param task the task to remove
  66259. */
  66260. removeTask(task: AbstractAssetTask): void;
  66261. private _decreaseWaitingTasksCount;
  66262. private _runTask;
  66263. /**
  66264. * Reset the AssetsManager and remove all tasks
  66265. * @return the current instance of the AssetsManager
  66266. */
  66267. reset(): AssetsManager;
  66268. /**
  66269. * Start the loading process
  66270. * @return the current instance of the AssetsManager
  66271. */
  66272. load(): AssetsManager;
  66273. /**
  66274. * Start the loading process as an async operation
  66275. * @return a promise returning the list of failed tasks
  66276. */
  66277. loadAsync(): Promise<void>;
  66278. }
  66279. }
  66280. declare module "babylonjs/Misc/deferred" {
  66281. /**
  66282. * Wrapper class for promise with external resolve and reject.
  66283. */
  66284. export class Deferred<T> {
  66285. /**
  66286. * The promise associated with this deferred object.
  66287. */
  66288. readonly promise: Promise<T>;
  66289. private _resolve;
  66290. private _reject;
  66291. /**
  66292. * The resolve method of the promise associated with this deferred object.
  66293. */
  66294. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66295. /**
  66296. * The reject method of the promise associated with this deferred object.
  66297. */
  66298. readonly reject: (reason?: any) => void;
  66299. /**
  66300. * Constructor for this deferred object.
  66301. */
  66302. constructor();
  66303. }
  66304. }
  66305. declare module "babylonjs/Misc/meshExploder" {
  66306. import { Mesh } from "babylonjs/Meshes/mesh";
  66307. /**
  66308. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66309. */
  66310. export class MeshExploder {
  66311. private _centerMesh;
  66312. private _meshes;
  66313. private _meshesOrigins;
  66314. private _toCenterVectors;
  66315. private _scaledDirection;
  66316. private _newPosition;
  66317. private _centerPosition;
  66318. /**
  66319. * Explodes meshes from a center mesh.
  66320. * @param meshes The meshes to explode.
  66321. * @param centerMesh The mesh to be center of explosion.
  66322. */
  66323. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66324. private _setCenterMesh;
  66325. /**
  66326. * Get class name
  66327. * @returns "MeshExploder"
  66328. */
  66329. getClassName(): string;
  66330. /**
  66331. * "Exploded meshes"
  66332. * @returns Array of meshes with the centerMesh at index 0.
  66333. */
  66334. getMeshes(): Array<Mesh>;
  66335. /**
  66336. * Explodes meshes giving a specific direction
  66337. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66338. */
  66339. explode(direction?: number): void;
  66340. }
  66341. }
  66342. declare module "babylonjs/Misc/filesInput" {
  66343. import { Engine } from "babylonjs/Engines/engine";
  66344. import { Scene } from "babylonjs/scene";
  66345. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66346. /**
  66347. * Class used to help managing file picking and drag'n'drop
  66348. */
  66349. export class FilesInput {
  66350. /**
  66351. * List of files ready to be loaded
  66352. */
  66353. static readonly FilesToLoad: {
  66354. [key: string]: File;
  66355. };
  66356. /**
  66357. * Callback called when a file is processed
  66358. */
  66359. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66360. private _engine;
  66361. private _currentScene;
  66362. private _sceneLoadedCallback;
  66363. private _progressCallback;
  66364. private _additionalRenderLoopLogicCallback;
  66365. private _textureLoadingCallback;
  66366. private _startingProcessingFilesCallback;
  66367. private _onReloadCallback;
  66368. private _errorCallback;
  66369. private _elementToMonitor;
  66370. private _sceneFileToLoad;
  66371. private _filesToLoad;
  66372. /**
  66373. * Creates a new FilesInput
  66374. * @param engine defines the rendering engine
  66375. * @param scene defines the hosting scene
  66376. * @param sceneLoadedCallback callback called when scene is loaded
  66377. * @param progressCallback callback called to track progress
  66378. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66379. * @param textureLoadingCallback callback called when a texture is loading
  66380. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66381. * @param onReloadCallback callback called when a reload is requested
  66382. * @param errorCallback callback call if an error occurs
  66383. */
  66384. 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);
  66385. private _dragEnterHandler;
  66386. private _dragOverHandler;
  66387. private _dropHandler;
  66388. /**
  66389. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66390. * @param elementToMonitor defines the DOM element to track
  66391. */
  66392. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66393. /**
  66394. * Release all associated resources
  66395. */
  66396. dispose(): void;
  66397. private renderFunction;
  66398. private drag;
  66399. private drop;
  66400. private _traverseFolder;
  66401. private _processFiles;
  66402. /**
  66403. * Load files from a drop event
  66404. * @param event defines the drop event to use as source
  66405. */
  66406. loadFiles(event: any): void;
  66407. private _processReload;
  66408. /**
  66409. * Reload the current scene from the loaded files
  66410. */
  66411. reload(): void;
  66412. }
  66413. }
  66414. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66415. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66416. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66417. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66418. }
  66419. declare module "babylonjs/Misc/sceneOptimizer" {
  66420. import { Scene, IDisposable } from "babylonjs/scene";
  66421. import { Observable } from "babylonjs/Misc/observable";
  66422. /**
  66423. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66424. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66425. */
  66426. export class SceneOptimization {
  66427. /**
  66428. * Defines the priority of this optimization (0 by default which means first in the list)
  66429. */
  66430. priority: number;
  66431. /**
  66432. * Gets a string describing the action executed by the current optimization
  66433. * @returns description string
  66434. */
  66435. getDescription(): string;
  66436. /**
  66437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66438. * @param scene defines the current scene where to apply this optimization
  66439. * @param optimizer defines the current optimizer
  66440. * @returns true if everything that can be done was applied
  66441. */
  66442. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66443. /**
  66444. * Creates the SceneOptimization object
  66445. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66446. * @param desc defines the description associated with the optimization
  66447. */
  66448. constructor(
  66449. /**
  66450. * Defines the priority of this optimization (0 by default which means first in the list)
  66451. */
  66452. priority?: number);
  66453. }
  66454. /**
  66455. * Defines an optimization used to reduce the size of render target textures
  66456. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66457. */
  66458. export class TextureOptimization extends SceneOptimization {
  66459. /**
  66460. * Defines the priority of this optimization (0 by default which means first in the list)
  66461. */
  66462. priority: number;
  66463. /**
  66464. * 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
  66465. */
  66466. maximumSize: number;
  66467. /**
  66468. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66469. */
  66470. step: number;
  66471. /**
  66472. * Gets a string describing the action executed by the current optimization
  66473. * @returns description string
  66474. */
  66475. getDescription(): string;
  66476. /**
  66477. * Creates the TextureOptimization object
  66478. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66479. * @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
  66480. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66481. */
  66482. constructor(
  66483. /**
  66484. * Defines the priority of this optimization (0 by default which means first in the list)
  66485. */
  66486. priority?: number,
  66487. /**
  66488. * 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
  66489. */
  66490. maximumSize?: number,
  66491. /**
  66492. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66493. */
  66494. step?: number);
  66495. /**
  66496. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66497. * @param scene defines the current scene where to apply this optimization
  66498. * @param optimizer defines the current optimizer
  66499. * @returns true if everything that can be done was applied
  66500. */
  66501. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66502. }
  66503. /**
  66504. * Defines an optimization used to increase or decrease the rendering resolution
  66505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66506. */
  66507. export class HardwareScalingOptimization extends SceneOptimization {
  66508. /**
  66509. * Defines the priority of this optimization (0 by default which means first in the list)
  66510. */
  66511. priority: number;
  66512. /**
  66513. * Defines the maximum scale to use (2 by default)
  66514. */
  66515. maximumScale: number;
  66516. /**
  66517. * Defines the step to use between two passes (0.5 by default)
  66518. */
  66519. step: number;
  66520. private _currentScale;
  66521. private _directionOffset;
  66522. /**
  66523. * Gets a string describing the action executed by the current optimization
  66524. * @return description string
  66525. */
  66526. getDescription(): string;
  66527. /**
  66528. * Creates the HardwareScalingOptimization object
  66529. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66530. * @param maximumScale defines the maximum scale to use (2 by default)
  66531. * @param step defines the step to use between two passes (0.5 by default)
  66532. */
  66533. constructor(
  66534. /**
  66535. * Defines the priority of this optimization (0 by default which means first in the list)
  66536. */
  66537. priority?: number,
  66538. /**
  66539. * Defines the maximum scale to use (2 by default)
  66540. */
  66541. maximumScale?: number,
  66542. /**
  66543. * Defines the step to use between two passes (0.5 by default)
  66544. */
  66545. step?: number);
  66546. /**
  66547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66548. * @param scene defines the current scene where to apply this optimization
  66549. * @param optimizer defines the current optimizer
  66550. * @returns true if everything that can be done was applied
  66551. */
  66552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66553. }
  66554. /**
  66555. * Defines an optimization used to remove shadows
  66556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66557. */
  66558. export class ShadowsOptimization extends SceneOptimization {
  66559. /**
  66560. * Gets a string describing the action executed by the current optimization
  66561. * @return description string
  66562. */
  66563. getDescription(): string;
  66564. /**
  66565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66566. * @param scene defines the current scene where to apply this optimization
  66567. * @param optimizer defines the current optimizer
  66568. * @returns true if everything that can be done was applied
  66569. */
  66570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66571. }
  66572. /**
  66573. * Defines an optimization used to turn post-processes off
  66574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66575. */
  66576. export class PostProcessesOptimization extends SceneOptimization {
  66577. /**
  66578. * Gets a string describing the action executed by the current optimization
  66579. * @return description string
  66580. */
  66581. getDescription(): string;
  66582. /**
  66583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66584. * @param scene defines the current scene where to apply this optimization
  66585. * @param optimizer defines the current optimizer
  66586. * @returns true if everything that can be done was applied
  66587. */
  66588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66589. }
  66590. /**
  66591. * Defines an optimization used to turn lens flares off
  66592. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66593. */
  66594. export class LensFlaresOptimization extends SceneOptimization {
  66595. /**
  66596. * Gets a string describing the action executed by the current optimization
  66597. * @return description string
  66598. */
  66599. getDescription(): string;
  66600. /**
  66601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66602. * @param scene defines the current scene where to apply this optimization
  66603. * @param optimizer defines the current optimizer
  66604. * @returns true if everything that can be done was applied
  66605. */
  66606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66607. }
  66608. /**
  66609. * Defines an optimization based on user defined callback.
  66610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66611. */
  66612. export class CustomOptimization extends SceneOptimization {
  66613. /**
  66614. * Callback called to apply the custom optimization.
  66615. */
  66616. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66617. /**
  66618. * Callback called to get custom description
  66619. */
  66620. onGetDescription: () => string;
  66621. /**
  66622. * Gets a string describing the action executed by the current optimization
  66623. * @returns description string
  66624. */
  66625. getDescription(): string;
  66626. /**
  66627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66628. * @param scene defines the current scene where to apply this optimization
  66629. * @param optimizer defines the current optimizer
  66630. * @returns true if everything that can be done was applied
  66631. */
  66632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66633. }
  66634. /**
  66635. * Defines an optimization used to turn particles off
  66636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66637. */
  66638. export class ParticlesOptimization extends SceneOptimization {
  66639. /**
  66640. * Gets a string describing the action executed by the current optimization
  66641. * @return description string
  66642. */
  66643. getDescription(): string;
  66644. /**
  66645. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66646. * @param scene defines the current scene where to apply this optimization
  66647. * @param optimizer defines the current optimizer
  66648. * @returns true if everything that can be done was applied
  66649. */
  66650. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66651. }
  66652. /**
  66653. * Defines an optimization used to turn render targets off
  66654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66655. */
  66656. export class RenderTargetsOptimization extends SceneOptimization {
  66657. /**
  66658. * Gets a string describing the action executed by the current optimization
  66659. * @return description string
  66660. */
  66661. getDescription(): string;
  66662. /**
  66663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66664. * @param scene defines the current scene where to apply this optimization
  66665. * @param optimizer defines the current optimizer
  66666. * @returns true if everything that can be done was applied
  66667. */
  66668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66669. }
  66670. /**
  66671. * Defines an optimization used to merge meshes with compatible materials
  66672. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66673. */
  66674. export class MergeMeshesOptimization extends SceneOptimization {
  66675. private static _UpdateSelectionTree;
  66676. /**
  66677. * Gets or sets a boolean which defines if optimization octree has to be updated
  66678. */
  66679. /**
  66680. * Gets or sets a boolean which defines if optimization octree has to be updated
  66681. */
  66682. static UpdateSelectionTree: boolean;
  66683. /**
  66684. * Gets a string describing the action executed by the current optimization
  66685. * @return description string
  66686. */
  66687. getDescription(): string;
  66688. private _canBeMerged;
  66689. /**
  66690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66691. * @param scene defines the current scene where to apply this optimization
  66692. * @param optimizer defines the current optimizer
  66693. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66694. * @returns true if everything that can be done was applied
  66695. */
  66696. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66697. }
  66698. /**
  66699. * Defines a list of options used by SceneOptimizer
  66700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66701. */
  66702. export class SceneOptimizerOptions {
  66703. /**
  66704. * Defines the target frame rate to reach (60 by default)
  66705. */
  66706. targetFrameRate: number;
  66707. /**
  66708. * Defines the interval between two checkes (2000ms by default)
  66709. */
  66710. trackerDuration: number;
  66711. /**
  66712. * Gets the list of optimizations to apply
  66713. */
  66714. optimizations: SceneOptimization[];
  66715. /**
  66716. * Creates a new list of options used by SceneOptimizer
  66717. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66718. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66719. */
  66720. constructor(
  66721. /**
  66722. * Defines the target frame rate to reach (60 by default)
  66723. */
  66724. targetFrameRate?: number,
  66725. /**
  66726. * Defines the interval between two checkes (2000ms by default)
  66727. */
  66728. trackerDuration?: number);
  66729. /**
  66730. * Add a new optimization
  66731. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66732. * @returns the current SceneOptimizerOptions
  66733. */
  66734. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66735. /**
  66736. * Add a new custom optimization
  66737. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66738. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66740. * @returns the current SceneOptimizerOptions
  66741. */
  66742. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66743. /**
  66744. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66745. * @param targetFrameRate defines the target frame rate (60 by default)
  66746. * @returns a SceneOptimizerOptions object
  66747. */
  66748. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66749. /**
  66750. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66751. * @param targetFrameRate defines the target frame rate (60 by default)
  66752. * @returns a SceneOptimizerOptions object
  66753. */
  66754. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66755. /**
  66756. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66757. * @param targetFrameRate defines the target frame rate (60 by default)
  66758. * @returns a SceneOptimizerOptions object
  66759. */
  66760. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66761. }
  66762. /**
  66763. * Class used to run optimizations in order to reach a target frame rate
  66764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66765. */
  66766. export class SceneOptimizer implements IDisposable {
  66767. private _isRunning;
  66768. private _options;
  66769. private _scene;
  66770. private _currentPriorityLevel;
  66771. private _targetFrameRate;
  66772. private _trackerDuration;
  66773. private _currentFrameRate;
  66774. private _sceneDisposeObserver;
  66775. private _improvementMode;
  66776. /**
  66777. * Defines an observable called when the optimizer reaches the target frame rate
  66778. */
  66779. onSuccessObservable: Observable<SceneOptimizer>;
  66780. /**
  66781. * Defines an observable called when the optimizer enables an optimization
  66782. */
  66783. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66784. /**
  66785. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66786. */
  66787. onFailureObservable: Observable<SceneOptimizer>;
  66788. /**
  66789. * Gets a boolean indicating if the optimizer is in improvement mode
  66790. */
  66791. readonly isInImprovementMode: boolean;
  66792. /**
  66793. * Gets the current priority level (0 at start)
  66794. */
  66795. readonly currentPriorityLevel: number;
  66796. /**
  66797. * Gets the current frame rate checked by the SceneOptimizer
  66798. */
  66799. readonly currentFrameRate: number;
  66800. /**
  66801. * Gets or sets the current target frame rate (60 by default)
  66802. */
  66803. /**
  66804. * Gets or sets the current target frame rate (60 by default)
  66805. */
  66806. targetFrameRate: number;
  66807. /**
  66808. * Gets or sets the current interval between two checks (every 2000ms by default)
  66809. */
  66810. /**
  66811. * Gets or sets the current interval between two checks (every 2000ms by default)
  66812. */
  66813. trackerDuration: number;
  66814. /**
  66815. * Gets the list of active optimizations
  66816. */
  66817. readonly optimizations: SceneOptimization[];
  66818. /**
  66819. * Creates a new SceneOptimizer
  66820. * @param scene defines the scene to work on
  66821. * @param options defines the options to use with the SceneOptimizer
  66822. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66823. * @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)
  66824. */
  66825. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66826. /**
  66827. * Stops the current optimizer
  66828. */
  66829. stop(): void;
  66830. /**
  66831. * Reset the optimizer to initial step (current priority level = 0)
  66832. */
  66833. reset(): void;
  66834. /**
  66835. * Start the optimizer. By default it will try to reach a specific framerate
  66836. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66837. */
  66838. start(): void;
  66839. private _checkCurrentState;
  66840. /**
  66841. * Release all resources
  66842. */
  66843. dispose(): void;
  66844. /**
  66845. * Helper function to create a SceneOptimizer with one single line of code
  66846. * @param scene defines the scene to work on
  66847. * @param options defines the options to use with the SceneOptimizer
  66848. * @param onSuccess defines a callback to call on success
  66849. * @param onFailure defines a callback to call on failure
  66850. * @returns the new SceneOptimizer object
  66851. */
  66852. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66853. }
  66854. }
  66855. declare module "babylonjs/Misc/sceneSerializer" {
  66856. import { Scene } from "babylonjs/scene";
  66857. /**
  66858. * Class used to serialize a scene into a string
  66859. */
  66860. export class SceneSerializer {
  66861. /**
  66862. * Clear cache used by a previous serialization
  66863. */
  66864. static ClearCache(): void;
  66865. /**
  66866. * Serialize a scene into a JSON compatible object
  66867. * @param scene defines the scene to serialize
  66868. * @returns a JSON compatible object
  66869. */
  66870. static Serialize(scene: Scene): any;
  66871. /**
  66872. * Serialize a mesh into a JSON compatible object
  66873. * @param toSerialize defines the mesh to serialize
  66874. * @param withParents defines if parents must be serialized as well
  66875. * @param withChildren defines if children must be serialized as well
  66876. * @returns a JSON compatible object
  66877. */
  66878. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66879. }
  66880. }
  66881. declare module "babylonjs/Misc/textureTools" {
  66882. import { Texture } from "babylonjs/Materials/Textures/texture";
  66883. /**
  66884. * Class used to host texture specific utilities
  66885. */
  66886. export class TextureTools {
  66887. /**
  66888. * Uses the GPU to create a copy texture rescaled at a given size
  66889. * @param texture Texture to copy from
  66890. * @param width defines the desired width
  66891. * @param height defines the desired height
  66892. * @param useBilinearMode defines if bilinear mode has to be used
  66893. * @return the generated texture
  66894. */
  66895. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66896. }
  66897. }
  66898. declare module "babylonjs/Misc/videoRecorder" {
  66899. import { Nullable } from "babylonjs/types";
  66900. import { Engine } from "babylonjs/Engines/engine";
  66901. /**
  66902. * This represents the different options available for the video capture.
  66903. */
  66904. export interface VideoRecorderOptions {
  66905. /** Defines the mime type of the video. */
  66906. mimeType: string;
  66907. /** Defines the FPS the video should be recorded at. */
  66908. fps: number;
  66909. /** Defines the chunk size for the recording data. */
  66910. recordChunckSize: number;
  66911. /** The audio tracks to attach to the recording. */
  66912. audioTracks?: MediaStreamTrack[];
  66913. }
  66914. /**
  66915. * This can help with recording videos from BabylonJS.
  66916. * This is based on the available WebRTC functionalities of the browser.
  66917. *
  66918. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66919. */
  66920. export class VideoRecorder {
  66921. private static readonly _defaultOptions;
  66922. /**
  66923. * Returns whether or not the VideoRecorder is available in your browser.
  66924. * @param engine Defines the Babylon Engine.
  66925. * @returns true if supported otherwise false.
  66926. */
  66927. static IsSupported(engine: Engine): boolean;
  66928. private readonly _options;
  66929. private _canvas;
  66930. private _mediaRecorder;
  66931. private _recordedChunks;
  66932. private _fileName;
  66933. private _resolve;
  66934. private _reject;
  66935. /**
  66936. * True when a recording is already in progress.
  66937. */
  66938. readonly isRecording: boolean;
  66939. /**
  66940. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66941. * @param engine Defines the BabylonJS Engine you wish to record.
  66942. * @param options Defines options that can be used to customize the capture.
  66943. */
  66944. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66945. /**
  66946. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66947. */
  66948. stopRecording(): void;
  66949. /**
  66950. * Starts recording the canvas for a max duration specified in parameters.
  66951. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66952. * If null no automatic download will start and you can rely on the promise to get the data back.
  66953. * @param maxDuration Defines the maximum recording time in seconds.
  66954. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66955. * @return A promise callback at the end of the recording with the video data in Blob.
  66956. */
  66957. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66958. /**
  66959. * Releases internal resources used during the recording.
  66960. */
  66961. dispose(): void;
  66962. private _handleDataAvailable;
  66963. private _handleError;
  66964. private _handleStop;
  66965. }
  66966. }
  66967. declare module "babylonjs/Misc/screenshotTools" {
  66968. import { Camera } from "babylonjs/Cameras/camera";
  66969. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66970. import { Engine } from "babylonjs/Engines/engine";
  66971. /**
  66972. * Class containing a set of static utilities functions for screenshots
  66973. */
  66974. export class ScreenshotTools {
  66975. /**
  66976. * Captures a screenshot of the current rendering
  66977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66978. * @param engine defines the rendering engine
  66979. * @param camera defines the source camera
  66980. * @param size This parameter can be set to a single number or to an object with the
  66981. * following (optional) properties: precision, width, height. If a single number is passed,
  66982. * it will be used for both width and height. If an object is passed, the screenshot size
  66983. * will be derived from the parameters. The precision property is a multiplier allowing
  66984. * rendering at a higher or lower resolution
  66985. * @param successCallback defines the callback receives a single parameter which contains the
  66986. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66987. * src parameter of an <img> to display it
  66988. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66989. * Check your browser for supported MIME types
  66990. */
  66991. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66992. /**
  66993. * Captures a screenshot of the current rendering
  66994. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66995. * @param engine defines the rendering engine
  66996. * @param camera defines the source camera
  66997. * @param size This parameter can be set to a single number or to an object with the
  66998. * following (optional) properties: precision, width, height. If a single number is passed,
  66999. * it will be used for both width and height. If an object is passed, the screenshot size
  67000. * will be derived from the parameters. The precision property is a multiplier allowing
  67001. * rendering at a higher or lower resolution
  67002. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67003. * Check your browser for supported MIME types
  67004. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67005. * to the src parameter of an <img> to display it
  67006. */
  67007. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67008. /**
  67009. * Generates an image screenshot from the specified camera.
  67010. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67011. * @param engine The engine to use for rendering
  67012. * @param camera The camera to use for rendering
  67013. * @param size This parameter can be set to a single number or to an object with the
  67014. * following (optional) properties: precision, width, height. If a single number is passed,
  67015. * it will be used for both width and height. If an object is passed, the screenshot size
  67016. * will be derived from the parameters. The precision property is a multiplier allowing
  67017. * rendering at a higher or lower resolution
  67018. * @param successCallback The callback receives a single parameter which contains the
  67019. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67020. * src parameter of an <img> to display it
  67021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67022. * Check your browser for supported MIME types
  67023. * @param samples Texture samples (default: 1)
  67024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67025. * @param fileName A name for for the downloaded file.
  67026. */
  67027. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67028. /**
  67029. * Generates an image screenshot from the specified camera.
  67030. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67031. * @param engine The engine to use for rendering
  67032. * @param camera The camera to use for rendering
  67033. * @param size This parameter can be set to a single number or to an object with the
  67034. * following (optional) properties: precision, width, height. If a single number is passed,
  67035. * it will be used for both width and height. If an object is passed, the screenshot size
  67036. * will be derived from the parameters. The precision property is a multiplier allowing
  67037. * rendering at a higher or lower resolution
  67038. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67039. * Check your browser for supported MIME types
  67040. * @param samples Texture samples (default: 1)
  67041. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67042. * @param fileName A name for for the downloaded file.
  67043. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67044. * to the src parameter of an <img> to display it
  67045. */
  67046. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67047. /**
  67048. * Gets height and width for screenshot size
  67049. * @private
  67050. */
  67051. private static _getScreenshotSize;
  67052. }
  67053. }
  67054. declare module "babylonjs/Misc/index" {
  67055. export * from "babylonjs/Misc/andOrNotEvaluator";
  67056. export * from "babylonjs/Misc/assetsManager";
  67057. export * from "babylonjs/Misc/dds";
  67058. export * from "babylonjs/Misc/decorators";
  67059. export * from "babylonjs/Misc/deferred";
  67060. export * from "babylonjs/Misc/environmentTextureTools";
  67061. export * from "babylonjs/Misc/meshExploder";
  67062. export * from "babylonjs/Misc/filesInput";
  67063. export * from "babylonjs/Misc/HighDynamicRange/index";
  67064. export * from "babylonjs/Misc/khronosTextureContainer";
  67065. export * from "babylonjs/Misc/observable";
  67066. export * from "babylonjs/Misc/performanceMonitor";
  67067. export * from "babylonjs/Misc/promise";
  67068. export * from "babylonjs/Misc/sceneOptimizer";
  67069. export * from "babylonjs/Misc/sceneSerializer";
  67070. export * from "babylonjs/Misc/smartArray";
  67071. export * from "babylonjs/Misc/stringDictionary";
  67072. export * from "babylonjs/Misc/tags";
  67073. export * from "babylonjs/Misc/textureTools";
  67074. export * from "babylonjs/Misc/tga";
  67075. export * from "babylonjs/Misc/tools";
  67076. export * from "babylonjs/Misc/videoRecorder";
  67077. export * from "babylonjs/Misc/virtualJoystick";
  67078. export * from "babylonjs/Misc/workerPool";
  67079. export * from "babylonjs/Misc/logger";
  67080. export * from "babylonjs/Misc/typeStore";
  67081. export * from "babylonjs/Misc/filesInputStore";
  67082. export * from "babylonjs/Misc/deepCopier";
  67083. export * from "babylonjs/Misc/pivotTools";
  67084. export * from "babylonjs/Misc/precisionDate";
  67085. export * from "babylonjs/Misc/screenshotTools";
  67086. export * from "babylonjs/Misc/typeStore";
  67087. export * from "babylonjs/Misc/webRequest";
  67088. export * from "babylonjs/Misc/iInspectable";
  67089. export * from "babylonjs/Misc/brdfTextureTools";
  67090. export * from "babylonjs/Misc/rgbdTextureTools";
  67091. export * from "babylonjs/Misc/gradients";
  67092. export * from "babylonjs/Misc/perfCounter";
  67093. export * from "babylonjs/Misc/fileRequest";
  67094. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67095. export * from "babylonjs/Misc/retryStrategy";
  67096. export * from "babylonjs/Misc/loadFileError";
  67097. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67098. }
  67099. declare module "babylonjs/index" {
  67100. export * from "babylonjs/abstractScene";
  67101. export * from "babylonjs/Actions/index";
  67102. export * from "babylonjs/Animations/index";
  67103. export * from "babylonjs/assetContainer";
  67104. export * from "babylonjs/Audio/index";
  67105. export * from "babylonjs/Behaviors/index";
  67106. export * from "babylonjs/Bones/index";
  67107. export * from "babylonjs/Cameras/index";
  67108. export * from "babylonjs/Collisions/index";
  67109. export * from "babylonjs/Culling/index";
  67110. export * from "babylonjs/Debug/index";
  67111. export * from "babylonjs/Engines/index";
  67112. export * from "babylonjs/Events/index";
  67113. export * from "babylonjs/Gamepads/index";
  67114. export * from "babylonjs/Gizmos/index";
  67115. export * from "babylonjs/Helpers/index";
  67116. export * from "babylonjs/Instrumentation/index";
  67117. export * from "babylonjs/Layers/index";
  67118. export * from "babylonjs/LensFlares/index";
  67119. export * from "babylonjs/Lights/index";
  67120. export * from "babylonjs/Loading/index";
  67121. export * from "babylonjs/Materials/index";
  67122. export * from "babylonjs/Maths/index";
  67123. export * from "babylonjs/Meshes/index";
  67124. export * from "babylonjs/Morph/index";
  67125. export * from "babylonjs/Navigation/index";
  67126. export * from "babylonjs/node";
  67127. export * from "babylonjs/Offline/index";
  67128. export * from "babylonjs/Particles/index";
  67129. export * from "babylonjs/Physics/index";
  67130. export * from "babylonjs/PostProcesses/index";
  67131. export * from "babylonjs/Probes/index";
  67132. export * from "babylonjs/Rendering/index";
  67133. export * from "babylonjs/scene";
  67134. export * from "babylonjs/sceneComponent";
  67135. export * from "babylonjs/Sprites/index";
  67136. export * from "babylonjs/States/index";
  67137. export * from "babylonjs/Misc/index";
  67138. export * from "babylonjs/types";
  67139. }
  67140. declare module "babylonjs/Animations/pathCursor" {
  67141. import { Vector3 } from "babylonjs/Maths/math.vector";
  67142. import { Path2 } from "babylonjs/Maths/math.path";
  67143. /**
  67144. * A cursor which tracks a point on a path
  67145. */
  67146. export class PathCursor {
  67147. private path;
  67148. /**
  67149. * Stores path cursor callbacks for when an onchange event is triggered
  67150. */
  67151. private _onchange;
  67152. /**
  67153. * The value of the path cursor
  67154. */
  67155. value: number;
  67156. /**
  67157. * The animation array of the path cursor
  67158. */
  67159. animations: Animation[];
  67160. /**
  67161. * Initializes the path cursor
  67162. * @param path The path to track
  67163. */
  67164. constructor(path: Path2);
  67165. /**
  67166. * Gets the cursor point on the path
  67167. * @returns A point on the path cursor at the cursor location
  67168. */
  67169. getPoint(): Vector3;
  67170. /**
  67171. * Moves the cursor ahead by the step amount
  67172. * @param step The amount to move the cursor forward
  67173. * @returns This path cursor
  67174. */
  67175. moveAhead(step?: number): PathCursor;
  67176. /**
  67177. * Moves the cursor behind by the step amount
  67178. * @param step The amount to move the cursor back
  67179. * @returns This path cursor
  67180. */
  67181. moveBack(step?: number): PathCursor;
  67182. /**
  67183. * Moves the cursor by the step amount
  67184. * If the step amount is greater than one, an exception is thrown
  67185. * @param step The amount to move the cursor
  67186. * @returns This path cursor
  67187. */
  67188. move(step: number): PathCursor;
  67189. /**
  67190. * Ensures that the value is limited between zero and one
  67191. * @returns This path cursor
  67192. */
  67193. private ensureLimits;
  67194. /**
  67195. * Runs onchange callbacks on change (used by the animation engine)
  67196. * @returns This path cursor
  67197. */
  67198. private raiseOnChange;
  67199. /**
  67200. * Executes a function on change
  67201. * @param f A path cursor onchange callback
  67202. * @returns This path cursor
  67203. */
  67204. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67205. }
  67206. }
  67207. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67208. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67209. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67210. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67211. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67212. }
  67213. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67214. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67215. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67216. }
  67217. declare module "babylonjs/Engines/Processors/index" {
  67218. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67219. export * from "babylonjs/Engines/Processors/Expressions/index";
  67220. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67221. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67222. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67223. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67224. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67225. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67226. }
  67227. declare module "babylonjs/Legacy/legacy" {
  67228. import * as Babylon from "babylonjs/index";
  67229. export * from "babylonjs/index";
  67230. }
  67231. declare module "babylonjs/Shaders/blur.fragment" {
  67232. /** @hidden */
  67233. export var blurPixelShader: {
  67234. name: string;
  67235. shader: string;
  67236. };
  67237. }
  67238. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67239. /** @hidden */
  67240. export var pointCloudVertexDeclaration: {
  67241. name: string;
  67242. shader: string;
  67243. };
  67244. }
  67245. declare module "babylonjs" {
  67246. export * from "babylonjs/Legacy/legacy";
  67247. }
  67248. declare module BABYLON {
  67249. /** Alias type for value that can be null */
  67250. export type Nullable<T> = T | null;
  67251. /**
  67252. * Alias type for number that are floats
  67253. * @ignorenaming
  67254. */
  67255. export type float = number;
  67256. /**
  67257. * Alias type for number that are doubles.
  67258. * @ignorenaming
  67259. */
  67260. export type double = number;
  67261. /**
  67262. * Alias type for number that are integer
  67263. * @ignorenaming
  67264. */
  67265. export type int = number;
  67266. /** Alias type for number array or Float32Array */
  67267. export type FloatArray = number[] | Float32Array;
  67268. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67269. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67270. /**
  67271. * Alias for types that can be used by a Buffer or VertexBuffer.
  67272. */
  67273. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67274. /**
  67275. * Alias type for primitive types
  67276. * @ignorenaming
  67277. */
  67278. type Primitive = undefined | null | boolean | string | number | Function;
  67279. /**
  67280. * Type modifier to make all the properties of an object Readonly
  67281. */
  67282. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67283. /**
  67284. * Type modifier to make all the properties of an object Readonly recursively
  67285. */
  67286. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67287. /**
  67288. * Type modifier to make object properties readonly.
  67289. */
  67290. export type DeepImmutableObject<T> = {
  67291. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67292. };
  67293. /** @hidden */
  67294. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67295. }
  67296. }
  67297. declare module BABYLON {
  67298. /**
  67299. * A class serves as a medium between the observable and its observers
  67300. */
  67301. export class EventState {
  67302. /**
  67303. * Create a new EventState
  67304. * @param mask defines the mask associated with this state
  67305. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67306. * @param target defines the original target of the state
  67307. * @param currentTarget defines the current target of the state
  67308. */
  67309. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67310. /**
  67311. * Initialize the current event state
  67312. * @param mask defines the mask associated with this state
  67313. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67314. * @param target defines the original target of the state
  67315. * @param currentTarget defines the current target of the state
  67316. * @returns the current event state
  67317. */
  67318. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67319. /**
  67320. * An Observer can set this property to true to prevent subsequent observers of being notified
  67321. */
  67322. skipNextObservers: boolean;
  67323. /**
  67324. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67325. */
  67326. mask: number;
  67327. /**
  67328. * The object that originally notified the event
  67329. */
  67330. target?: any;
  67331. /**
  67332. * The current object in the bubbling phase
  67333. */
  67334. currentTarget?: any;
  67335. /**
  67336. * This will be populated with the return value of the last function that was executed.
  67337. * If it is the first function in the callback chain it will be the event data.
  67338. */
  67339. lastReturnValue?: any;
  67340. }
  67341. /**
  67342. * Represent an Observer registered to a given Observable object.
  67343. */
  67344. export class Observer<T> {
  67345. /**
  67346. * Defines the callback to call when the observer is notified
  67347. */
  67348. callback: (eventData: T, eventState: EventState) => void;
  67349. /**
  67350. * Defines the mask of the observer (used to filter notifications)
  67351. */
  67352. mask: number;
  67353. /**
  67354. * Defines the current scope used to restore the JS context
  67355. */
  67356. scope: any;
  67357. /** @hidden */
  67358. _willBeUnregistered: boolean;
  67359. /**
  67360. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67361. */
  67362. unregisterOnNextCall: boolean;
  67363. /**
  67364. * Creates a new observer
  67365. * @param callback defines the callback to call when the observer is notified
  67366. * @param mask defines the mask of the observer (used to filter notifications)
  67367. * @param scope defines the current scope used to restore the JS context
  67368. */
  67369. constructor(
  67370. /**
  67371. * Defines the callback to call when the observer is notified
  67372. */
  67373. callback: (eventData: T, eventState: EventState) => void,
  67374. /**
  67375. * Defines the mask of the observer (used to filter notifications)
  67376. */
  67377. mask: number,
  67378. /**
  67379. * Defines the current scope used to restore the JS context
  67380. */
  67381. scope?: any);
  67382. }
  67383. /**
  67384. * Represent a list of observers registered to multiple Observables object.
  67385. */
  67386. export class MultiObserver<T> {
  67387. private _observers;
  67388. private _observables;
  67389. /**
  67390. * Release associated resources
  67391. */
  67392. dispose(): void;
  67393. /**
  67394. * Raise a callback when one of the observable will notify
  67395. * @param observables defines a list of observables to watch
  67396. * @param callback defines the callback to call on notification
  67397. * @param mask defines the mask used to filter notifications
  67398. * @param scope defines the current scope used to restore the JS context
  67399. * @returns the new MultiObserver
  67400. */
  67401. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67402. }
  67403. /**
  67404. * The Observable class is a simple implementation of the Observable pattern.
  67405. *
  67406. * 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.
  67407. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67408. * 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).
  67409. * 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.
  67410. */
  67411. export class Observable<T> {
  67412. private _observers;
  67413. private _eventState;
  67414. private _onObserverAdded;
  67415. /**
  67416. * Gets the list of observers
  67417. */
  67418. readonly observers: Array<Observer<T>>;
  67419. /**
  67420. * Creates a new observable
  67421. * @param onObserverAdded defines a callback to call when a new observer is added
  67422. */
  67423. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67424. /**
  67425. * Create a new Observer with the specified callback
  67426. * @param callback the callback that will be executed for that Observer
  67427. * @param mask the mask used to filter observers
  67428. * @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.
  67429. * @param scope optional scope for the callback to be called from
  67430. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67431. * @returns the new observer created for the callback
  67432. */
  67433. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67434. /**
  67435. * Create a new Observer with the specified callback and unregisters after the next notification
  67436. * @param callback the callback that will be executed for that Observer
  67437. * @returns the new observer created for the callback
  67438. */
  67439. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67440. /**
  67441. * Remove an Observer from the Observable object
  67442. * @param observer the instance of the Observer to remove
  67443. * @returns false if it doesn't belong to this Observable
  67444. */
  67445. remove(observer: Nullable<Observer<T>>): boolean;
  67446. /**
  67447. * Remove a callback from the Observable object
  67448. * @param callback the callback to remove
  67449. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67450. * @returns false if it doesn't belong to this Observable
  67451. */
  67452. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67453. private _deferUnregister;
  67454. private _remove;
  67455. /**
  67456. * Moves the observable to the top of the observer list making it get called first when notified
  67457. * @param observer the observer to move
  67458. */
  67459. makeObserverTopPriority(observer: Observer<T>): void;
  67460. /**
  67461. * Moves the observable to the bottom of the observer list making it get called last when notified
  67462. * @param observer the observer to move
  67463. */
  67464. makeObserverBottomPriority(observer: Observer<T>): void;
  67465. /**
  67466. * Notify all Observers by calling their respective callback with the given data
  67467. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67468. * @param eventData defines the data to send to all observers
  67469. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67470. * @param target defines the original target of the state
  67471. * @param currentTarget defines the current target of the state
  67472. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67473. */
  67474. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67475. /**
  67476. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67477. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67478. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67479. * and it is crucial that all callbacks will be executed.
  67480. * The order of the callbacks is kept, callbacks are not executed parallel.
  67481. *
  67482. * @param eventData The data to be sent to each callback
  67483. * @param mask is used to filter observers defaults to -1
  67484. * @param target defines the callback target (see EventState)
  67485. * @param currentTarget defines he current object in the bubbling phase
  67486. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67487. */
  67488. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67489. /**
  67490. * Notify a specific observer
  67491. * @param observer defines the observer to notify
  67492. * @param eventData defines the data to be sent to each callback
  67493. * @param mask is used to filter observers defaults to -1
  67494. */
  67495. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67496. /**
  67497. * Gets a boolean indicating if the observable has at least one observer
  67498. * @returns true is the Observable has at least one Observer registered
  67499. */
  67500. hasObservers(): boolean;
  67501. /**
  67502. * Clear the list of observers
  67503. */
  67504. clear(): void;
  67505. /**
  67506. * Clone the current observable
  67507. * @returns a new observable
  67508. */
  67509. clone(): Observable<T>;
  67510. /**
  67511. * Does this observable handles observer registered with a given mask
  67512. * @param mask defines the mask to be tested
  67513. * @return whether or not one observer registered with the given mask is handeled
  67514. **/
  67515. hasSpecificMask(mask?: number): boolean;
  67516. }
  67517. }
  67518. declare module BABYLON {
  67519. /**
  67520. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67521. * Babylon.js
  67522. */
  67523. export class DomManagement {
  67524. /**
  67525. * Checks if the window object exists
  67526. * @returns true if the window object exists
  67527. */
  67528. static IsWindowObjectExist(): boolean;
  67529. /**
  67530. * Checks if the navigator object exists
  67531. * @returns true if the navigator object exists
  67532. */
  67533. static IsNavigatorAvailable(): boolean;
  67534. /**
  67535. * Extracts text content from a DOM element hierarchy
  67536. * @param element defines the root element
  67537. * @returns a string
  67538. */
  67539. static GetDOMTextContent(element: HTMLElement): string;
  67540. }
  67541. }
  67542. declare module BABYLON {
  67543. /**
  67544. * Logger used througouht the application to allow configuration of
  67545. * the log level required for the messages.
  67546. */
  67547. export class Logger {
  67548. /**
  67549. * No log
  67550. */
  67551. static readonly NoneLogLevel: number;
  67552. /**
  67553. * Only message logs
  67554. */
  67555. static readonly MessageLogLevel: number;
  67556. /**
  67557. * Only warning logs
  67558. */
  67559. static readonly WarningLogLevel: number;
  67560. /**
  67561. * Only error logs
  67562. */
  67563. static readonly ErrorLogLevel: number;
  67564. /**
  67565. * All logs
  67566. */
  67567. static readonly AllLogLevel: number;
  67568. private static _LogCache;
  67569. /**
  67570. * Gets a value indicating the number of loading errors
  67571. * @ignorenaming
  67572. */
  67573. static errorsCount: number;
  67574. /**
  67575. * Callback called when a new log is added
  67576. */
  67577. static OnNewCacheEntry: (entry: string) => void;
  67578. private static _AddLogEntry;
  67579. private static _FormatMessage;
  67580. private static _LogDisabled;
  67581. private static _LogEnabled;
  67582. private static _WarnDisabled;
  67583. private static _WarnEnabled;
  67584. private static _ErrorDisabled;
  67585. private static _ErrorEnabled;
  67586. /**
  67587. * Log a message to the console
  67588. */
  67589. static Log: (message: string) => void;
  67590. /**
  67591. * Write a warning message to the console
  67592. */
  67593. static Warn: (message: string) => void;
  67594. /**
  67595. * Write an error message to the console
  67596. */
  67597. static Error: (message: string) => void;
  67598. /**
  67599. * Gets current log cache (list of logs)
  67600. */
  67601. static readonly LogCache: string;
  67602. /**
  67603. * Clears the log cache
  67604. */
  67605. static ClearLogCache(): void;
  67606. /**
  67607. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67608. */
  67609. static LogLevels: number;
  67610. }
  67611. }
  67612. declare module BABYLON {
  67613. /** @hidden */
  67614. export class _TypeStore {
  67615. /** @hidden */
  67616. static RegisteredTypes: {
  67617. [key: string]: Object;
  67618. };
  67619. /** @hidden */
  67620. static GetClass(fqdn: string): any;
  67621. }
  67622. }
  67623. declare module BABYLON {
  67624. /**
  67625. * Class containing a set of static utilities functions for deep copy.
  67626. */
  67627. export class DeepCopier {
  67628. /**
  67629. * Tries to copy an object by duplicating every property
  67630. * @param source defines the source object
  67631. * @param destination defines the target object
  67632. * @param doNotCopyList defines a list of properties to avoid
  67633. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67634. */
  67635. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67636. }
  67637. }
  67638. declare module BABYLON {
  67639. /**
  67640. * Class containing a set of static utilities functions for precision date
  67641. */
  67642. export class PrecisionDate {
  67643. /**
  67644. * Gets either window.performance.now() if supported or Date.now() else
  67645. */
  67646. static readonly Now: number;
  67647. }
  67648. }
  67649. declare module BABYLON {
  67650. /** @hidden */
  67651. export class _DevTools {
  67652. static WarnImport(name: string): string;
  67653. }
  67654. }
  67655. declare module BABYLON {
  67656. /**
  67657. * Interface used to define the mechanism to get data from the network
  67658. */
  67659. export interface IWebRequest {
  67660. /**
  67661. * Returns client's response url
  67662. */
  67663. responseURL: string;
  67664. /**
  67665. * Returns client's status
  67666. */
  67667. status: number;
  67668. /**
  67669. * Returns client's status as a text
  67670. */
  67671. statusText: string;
  67672. }
  67673. }
  67674. declare module BABYLON {
  67675. /**
  67676. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67677. */
  67678. export class WebRequest implements IWebRequest {
  67679. private _xhr;
  67680. /**
  67681. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67682. * i.e. when loading files, where the server/service expects an Authorization header
  67683. */
  67684. static CustomRequestHeaders: {
  67685. [key: string]: string;
  67686. };
  67687. /**
  67688. * Add callback functions in this array to update all the requests before they get sent to the network
  67689. */
  67690. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67691. private _injectCustomRequestHeaders;
  67692. /**
  67693. * Gets or sets a function to be called when loading progress changes
  67694. */
  67695. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67696. /**
  67697. * Returns client's state
  67698. */
  67699. readonly readyState: number;
  67700. /**
  67701. * Returns client's status
  67702. */
  67703. readonly status: number;
  67704. /**
  67705. * Returns client's status as a text
  67706. */
  67707. readonly statusText: string;
  67708. /**
  67709. * Returns client's response
  67710. */
  67711. readonly response: any;
  67712. /**
  67713. * Returns client's response url
  67714. */
  67715. readonly responseURL: string;
  67716. /**
  67717. * Returns client's response as text
  67718. */
  67719. readonly responseText: string;
  67720. /**
  67721. * Gets or sets the expected response type
  67722. */
  67723. responseType: XMLHttpRequestResponseType;
  67724. /** @hidden */
  67725. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67726. /** @hidden */
  67727. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67728. /**
  67729. * Cancels any network activity
  67730. */
  67731. abort(): void;
  67732. /**
  67733. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67734. * @param body defines an optional request body
  67735. */
  67736. send(body?: Document | BodyInit | null): void;
  67737. /**
  67738. * Sets the request method, request URL
  67739. * @param method defines the method to use (GET, POST, etc..)
  67740. * @param url defines the url to connect with
  67741. */
  67742. open(method: string, url: string): void;
  67743. }
  67744. }
  67745. declare module BABYLON {
  67746. /**
  67747. * File request interface
  67748. */
  67749. export interface IFileRequest {
  67750. /**
  67751. * Raised when the request is complete (success or error).
  67752. */
  67753. onCompleteObservable: Observable<IFileRequest>;
  67754. /**
  67755. * Aborts the request for a file.
  67756. */
  67757. abort: () => void;
  67758. }
  67759. }
  67760. declare module BABYLON {
  67761. /**
  67762. * Define options used to create a render target texture
  67763. */
  67764. export class RenderTargetCreationOptions {
  67765. /**
  67766. * Specifies is mipmaps must be generated
  67767. */
  67768. generateMipMaps?: boolean;
  67769. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67770. generateDepthBuffer?: boolean;
  67771. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67772. generateStencilBuffer?: boolean;
  67773. /** Defines texture type (int by default) */
  67774. type?: number;
  67775. /** Defines sampling mode (trilinear by default) */
  67776. samplingMode?: number;
  67777. /** Defines format (RGBA by default) */
  67778. format?: number;
  67779. }
  67780. }
  67781. declare module BABYLON {
  67782. /**
  67783. * @hidden
  67784. **/
  67785. export class _TimeToken {
  67786. _startTimeQuery: Nullable<WebGLQuery>;
  67787. _endTimeQuery: Nullable<WebGLQuery>;
  67788. _timeElapsedQuery: Nullable<WebGLQuery>;
  67789. _timeElapsedQueryEnded: boolean;
  67790. }
  67791. }
  67792. declare module BABYLON {
  67793. /** Defines the cross module used constants to avoid circular dependncies */
  67794. export class Constants {
  67795. /** Defines that alpha blending is disabled */
  67796. static readonly ALPHA_DISABLE: number;
  67797. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67798. static readonly ALPHA_ADD: number;
  67799. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67800. static readonly ALPHA_COMBINE: number;
  67801. /** Defines that alpha blending to DEST - SRC * DEST */
  67802. static readonly ALPHA_SUBTRACT: number;
  67803. /** Defines that alpha blending to SRC * DEST */
  67804. static readonly ALPHA_MULTIPLY: number;
  67805. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67806. static readonly ALPHA_MAXIMIZED: number;
  67807. /** Defines that alpha blending to SRC + DEST */
  67808. static readonly ALPHA_ONEONE: number;
  67809. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67810. static readonly ALPHA_PREMULTIPLIED: number;
  67811. /**
  67812. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67813. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67814. */
  67815. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67816. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67817. static readonly ALPHA_INTERPOLATE: number;
  67818. /**
  67819. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67820. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67821. */
  67822. static readonly ALPHA_SCREENMODE: number;
  67823. /**
  67824. * Defines that alpha blending to SRC + DST
  67825. * Alpha will be set to SRC ALPHA + DST ALPHA
  67826. */
  67827. static readonly ALPHA_ONEONE_ONEONE: number;
  67828. /**
  67829. * Defines that alpha blending to SRC * DST ALPHA + DST
  67830. * Alpha will be set to 0
  67831. */
  67832. static readonly ALPHA_ALPHATOCOLOR: number;
  67833. /**
  67834. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67835. */
  67836. static readonly ALPHA_REVERSEONEMINUS: number;
  67837. /**
  67838. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67839. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67840. */
  67841. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67842. /**
  67843. * Defines that alpha blending to SRC + DST
  67844. * Alpha will be set to SRC ALPHA
  67845. */
  67846. static readonly ALPHA_ONEONE_ONEZERO: number;
  67847. /** Defines that alpha blending equation a SUM */
  67848. static readonly ALPHA_EQUATION_ADD: number;
  67849. /** Defines that alpha blending equation a SUBSTRACTION */
  67850. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67851. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67852. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67853. /** Defines that alpha blending equation a MAX operation */
  67854. static readonly ALPHA_EQUATION_MAX: number;
  67855. /** Defines that alpha blending equation a MIN operation */
  67856. static readonly ALPHA_EQUATION_MIN: number;
  67857. /**
  67858. * Defines that alpha blending equation a DARKEN operation:
  67859. * It takes the min of the src and sums the alpha channels.
  67860. */
  67861. static readonly ALPHA_EQUATION_DARKEN: number;
  67862. /** Defines that the ressource is not delayed*/
  67863. static readonly DELAYLOADSTATE_NONE: number;
  67864. /** Defines that the ressource was successfully delay loaded */
  67865. static readonly DELAYLOADSTATE_LOADED: number;
  67866. /** Defines that the ressource is currently delay loading */
  67867. static readonly DELAYLOADSTATE_LOADING: number;
  67868. /** Defines that the ressource is delayed and has not started loading */
  67869. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67870. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67871. static readonly NEVER: number;
  67872. /** 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 */
  67873. static readonly ALWAYS: number;
  67874. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67875. static readonly LESS: number;
  67876. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67877. static readonly EQUAL: number;
  67878. /** 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 */
  67879. static readonly LEQUAL: number;
  67880. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67881. static readonly GREATER: number;
  67882. /** 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 */
  67883. static readonly GEQUAL: number;
  67884. /** 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 */
  67885. static readonly NOTEQUAL: number;
  67886. /** Passed to stencilOperation to specify that stencil value must be kept */
  67887. static readonly KEEP: number;
  67888. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67889. static readonly REPLACE: number;
  67890. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67891. static readonly INCR: number;
  67892. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67893. static readonly DECR: number;
  67894. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67895. static readonly INVERT: number;
  67896. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67897. static readonly INCR_WRAP: number;
  67898. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67899. static readonly DECR_WRAP: number;
  67900. /** Texture is not repeating outside of 0..1 UVs */
  67901. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67902. /** Texture is repeating outside of 0..1 UVs */
  67903. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67904. /** Texture is repeating and mirrored */
  67905. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67906. /** ALPHA */
  67907. static readonly TEXTUREFORMAT_ALPHA: number;
  67908. /** LUMINANCE */
  67909. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67910. /** LUMINANCE_ALPHA */
  67911. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67912. /** RGB */
  67913. static readonly TEXTUREFORMAT_RGB: number;
  67914. /** RGBA */
  67915. static readonly TEXTUREFORMAT_RGBA: number;
  67916. /** RED */
  67917. static readonly TEXTUREFORMAT_RED: number;
  67918. /** RED (2nd reference) */
  67919. static readonly TEXTUREFORMAT_R: number;
  67920. /** RG */
  67921. static readonly TEXTUREFORMAT_RG: number;
  67922. /** RED_INTEGER */
  67923. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67924. /** RED_INTEGER (2nd reference) */
  67925. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67926. /** RG_INTEGER */
  67927. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67928. /** RGB_INTEGER */
  67929. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67930. /** RGBA_INTEGER */
  67931. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67932. /** UNSIGNED_BYTE */
  67933. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67934. /** UNSIGNED_BYTE (2nd reference) */
  67935. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67936. /** FLOAT */
  67937. static readonly TEXTURETYPE_FLOAT: number;
  67938. /** HALF_FLOAT */
  67939. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67940. /** BYTE */
  67941. static readonly TEXTURETYPE_BYTE: number;
  67942. /** SHORT */
  67943. static readonly TEXTURETYPE_SHORT: number;
  67944. /** UNSIGNED_SHORT */
  67945. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67946. /** INT */
  67947. static readonly TEXTURETYPE_INT: number;
  67948. /** UNSIGNED_INT */
  67949. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67950. /** UNSIGNED_SHORT_4_4_4_4 */
  67951. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67952. /** UNSIGNED_SHORT_5_5_5_1 */
  67953. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67954. /** UNSIGNED_SHORT_5_6_5 */
  67955. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67956. /** UNSIGNED_INT_2_10_10_10_REV */
  67957. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67958. /** UNSIGNED_INT_24_8 */
  67959. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67960. /** UNSIGNED_INT_10F_11F_11F_REV */
  67961. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67962. /** UNSIGNED_INT_5_9_9_9_REV */
  67963. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67964. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67965. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67966. /** nearest is mag = nearest and min = nearest and mip = linear */
  67967. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67968. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67969. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67970. /** Trilinear is mag = linear and min = linear and mip = linear */
  67971. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67972. /** nearest is mag = nearest and min = nearest and mip = linear */
  67973. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67974. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67975. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67976. /** Trilinear is mag = linear and min = linear and mip = linear */
  67977. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67978. /** mag = nearest and min = nearest and mip = nearest */
  67979. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67980. /** mag = nearest and min = linear and mip = nearest */
  67981. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67982. /** mag = nearest and min = linear and mip = linear */
  67983. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67984. /** mag = nearest and min = linear and mip = none */
  67985. static readonly TEXTURE_NEAREST_LINEAR: number;
  67986. /** mag = nearest and min = nearest and mip = none */
  67987. static readonly TEXTURE_NEAREST_NEAREST: number;
  67988. /** mag = linear and min = nearest and mip = nearest */
  67989. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67990. /** mag = linear and min = nearest and mip = linear */
  67991. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67992. /** mag = linear and min = linear and mip = none */
  67993. static readonly TEXTURE_LINEAR_LINEAR: number;
  67994. /** mag = linear and min = nearest and mip = none */
  67995. static readonly TEXTURE_LINEAR_NEAREST: number;
  67996. /** Explicit coordinates mode */
  67997. static readonly TEXTURE_EXPLICIT_MODE: number;
  67998. /** Spherical coordinates mode */
  67999. static readonly TEXTURE_SPHERICAL_MODE: number;
  68000. /** Planar coordinates mode */
  68001. static readonly TEXTURE_PLANAR_MODE: number;
  68002. /** Cubic coordinates mode */
  68003. static readonly TEXTURE_CUBIC_MODE: number;
  68004. /** Projection coordinates mode */
  68005. static readonly TEXTURE_PROJECTION_MODE: number;
  68006. /** Skybox coordinates mode */
  68007. static readonly TEXTURE_SKYBOX_MODE: number;
  68008. /** Inverse Cubic coordinates mode */
  68009. static readonly TEXTURE_INVCUBIC_MODE: number;
  68010. /** Equirectangular coordinates mode */
  68011. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68012. /** Equirectangular Fixed coordinates mode */
  68013. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68014. /** Equirectangular Fixed Mirrored coordinates mode */
  68015. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68016. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68017. static readonly SCALEMODE_FLOOR: number;
  68018. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68019. static readonly SCALEMODE_NEAREST: number;
  68020. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68021. static readonly SCALEMODE_CEILING: number;
  68022. /**
  68023. * The dirty texture flag value
  68024. */
  68025. static readonly MATERIAL_TextureDirtyFlag: number;
  68026. /**
  68027. * The dirty light flag value
  68028. */
  68029. static readonly MATERIAL_LightDirtyFlag: number;
  68030. /**
  68031. * The dirty fresnel flag value
  68032. */
  68033. static readonly MATERIAL_FresnelDirtyFlag: number;
  68034. /**
  68035. * The dirty attribute flag value
  68036. */
  68037. static readonly MATERIAL_AttributesDirtyFlag: number;
  68038. /**
  68039. * The dirty misc flag value
  68040. */
  68041. static readonly MATERIAL_MiscDirtyFlag: number;
  68042. /**
  68043. * The all dirty flag value
  68044. */
  68045. static readonly MATERIAL_AllDirtyFlag: number;
  68046. /**
  68047. * Returns the triangle fill mode
  68048. */
  68049. static readonly MATERIAL_TriangleFillMode: number;
  68050. /**
  68051. * Returns the wireframe mode
  68052. */
  68053. static readonly MATERIAL_WireFrameFillMode: number;
  68054. /**
  68055. * Returns the point fill mode
  68056. */
  68057. static readonly MATERIAL_PointFillMode: number;
  68058. /**
  68059. * Returns the point list draw mode
  68060. */
  68061. static readonly MATERIAL_PointListDrawMode: number;
  68062. /**
  68063. * Returns the line list draw mode
  68064. */
  68065. static readonly MATERIAL_LineListDrawMode: number;
  68066. /**
  68067. * Returns the line loop draw mode
  68068. */
  68069. static readonly MATERIAL_LineLoopDrawMode: number;
  68070. /**
  68071. * Returns the line strip draw mode
  68072. */
  68073. static readonly MATERIAL_LineStripDrawMode: number;
  68074. /**
  68075. * Returns the triangle strip draw mode
  68076. */
  68077. static readonly MATERIAL_TriangleStripDrawMode: number;
  68078. /**
  68079. * Returns the triangle fan draw mode
  68080. */
  68081. static readonly MATERIAL_TriangleFanDrawMode: number;
  68082. /**
  68083. * Stores the clock-wise side orientation
  68084. */
  68085. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68086. /**
  68087. * Stores the counter clock-wise side orientation
  68088. */
  68089. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68090. /**
  68091. * Nothing
  68092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68093. */
  68094. static readonly ACTION_NothingTrigger: number;
  68095. /**
  68096. * On pick
  68097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68098. */
  68099. static readonly ACTION_OnPickTrigger: number;
  68100. /**
  68101. * On left pick
  68102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68103. */
  68104. static readonly ACTION_OnLeftPickTrigger: number;
  68105. /**
  68106. * On right pick
  68107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68108. */
  68109. static readonly ACTION_OnRightPickTrigger: number;
  68110. /**
  68111. * On center pick
  68112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68113. */
  68114. static readonly ACTION_OnCenterPickTrigger: number;
  68115. /**
  68116. * On pick down
  68117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68118. */
  68119. static readonly ACTION_OnPickDownTrigger: number;
  68120. /**
  68121. * On double pick
  68122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68123. */
  68124. static readonly ACTION_OnDoublePickTrigger: number;
  68125. /**
  68126. * On pick up
  68127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68128. */
  68129. static readonly ACTION_OnPickUpTrigger: number;
  68130. /**
  68131. * On pick out.
  68132. * This trigger will only be raised if you also declared a OnPickDown
  68133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68134. */
  68135. static readonly ACTION_OnPickOutTrigger: number;
  68136. /**
  68137. * On long press
  68138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68139. */
  68140. static readonly ACTION_OnLongPressTrigger: number;
  68141. /**
  68142. * On pointer over
  68143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68144. */
  68145. static readonly ACTION_OnPointerOverTrigger: number;
  68146. /**
  68147. * On pointer out
  68148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68149. */
  68150. static readonly ACTION_OnPointerOutTrigger: number;
  68151. /**
  68152. * On every frame
  68153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68154. */
  68155. static readonly ACTION_OnEveryFrameTrigger: number;
  68156. /**
  68157. * On intersection enter
  68158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68159. */
  68160. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68161. /**
  68162. * On intersection exit
  68163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68164. */
  68165. static readonly ACTION_OnIntersectionExitTrigger: number;
  68166. /**
  68167. * On key down
  68168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68169. */
  68170. static readonly ACTION_OnKeyDownTrigger: number;
  68171. /**
  68172. * On key up
  68173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68174. */
  68175. static readonly ACTION_OnKeyUpTrigger: number;
  68176. /**
  68177. * Billboard mode will only apply to Y axis
  68178. */
  68179. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68180. /**
  68181. * Billboard mode will apply to all axes
  68182. */
  68183. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68184. /**
  68185. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68186. */
  68187. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68188. /**
  68189. * Gets or sets base Assets URL
  68190. */
  68191. static PARTICLES_BaseAssetsUrl: string;
  68192. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68193. * Test order :
  68194. * Is the bounding sphere outside the frustum ?
  68195. * If not, are the bounding box vertices outside the frustum ?
  68196. * It not, then the cullable object is in the frustum.
  68197. */
  68198. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68199. /** Culling strategy : Bounding Sphere Only.
  68200. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68201. * It's also less accurate than the standard because some not visible objects can still be selected.
  68202. * Test : is the bounding sphere outside the frustum ?
  68203. * If not, then the cullable object is in the frustum.
  68204. */
  68205. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68206. /** Culling strategy : Optimistic Inclusion.
  68207. * This in an inclusion test first, then the standard exclusion test.
  68208. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68209. * 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.
  68210. * Anyway, it's as accurate as the standard strategy.
  68211. * Test :
  68212. * Is the cullable object bounding sphere center in the frustum ?
  68213. * If not, apply the default culling strategy.
  68214. */
  68215. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68216. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68217. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68218. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68219. * 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.
  68220. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68221. * Test :
  68222. * Is the cullable object bounding sphere center in the frustum ?
  68223. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68224. */
  68225. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68226. /**
  68227. * No logging while loading
  68228. */
  68229. static readonly SCENELOADER_NO_LOGGING: number;
  68230. /**
  68231. * Minimal logging while loading
  68232. */
  68233. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68234. /**
  68235. * Summary logging while loading
  68236. */
  68237. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68238. /**
  68239. * Detailled logging while loading
  68240. */
  68241. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68242. }
  68243. }
  68244. declare module BABYLON {
  68245. /**
  68246. * This represents the required contract to create a new type of texture loader.
  68247. */
  68248. export interface IInternalTextureLoader {
  68249. /**
  68250. * Defines wether the loader supports cascade loading the different faces.
  68251. */
  68252. supportCascades: boolean;
  68253. /**
  68254. * This returns if the loader support the current file information.
  68255. * @param extension defines the file extension of the file being loaded
  68256. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68257. * @param fallback defines the fallback internal texture if any
  68258. * @param isBase64 defines whether the texture is encoded as a base64
  68259. * @param isBuffer defines whether the texture data are stored as a buffer
  68260. * @returns true if the loader can load the specified file
  68261. */
  68262. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68263. /**
  68264. * Transform the url before loading if required.
  68265. * @param rootUrl the url of the texture
  68266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68267. * @returns the transformed texture
  68268. */
  68269. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68270. /**
  68271. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68272. * @param rootUrl the url of the texture
  68273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68274. * @returns the fallback texture
  68275. */
  68276. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68277. /**
  68278. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68279. * @param data contains the texture data
  68280. * @param texture defines the BabylonJS internal texture
  68281. * @param createPolynomials will be true if polynomials have been requested
  68282. * @param onLoad defines the callback to trigger once the texture is ready
  68283. * @param onError defines the callback to trigger in case of error
  68284. */
  68285. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68286. /**
  68287. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68288. * @param data contains the texture data
  68289. * @param texture defines the BabylonJS internal texture
  68290. * @param callback defines the method to call once ready to upload
  68291. */
  68292. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. /**
  68297. * Class used to store and describe the pipeline context associated with an effect
  68298. */
  68299. export interface IPipelineContext {
  68300. /**
  68301. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68302. */
  68303. isAsync: boolean;
  68304. /**
  68305. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68306. */
  68307. isReady: boolean;
  68308. /** @hidden */
  68309. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68310. }
  68311. }
  68312. declare module BABYLON {
  68313. /**
  68314. * Class used to store gfx data (like WebGLBuffer)
  68315. */
  68316. export class DataBuffer {
  68317. /**
  68318. * Gets or sets the number of objects referencing this buffer
  68319. */
  68320. references: number;
  68321. /** Gets or sets the size of the underlying buffer */
  68322. capacity: number;
  68323. /**
  68324. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68325. */
  68326. is32Bits: boolean;
  68327. /**
  68328. * Gets the underlying buffer
  68329. */
  68330. readonly underlyingResource: any;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /** @hidden */
  68335. export interface IShaderProcessor {
  68336. attributeProcessor?: (attribute: string) => string;
  68337. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68338. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68339. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68340. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68341. lineProcessor?: (line: string, isFragment: boolean) => string;
  68342. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68343. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /** @hidden */
  68348. export interface ProcessingOptions {
  68349. defines: string[];
  68350. indexParameters: any;
  68351. isFragment: boolean;
  68352. shouldUseHighPrecisionShader: boolean;
  68353. supportsUniformBuffers: boolean;
  68354. shadersRepository: string;
  68355. includesShadersStore: {
  68356. [key: string]: string;
  68357. };
  68358. processor?: IShaderProcessor;
  68359. version: string;
  68360. platformName: string;
  68361. lookForClosingBracketForUniformBuffer?: boolean;
  68362. }
  68363. }
  68364. declare module BABYLON {
  68365. /**
  68366. * Helper to manipulate strings
  68367. */
  68368. export class StringTools {
  68369. /**
  68370. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68371. * @param str Source string
  68372. * @param suffix Suffix to search for in the source string
  68373. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68374. */
  68375. static EndsWith(str: string, suffix: string): boolean;
  68376. /**
  68377. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68378. * @param str Source string
  68379. * @param suffix Suffix to search for in the source string
  68380. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68381. */
  68382. static StartsWith(str: string, suffix: string): boolean;
  68383. }
  68384. }
  68385. declare module BABYLON {
  68386. /** @hidden */
  68387. export class ShaderCodeNode {
  68388. line: string;
  68389. children: ShaderCodeNode[];
  68390. additionalDefineKey?: string;
  68391. additionalDefineValue?: string;
  68392. isValid(preprocessors: {
  68393. [key: string]: string;
  68394. }): boolean;
  68395. process(preprocessors: {
  68396. [key: string]: string;
  68397. }, options: ProcessingOptions): string;
  68398. }
  68399. }
  68400. declare module BABYLON {
  68401. /** @hidden */
  68402. export class ShaderCodeCursor {
  68403. private _lines;
  68404. lineIndex: number;
  68405. readonly currentLine: string;
  68406. readonly canRead: boolean;
  68407. lines: string[];
  68408. }
  68409. }
  68410. declare module BABYLON {
  68411. /** @hidden */
  68412. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68413. process(preprocessors: {
  68414. [key: string]: string;
  68415. }, options: ProcessingOptions): string;
  68416. }
  68417. }
  68418. declare module BABYLON {
  68419. /** @hidden */
  68420. export class ShaderDefineExpression {
  68421. isTrue(preprocessors: {
  68422. [key: string]: string;
  68423. }): boolean;
  68424. }
  68425. }
  68426. declare module BABYLON {
  68427. /** @hidden */
  68428. export class ShaderCodeTestNode extends ShaderCodeNode {
  68429. testExpression: ShaderDefineExpression;
  68430. isValid(preprocessors: {
  68431. [key: string]: string;
  68432. }): boolean;
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /** @hidden */
  68437. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68438. define: string;
  68439. not: boolean;
  68440. constructor(define: string, not?: boolean);
  68441. isTrue(preprocessors: {
  68442. [key: string]: string;
  68443. }): boolean;
  68444. }
  68445. }
  68446. declare module BABYLON {
  68447. /** @hidden */
  68448. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68449. leftOperand: ShaderDefineExpression;
  68450. rightOperand: ShaderDefineExpression;
  68451. isTrue(preprocessors: {
  68452. [key: string]: string;
  68453. }): boolean;
  68454. }
  68455. }
  68456. declare module BABYLON {
  68457. /** @hidden */
  68458. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68459. leftOperand: ShaderDefineExpression;
  68460. rightOperand: ShaderDefineExpression;
  68461. isTrue(preprocessors: {
  68462. [key: string]: string;
  68463. }): boolean;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /** @hidden */
  68468. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68469. define: string;
  68470. operand: string;
  68471. testValue: string;
  68472. constructor(define: string, operand: string, testValue: string);
  68473. isTrue(preprocessors: {
  68474. [key: string]: string;
  68475. }): boolean;
  68476. }
  68477. }
  68478. declare module BABYLON {
  68479. /**
  68480. * @ignore
  68481. * Application error to support additional information when loading a file
  68482. */
  68483. export class LoadFileError extends Error {
  68484. /** defines the optional web request */
  68485. request?: WebRequest | undefined;
  68486. private static _setPrototypeOf;
  68487. /**
  68488. * Creates a new LoadFileError
  68489. * @param message defines the message of the error
  68490. * @param request defines the optional web request
  68491. */
  68492. constructor(message: string,
  68493. /** defines the optional web request */
  68494. request?: WebRequest | undefined);
  68495. }
  68496. }
  68497. declare module BABYLON {
  68498. /**
  68499. * Class used to enable access to offline support
  68500. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68501. */
  68502. export interface IOfflineProvider {
  68503. /**
  68504. * Gets a boolean indicating if scene must be saved in the database
  68505. */
  68506. enableSceneOffline: boolean;
  68507. /**
  68508. * Gets a boolean indicating if textures must be saved in the database
  68509. */
  68510. enableTexturesOffline: boolean;
  68511. /**
  68512. * Open the offline support and make it available
  68513. * @param successCallback defines the callback to call on success
  68514. * @param errorCallback defines the callback to call on error
  68515. */
  68516. open(successCallback: () => void, errorCallback: () => void): void;
  68517. /**
  68518. * Loads an image from the offline support
  68519. * @param url defines the url to load from
  68520. * @param image defines the target DOM image
  68521. */
  68522. loadImage(url: string, image: HTMLImageElement): void;
  68523. /**
  68524. * Loads a file from offline support
  68525. * @param url defines the URL to load from
  68526. * @param sceneLoaded defines a callback to call on success
  68527. * @param progressCallBack defines a callback to call when progress changed
  68528. * @param errorCallback defines a callback to call on error
  68529. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68530. */
  68531. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Class used to help managing file picking and drag'n'drop
  68537. * File Storage
  68538. */
  68539. export class FilesInputStore {
  68540. /**
  68541. * List of files ready to be loaded
  68542. */
  68543. static FilesToLoad: {
  68544. [key: string]: File;
  68545. };
  68546. }
  68547. }
  68548. declare module BABYLON {
  68549. /**
  68550. * Class used to define a retry strategy when error happens while loading assets
  68551. */
  68552. export class RetryStrategy {
  68553. /**
  68554. * Function used to defines an exponential back off strategy
  68555. * @param maxRetries defines the maximum number of retries (3 by default)
  68556. * @param baseInterval defines the interval between retries
  68557. * @returns the strategy function to use
  68558. */
  68559. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68560. }
  68561. }
  68562. declare module BABYLON {
  68563. /**
  68564. * @hidden
  68565. */
  68566. export class FileTools {
  68567. /**
  68568. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68569. */
  68570. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68571. /**
  68572. * Gets or sets the base URL to use to load assets
  68573. */
  68574. static BaseUrl: string;
  68575. /**
  68576. * Default behaviour for cors in the application.
  68577. * It can be a string if the expected behavior is identical in the entire app.
  68578. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68579. */
  68580. static CorsBehavior: string | ((url: string | string[]) => string);
  68581. /**
  68582. * Gets or sets a function used to pre-process url before using them to load assets
  68583. */
  68584. static PreprocessUrl: (url: string) => string;
  68585. /**
  68586. * Removes unwanted characters from an url
  68587. * @param url defines the url to clean
  68588. * @returns the cleaned url
  68589. */
  68590. private static _CleanUrl;
  68591. /**
  68592. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68593. * @param url define the url we are trying
  68594. * @param element define the dom element where to configure the cors policy
  68595. */
  68596. static SetCorsBehavior(url: string | string[], element: {
  68597. crossOrigin: string | null;
  68598. }): void;
  68599. private static _ArrayBufferToBase64;
  68600. /**
  68601. * Loads an image as an HTMLImageElement.
  68602. * @param input url string, ArrayBuffer, or Blob to load
  68603. * @param onLoad callback called when the image successfully loads
  68604. * @param onError callback called when the image fails to load
  68605. * @param offlineProvider offline provider for caching
  68606. * @param mimeType optional mime type
  68607. * @returns the HTMLImageElement of the loaded image
  68608. */
  68609. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  68610. /**
  68611. * Loads a file
  68612. * @param fileToLoad defines the file to load
  68613. * @param callback defines the callback to call when data is loaded
  68614. * @param progressCallBack defines the callback to call during loading process
  68615. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68616. * @returns a file request object
  68617. */
  68618. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68619. /**
  68620. * Loads a file
  68621. * @param url url string, ArrayBuffer, or Blob to load
  68622. * @param onSuccess callback called when the file successfully loads
  68623. * @param onProgress callback called while file is loading (if the server supports this mode)
  68624. * @param offlineProvider defines the offline provider for caching
  68625. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68626. * @param onError callback called when the file fails to load
  68627. * @returns a file request object
  68628. */
  68629. 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;
  68630. /**
  68631. * Checks if the loaded document was accessed via `file:`-Protocol.
  68632. * @returns boolean
  68633. */
  68634. static IsFileURL(): boolean;
  68635. }
  68636. }
  68637. declare module BABYLON {
  68638. /** @hidden */
  68639. export class ShaderProcessor {
  68640. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68641. private static _ProcessPrecision;
  68642. private static _ExtractOperation;
  68643. private static _BuildSubExpression;
  68644. private static _BuildExpression;
  68645. private static _MoveCursorWithinIf;
  68646. private static _MoveCursor;
  68647. private static _EvaluatePreProcessors;
  68648. private static _PreparePreProcessors;
  68649. private static _ProcessShaderConversion;
  68650. private static _ProcessIncludes;
  68651. }
  68652. }
  68653. declare module BABYLON {
  68654. /**
  68655. * @hidden
  68656. */
  68657. export interface IColor4Like {
  68658. r: float;
  68659. g: float;
  68660. b: float;
  68661. a: float;
  68662. }
  68663. /**
  68664. * @hidden
  68665. */
  68666. export interface IColor3Like {
  68667. r: float;
  68668. g: float;
  68669. b: float;
  68670. }
  68671. /**
  68672. * @hidden
  68673. */
  68674. export interface IVector4Like {
  68675. x: float;
  68676. y: float;
  68677. z: float;
  68678. w: float;
  68679. }
  68680. /**
  68681. * @hidden
  68682. */
  68683. export interface IVector3Like {
  68684. x: float;
  68685. y: float;
  68686. z: float;
  68687. }
  68688. /**
  68689. * @hidden
  68690. */
  68691. export interface IVector2Like {
  68692. x: float;
  68693. y: float;
  68694. }
  68695. /**
  68696. * @hidden
  68697. */
  68698. export interface IMatrixLike {
  68699. toArray(): DeepImmutable<Float32Array>;
  68700. updateFlag: int;
  68701. }
  68702. /**
  68703. * @hidden
  68704. */
  68705. export interface IViewportLike {
  68706. x: float;
  68707. y: float;
  68708. width: float;
  68709. height: float;
  68710. }
  68711. /**
  68712. * @hidden
  68713. */
  68714. export interface IPlaneLike {
  68715. normal: IVector3Like;
  68716. d: float;
  68717. normalize(): void;
  68718. }
  68719. }
  68720. declare module BABYLON {
  68721. /**
  68722. * Interface used to define common properties for effect fallbacks
  68723. */
  68724. export interface IEffectFallbacks {
  68725. /**
  68726. * Removes the defines that should be removed when falling back.
  68727. * @param currentDefines defines the current define statements for the shader.
  68728. * @param effect defines the current effect we try to compile
  68729. * @returns The resulting defines with defines of the current rank removed.
  68730. */
  68731. reduce(currentDefines: string, effect: Effect): string;
  68732. /**
  68733. * Removes the fallback from the bound mesh.
  68734. */
  68735. unBindMesh(): void;
  68736. /**
  68737. * Checks to see if more fallbacks are still availible.
  68738. */
  68739. hasMoreFallbacks: boolean;
  68740. }
  68741. }
  68742. declare module BABYLON {
  68743. /**
  68744. * Class used to evalaute queries containing `and` and `or` operators
  68745. */
  68746. export class AndOrNotEvaluator {
  68747. /**
  68748. * Evaluate a query
  68749. * @param query defines the query to evaluate
  68750. * @param evaluateCallback defines the callback used to filter result
  68751. * @returns true if the query matches
  68752. */
  68753. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68754. private static _HandleParenthesisContent;
  68755. private static _SimplifyNegation;
  68756. }
  68757. }
  68758. declare module BABYLON {
  68759. /**
  68760. * Class used to store custom tags
  68761. */
  68762. export class Tags {
  68763. /**
  68764. * Adds support for tags on the given object
  68765. * @param obj defines the object to use
  68766. */
  68767. static EnableFor(obj: any): void;
  68768. /**
  68769. * Removes tags support
  68770. * @param obj defines the object to use
  68771. */
  68772. static DisableFor(obj: any): void;
  68773. /**
  68774. * Gets a boolean indicating if the given object has tags
  68775. * @param obj defines the object to use
  68776. * @returns a boolean
  68777. */
  68778. static HasTags(obj: any): boolean;
  68779. /**
  68780. * Gets the tags available on a given object
  68781. * @param obj defines the object to use
  68782. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68783. * @returns the tags
  68784. */
  68785. static GetTags(obj: any, asString?: boolean): any;
  68786. /**
  68787. * Adds tags to an object
  68788. * @param obj defines the object to use
  68789. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68790. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68791. */
  68792. static AddTagsTo(obj: any, tagsString: string): void;
  68793. /**
  68794. * @hidden
  68795. */
  68796. static _AddTagTo(obj: any, tag: string): void;
  68797. /**
  68798. * Removes specific tags from a specific object
  68799. * @param obj defines the object to use
  68800. * @param tagsString defines the tags to remove
  68801. */
  68802. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68803. /**
  68804. * @hidden
  68805. */
  68806. static _RemoveTagFrom(obj: any, tag: string): void;
  68807. /**
  68808. * Defines if tags hosted on an object match a given query
  68809. * @param obj defines the object to use
  68810. * @param tagsQuery defines the tag query
  68811. * @returns a boolean
  68812. */
  68813. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68814. }
  68815. }
  68816. declare module BABYLON {
  68817. /**
  68818. * Scalar computation library
  68819. */
  68820. export class Scalar {
  68821. /**
  68822. * Two pi constants convenient for computation.
  68823. */
  68824. static TwoPi: number;
  68825. /**
  68826. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68827. * @param a number
  68828. * @param b number
  68829. * @param epsilon (default = 1.401298E-45)
  68830. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68831. */
  68832. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68833. /**
  68834. * Returns a string : the upper case translation of the number i to hexadecimal.
  68835. * @param i number
  68836. * @returns the upper case translation of the number i to hexadecimal.
  68837. */
  68838. static ToHex(i: number): string;
  68839. /**
  68840. * Returns -1 if value is negative and +1 is value is positive.
  68841. * @param value the value
  68842. * @returns the value itself if it's equal to zero.
  68843. */
  68844. static Sign(value: number): number;
  68845. /**
  68846. * Returns the value itself if it's between min and max.
  68847. * Returns min if the value is lower than min.
  68848. * Returns max if the value is greater than max.
  68849. * @param value the value to clmap
  68850. * @param min the min value to clamp to (default: 0)
  68851. * @param max the max value to clamp to (default: 1)
  68852. * @returns the clamped value
  68853. */
  68854. static Clamp(value: number, min?: number, max?: number): number;
  68855. /**
  68856. * the log2 of value.
  68857. * @param value the value to compute log2 of
  68858. * @returns the log2 of value.
  68859. */
  68860. static Log2(value: number): number;
  68861. /**
  68862. * Loops the value, so that it is never larger than length and never smaller than 0.
  68863. *
  68864. * This is similar to the modulo operator but it works with floating point numbers.
  68865. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68866. * With t = 5 and length = 2.5, the result would be 0.0.
  68867. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68868. * @param value the value
  68869. * @param length the length
  68870. * @returns the looped value
  68871. */
  68872. static Repeat(value: number, length: number): number;
  68873. /**
  68874. * Normalize the value between 0.0 and 1.0 using min and max values
  68875. * @param value value to normalize
  68876. * @param min max to normalize between
  68877. * @param max min to normalize between
  68878. * @returns the normalized value
  68879. */
  68880. static Normalize(value: number, min: number, max: number): number;
  68881. /**
  68882. * Denormalize the value from 0.0 and 1.0 using min and max values
  68883. * @param normalized value to denormalize
  68884. * @param min max to denormalize between
  68885. * @param max min to denormalize between
  68886. * @returns the denormalized value
  68887. */
  68888. static Denormalize(normalized: number, min: number, max: number): number;
  68889. /**
  68890. * Calculates the shortest difference between two given angles given in degrees.
  68891. * @param current current angle in degrees
  68892. * @param target target angle in degrees
  68893. * @returns the delta
  68894. */
  68895. static DeltaAngle(current: number, target: number): number;
  68896. /**
  68897. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68898. * @param tx value
  68899. * @param length length
  68900. * @returns The returned value will move back and forth between 0 and length
  68901. */
  68902. static PingPong(tx: number, length: number): number;
  68903. /**
  68904. * Interpolates between min and max with smoothing at the limits.
  68905. *
  68906. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68907. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68908. * @param from from
  68909. * @param to to
  68910. * @param tx value
  68911. * @returns the smooth stepped value
  68912. */
  68913. static SmoothStep(from: number, to: number, tx: number): number;
  68914. /**
  68915. * Moves a value current towards target.
  68916. *
  68917. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68918. * Negative values of maxDelta pushes the value away from target.
  68919. * @param current current value
  68920. * @param target target value
  68921. * @param maxDelta max distance to move
  68922. * @returns resulting value
  68923. */
  68924. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68925. /**
  68926. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68927. *
  68928. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68929. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68930. * @param current current value
  68931. * @param target target value
  68932. * @param maxDelta max distance to move
  68933. * @returns resulting angle
  68934. */
  68935. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68936. /**
  68937. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68938. * @param start start value
  68939. * @param end target value
  68940. * @param amount amount to lerp between
  68941. * @returns the lerped value
  68942. */
  68943. static Lerp(start: number, end: number, amount: number): number;
  68944. /**
  68945. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68946. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68947. * @param start start value
  68948. * @param end target value
  68949. * @param amount amount to lerp between
  68950. * @returns the lerped value
  68951. */
  68952. static LerpAngle(start: number, end: number, amount: number): number;
  68953. /**
  68954. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68955. * @param a start value
  68956. * @param b target value
  68957. * @param value value between a and b
  68958. * @returns the inverseLerp value
  68959. */
  68960. static InverseLerp(a: number, b: number, value: number): number;
  68961. /**
  68962. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68963. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68964. * @param value1 spline value
  68965. * @param tangent1 spline value
  68966. * @param value2 spline value
  68967. * @param tangent2 spline value
  68968. * @param amount input value
  68969. * @returns hermite result
  68970. */
  68971. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68972. /**
  68973. * Returns a random float number between and min and max values
  68974. * @param min min value of random
  68975. * @param max max value of random
  68976. * @returns random value
  68977. */
  68978. static RandomRange(min: number, max: number): number;
  68979. /**
  68980. * This function returns percentage of a number in a given range.
  68981. *
  68982. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68983. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68984. * @param number to convert to percentage
  68985. * @param min min range
  68986. * @param max max range
  68987. * @returns the percentage
  68988. */
  68989. static RangeToPercent(number: number, min: number, max: number): number;
  68990. /**
  68991. * This function returns number that corresponds to the percentage in a given range.
  68992. *
  68993. * PercentToRange(0.34,0,100) will return 34.
  68994. * @param percent to convert to number
  68995. * @param min min range
  68996. * @param max max range
  68997. * @returns the number
  68998. */
  68999. static PercentToRange(percent: number, min: number, max: number): number;
  69000. /**
  69001. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69002. * @param angle The angle to normalize in radian.
  69003. * @return The converted angle.
  69004. */
  69005. static NormalizeRadians(angle: number): number;
  69006. }
  69007. }
  69008. declare module BABYLON {
  69009. /**
  69010. * Constant used to convert a value to gamma space
  69011. * @ignorenaming
  69012. */
  69013. export const ToGammaSpace: number;
  69014. /**
  69015. * Constant used to convert a value to linear space
  69016. * @ignorenaming
  69017. */
  69018. export const ToLinearSpace = 2.2;
  69019. /**
  69020. * Constant used to define the minimal number value in Babylon.js
  69021. * @ignorenaming
  69022. */
  69023. let Epsilon: number;
  69024. }
  69025. declare module BABYLON {
  69026. /**
  69027. * Class used to represent a viewport on screen
  69028. */
  69029. export class Viewport {
  69030. /** viewport left coordinate */
  69031. x: number;
  69032. /** viewport top coordinate */
  69033. y: number;
  69034. /**viewport width */
  69035. width: number;
  69036. /** viewport height */
  69037. height: number;
  69038. /**
  69039. * Creates a Viewport object located at (x, y) and sized (width, height)
  69040. * @param x defines viewport left coordinate
  69041. * @param y defines viewport top coordinate
  69042. * @param width defines the viewport width
  69043. * @param height defines the viewport height
  69044. */
  69045. constructor(
  69046. /** viewport left coordinate */
  69047. x: number,
  69048. /** viewport top coordinate */
  69049. y: number,
  69050. /**viewport width */
  69051. width: number,
  69052. /** viewport height */
  69053. height: number);
  69054. /**
  69055. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69056. * @param renderWidth defines the rendering width
  69057. * @param renderHeight defines the rendering height
  69058. * @returns a new Viewport
  69059. */
  69060. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69061. /**
  69062. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69063. * @param renderWidth defines the rendering width
  69064. * @param renderHeight defines the rendering height
  69065. * @param ref defines the target viewport
  69066. * @returns the current viewport
  69067. */
  69068. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69069. /**
  69070. * Returns a new Viewport copied from the current one
  69071. * @returns a new Viewport
  69072. */
  69073. clone(): Viewport;
  69074. }
  69075. }
  69076. declare module BABYLON {
  69077. /**
  69078. * Class containing a set of static utilities functions for arrays.
  69079. */
  69080. export class ArrayTools {
  69081. /**
  69082. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69083. * @param size the number of element to construct and put in the array
  69084. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69085. * @returns a new array filled with new objects
  69086. */
  69087. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69088. }
  69089. }
  69090. declare module BABYLON {
  69091. /**
  69092. * Class representing a vector containing 2 coordinates
  69093. */
  69094. export class Vector2 {
  69095. /** defines the first coordinate */
  69096. x: number;
  69097. /** defines the second coordinate */
  69098. y: number;
  69099. /**
  69100. * Creates a new Vector2 from the given x and y coordinates
  69101. * @param x defines the first coordinate
  69102. * @param y defines the second coordinate
  69103. */
  69104. constructor(
  69105. /** defines the first coordinate */
  69106. x?: number,
  69107. /** defines the second coordinate */
  69108. y?: number);
  69109. /**
  69110. * Gets a string with the Vector2 coordinates
  69111. * @returns a string with the Vector2 coordinates
  69112. */
  69113. toString(): string;
  69114. /**
  69115. * Gets class name
  69116. * @returns the string "Vector2"
  69117. */
  69118. getClassName(): string;
  69119. /**
  69120. * Gets current vector hash code
  69121. * @returns the Vector2 hash code as a number
  69122. */
  69123. getHashCode(): number;
  69124. /**
  69125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69126. * @param array defines the source array
  69127. * @param index defines the offset in source array
  69128. * @returns the current Vector2
  69129. */
  69130. toArray(array: FloatArray, index?: number): Vector2;
  69131. /**
  69132. * Copy the current vector to an array
  69133. * @returns a new array with 2 elements: the Vector2 coordinates.
  69134. */
  69135. asArray(): number[];
  69136. /**
  69137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69138. * @param source defines the source Vector2
  69139. * @returns the current updated Vector2
  69140. */
  69141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69142. /**
  69143. * Sets the Vector2 coordinates with the given floats
  69144. * @param x defines the first coordinate
  69145. * @param y defines the second coordinate
  69146. * @returns the current updated Vector2
  69147. */
  69148. copyFromFloats(x: number, y: number): Vector2;
  69149. /**
  69150. * Sets the Vector2 coordinates with the given floats
  69151. * @param x defines the first coordinate
  69152. * @param y defines the second coordinate
  69153. * @returns the current updated Vector2
  69154. */
  69155. set(x: number, y: number): Vector2;
  69156. /**
  69157. * Add another vector with the current one
  69158. * @param otherVector defines the other vector
  69159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69160. */
  69161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69162. /**
  69163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69164. * @param otherVector defines the other vector
  69165. * @param result defines the target vector
  69166. * @returns the unmodified current Vector2
  69167. */
  69168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69169. /**
  69170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69171. * @param otherVector defines the other vector
  69172. * @returns the current updated Vector2
  69173. */
  69174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69175. /**
  69176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69177. * @param otherVector defines the other vector
  69178. * @returns a new Vector2
  69179. */
  69180. addVector3(otherVector: Vector3): Vector2;
  69181. /**
  69182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69183. * @param otherVector defines the other vector
  69184. * @returns a new Vector2
  69185. */
  69186. subtract(otherVector: Vector2): Vector2;
  69187. /**
  69188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69189. * @param otherVector defines the other vector
  69190. * @param result defines the target vector
  69191. * @returns the unmodified current Vector2
  69192. */
  69193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69194. /**
  69195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69196. * @param otherVector defines the other vector
  69197. * @returns the current updated Vector2
  69198. */
  69199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69200. /**
  69201. * Multiplies in place the current Vector2 coordinates by the given ones
  69202. * @param otherVector defines the other vector
  69203. * @returns the current updated Vector2
  69204. */
  69205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69206. /**
  69207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69208. * @param otherVector defines the other vector
  69209. * @returns a new Vector2
  69210. */
  69211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69212. /**
  69213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69214. * @param otherVector defines the other vector
  69215. * @param result defines the target vector
  69216. * @returns the unmodified current Vector2
  69217. */
  69218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69219. /**
  69220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69221. * @param x defines the first coordinate
  69222. * @param y defines the second coordinate
  69223. * @returns a new Vector2
  69224. */
  69225. multiplyByFloats(x: number, y: number): Vector2;
  69226. /**
  69227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69228. * @param otherVector defines the other vector
  69229. * @returns a new Vector2
  69230. */
  69231. divide(otherVector: Vector2): Vector2;
  69232. /**
  69233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69234. * @param otherVector defines the other vector
  69235. * @param result defines the target vector
  69236. * @returns the unmodified current Vector2
  69237. */
  69238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69239. /**
  69240. * Divides the current Vector2 coordinates by the given ones
  69241. * @param otherVector defines the other vector
  69242. * @returns the current updated Vector2
  69243. */
  69244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69245. /**
  69246. * Gets a new Vector2 with current Vector2 negated coordinates
  69247. * @returns a new Vector2
  69248. */
  69249. negate(): Vector2;
  69250. /**
  69251. * Multiply the Vector2 coordinates by scale
  69252. * @param scale defines the scaling factor
  69253. * @returns the current updated Vector2
  69254. */
  69255. scaleInPlace(scale: number): Vector2;
  69256. /**
  69257. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69258. * @param scale defines the scaling factor
  69259. * @returns a new Vector2
  69260. */
  69261. scale(scale: number): Vector2;
  69262. /**
  69263. * Scale the current Vector2 values by a factor to a given Vector2
  69264. * @param scale defines the scale factor
  69265. * @param result defines the Vector2 object where to store the result
  69266. * @returns the unmodified current Vector2
  69267. */
  69268. scaleToRef(scale: number, result: Vector2): Vector2;
  69269. /**
  69270. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69271. * @param scale defines the scale factor
  69272. * @param result defines the Vector2 object where to store the result
  69273. * @returns the unmodified current Vector2
  69274. */
  69275. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69276. /**
  69277. * Gets a boolean if two vectors are equals
  69278. * @param otherVector defines the other vector
  69279. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69280. */
  69281. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69282. /**
  69283. * Gets a boolean if two vectors are equals (using an epsilon value)
  69284. * @param otherVector defines the other vector
  69285. * @param epsilon defines the minimal distance to consider equality
  69286. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69287. */
  69288. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69289. /**
  69290. * Gets a new Vector2 from current Vector2 floored values
  69291. * @returns a new Vector2
  69292. */
  69293. floor(): Vector2;
  69294. /**
  69295. * Gets a new Vector2 from current Vector2 floored values
  69296. * @returns a new Vector2
  69297. */
  69298. fract(): Vector2;
  69299. /**
  69300. * Gets the length of the vector
  69301. * @returns the vector length (float)
  69302. */
  69303. length(): number;
  69304. /**
  69305. * Gets the vector squared length
  69306. * @returns the vector squared length (float)
  69307. */
  69308. lengthSquared(): number;
  69309. /**
  69310. * Normalize the vector
  69311. * @returns the current updated Vector2
  69312. */
  69313. normalize(): Vector2;
  69314. /**
  69315. * Gets a new Vector2 copied from the Vector2
  69316. * @returns a new Vector2
  69317. */
  69318. clone(): Vector2;
  69319. /**
  69320. * Gets a new Vector2(0, 0)
  69321. * @returns a new Vector2
  69322. */
  69323. static Zero(): Vector2;
  69324. /**
  69325. * Gets a new Vector2(1, 1)
  69326. * @returns a new Vector2
  69327. */
  69328. static One(): Vector2;
  69329. /**
  69330. * Gets a new Vector2 set from the given index element of the given array
  69331. * @param array defines the data source
  69332. * @param offset defines the offset in the data source
  69333. * @returns a new Vector2
  69334. */
  69335. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69336. /**
  69337. * Sets "result" from the given index element of the given array
  69338. * @param array defines the data source
  69339. * @param offset defines the offset in the data source
  69340. * @param result defines the target vector
  69341. */
  69342. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69343. /**
  69344. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69345. * @param value1 defines 1st point of control
  69346. * @param value2 defines 2nd point of control
  69347. * @param value3 defines 3rd point of control
  69348. * @param value4 defines 4th point of control
  69349. * @param amount defines the interpolation factor
  69350. * @returns a new Vector2
  69351. */
  69352. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69353. /**
  69354. * 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".
  69355. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69356. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69357. * @param value defines the value to clamp
  69358. * @param min defines the lower limit
  69359. * @param max defines the upper limit
  69360. * @returns a new Vector2
  69361. */
  69362. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69363. /**
  69364. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69365. * @param value1 defines the 1st control point
  69366. * @param tangent1 defines the outgoing tangent
  69367. * @param value2 defines the 2nd control point
  69368. * @param tangent2 defines the incoming tangent
  69369. * @param amount defines the interpolation factor
  69370. * @returns a new Vector2
  69371. */
  69372. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69373. /**
  69374. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69375. * @param start defines the start vector
  69376. * @param end defines the end vector
  69377. * @param amount defines the interpolation factor
  69378. * @returns a new Vector2
  69379. */
  69380. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69381. /**
  69382. * Gets the dot product of the vector "left" and the vector "right"
  69383. * @param left defines first vector
  69384. * @param right defines second vector
  69385. * @returns the dot product (float)
  69386. */
  69387. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69388. /**
  69389. * Returns a new Vector2 equal to the normalized given vector
  69390. * @param vector defines the vector to normalize
  69391. * @returns a new Vector2
  69392. */
  69393. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69394. /**
  69395. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69396. * @param left defines 1st vector
  69397. * @param right defines 2nd vector
  69398. * @returns a new Vector2
  69399. */
  69400. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69401. /**
  69402. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69403. * @param left defines 1st vector
  69404. * @param right defines 2nd vector
  69405. * @returns a new Vector2
  69406. */
  69407. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69408. /**
  69409. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69410. * @param vector defines the vector to transform
  69411. * @param transformation defines the matrix to apply
  69412. * @returns a new Vector2
  69413. */
  69414. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69415. /**
  69416. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69417. * @param vector defines the vector to transform
  69418. * @param transformation defines the matrix to apply
  69419. * @param result defines the target vector
  69420. */
  69421. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69422. /**
  69423. * Determines if a given vector is included in a triangle
  69424. * @param p defines the vector to test
  69425. * @param p0 defines 1st triangle point
  69426. * @param p1 defines 2nd triangle point
  69427. * @param p2 defines 3rd triangle point
  69428. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69429. */
  69430. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69431. /**
  69432. * Gets the distance between the vectors "value1" and "value2"
  69433. * @param value1 defines first vector
  69434. * @param value2 defines second vector
  69435. * @returns the distance between vectors
  69436. */
  69437. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69438. /**
  69439. * Returns the squared distance between the vectors "value1" and "value2"
  69440. * @param value1 defines first vector
  69441. * @param value2 defines second vector
  69442. * @returns the squared distance between vectors
  69443. */
  69444. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69445. /**
  69446. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69447. * @param value1 defines first vector
  69448. * @param value2 defines second vector
  69449. * @returns a new Vector2
  69450. */
  69451. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69452. /**
  69453. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69454. * @param p defines the middle point
  69455. * @param segA defines one point of the segment
  69456. * @param segB defines the other point of the segment
  69457. * @returns the shortest distance
  69458. */
  69459. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69460. }
  69461. /**
  69462. * Classed used to store (x,y,z) vector representation
  69463. * A Vector3 is the main object used in 3D geometry
  69464. * It can represent etiher the coordinates of a point the space, either a direction
  69465. * Reminder: js uses a left handed forward facing system
  69466. */
  69467. export class Vector3 {
  69468. /**
  69469. * Defines the first coordinates (on X axis)
  69470. */
  69471. x: number;
  69472. /**
  69473. * Defines the second coordinates (on Y axis)
  69474. */
  69475. y: number;
  69476. /**
  69477. * Defines the third coordinates (on Z axis)
  69478. */
  69479. z: number;
  69480. private static _UpReadOnly;
  69481. private static _ZeroReadOnly;
  69482. /**
  69483. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69484. * @param x defines the first coordinates (on X axis)
  69485. * @param y defines the second coordinates (on Y axis)
  69486. * @param z defines the third coordinates (on Z axis)
  69487. */
  69488. constructor(
  69489. /**
  69490. * Defines the first coordinates (on X axis)
  69491. */
  69492. x?: number,
  69493. /**
  69494. * Defines the second coordinates (on Y axis)
  69495. */
  69496. y?: number,
  69497. /**
  69498. * Defines the third coordinates (on Z axis)
  69499. */
  69500. z?: number);
  69501. /**
  69502. * Creates a string representation of the Vector3
  69503. * @returns a string with the Vector3 coordinates.
  69504. */
  69505. toString(): string;
  69506. /**
  69507. * Gets the class name
  69508. * @returns the string "Vector3"
  69509. */
  69510. getClassName(): string;
  69511. /**
  69512. * Creates the Vector3 hash code
  69513. * @returns a number which tends to be unique between Vector3 instances
  69514. */
  69515. getHashCode(): number;
  69516. /**
  69517. * Creates an array containing three elements : the coordinates of the Vector3
  69518. * @returns a new array of numbers
  69519. */
  69520. asArray(): number[];
  69521. /**
  69522. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69523. * @param array defines the destination array
  69524. * @param index defines the offset in the destination array
  69525. * @returns the current Vector3
  69526. */
  69527. toArray(array: FloatArray, index?: number): Vector3;
  69528. /**
  69529. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69530. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69531. */
  69532. toQuaternion(): Quaternion;
  69533. /**
  69534. * Adds the given vector to the current Vector3
  69535. * @param otherVector defines the second operand
  69536. * @returns the current updated Vector3
  69537. */
  69538. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69539. /**
  69540. * Adds the given coordinates to the current Vector3
  69541. * @param x defines the x coordinate of the operand
  69542. * @param y defines the y coordinate of the operand
  69543. * @param z defines the z coordinate of the operand
  69544. * @returns the current updated Vector3
  69545. */
  69546. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69547. /**
  69548. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69549. * @param otherVector defines the second operand
  69550. * @returns the resulting Vector3
  69551. */
  69552. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69553. /**
  69554. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69555. * @param otherVector defines the second operand
  69556. * @param result defines the Vector3 object where to store the result
  69557. * @returns the current Vector3
  69558. */
  69559. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69560. /**
  69561. * Subtract the given vector from the current Vector3
  69562. * @param otherVector defines the second operand
  69563. * @returns the current updated Vector3
  69564. */
  69565. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69566. /**
  69567. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69568. * @param otherVector defines the second operand
  69569. * @returns the resulting Vector3
  69570. */
  69571. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69572. /**
  69573. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69574. * @param otherVector defines the second operand
  69575. * @param result defines the Vector3 object where to store the result
  69576. * @returns the current Vector3
  69577. */
  69578. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69579. /**
  69580. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69581. * @param x defines the x coordinate of the operand
  69582. * @param y defines the y coordinate of the operand
  69583. * @param z defines the z coordinate of the operand
  69584. * @returns the resulting Vector3
  69585. */
  69586. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69587. /**
  69588. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69589. * @param x defines the x coordinate of the operand
  69590. * @param y defines the y coordinate of the operand
  69591. * @param z defines the z coordinate of the operand
  69592. * @param result defines the Vector3 object where to store the result
  69593. * @returns the current Vector3
  69594. */
  69595. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69596. /**
  69597. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69598. * @returns a new Vector3
  69599. */
  69600. negate(): Vector3;
  69601. /**
  69602. * Multiplies the Vector3 coordinates by the float "scale"
  69603. * @param scale defines the multiplier factor
  69604. * @returns the current updated Vector3
  69605. */
  69606. scaleInPlace(scale: number): Vector3;
  69607. /**
  69608. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69609. * @param scale defines the multiplier factor
  69610. * @returns a new Vector3
  69611. */
  69612. scale(scale: number): Vector3;
  69613. /**
  69614. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69615. * @param scale defines the multiplier factor
  69616. * @param result defines the Vector3 object where to store the result
  69617. * @returns the current Vector3
  69618. */
  69619. scaleToRef(scale: number, result: Vector3): Vector3;
  69620. /**
  69621. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69622. * @param scale defines the scale factor
  69623. * @param result defines the Vector3 object where to store the result
  69624. * @returns the unmodified current Vector3
  69625. */
  69626. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69627. /**
  69628. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69629. * @param otherVector defines the second operand
  69630. * @returns true if both vectors are equals
  69631. */
  69632. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69633. /**
  69634. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69635. * @param otherVector defines the second operand
  69636. * @param epsilon defines the minimal distance to define values as equals
  69637. * @returns true if both vectors are distant less than epsilon
  69638. */
  69639. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69640. /**
  69641. * Returns true if the current Vector3 coordinates equals the given floats
  69642. * @param x defines the x coordinate of the operand
  69643. * @param y defines the y coordinate of the operand
  69644. * @param z defines the z coordinate of the operand
  69645. * @returns true if both vectors are equals
  69646. */
  69647. equalsToFloats(x: number, y: number, z: number): boolean;
  69648. /**
  69649. * Multiplies the current Vector3 coordinates by the given ones
  69650. * @param otherVector defines the second operand
  69651. * @returns the current updated Vector3
  69652. */
  69653. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69654. /**
  69655. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69656. * @param otherVector defines the second operand
  69657. * @returns the new Vector3
  69658. */
  69659. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69660. /**
  69661. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69662. * @param otherVector defines the second operand
  69663. * @param result defines the Vector3 object where to store the result
  69664. * @returns the current Vector3
  69665. */
  69666. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69667. /**
  69668. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69669. * @param x defines the x coordinate of the operand
  69670. * @param y defines the y coordinate of the operand
  69671. * @param z defines the z coordinate of the operand
  69672. * @returns the new Vector3
  69673. */
  69674. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69675. /**
  69676. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69677. * @param otherVector defines the second operand
  69678. * @returns the new Vector3
  69679. */
  69680. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69681. /**
  69682. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69683. * @param otherVector defines the second operand
  69684. * @param result defines the Vector3 object where to store the result
  69685. * @returns the current Vector3
  69686. */
  69687. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69688. /**
  69689. * Divides the current Vector3 coordinates by the given ones.
  69690. * @param otherVector defines the second operand
  69691. * @returns the current updated Vector3
  69692. */
  69693. divideInPlace(otherVector: Vector3): Vector3;
  69694. /**
  69695. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69696. * @param other defines the second operand
  69697. * @returns the current updated Vector3
  69698. */
  69699. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69700. /**
  69701. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69702. * @param other defines the second operand
  69703. * @returns the current updated Vector3
  69704. */
  69705. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69706. /**
  69707. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69708. * @param x defines the x coordinate of the operand
  69709. * @param y defines the y coordinate of the operand
  69710. * @param z defines the z coordinate of the operand
  69711. * @returns the current updated Vector3
  69712. */
  69713. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69714. /**
  69715. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69716. * @param x defines the x coordinate of the operand
  69717. * @param y defines the y coordinate of the operand
  69718. * @param z defines the z coordinate of the operand
  69719. * @returns the current updated Vector3
  69720. */
  69721. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69722. /**
  69723. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69724. * Check if is non uniform within a certain amount of decimal places to account for this
  69725. * @param epsilon the amount the values can differ
  69726. * @returns if the the vector is non uniform to a certain number of decimal places
  69727. */
  69728. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69729. /**
  69730. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69731. */
  69732. readonly isNonUniform: boolean;
  69733. /**
  69734. * Gets a new Vector3 from current Vector3 floored values
  69735. * @returns a new Vector3
  69736. */
  69737. floor(): Vector3;
  69738. /**
  69739. * Gets a new Vector3 from current Vector3 floored values
  69740. * @returns a new Vector3
  69741. */
  69742. fract(): Vector3;
  69743. /**
  69744. * Gets the length of the Vector3
  69745. * @returns the length of the Vector3
  69746. */
  69747. length(): number;
  69748. /**
  69749. * Gets the squared length of the Vector3
  69750. * @returns squared length of the Vector3
  69751. */
  69752. lengthSquared(): number;
  69753. /**
  69754. * Normalize the current Vector3.
  69755. * Please note that this is an in place operation.
  69756. * @returns the current updated Vector3
  69757. */
  69758. normalize(): Vector3;
  69759. /**
  69760. * Reorders the x y z properties of the vector in place
  69761. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69762. * @returns the current updated vector
  69763. */
  69764. reorderInPlace(order: string): this;
  69765. /**
  69766. * Rotates the vector around 0,0,0 by a quaternion
  69767. * @param quaternion the rotation quaternion
  69768. * @param result vector to store the result
  69769. * @returns the resulting vector
  69770. */
  69771. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69772. /**
  69773. * Rotates a vector around a given point
  69774. * @param quaternion the rotation quaternion
  69775. * @param point the point to rotate around
  69776. * @param result vector to store the result
  69777. * @returns the resulting vector
  69778. */
  69779. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69780. /**
  69781. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69782. * The cross product is then orthogonal to both current and "other"
  69783. * @param other defines the right operand
  69784. * @returns the cross product
  69785. */
  69786. cross(other: Vector3): Vector3;
  69787. /**
  69788. * Normalize the current Vector3 with the given input length.
  69789. * Please note that this is an in place operation.
  69790. * @param len the length of the vector
  69791. * @returns the current updated Vector3
  69792. */
  69793. normalizeFromLength(len: number): Vector3;
  69794. /**
  69795. * Normalize the current Vector3 to a new vector
  69796. * @returns the new Vector3
  69797. */
  69798. normalizeToNew(): Vector3;
  69799. /**
  69800. * Normalize the current Vector3 to the reference
  69801. * @param reference define the Vector3 to update
  69802. * @returns the updated Vector3
  69803. */
  69804. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69805. /**
  69806. * Creates a new Vector3 copied from the current Vector3
  69807. * @returns the new Vector3
  69808. */
  69809. clone(): Vector3;
  69810. /**
  69811. * Copies the given vector coordinates to the current Vector3 ones
  69812. * @param source defines the source Vector3
  69813. * @returns the current updated Vector3
  69814. */
  69815. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69816. /**
  69817. * Copies the given floats to the current Vector3 coordinates
  69818. * @param x defines the x coordinate of the operand
  69819. * @param y defines the y coordinate of the operand
  69820. * @param z defines the z coordinate of the operand
  69821. * @returns the current updated Vector3
  69822. */
  69823. copyFromFloats(x: number, y: number, z: number): Vector3;
  69824. /**
  69825. * Copies the given floats to the current Vector3 coordinates
  69826. * @param x defines the x coordinate of the operand
  69827. * @param y defines the y coordinate of the operand
  69828. * @param z defines the z coordinate of the operand
  69829. * @returns the current updated Vector3
  69830. */
  69831. set(x: number, y: number, z: number): Vector3;
  69832. /**
  69833. * Copies the given float to the current Vector3 coordinates
  69834. * @param v defines the x, y and z coordinates of the operand
  69835. * @returns the current updated Vector3
  69836. */
  69837. setAll(v: number): Vector3;
  69838. /**
  69839. * Get the clip factor between two vectors
  69840. * @param vector0 defines the first operand
  69841. * @param vector1 defines the second operand
  69842. * @param axis defines the axis to use
  69843. * @param size defines the size along the axis
  69844. * @returns the clip factor
  69845. */
  69846. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69847. /**
  69848. * Get angle between two vectors
  69849. * @param vector0 angle between vector0 and vector1
  69850. * @param vector1 angle between vector0 and vector1
  69851. * @param normal direction of the normal
  69852. * @return the angle between vector0 and vector1
  69853. */
  69854. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69855. /**
  69856. * Returns a new Vector3 set from the index "offset" of the given array
  69857. * @param array defines the source array
  69858. * @param offset defines the offset in the source array
  69859. * @returns the new Vector3
  69860. */
  69861. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69862. /**
  69863. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69864. * This function is deprecated. Use FromArray instead
  69865. * @param array defines the source array
  69866. * @param offset defines the offset in the source array
  69867. * @returns the new Vector3
  69868. */
  69869. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69870. /**
  69871. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69872. * @param array defines the source array
  69873. * @param offset defines the offset in the source array
  69874. * @param result defines the Vector3 where to store the result
  69875. */
  69876. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69877. /**
  69878. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69879. * This function is deprecated. Use FromArrayToRef instead.
  69880. * @param array defines the source array
  69881. * @param offset defines the offset in the source array
  69882. * @param result defines the Vector3 where to store the result
  69883. */
  69884. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69885. /**
  69886. * Sets the given vector "result" with the given floats.
  69887. * @param x defines the x coordinate of the source
  69888. * @param y defines the y coordinate of the source
  69889. * @param z defines the z coordinate of the source
  69890. * @param result defines the Vector3 where to store the result
  69891. */
  69892. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69893. /**
  69894. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69895. * @returns a new empty Vector3
  69896. */
  69897. static Zero(): Vector3;
  69898. /**
  69899. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69900. * @returns a new unit Vector3
  69901. */
  69902. static One(): Vector3;
  69903. /**
  69904. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69905. * @returns a new up Vector3
  69906. */
  69907. static Up(): Vector3;
  69908. /**
  69909. * Gets a up Vector3 that must not be updated
  69910. */
  69911. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69912. /**
  69913. * Gets a zero Vector3 that must not be updated
  69914. */
  69915. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69916. /**
  69917. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69918. * @returns a new down Vector3
  69919. */
  69920. static Down(): Vector3;
  69921. /**
  69922. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69923. * @returns a new forward Vector3
  69924. */
  69925. static Forward(): Vector3;
  69926. /**
  69927. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69928. * @returns a new forward Vector3
  69929. */
  69930. static Backward(): Vector3;
  69931. /**
  69932. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69933. * @returns a new right Vector3
  69934. */
  69935. static Right(): Vector3;
  69936. /**
  69937. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69938. * @returns a new left Vector3
  69939. */
  69940. static Left(): Vector3;
  69941. /**
  69942. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69943. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69944. * @param vector defines the Vector3 to transform
  69945. * @param transformation defines the transformation matrix
  69946. * @returns the transformed Vector3
  69947. */
  69948. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69949. /**
  69950. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69951. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69952. * @param vector defines the Vector3 to transform
  69953. * @param transformation defines the transformation matrix
  69954. * @param result defines the Vector3 where to store the result
  69955. */
  69956. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69957. /**
  69958. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69959. * This method computes tranformed coordinates only, not transformed direction vectors
  69960. * @param x define the x coordinate of the source vector
  69961. * @param y define the y coordinate of the source vector
  69962. * @param z define the z coordinate of the source vector
  69963. * @param transformation defines the transformation matrix
  69964. * @param result defines the Vector3 where to store the result
  69965. */
  69966. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69967. /**
  69968. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69970. * @param vector defines the Vector3 to transform
  69971. * @param transformation defines the transformation matrix
  69972. * @returns the new Vector3
  69973. */
  69974. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69975. /**
  69976. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69977. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69978. * @param vector defines the Vector3 to transform
  69979. * @param transformation defines the transformation matrix
  69980. * @param result defines the Vector3 where to store the result
  69981. */
  69982. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69983. /**
  69984. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69985. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69986. * @param x define the x coordinate of the source vector
  69987. * @param y define the y coordinate of the source vector
  69988. * @param z define the z coordinate of the source vector
  69989. * @param transformation defines the transformation matrix
  69990. * @param result defines the Vector3 where to store the result
  69991. */
  69992. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69993. /**
  69994. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69995. * @param value1 defines the first control point
  69996. * @param value2 defines the second control point
  69997. * @param value3 defines the third control point
  69998. * @param value4 defines the fourth control point
  69999. * @param amount defines the amount on the spline to use
  70000. * @returns the new Vector3
  70001. */
  70002. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70003. /**
  70004. * 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"
  70005. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70006. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70007. * @param value defines the current value
  70008. * @param min defines the lower range value
  70009. * @param max defines the upper range value
  70010. * @returns the new Vector3
  70011. */
  70012. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70013. /**
  70014. * 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"
  70015. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70016. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70017. * @param value defines the current value
  70018. * @param min defines the lower range value
  70019. * @param max defines the upper range value
  70020. * @param result defines the Vector3 where to store the result
  70021. */
  70022. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70023. /**
  70024. * Checks if a given vector is inside a specific range
  70025. * @param v defines the vector to test
  70026. * @param min defines the minimum range
  70027. * @param max defines the maximum range
  70028. */
  70029. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70030. /**
  70031. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70032. * @param value1 defines the first control point
  70033. * @param tangent1 defines the first tangent vector
  70034. * @param value2 defines the second control point
  70035. * @param tangent2 defines the second tangent vector
  70036. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70037. * @returns the new Vector3
  70038. */
  70039. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70040. /**
  70041. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70042. * @param start defines the start value
  70043. * @param end defines the end value
  70044. * @param amount max defines amount between both (between 0 and 1)
  70045. * @returns the new Vector3
  70046. */
  70047. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70048. /**
  70049. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70050. * @param start defines the start value
  70051. * @param end defines the end value
  70052. * @param amount max defines amount between both (between 0 and 1)
  70053. * @param result defines the Vector3 where to store the result
  70054. */
  70055. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70056. /**
  70057. * Returns the dot product (float) between the vectors "left" and "right"
  70058. * @param left defines the left operand
  70059. * @param right defines the right operand
  70060. * @returns the dot product
  70061. */
  70062. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70063. /**
  70064. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70065. * The cross product is then orthogonal to both "left" and "right"
  70066. * @param left defines the left operand
  70067. * @param right defines the right operand
  70068. * @returns the cross product
  70069. */
  70070. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70071. /**
  70072. * Sets the given vector "result" with the cross product of "left" and "right"
  70073. * The cross product is then orthogonal to both "left" and "right"
  70074. * @param left defines the left operand
  70075. * @param right defines the right operand
  70076. * @param result defines the Vector3 where to store the result
  70077. */
  70078. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70079. /**
  70080. * Returns a new Vector3 as the normalization of the given vector
  70081. * @param vector defines the Vector3 to normalize
  70082. * @returns the new Vector3
  70083. */
  70084. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70085. /**
  70086. * Sets the given vector "result" with the normalization of the given first vector
  70087. * @param vector defines the Vector3 to normalize
  70088. * @param result defines the Vector3 where to store the result
  70089. */
  70090. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70091. /**
  70092. * Project a Vector3 onto screen space
  70093. * @param vector defines the Vector3 to project
  70094. * @param world defines the world matrix to use
  70095. * @param transform defines the transform (view x projection) matrix to use
  70096. * @param viewport defines the screen viewport to use
  70097. * @returns the new Vector3
  70098. */
  70099. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70100. /** @hidden */
  70101. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70102. /**
  70103. * Unproject from screen space to object space
  70104. * @param source defines the screen space Vector3 to use
  70105. * @param viewportWidth defines the current width of the viewport
  70106. * @param viewportHeight defines the current height of the viewport
  70107. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70108. * @param transform defines the transform (view x projection) matrix to use
  70109. * @returns the new Vector3
  70110. */
  70111. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70112. /**
  70113. * Unproject from screen space to object space
  70114. * @param source defines the screen space Vector3 to use
  70115. * @param viewportWidth defines the current width of the viewport
  70116. * @param viewportHeight defines the current height of the viewport
  70117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70118. * @param view defines the view matrix to use
  70119. * @param projection defines the projection matrix to use
  70120. * @returns the new Vector3
  70121. */
  70122. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70123. /**
  70124. * Unproject from screen space to object space
  70125. * @param source defines the screen space Vector3 to use
  70126. * @param viewportWidth defines the current width of the viewport
  70127. * @param viewportHeight defines the current height of the viewport
  70128. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70129. * @param view defines the view matrix to use
  70130. * @param projection defines the projection matrix to use
  70131. * @param result defines the Vector3 where to store the result
  70132. */
  70133. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70134. /**
  70135. * Unproject from screen space to object space
  70136. * @param sourceX defines the screen space x coordinate to use
  70137. * @param sourceY defines the screen space y coordinate to use
  70138. * @param sourceZ defines the screen space z coordinate to use
  70139. * @param viewportWidth defines the current width of the viewport
  70140. * @param viewportHeight defines the current height of the viewport
  70141. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70142. * @param view defines the view matrix to use
  70143. * @param projection defines the projection matrix to use
  70144. * @param result defines the Vector3 where to store the result
  70145. */
  70146. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70147. /**
  70148. * Gets the minimal coordinate values between two Vector3
  70149. * @param left defines the first operand
  70150. * @param right defines the second operand
  70151. * @returns the new Vector3
  70152. */
  70153. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70154. /**
  70155. * Gets the maximal coordinate values between two Vector3
  70156. * @param left defines the first operand
  70157. * @param right defines the second operand
  70158. * @returns the new Vector3
  70159. */
  70160. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70161. /**
  70162. * Returns the distance between the vectors "value1" and "value2"
  70163. * @param value1 defines the first operand
  70164. * @param value2 defines the second operand
  70165. * @returns the distance
  70166. */
  70167. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70168. /**
  70169. * Returns the squared distance between the vectors "value1" and "value2"
  70170. * @param value1 defines the first operand
  70171. * @param value2 defines the second operand
  70172. * @returns the squared distance
  70173. */
  70174. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70175. /**
  70176. * Returns a new Vector3 located at the center between "value1" and "value2"
  70177. * @param value1 defines the first operand
  70178. * @param value2 defines the second operand
  70179. * @returns the new Vector3
  70180. */
  70181. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70182. /**
  70183. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70184. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70185. * to something in order to rotate it from its local system to the given target system
  70186. * Note: axis1, axis2 and axis3 are normalized during this operation
  70187. * @param axis1 defines the first axis
  70188. * @param axis2 defines the second axis
  70189. * @param axis3 defines the third axis
  70190. * @returns a new Vector3
  70191. */
  70192. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70193. /**
  70194. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70195. * @param axis1 defines the first axis
  70196. * @param axis2 defines the second axis
  70197. * @param axis3 defines the third axis
  70198. * @param ref defines the Vector3 where to store the result
  70199. */
  70200. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70201. }
  70202. /**
  70203. * Vector4 class created for EulerAngle class conversion to Quaternion
  70204. */
  70205. export class Vector4 {
  70206. /** x value of the vector */
  70207. x: number;
  70208. /** y value of the vector */
  70209. y: number;
  70210. /** z value of the vector */
  70211. z: number;
  70212. /** w value of the vector */
  70213. w: number;
  70214. /**
  70215. * Creates a Vector4 object from the given floats.
  70216. * @param x x value of the vector
  70217. * @param y y value of the vector
  70218. * @param z z value of the vector
  70219. * @param w w value of the vector
  70220. */
  70221. constructor(
  70222. /** x value of the vector */
  70223. x: number,
  70224. /** y value of the vector */
  70225. y: number,
  70226. /** z value of the vector */
  70227. z: number,
  70228. /** w value of the vector */
  70229. w: number);
  70230. /**
  70231. * Returns the string with the Vector4 coordinates.
  70232. * @returns a string containing all the vector values
  70233. */
  70234. toString(): string;
  70235. /**
  70236. * Returns the string "Vector4".
  70237. * @returns "Vector4"
  70238. */
  70239. getClassName(): string;
  70240. /**
  70241. * Returns the Vector4 hash code.
  70242. * @returns a unique hash code
  70243. */
  70244. getHashCode(): number;
  70245. /**
  70246. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70247. * @returns the resulting array
  70248. */
  70249. asArray(): number[];
  70250. /**
  70251. * Populates the given array from the given index with the Vector4 coordinates.
  70252. * @param array array to populate
  70253. * @param index index of the array to start at (default: 0)
  70254. * @returns the Vector4.
  70255. */
  70256. toArray(array: FloatArray, index?: number): Vector4;
  70257. /**
  70258. * Adds the given vector to the current Vector4.
  70259. * @param otherVector the vector to add
  70260. * @returns the updated Vector4.
  70261. */
  70262. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70263. /**
  70264. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70265. * @param otherVector the vector to add
  70266. * @returns the resulting vector
  70267. */
  70268. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70269. /**
  70270. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70271. * @param otherVector the vector to add
  70272. * @param result the vector to store the result
  70273. * @returns the current Vector4.
  70274. */
  70275. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70276. /**
  70277. * Subtract in place the given vector from the current Vector4.
  70278. * @param otherVector the vector to subtract
  70279. * @returns the updated Vector4.
  70280. */
  70281. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70282. /**
  70283. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70284. * @param otherVector the vector to add
  70285. * @returns the new vector with the result
  70286. */
  70287. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70288. /**
  70289. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70290. * @param otherVector the vector to subtract
  70291. * @param result the vector to store the result
  70292. * @returns the current Vector4.
  70293. */
  70294. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70295. /**
  70296. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70297. */
  70298. /**
  70299. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70300. * @param x value to subtract
  70301. * @param y value to subtract
  70302. * @param z value to subtract
  70303. * @param w value to subtract
  70304. * @returns new vector containing the result
  70305. */
  70306. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70307. /**
  70308. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70309. * @param x value to subtract
  70310. * @param y value to subtract
  70311. * @param z value to subtract
  70312. * @param w value to subtract
  70313. * @param result the vector to store the result in
  70314. * @returns the current Vector4.
  70315. */
  70316. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70317. /**
  70318. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70319. * @returns a new vector with the negated values
  70320. */
  70321. negate(): Vector4;
  70322. /**
  70323. * Multiplies the current Vector4 coordinates by scale (float).
  70324. * @param scale the number to scale with
  70325. * @returns the updated Vector4.
  70326. */
  70327. scaleInPlace(scale: number): Vector4;
  70328. /**
  70329. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70330. * @param scale the number to scale with
  70331. * @returns a new vector with the result
  70332. */
  70333. scale(scale: number): Vector4;
  70334. /**
  70335. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70336. * @param scale the number to scale with
  70337. * @param result a vector to store the result in
  70338. * @returns the current Vector4.
  70339. */
  70340. scaleToRef(scale: number, result: Vector4): Vector4;
  70341. /**
  70342. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70343. * @param scale defines the scale factor
  70344. * @param result defines the Vector4 object where to store the result
  70345. * @returns the unmodified current Vector4
  70346. */
  70347. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70348. /**
  70349. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70350. * @param otherVector the vector to compare against
  70351. * @returns true if they are equal
  70352. */
  70353. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70354. /**
  70355. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70356. * @param otherVector vector to compare against
  70357. * @param epsilon (Default: very small number)
  70358. * @returns true if they are equal
  70359. */
  70360. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70361. /**
  70362. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70363. * @param x x value to compare against
  70364. * @param y y value to compare against
  70365. * @param z z value to compare against
  70366. * @param w w value to compare against
  70367. * @returns true if equal
  70368. */
  70369. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70370. /**
  70371. * Multiplies in place the current Vector4 by the given one.
  70372. * @param otherVector vector to multiple with
  70373. * @returns the updated Vector4.
  70374. */
  70375. multiplyInPlace(otherVector: Vector4): Vector4;
  70376. /**
  70377. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70378. * @param otherVector vector to multiple with
  70379. * @returns resulting new vector
  70380. */
  70381. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70382. /**
  70383. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70384. * @param otherVector vector to multiple with
  70385. * @param result vector to store the result
  70386. * @returns the current Vector4.
  70387. */
  70388. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70389. /**
  70390. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70391. * @param x x value multiply with
  70392. * @param y y value multiply with
  70393. * @param z z value multiply with
  70394. * @param w w value multiply with
  70395. * @returns resulting new vector
  70396. */
  70397. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70398. /**
  70399. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70400. * @param otherVector vector to devide with
  70401. * @returns resulting new vector
  70402. */
  70403. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70404. /**
  70405. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70406. * @param otherVector vector to devide with
  70407. * @param result vector to store the result
  70408. * @returns the current Vector4.
  70409. */
  70410. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70411. /**
  70412. * Divides the current Vector3 coordinates by the given ones.
  70413. * @param otherVector vector to devide with
  70414. * @returns the updated Vector3.
  70415. */
  70416. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70417. /**
  70418. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70419. * @param other defines the second operand
  70420. * @returns the current updated Vector4
  70421. */
  70422. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70423. /**
  70424. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70425. * @param other defines the second operand
  70426. * @returns the current updated Vector4
  70427. */
  70428. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70429. /**
  70430. * Gets a new Vector4 from current Vector4 floored values
  70431. * @returns a new Vector4
  70432. */
  70433. floor(): Vector4;
  70434. /**
  70435. * Gets a new Vector4 from current Vector3 floored values
  70436. * @returns a new Vector4
  70437. */
  70438. fract(): Vector4;
  70439. /**
  70440. * Returns the Vector4 length (float).
  70441. * @returns the length
  70442. */
  70443. length(): number;
  70444. /**
  70445. * Returns the Vector4 squared length (float).
  70446. * @returns the length squared
  70447. */
  70448. lengthSquared(): number;
  70449. /**
  70450. * Normalizes in place the Vector4.
  70451. * @returns the updated Vector4.
  70452. */
  70453. normalize(): Vector4;
  70454. /**
  70455. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70456. * @returns this converted to a new vector3
  70457. */
  70458. toVector3(): Vector3;
  70459. /**
  70460. * Returns a new Vector4 copied from the current one.
  70461. * @returns the new cloned vector
  70462. */
  70463. clone(): Vector4;
  70464. /**
  70465. * Updates the current Vector4 with the given one coordinates.
  70466. * @param source the source vector to copy from
  70467. * @returns the updated Vector4.
  70468. */
  70469. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70470. /**
  70471. * Updates the current Vector4 coordinates with the given floats.
  70472. * @param x float to copy from
  70473. * @param y float to copy from
  70474. * @param z float to copy from
  70475. * @param w float to copy from
  70476. * @returns the updated Vector4.
  70477. */
  70478. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70479. /**
  70480. * Updates the current Vector4 coordinates with the given floats.
  70481. * @param x float to set from
  70482. * @param y float to set from
  70483. * @param z float to set from
  70484. * @param w float to set from
  70485. * @returns the updated Vector4.
  70486. */
  70487. set(x: number, y: number, z: number, w: number): Vector4;
  70488. /**
  70489. * Copies the given float to the current Vector3 coordinates
  70490. * @param v defines the x, y, z and w coordinates of the operand
  70491. * @returns the current updated Vector3
  70492. */
  70493. setAll(v: number): Vector4;
  70494. /**
  70495. * Returns a new Vector4 set from the starting index of the given array.
  70496. * @param array the array to pull values from
  70497. * @param offset the offset into the array to start at
  70498. * @returns the new vector
  70499. */
  70500. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70501. /**
  70502. * Updates the given vector "result" from the starting index of the given array.
  70503. * @param array the array to pull values from
  70504. * @param offset the offset into the array to start at
  70505. * @param result the vector to store the result in
  70506. */
  70507. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70508. /**
  70509. * Updates the given vector "result" from the starting index of the given Float32Array.
  70510. * @param array the array to pull values from
  70511. * @param offset the offset into the array to start at
  70512. * @param result the vector to store the result in
  70513. */
  70514. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70515. /**
  70516. * Updates the given vector "result" coordinates from the given floats.
  70517. * @param x float to set from
  70518. * @param y float to set from
  70519. * @param z float to set from
  70520. * @param w float to set from
  70521. * @param result the vector to the floats in
  70522. */
  70523. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70524. /**
  70525. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70526. * @returns the new vector
  70527. */
  70528. static Zero(): Vector4;
  70529. /**
  70530. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70531. * @returns the new vector
  70532. */
  70533. static One(): Vector4;
  70534. /**
  70535. * Returns a new normalized Vector4 from the given one.
  70536. * @param vector the vector to normalize
  70537. * @returns the vector
  70538. */
  70539. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70540. /**
  70541. * Updates the given vector "result" from the normalization of the given one.
  70542. * @param vector the vector to normalize
  70543. * @param result the vector to store the result in
  70544. */
  70545. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70546. /**
  70547. * Returns a vector with the minimum values from the left and right vectors
  70548. * @param left left vector to minimize
  70549. * @param right right vector to minimize
  70550. * @returns a new vector with the minimum of the left and right vector values
  70551. */
  70552. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70553. /**
  70554. * Returns a vector with the maximum values from the left and right vectors
  70555. * @param left left vector to maximize
  70556. * @param right right vector to maximize
  70557. * @returns a new vector with the maximum of the left and right vector values
  70558. */
  70559. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70560. /**
  70561. * Returns the distance (float) between the vectors "value1" and "value2".
  70562. * @param value1 value to calulate the distance between
  70563. * @param value2 value to calulate the distance between
  70564. * @return the distance between the two vectors
  70565. */
  70566. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70567. /**
  70568. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70569. * @param value1 value to calulate the distance between
  70570. * @param value2 value to calulate the distance between
  70571. * @return the distance between the two vectors squared
  70572. */
  70573. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70574. /**
  70575. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70576. * @param value1 value to calulate the center between
  70577. * @param value2 value to calulate the center between
  70578. * @return the center between the two vectors
  70579. */
  70580. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70581. /**
  70582. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70583. * This methods computes transformed normalized direction vectors only.
  70584. * @param vector the vector to transform
  70585. * @param transformation the transformation matrix to apply
  70586. * @returns the new vector
  70587. */
  70588. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70589. /**
  70590. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70591. * This methods computes transformed normalized direction vectors only.
  70592. * @param vector the vector to transform
  70593. * @param transformation the transformation matrix to apply
  70594. * @param result the vector to store the result in
  70595. */
  70596. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70597. /**
  70598. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70599. * This methods computes transformed normalized direction vectors only.
  70600. * @param x value to transform
  70601. * @param y value to transform
  70602. * @param z value to transform
  70603. * @param w value to transform
  70604. * @param transformation the transformation matrix to apply
  70605. * @param result the vector to store the results in
  70606. */
  70607. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70608. /**
  70609. * Creates a new Vector4 from a Vector3
  70610. * @param source defines the source data
  70611. * @param w defines the 4th component (default is 0)
  70612. * @returns a new Vector4
  70613. */
  70614. static FromVector3(source: Vector3, w?: number): Vector4;
  70615. }
  70616. /**
  70617. * Class used to store quaternion data
  70618. * @see https://en.wikipedia.org/wiki/Quaternion
  70619. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70620. */
  70621. export class Quaternion {
  70622. /** defines the first component (0 by default) */
  70623. x: number;
  70624. /** defines the second component (0 by default) */
  70625. y: number;
  70626. /** defines the third component (0 by default) */
  70627. z: number;
  70628. /** defines the fourth component (1.0 by default) */
  70629. w: number;
  70630. /**
  70631. * Creates a new Quaternion from the given floats
  70632. * @param x defines the first component (0 by default)
  70633. * @param y defines the second component (0 by default)
  70634. * @param z defines the third component (0 by default)
  70635. * @param w defines the fourth component (1.0 by default)
  70636. */
  70637. constructor(
  70638. /** defines the first component (0 by default) */
  70639. x?: number,
  70640. /** defines the second component (0 by default) */
  70641. y?: number,
  70642. /** defines the third component (0 by default) */
  70643. z?: number,
  70644. /** defines the fourth component (1.0 by default) */
  70645. w?: number);
  70646. /**
  70647. * Gets a string representation for the current quaternion
  70648. * @returns a string with the Quaternion coordinates
  70649. */
  70650. toString(): string;
  70651. /**
  70652. * Gets the class name of the quaternion
  70653. * @returns the string "Quaternion"
  70654. */
  70655. getClassName(): string;
  70656. /**
  70657. * Gets a hash code for this quaternion
  70658. * @returns the quaternion hash code
  70659. */
  70660. getHashCode(): number;
  70661. /**
  70662. * Copy the quaternion to an array
  70663. * @returns a new array populated with 4 elements from the quaternion coordinates
  70664. */
  70665. asArray(): number[];
  70666. /**
  70667. * Check if two quaternions are equals
  70668. * @param otherQuaternion defines the second operand
  70669. * @return true if the current quaternion and the given one coordinates are strictly equals
  70670. */
  70671. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70672. /**
  70673. * Clone the current quaternion
  70674. * @returns a new quaternion copied from the current one
  70675. */
  70676. clone(): Quaternion;
  70677. /**
  70678. * Copy a quaternion to the current one
  70679. * @param other defines the other quaternion
  70680. * @returns the updated current quaternion
  70681. */
  70682. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70683. /**
  70684. * Updates the current quaternion with the given float coordinates
  70685. * @param x defines the x coordinate
  70686. * @param y defines the y coordinate
  70687. * @param z defines the z coordinate
  70688. * @param w defines the w coordinate
  70689. * @returns the updated current quaternion
  70690. */
  70691. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70692. /**
  70693. * Updates the current quaternion from the given float coordinates
  70694. * @param x defines the x coordinate
  70695. * @param y defines the y coordinate
  70696. * @param z defines the z coordinate
  70697. * @param w defines the w coordinate
  70698. * @returns the updated current quaternion
  70699. */
  70700. set(x: number, y: number, z: number, w: number): Quaternion;
  70701. /**
  70702. * Adds two quaternions
  70703. * @param other defines the second operand
  70704. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70705. */
  70706. add(other: DeepImmutable<Quaternion>): Quaternion;
  70707. /**
  70708. * Add a quaternion to the current one
  70709. * @param other defines the quaternion to add
  70710. * @returns the current quaternion
  70711. */
  70712. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70713. /**
  70714. * Subtract two quaternions
  70715. * @param other defines the second operand
  70716. * @returns a new quaternion as the subtraction result of the given one from the current one
  70717. */
  70718. subtract(other: Quaternion): Quaternion;
  70719. /**
  70720. * Multiplies the current quaternion by a scale factor
  70721. * @param value defines the scale factor
  70722. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70723. */
  70724. scale(value: number): Quaternion;
  70725. /**
  70726. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70727. * @param scale defines the scale factor
  70728. * @param result defines the Quaternion object where to store the result
  70729. * @returns the unmodified current quaternion
  70730. */
  70731. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70732. /**
  70733. * Multiplies in place the current quaternion by a scale factor
  70734. * @param value defines the scale factor
  70735. * @returns the current modified quaternion
  70736. */
  70737. scaleInPlace(value: number): Quaternion;
  70738. /**
  70739. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70740. * @param scale defines the scale factor
  70741. * @param result defines the Quaternion object where to store the result
  70742. * @returns the unmodified current quaternion
  70743. */
  70744. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70745. /**
  70746. * Multiplies two quaternions
  70747. * @param q1 defines the second operand
  70748. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70749. */
  70750. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70751. /**
  70752. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70753. * @param q1 defines the second operand
  70754. * @param result defines the target quaternion
  70755. * @returns the current quaternion
  70756. */
  70757. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70758. /**
  70759. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70760. * @param q1 defines the second operand
  70761. * @returns the currentupdated quaternion
  70762. */
  70763. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70764. /**
  70765. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70766. * @param ref defines the target quaternion
  70767. * @returns the current quaternion
  70768. */
  70769. conjugateToRef(ref: Quaternion): Quaternion;
  70770. /**
  70771. * Conjugates in place (1-q) the current quaternion
  70772. * @returns the current updated quaternion
  70773. */
  70774. conjugateInPlace(): Quaternion;
  70775. /**
  70776. * Conjugates in place (1-q) the current quaternion
  70777. * @returns a new quaternion
  70778. */
  70779. conjugate(): Quaternion;
  70780. /**
  70781. * Gets length of current quaternion
  70782. * @returns the quaternion length (float)
  70783. */
  70784. length(): number;
  70785. /**
  70786. * Normalize in place the current quaternion
  70787. * @returns the current updated quaternion
  70788. */
  70789. normalize(): Quaternion;
  70790. /**
  70791. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70792. * @param order is a reserved parameter and is ignore for now
  70793. * @returns a new Vector3 containing the Euler angles
  70794. */
  70795. toEulerAngles(order?: string): Vector3;
  70796. /**
  70797. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70798. * @param result defines the vector which will be filled with the Euler angles
  70799. * @param order is a reserved parameter and is ignore for now
  70800. * @returns the current unchanged quaternion
  70801. */
  70802. toEulerAnglesToRef(result: Vector3): Quaternion;
  70803. /**
  70804. * Updates the given rotation matrix with the current quaternion values
  70805. * @param result defines the target matrix
  70806. * @returns the current unchanged quaternion
  70807. */
  70808. toRotationMatrix(result: Matrix): Quaternion;
  70809. /**
  70810. * Updates the current quaternion from the given rotation matrix values
  70811. * @param matrix defines the source matrix
  70812. * @returns the current updated quaternion
  70813. */
  70814. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70815. /**
  70816. * Creates a new quaternion from a rotation matrix
  70817. * @param matrix defines the source matrix
  70818. * @returns a new quaternion created from the given rotation matrix values
  70819. */
  70820. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70821. /**
  70822. * Updates the given quaternion with the given rotation matrix values
  70823. * @param matrix defines the source matrix
  70824. * @param result defines the target quaternion
  70825. */
  70826. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70827. /**
  70828. * Returns the dot product (float) between the quaternions "left" and "right"
  70829. * @param left defines the left operand
  70830. * @param right defines the right operand
  70831. * @returns the dot product
  70832. */
  70833. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70834. /**
  70835. * Checks if the two quaternions are close to each other
  70836. * @param quat0 defines the first quaternion to check
  70837. * @param quat1 defines the second quaternion to check
  70838. * @returns true if the two quaternions are close to each other
  70839. */
  70840. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70841. /**
  70842. * Creates an empty quaternion
  70843. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70844. */
  70845. static Zero(): Quaternion;
  70846. /**
  70847. * Inverse a given quaternion
  70848. * @param q defines the source quaternion
  70849. * @returns a new quaternion as the inverted current quaternion
  70850. */
  70851. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70852. /**
  70853. * Inverse a given quaternion
  70854. * @param q defines the source quaternion
  70855. * @param result the quaternion the result will be stored in
  70856. * @returns the result quaternion
  70857. */
  70858. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70859. /**
  70860. * Creates an identity quaternion
  70861. * @returns the identity quaternion
  70862. */
  70863. static Identity(): Quaternion;
  70864. /**
  70865. * Gets a boolean indicating if the given quaternion is identity
  70866. * @param quaternion defines the quaternion to check
  70867. * @returns true if the quaternion is identity
  70868. */
  70869. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70870. /**
  70871. * Creates a quaternion from a rotation around an axis
  70872. * @param axis defines the axis to use
  70873. * @param angle defines the angle to use
  70874. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70875. */
  70876. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70877. /**
  70878. * Creates a rotation around an axis and stores it into the given quaternion
  70879. * @param axis defines the axis to use
  70880. * @param angle defines the angle to use
  70881. * @param result defines the target quaternion
  70882. * @returns the target quaternion
  70883. */
  70884. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70885. /**
  70886. * Creates a new quaternion from data stored into an array
  70887. * @param array defines the data source
  70888. * @param offset defines the offset in the source array where the data starts
  70889. * @returns a new quaternion
  70890. */
  70891. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70892. /**
  70893. * Create a quaternion from Euler rotation angles
  70894. * @param x Pitch
  70895. * @param y Yaw
  70896. * @param z Roll
  70897. * @returns the new Quaternion
  70898. */
  70899. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70900. /**
  70901. * Updates a quaternion from Euler rotation angles
  70902. * @param x Pitch
  70903. * @param y Yaw
  70904. * @param z Roll
  70905. * @param result the quaternion to store the result
  70906. * @returns the updated quaternion
  70907. */
  70908. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70909. /**
  70910. * Create a quaternion from Euler rotation vector
  70911. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70912. * @returns the new Quaternion
  70913. */
  70914. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70915. /**
  70916. * Updates a quaternion from Euler rotation vector
  70917. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70918. * @param result the quaternion to store the result
  70919. * @returns the updated quaternion
  70920. */
  70921. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70922. /**
  70923. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70924. * @param yaw defines the rotation around Y axis
  70925. * @param pitch defines the rotation around X axis
  70926. * @param roll defines the rotation around Z axis
  70927. * @returns the new quaternion
  70928. */
  70929. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70930. /**
  70931. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70932. * @param yaw defines the rotation around Y axis
  70933. * @param pitch defines the rotation around X axis
  70934. * @param roll defines the rotation around Z axis
  70935. * @param result defines the target quaternion
  70936. */
  70937. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70938. /**
  70939. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70940. * @param alpha defines the rotation around first axis
  70941. * @param beta defines the rotation around second axis
  70942. * @param gamma defines the rotation around third axis
  70943. * @returns the new quaternion
  70944. */
  70945. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70946. /**
  70947. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70948. * @param alpha defines the rotation around first axis
  70949. * @param beta defines the rotation around second axis
  70950. * @param gamma defines the rotation around third axis
  70951. * @param result defines the target quaternion
  70952. */
  70953. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70954. /**
  70955. * 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)
  70956. * @param axis1 defines the first axis
  70957. * @param axis2 defines the second axis
  70958. * @param axis3 defines the third axis
  70959. * @returns the new quaternion
  70960. */
  70961. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70962. /**
  70963. * 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
  70964. * @param axis1 defines the first axis
  70965. * @param axis2 defines the second axis
  70966. * @param axis3 defines the third axis
  70967. * @param ref defines the target quaternion
  70968. */
  70969. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70970. /**
  70971. * Interpolates between two quaternions
  70972. * @param left defines first quaternion
  70973. * @param right defines second quaternion
  70974. * @param amount defines the gradient to use
  70975. * @returns the new interpolated quaternion
  70976. */
  70977. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70978. /**
  70979. * Interpolates between two quaternions and stores it into a target quaternion
  70980. * @param left defines first quaternion
  70981. * @param right defines second quaternion
  70982. * @param amount defines the gradient to use
  70983. * @param result defines the target quaternion
  70984. */
  70985. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70986. /**
  70987. * Interpolate between two quaternions using Hermite interpolation
  70988. * @param value1 defines first quaternion
  70989. * @param tangent1 defines the incoming tangent
  70990. * @param value2 defines second quaternion
  70991. * @param tangent2 defines the outgoing tangent
  70992. * @param amount defines the target quaternion
  70993. * @returns the new interpolated quaternion
  70994. */
  70995. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70996. }
  70997. /**
  70998. * Class used to store matrix data (4x4)
  70999. */
  71000. export class Matrix {
  71001. private static _updateFlagSeed;
  71002. private static _identityReadOnly;
  71003. private _isIdentity;
  71004. private _isIdentityDirty;
  71005. private _isIdentity3x2;
  71006. private _isIdentity3x2Dirty;
  71007. /**
  71008. * Gets the update flag of the matrix which is an unique number for the matrix.
  71009. * It will be incremented every time the matrix data change.
  71010. * You can use it to speed the comparison between two versions of the same matrix.
  71011. */
  71012. updateFlag: number;
  71013. private readonly _m;
  71014. /**
  71015. * Gets the internal data of the matrix
  71016. */
  71017. readonly m: DeepImmutable<Float32Array>;
  71018. /** @hidden */
  71019. _markAsUpdated(): void;
  71020. /** @hidden */
  71021. private _updateIdentityStatus;
  71022. /**
  71023. * Creates an empty matrix (filled with zeros)
  71024. */
  71025. constructor();
  71026. /**
  71027. * Check if the current matrix is identity
  71028. * @returns true is the matrix is the identity matrix
  71029. */
  71030. isIdentity(): boolean;
  71031. /**
  71032. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71033. * @returns true is the matrix is the identity matrix
  71034. */
  71035. isIdentityAs3x2(): boolean;
  71036. /**
  71037. * Gets the determinant of the matrix
  71038. * @returns the matrix determinant
  71039. */
  71040. determinant(): number;
  71041. /**
  71042. * Returns the matrix as a Float32Array
  71043. * @returns the matrix underlying array
  71044. */
  71045. toArray(): DeepImmutable<Float32Array>;
  71046. /**
  71047. * Returns the matrix as a Float32Array
  71048. * @returns the matrix underlying array.
  71049. */
  71050. asArray(): DeepImmutable<Float32Array>;
  71051. /**
  71052. * Inverts the current matrix in place
  71053. * @returns the current inverted matrix
  71054. */
  71055. invert(): Matrix;
  71056. /**
  71057. * Sets all the matrix elements to zero
  71058. * @returns the current matrix
  71059. */
  71060. reset(): Matrix;
  71061. /**
  71062. * Adds the current matrix with a second one
  71063. * @param other defines the matrix to add
  71064. * @returns a new matrix as the addition of the current matrix and the given one
  71065. */
  71066. add(other: DeepImmutable<Matrix>): Matrix;
  71067. /**
  71068. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71069. * @param other defines the matrix to add
  71070. * @param result defines the target matrix
  71071. * @returns the current matrix
  71072. */
  71073. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71074. /**
  71075. * Adds in place the given matrix to the current matrix
  71076. * @param other defines the second operand
  71077. * @returns the current updated matrix
  71078. */
  71079. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71080. /**
  71081. * Sets the given matrix to the current inverted Matrix
  71082. * @param other defines the target matrix
  71083. * @returns the unmodified current matrix
  71084. */
  71085. invertToRef(other: Matrix): Matrix;
  71086. /**
  71087. * add a value at the specified position in the current Matrix
  71088. * @param index the index of the value within the matrix. between 0 and 15.
  71089. * @param value the value to be added
  71090. * @returns the current updated matrix
  71091. */
  71092. addAtIndex(index: number, value: number): Matrix;
  71093. /**
  71094. * mutiply the specified position in the current Matrix by a value
  71095. * @param index the index of the value within the matrix. between 0 and 15.
  71096. * @param value the value to be added
  71097. * @returns the current updated matrix
  71098. */
  71099. multiplyAtIndex(index: number, value: number): Matrix;
  71100. /**
  71101. * Inserts the translation vector (using 3 floats) in the current matrix
  71102. * @param x defines the 1st component of the translation
  71103. * @param y defines the 2nd component of the translation
  71104. * @param z defines the 3rd component of the translation
  71105. * @returns the current updated matrix
  71106. */
  71107. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71108. /**
  71109. * Adds the translation vector (using 3 floats) in the current matrix
  71110. * @param x defines the 1st component of the translation
  71111. * @param y defines the 2nd component of the translation
  71112. * @param z defines the 3rd component of the translation
  71113. * @returns the current updated matrix
  71114. */
  71115. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71116. /**
  71117. * Inserts the translation vector in the current matrix
  71118. * @param vector3 defines the translation to insert
  71119. * @returns the current updated matrix
  71120. */
  71121. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71122. /**
  71123. * Gets the translation value of the current matrix
  71124. * @returns a new Vector3 as the extracted translation from the matrix
  71125. */
  71126. getTranslation(): Vector3;
  71127. /**
  71128. * Fill a Vector3 with the extracted translation from the matrix
  71129. * @param result defines the Vector3 where to store the translation
  71130. * @returns the current matrix
  71131. */
  71132. getTranslationToRef(result: Vector3): Matrix;
  71133. /**
  71134. * Remove rotation and scaling part from the matrix
  71135. * @returns the updated matrix
  71136. */
  71137. removeRotationAndScaling(): Matrix;
  71138. /**
  71139. * Multiply two matrices
  71140. * @param other defines the second operand
  71141. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71142. */
  71143. multiply(other: DeepImmutable<Matrix>): Matrix;
  71144. /**
  71145. * Copy the current matrix from the given one
  71146. * @param other defines the source matrix
  71147. * @returns the current updated matrix
  71148. */
  71149. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71150. /**
  71151. * Populates the given array from the starting index with the current matrix values
  71152. * @param array defines the target array
  71153. * @param offset defines the offset in the target array where to start storing values
  71154. * @returns the current matrix
  71155. */
  71156. copyToArray(array: Float32Array, offset?: number): Matrix;
  71157. /**
  71158. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71159. * @param other defines the second operand
  71160. * @param result defines the matrix where to store the multiplication
  71161. * @returns the current matrix
  71162. */
  71163. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71164. /**
  71165. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71166. * @param other defines the second operand
  71167. * @param result defines the array where to store the multiplication
  71168. * @param offset defines the offset in the target array where to start storing values
  71169. * @returns the current matrix
  71170. */
  71171. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71172. /**
  71173. * Check equality between this matrix and a second one
  71174. * @param value defines the second matrix to compare
  71175. * @returns true is the current matrix and the given one values are strictly equal
  71176. */
  71177. equals(value: DeepImmutable<Matrix>): boolean;
  71178. /**
  71179. * Clone the current matrix
  71180. * @returns a new matrix from the current matrix
  71181. */
  71182. clone(): Matrix;
  71183. /**
  71184. * Returns the name of the current matrix class
  71185. * @returns the string "Matrix"
  71186. */
  71187. getClassName(): string;
  71188. /**
  71189. * Gets the hash code of the current matrix
  71190. * @returns the hash code
  71191. */
  71192. getHashCode(): number;
  71193. /**
  71194. * Decomposes the current Matrix into a translation, rotation and scaling components
  71195. * @param scale defines the scale vector3 given as a reference to update
  71196. * @param rotation defines the rotation quaternion given as a reference to update
  71197. * @param translation defines the translation vector3 given as a reference to update
  71198. * @returns true if operation was successful
  71199. */
  71200. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71201. /**
  71202. * Gets specific row of the matrix
  71203. * @param index defines the number of the row to get
  71204. * @returns the index-th row of the current matrix as a new Vector4
  71205. */
  71206. getRow(index: number): Nullable<Vector4>;
  71207. /**
  71208. * Sets the index-th row of the current matrix to the vector4 values
  71209. * @param index defines the number of the row to set
  71210. * @param row defines the target vector4
  71211. * @returns the updated current matrix
  71212. */
  71213. setRow(index: number, row: Vector4): Matrix;
  71214. /**
  71215. * Compute the transpose of the matrix
  71216. * @returns the new transposed matrix
  71217. */
  71218. transpose(): Matrix;
  71219. /**
  71220. * Compute the transpose of the matrix and store it in a given matrix
  71221. * @param result defines the target matrix
  71222. * @returns the current matrix
  71223. */
  71224. transposeToRef(result: Matrix): Matrix;
  71225. /**
  71226. * Sets the index-th row of the current matrix with the given 4 x float values
  71227. * @param index defines the row index
  71228. * @param x defines the x component to set
  71229. * @param y defines the y component to set
  71230. * @param z defines the z component to set
  71231. * @param w defines the w component to set
  71232. * @returns the updated current matrix
  71233. */
  71234. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71235. /**
  71236. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71237. * @param scale defines the scale factor
  71238. * @returns a new matrix
  71239. */
  71240. scale(scale: number): Matrix;
  71241. /**
  71242. * Scale the current matrix values by a factor to a given result matrix
  71243. * @param scale defines the scale factor
  71244. * @param result defines the matrix to store the result
  71245. * @returns the current matrix
  71246. */
  71247. scaleToRef(scale: number, result: Matrix): Matrix;
  71248. /**
  71249. * Scale the current matrix values by a factor and add the result to a given matrix
  71250. * @param scale defines the scale factor
  71251. * @param result defines the Matrix to store the result
  71252. * @returns the current matrix
  71253. */
  71254. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71255. /**
  71256. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71257. * @param ref matrix to store the result
  71258. */
  71259. toNormalMatrix(ref: Matrix): void;
  71260. /**
  71261. * Gets only rotation part of the current matrix
  71262. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71263. */
  71264. getRotationMatrix(): Matrix;
  71265. /**
  71266. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71267. * @param result defines the target matrix to store data to
  71268. * @returns the current matrix
  71269. */
  71270. getRotationMatrixToRef(result: Matrix): Matrix;
  71271. /**
  71272. * Toggles model matrix from being right handed to left handed in place and vice versa
  71273. */
  71274. toggleModelMatrixHandInPlace(): void;
  71275. /**
  71276. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71277. */
  71278. toggleProjectionMatrixHandInPlace(): void;
  71279. /**
  71280. * Creates a matrix from an array
  71281. * @param array defines the source array
  71282. * @param offset defines an offset in the source array
  71283. * @returns a new Matrix set from the starting index of the given array
  71284. */
  71285. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71286. /**
  71287. * Copy the content of an array into a given matrix
  71288. * @param array defines the source array
  71289. * @param offset defines an offset in the source array
  71290. * @param result defines the target matrix
  71291. */
  71292. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71293. /**
  71294. * Stores an array into a matrix after having multiplied each component by a given factor
  71295. * @param array defines the source array
  71296. * @param offset defines the offset in the source array
  71297. * @param scale defines the scaling factor
  71298. * @param result defines the target matrix
  71299. */
  71300. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71301. /**
  71302. * Gets an identity matrix that must not be updated
  71303. */
  71304. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71305. /**
  71306. * Stores a list of values (16) inside a given matrix
  71307. * @param initialM11 defines 1st value of 1st row
  71308. * @param initialM12 defines 2nd value of 1st row
  71309. * @param initialM13 defines 3rd value of 1st row
  71310. * @param initialM14 defines 4th value of 1st row
  71311. * @param initialM21 defines 1st value of 2nd row
  71312. * @param initialM22 defines 2nd value of 2nd row
  71313. * @param initialM23 defines 3rd value of 2nd row
  71314. * @param initialM24 defines 4th value of 2nd row
  71315. * @param initialM31 defines 1st value of 3rd row
  71316. * @param initialM32 defines 2nd value of 3rd row
  71317. * @param initialM33 defines 3rd value of 3rd row
  71318. * @param initialM34 defines 4th value of 3rd row
  71319. * @param initialM41 defines 1st value of 4th row
  71320. * @param initialM42 defines 2nd value of 4th row
  71321. * @param initialM43 defines 3rd value of 4th row
  71322. * @param initialM44 defines 4th value of 4th row
  71323. * @param result defines the target matrix
  71324. */
  71325. 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;
  71326. /**
  71327. * Creates new matrix from a list of values (16)
  71328. * @param initialM11 defines 1st value of 1st row
  71329. * @param initialM12 defines 2nd value of 1st row
  71330. * @param initialM13 defines 3rd value of 1st row
  71331. * @param initialM14 defines 4th value of 1st row
  71332. * @param initialM21 defines 1st value of 2nd row
  71333. * @param initialM22 defines 2nd value of 2nd row
  71334. * @param initialM23 defines 3rd value of 2nd row
  71335. * @param initialM24 defines 4th value of 2nd row
  71336. * @param initialM31 defines 1st value of 3rd row
  71337. * @param initialM32 defines 2nd value of 3rd row
  71338. * @param initialM33 defines 3rd value of 3rd row
  71339. * @param initialM34 defines 4th value of 3rd row
  71340. * @param initialM41 defines 1st value of 4th row
  71341. * @param initialM42 defines 2nd value of 4th row
  71342. * @param initialM43 defines 3rd value of 4th row
  71343. * @param initialM44 defines 4th value of 4th row
  71344. * @returns the new matrix
  71345. */
  71346. 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;
  71347. /**
  71348. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71349. * @param scale defines the scale vector3
  71350. * @param rotation defines the rotation quaternion
  71351. * @param translation defines the translation vector3
  71352. * @returns a new matrix
  71353. */
  71354. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71355. /**
  71356. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71357. * @param scale defines the scale vector3
  71358. * @param rotation defines the rotation quaternion
  71359. * @param translation defines the translation vector3
  71360. * @param result defines the target matrix
  71361. */
  71362. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71363. /**
  71364. * Creates a new identity matrix
  71365. * @returns a new identity matrix
  71366. */
  71367. static Identity(): Matrix;
  71368. /**
  71369. * Creates a new identity matrix and stores the result in a given matrix
  71370. * @param result defines the target matrix
  71371. */
  71372. static IdentityToRef(result: Matrix): void;
  71373. /**
  71374. * Creates a new zero matrix
  71375. * @returns a new zero matrix
  71376. */
  71377. static Zero(): Matrix;
  71378. /**
  71379. * Creates a new rotation matrix for "angle" radians around the X axis
  71380. * @param angle defines the angle (in radians) to use
  71381. * @return the new matrix
  71382. */
  71383. static RotationX(angle: number): Matrix;
  71384. /**
  71385. * Creates a new matrix as the invert of a given matrix
  71386. * @param source defines the source matrix
  71387. * @returns the new matrix
  71388. */
  71389. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71390. /**
  71391. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71392. * @param angle defines the angle (in radians) to use
  71393. * @param result defines the target matrix
  71394. */
  71395. static RotationXToRef(angle: number, result: Matrix): void;
  71396. /**
  71397. * Creates a new rotation matrix for "angle" radians around the Y axis
  71398. * @param angle defines the angle (in radians) to use
  71399. * @return the new matrix
  71400. */
  71401. static RotationY(angle: number): Matrix;
  71402. /**
  71403. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71404. * @param angle defines the angle (in radians) to use
  71405. * @param result defines the target matrix
  71406. */
  71407. static RotationYToRef(angle: number, result: Matrix): void;
  71408. /**
  71409. * Creates a new rotation matrix for "angle" radians around the Z axis
  71410. * @param angle defines the angle (in radians) to use
  71411. * @return the new matrix
  71412. */
  71413. static RotationZ(angle: number): Matrix;
  71414. /**
  71415. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71416. * @param angle defines the angle (in radians) to use
  71417. * @param result defines the target matrix
  71418. */
  71419. static RotationZToRef(angle: number, result: Matrix): void;
  71420. /**
  71421. * Creates a new rotation matrix for "angle" radians around the given axis
  71422. * @param axis defines the axis to use
  71423. * @param angle defines the angle (in radians) to use
  71424. * @return the new matrix
  71425. */
  71426. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71427. /**
  71428. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71429. * @param axis defines the axis to use
  71430. * @param angle defines the angle (in radians) to use
  71431. * @param result defines the target matrix
  71432. */
  71433. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71434. /**
  71435. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71436. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71437. * @param from defines the vector to align
  71438. * @param to defines the vector to align to
  71439. * @param result defines the target matrix
  71440. */
  71441. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71442. /**
  71443. * Creates a rotation matrix
  71444. * @param yaw defines the yaw angle in radians (Y axis)
  71445. * @param pitch defines the pitch angle in radians (X axis)
  71446. * @param roll defines the roll angle in radians (X axis)
  71447. * @returns the new rotation matrix
  71448. */
  71449. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71450. /**
  71451. * Creates a rotation matrix and stores it in a given matrix
  71452. * @param yaw defines the yaw angle in radians (Y axis)
  71453. * @param pitch defines the pitch angle in radians (X axis)
  71454. * @param roll defines the roll angle in radians (X axis)
  71455. * @param result defines the target matrix
  71456. */
  71457. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71458. /**
  71459. * Creates a scaling matrix
  71460. * @param x defines the scale factor on X axis
  71461. * @param y defines the scale factor on Y axis
  71462. * @param z defines the scale factor on Z axis
  71463. * @returns the new matrix
  71464. */
  71465. static Scaling(x: number, y: number, z: number): Matrix;
  71466. /**
  71467. * Creates a scaling matrix and stores it in a given matrix
  71468. * @param x defines the scale factor on X axis
  71469. * @param y defines the scale factor on Y axis
  71470. * @param z defines the scale factor on Z axis
  71471. * @param result defines the target matrix
  71472. */
  71473. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71474. /**
  71475. * Creates a translation matrix
  71476. * @param x defines the translation on X axis
  71477. * @param y defines the translation on Y axis
  71478. * @param z defines the translationon Z axis
  71479. * @returns the new matrix
  71480. */
  71481. static Translation(x: number, y: number, z: number): Matrix;
  71482. /**
  71483. * Creates a translation matrix and stores it in a given matrix
  71484. * @param x defines the translation on X axis
  71485. * @param y defines the translation on Y axis
  71486. * @param z defines the translationon Z axis
  71487. * @param result defines the target matrix
  71488. */
  71489. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71490. /**
  71491. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71492. * @param startValue defines the start value
  71493. * @param endValue defines the end value
  71494. * @param gradient defines the gradient factor
  71495. * @returns the new matrix
  71496. */
  71497. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71498. /**
  71499. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71500. * @param startValue defines the start value
  71501. * @param endValue defines the end value
  71502. * @param gradient defines the gradient factor
  71503. * @param result defines the Matrix object where to store data
  71504. */
  71505. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71506. /**
  71507. * Builds a new matrix whose values are computed by:
  71508. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71509. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71510. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71511. * @param startValue defines the first matrix
  71512. * @param endValue defines the second matrix
  71513. * @param gradient defines the gradient between the two matrices
  71514. * @returns the new matrix
  71515. */
  71516. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71517. /**
  71518. * Update a matrix to values which are computed by:
  71519. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71520. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71521. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71522. * @param startValue defines the first matrix
  71523. * @param endValue defines the second matrix
  71524. * @param gradient defines the gradient between the two matrices
  71525. * @param result defines the target matrix
  71526. */
  71527. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71528. /**
  71529. * 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"
  71530. * This function works in left handed mode
  71531. * @param eye defines the final position of the entity
  71532. * @param target defines where the entity should look at
  71533. * @param up defines the up vector for the entity
  71534. * @returns the new matrix
  71535. */
  71536. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71537. /**
  71538. * 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".
  71539. * This function works in left handed mode
  71540. * @param eye defines the final position of the entity
  71541. * @param target defines where the entity should look at
  71542. * @param up defines the up vector for the entity
  71543. * @param result defines the target matrix
  71544. */
  71545. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71546. /**
  71547. * 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"
  71548. * This function works in right handed mode
  71549. * @param eye defines the final position of the entity
  71550. * @param target defines where the entity should look at
  71551. * @param up defines the up vector for the entity
  71552. * @returns the new matrix
  71553. */
  71554. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71555. /**
  71556. * 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".
  71557. * This function works in right handed mode
  71558. * @param eye defines the final position of the entity
  71559. * @param target defines where the entity should look at
  71560. * @param up defines the up vector for the entity
  71561. * @param result defines the target matrix
  71562. */
  71563. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71564. /**
  71565. * Create a left-handed orthographic projection matrix
  71566. * @param width defines the viewport width
  71567. * @param height defines the viewport height
  71568. * @param znear defines the near clip plane
  71569. * @param zfar defines the far clip plane
  71570. * @returns a new matrix as a left-handed orthographic projection matrix
  71571. */
  71572. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71573. /**
  71574. * Store a left-handed orthographic projection to a given matrix
  71575. * @param width defines the viewport width
  71576. * @param height defines the viewport height
  71577. * @param znear defines the near clip plane
  71578. * @param zfar defines the far clip plane
  71579. * @param result defines the target matrix
  71580. */
  71581. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71582. /**
  71583. * Create a left-handed orthographic projection matrix
  71584. * @param left defines the viewport left coordinate
  71585. * @param right defines the viewport right coordinate
  71586. * @param bottom defines the viewport bottom coordinate
  71587. * @param top defines the viewport top coordinate
  71588. * @param znear defines the near clip plane
  71589. * @param zfar defines the far clip plane
  71590. * @returns a new matrix as a left-handed orthographic projection matrix
  71591. */
  71592. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71593. /**
  71594. * Stores a left-handed orthographic projection into a given matrix
  71595. * @param left defines the viewport left coordinate
  71596. * @param right defines the viewport right coordinate
  71597. * @param bottom defines the viewport bottom coordinate
  71598. * @param top defines the viewport top coordinate
  71599. * @param znear defines the near clip plane
  71600. * @param zfar defines the far clip plane
  71601. * @param result defines the target matrix
  71602. */
  71603. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71604. /**
  71605. * Creates a right-handed orthographic projection matrix
  71606. * @param left defines the viewport left coordinate
  71607. * @param right defines the viewport right coordinate
  71608. * @param bottom defines the viewport bottom coordinate
  71609. * @param top defines the viewport top coordinate
  71610. * @param znear defines the near clip plane
  71611. * @param zfar defines the far clip plane
  71612. * @returns a new matrix as a right-handed orthographic projection matrix
  71613. */
  71614. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71615. /**
  71616. * Stores a right-handed orthographic projection into a given matrix
  71617. * @param left defines the viewport left coordinate
  71618. * @param right defines the viewport right coordinate
  71619. * @param bottom defines the viewport bottom coordinate
  71620. * @param top defines the viewport top coordinate
  71621. * @param znear defines the near clip plane
  71622. * @param zfar defines the far clip plane
  71623. * @param result defines the target matrix
  71624. */
  71625. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71626. /**
  71627. * Creates a left-handed perspective projection matrix
  71628. * @param width defines the viewport width
  71629. * @param height defines the viewport height
  71630. * @param znear defines the near clip plane
  71631. * @param zfar defines the far clip plane
  71632. * @returns a new matrix as a left-handed perspective projection matrix
  71633. */
  71634. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71635. /**
  71636. * Creates a left-handed perspective projection matrix
  71637. * @param fov defines the horizontal field of view
  71638. * @param aspect defines the aspect ratio
  71639. * @param znear defines the near clip plane
  71640. * @param zfar defines the far clip plane
  71641. * @returns a new matrix as a left-handed perspective projection matrix
  71642. */
  71643. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71644. /**
  71645. * Stores a left-handed perspective projection into a given matrix
  71646. * @param fov defines the horizontal field of view
  71647. * @param aspect defines the aspect ratio
  71648. * @param znear defines the near clip plane
  71649. * @param zfar defines the far clip plane
  71650. * @param result defines the target matrix
  71651. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71652. */
  71653. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71654. /**
  71655. * Creates a right-handed perspective projection matrix
  71656. * @param fov defines the horizontal field of view
  71657. * @param aspect defines the aspect ratio
  71658. * @param znear defines the near clip plane
  71659. * @param zfar defines the far clip plane
  71660. * @returns a new matrix as a right-handed perspective projection matrix
  71661. */
  71662. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71663. /**
  71664. * Stores a right-handed perspective projection into a given matrix
  71665. * @param fov defines the horizontal field of view
  71666. * @param aspect defines the aspect ratio
  71667. * @param znear defines the near clip plane
  71668. * @param zfar defines the far clip plane
  71669. * @param result defines the target matrix
  71670. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71671. */
  71672. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71673. /**
  71674. * Stores a perspective projection for WebVR info a given matrix
  71675. * @param fov defines the field of view
  71676. * @param znear defines the near clip plane
  71677. * @param zfar defines the far clip plane
  71678. * @param result defines the target matrix
  71679. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71680. */
  71681. static PerspectiveFovWebVRToRef(fov: {
  71682. upDegrees: number;
  71683. downDegrees: number;
  71684. leftDegrees: number;
  71685. rightDegrees: number;
  71686. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71687. /**
  71688. * Computes a complete transformation matrix
  71689. * @param viewport defines the viewport to use
  71690. * @param world defines the world matrix
  71691. * @param view defines the view matrix
  71692. * @param projection defines the projection matrix
  71693. * @param zmin defines the near clip plane
  71694. * @param zmax defines the far clip plane
  71695. * @returns the transformation matrix
  71696. */
  71697. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71698. /**
  71699. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71700. * @param matrix defines the matrix to use
  71701. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71702. */
  71703. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71704. /**
  71705. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71706. * @param matrix defines the matrix to use
  71707. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71708. */
  71709. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71710. /**
  71711. * Compute the transpose of a given matrix
  71712. * @param matrix defines the matrix to transpose
  71713. * @returns the new matrix
  71714. */
  71715. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71716. /**
  71717. * Compute the transpose of a matrix and store it in a target matrix
  71718. * @param matrix defines the matrix to transpose
  71719. * @param result defines the target matrix
  71720. */
  71721. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71722. /**
  71723. * Computes a reflection matrix from a plane
  71724. * @param plane defines the reflection plane
  71725. * @returns a new matrix
  71726. */
  71727. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71728. /**
  71729. * Computes a reflection matrix from a plane
  71730. * @param plane defines the reflection plane
  71731. * @param result defines the target matrix
  71732. */
  71733. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71734. /**
  71735. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71736. * @param xaxis defines the value of the 1st axis
  71737. * @param yaxis defines the value of the 2nd axis
  71738. * @param zaxis defines the value of the 3rd axis
  71739. * @param result defines the target matrix
  71740. */
  71741. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71742. /**
  71743. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71744. * @param quat defines the quaternion to use
  71745. * @param result defines the target matrix
  71746. */
  71747. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71748. }
  71749. /**
  71750. * @hidden
  71751. */
  71752. export class TmpVectors {
  71753. static Vector2: Vector2[];
  71754. static Vector3: Vector3[];
  71755. static Vector4: Vector4[];
  71756. static Quaternion: Quaternion[];
  71757. static Matrix: Matrix[];
  71758. }
  71759. }
  71760. declare module BABYLON {
  71761. /**
  71762. * Defines potential orientation for back face culling
  71763. */
  71764. export enum Orientation {
  71765. /**
  71766. * Clockwise
  71767. */
  71768. CW = 0,
  71769. /** Counter clockwise */
  71770. CCW = 1
  71771. }
  71772. /** Class used to represent a Bezier curve */
  71773. export class BezierCurve {
  71774. /**
  71775. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71776. * @param t defines the time
  71777. * @param x1 defines the left coordinate on X axis
  71778. * @param y1 defines the left coordinate on Y axis
  71779. * @param x2 defines the right coordinate on X axis
  71780. * @param y2 defines the right coordinate on Y axis
  71781. * @returns the interpolated value
  71782. */
  71783. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71784. }
  71785. /**
  71786. * Defines angle representation
  71787. */
  71788. export class Angle {
  71789. private _radians;
  71790. /**
  71791. * Creates an Angle object of "radians" radians (float).
  71792. * @param radians the angle in radians
  71793. */
  71794. constructor(radians: number);
  71795. /**
  71796. * Get value in degrees
  71797. * @returns the Angle value in degrees (float)
  71798. */
  71799. degrees(): number;
  71800. /**
  71801. * Get value in radians
  71802. * @returns the Angle value in radians (float)
  71803. */
  71804. radians(): number;
  71805. /**
  71806. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71807. * @param a defines first vector
  71808. * @param b defines second vector
  71809. * @returns a new Angle
  71810. */
  71811. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71812. /**
  71813. * Gets a new Angle object from the given float in radians
  71814. * @param radians defines the angle value in radians
  71815. * @returns a new Angle
  71816. */
  71817. static FromRadians(radians: number): Angle;
  71818. /**
  71819. * Gets a new Angle object from the given float in degrees
  71820. * @param degrees defines the angle value in degrees
  71821. * @returns a new Angle
  71822. */
  71823. static FromDegrees(degrees: number): Angle;
  71824. }
  71825. /**
  71826. * This represents an arc in a 2d space.
  71827. */
  71828. export class Arc2 {
  71829. /** Defines the start point of the arc */
  71830. startPoint: Vector2;
  71831. /** Defines the mid point of the arc */
  71832. midPoint: Vector2;
  71833. /** Defines the end point of the arc */
  71834. endPoint: Vector2;
  71835. /**
  71836. * Defines the center point of the arc.
  71837. */
  71838. centerPoint: Vector2;
  71839. /**
  71840. * Defines the radius of the arc.
  71841. */
  71842. radius: number;
  71843. /**
  71844. * Defines the angle of the arc (from mid point to end point).
  71845. */
  71846. angle: Angle;
  71847. /**
  71848. * Defines the start angle of the arc (from start point to middle point).
  71849. */
  71850. startAngle: Angle;
  71851. /**
  71852. * Defines the orientation of the arc (clock wise/counter clock wise).
  71853. */
  71854. orientation: Orientation;
  71855. /**
  71856. * Creates an Arc object from the three given points : start, middle and end.
  71857. * @param startPoint Defines the start point of the arc
  71858. * @param midPoint Defines the midlle point of the arc
  71859. * @param endPoint Defines the end point of the arc
  71860. */
  71861. constructor(
  71862. /** Defines the start point of the arc */
  71863. startPoint: Vector2,
  71864. /** Defines the mid point of the arc */
  71865. midPoint: Vector2,
  71866. /** Defines the end point of the arc */
  71867. endPoint: Vector2);
  71868. }
  71869. /**
  71870. * Represents a 2D path made up of multiple 2D points
  71871. */
  71872. export class Path2 {
  71873. private _points;
  71874. private _length;
  71875. /**
  71876. * If the path start and end point are the same
  71877. */
  71878. closed: boolean;
  71879. /**
  71880. * Creates a Path2 object from the starting 2D coordinates x and y.
  71881. * @param x the starting points x value
  71882. * @param y the starting points y value
  71883. */
  71884. constructor(x: number, y: number);
  71885. /**
  71886. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71887. * @param x the added points x value
  71888. * @param y the added points y value
  71889. * @returns the updated Path2.
  71890. */
  71891. addLineTo(x: number, y: number): Path2;
  71892. /**
  71893. * 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.
  71894. * @param midX middle point x value
  71895. * @param midY middle point y value
  71896. * @param endX end point x value
  71897. * @param endY end point y value
  71898. * @param numberOfSegments (default: 36)
  71899. * @returns the updated Path2.
  71900. */
  71901. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71902. /**
  71903. * Closes the Path2.
  71904. * @returns the Path2.
  71905. */
  71906. close(): Path2;
  71907. /**
  71908. * Gets the sum of the distance between each sequential point in the path
  71909. * @returns the Path2 total length (float).
  71910. */
  71911. length(): number;
  71912. /**
  71913. * Gets the points which construct the path
  71914. * @returns the Path2 internal array of points.
  71915. */
  71916. getPoints(): Vector2[];
  71917. /**
  71918. * Retreives the point at the distance aways from the starting point
  71919. * @param normalizedLengthPosition the length along the path to retreive the point from
  71920. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71921. */
  71922. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71923. /**
  71924. * Creates a new path starting from an x and y position
  71925. * @param x starting x value
  71926. * @param y starting y value
  71927. * @returns a new Path2 starting at the coordinates (x, y).
  71928. */
  71929. static StartingAt(x: number, y: number): Path2;
  71930. }
  71931. /**
  71932. * Represents a 3D path made up of multiple 3D points
  71933. */
  71934. export class Path3D {
  71935. /**
  71936. * an array of Vector3, the curve axis of the Path3D
  71937. */
  71938. path: Vector3[];
  71939. private _curve;
  71940. private _distances;
  71941. private _tangents;
  71942. private _normals;
  71943. private _binormals;
  71944. private _raw;
  71945. /**
  71946. * new Path3D(path, normal, raw)
  71947. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71948. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71949. * @param path an array of Vector3, the curve axis of the Path3D
  71950. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71951. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71952. */
  71953. constructor(
  71954. /**
  71955. * an array of Vector3, the curve axis of the Path3D
  71956. */
  71957. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71958. /**
  71959. * Returns the Path3D array of successive Vector3 designing its curve.
  71960. * @returns the Path3D array of successive Vector3 designing its curve.
  71961. */
  71962. getCurve(): Vector3[];
  71963. /**
  71964. * Returns an array populated with tangent vectors on each Path3D curve point.
  71965. * @returns an array populated with tangent vectors on each Path3D curve point.
  71966. */
  71967. getTangents(): Vector3[];
  71968. /**
  71969. * Returns an array populated with normal vectors on each Path3D curve point.
  71970. * @returns an array populated with normal vectors on each Path3D curve point.
  71971. */
  71972. getNormals(): Vector3[];
  71973. /**
  71974. * Returns an array populated with binormal vectors on each Path3D curve point.
  71975. * @returns an array populated with binormal vectors on each Path3D curve point.
  71976. */
  71977. getBinormals(): Vector3[];
  71978. /**
  71979. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71980. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71981. */
  71982. getDistances(): number[];
  71983. /**
  71984. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71985. * @param path path which all values are copied into the curves points
  71986. * @param firstNormal which should be projected onto the curve
  71987. * @returns the same object updated.
  71988. */
  71989. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71990. private _compute;
  71991. private _getFirstNonNullVector;
  71992. private _getLastNonNullVector;
  71993. private _normalVector;
  71994. }
  71995. /**
  71996. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71997. * A Curve3 is designed from a series of successive Vector3.
  71998. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71999. */
  72000. export class Curve3 {
  72001. private _points;
  72002. private _length;
  72003. /**
  72004. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72005. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72006. * @param v1 (Vector3) the control point
  72007. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72008. * @param nbPoints (integer) the wanted number of points in the curve
  72009. * @returns the created Curve3
  72010. */
  72011. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72012. /**
  72013. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72014. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72015. * @param v1 (Vector3) the first control point
  72016. * @param v2 (Vector3) the second control point
  72017. * @param v3 (Vector3) the end point of the Cubic Bezier
  72018. * @param nbPoints (integer) the wanted number of points in the curve
  72019. * @returns the created Curve3
  72020. */
  72021. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72022. /**
  72023. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72024. * @param p1 (Vector3) the origin point of the Hermite Spline
  72025. * @param t1 (Vector3) the tangent vector at the origin point
  72026. * @param p2 (Vector3) the end point of the Hermite Spline
  72027. * @param t2 (Vector3) the tangent vector at the end point
  72028. * @param nbPoints (integer) the wanted number of points in the curve
  72029. * @returns the created Curve3
  72030. */
  72031. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72032. /**
  72033. * Returns a Curve3 object along a CatmullRom Spline curve :
  72034. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72035. * @param nbPoints (integer) the wanted number of points between each curve control points
  72036. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72037. * @returns the created Curve3
  72038. */
  72039. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72040. /**
  72041. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72042. * A Curve3 is designed from a series of successive Vector3.
  72043. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72044. * @param points points which make up the curve
  72045. */
  72046. constructor(points: Vector3[]);
  72047. /**
  72048. * @returns the Curve3 stored array of successive Vector3
  72049. */
  72050. getPoints(): Vector3[];
  72051. /**
  72052. * @returns the computed length (float) of the curve.
  72053. */
  72054. length(): number;
  72055. /**
  72056. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72057. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72058. * curveA and curveB keep unchanged.
  72059. * @param curve the curve to continue from this curve
  72060. * @returns the newly constructed curve
  72061. */
  72062. continue(curve: DeepImmutable<Curve3>): Curve3;
  72063. private _computeLength;
  72064. }
  72065. }
  72066. declare module BABYLON {
  72067. /**
  72068. * This represents the main contract an easing function should follow.
  72069. * Easing functions are used throughout the animation system.
  72070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72071. */
  72072. export interface IEasingFunction {
  72073. /**
  72074. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72075. * of the easing function.
  72076. * The link below provides some of the most common examples of easing functions.
  72077. * @see https://easings.net/
  72078. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72079. * @returns the corresponding value on the curve defined by the easing function
  72080. */
  72081. ease(gradient: number): number;
  72082. }
  72083. /**
  72084. * Base class used for every default easing function.
  72085. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72086. */
  72087. export class EasingFunction implements IEasingFunction {
  72088. /**
  72089. * Interpolation follows the mathematical formula associated with the easing function.
  72090. */
  72091. static readonly EASINGMODE_EASEIN: number;
  72092. /**
  72093. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72094. */
  72095. static readonly EASINGMODE_EASEOUT: number;
  72096. /**
  72097. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72098. */
  72099. static readonly EASINGMODE_EASEINOUT: number;
  72100. private _easingMode;
  72101. /**
  72102. * Sets the easing mode of the current function.
  72103. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72104. */
  72105. setEasingMode(easingMode: number): void;
  72106. /**
  72107. * Gets the current easing mode.
  72108. * @returns the easing mode
  72109. */
  72110. getEasingMode(): number;
  72111. /**
  72112. * @hidden
  72113. */
  72114. easeInCore(gradient: number): number;
  72115. /**
  72116. * Given an input gradient between 0 and 1, this returns the corresponding value
  72117. * of the easing function.
  72118. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72119. * @returns the corresponding value on the curve defined by the easing function
  72120. */
  72121. ease(gradient: number): number;
  72122. }
  72123. /**
  72124. * Easing function with a circle shape (see link below).
  72125. * @see https://easings.net/#easeInCirc
  72126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72127. */
  72128. export class CircleEase extends EasingFunction implements IEasingFunction {
  72129. /** @hidden */
  72130. easeInCore(gradient: number): number;
  72131. }
  72132. /**
  72133. * Easing function with a ease back shape (see link below).
  72134. * @see https://easings.net/#easeInBack
  72135. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72136. */
  72137. export class BackEase extends EasingFunction implements IEasingFunction {
  72138. /** Defines the amplitude of the function */
  72139. amplitude: number;
  72140. /**
  72141. * Instantiates a back ease easing
  72142. * @see https://easings.net/#easeInBack
  72143. * @param amplitude Defines the amplitude of the function
  72144. */
  72145. constructor(
  72146. /** Defines the amplitude of the function */
  72147. amplitude?: number);
  72148. /** @hidden */
  72149. easeInCore(gradient: number): number;
  72150. }
  72151. /**
  72152. * Easing function with a bouncing shape (see link below).
  72153. * @see https://easings.net/#easeInBounce
  72154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72155. */
  72156. export class BounceEase extends EasingFunction implements IEasingFunction {
  72157. /** Defines the number of bounces */
  72158. bounces: number;
  72159. /** Defines the amplitude of the bounce */
  72160. bounciness: number;
  72161. /**
  72162. * Instantiates a bounce easing
  72163. * @see https://easings.net/#easeInBounce
  72164. * @param bounces Defines the number of bounces
  72165. * @param bounciness Defines the amplitude of the bounce
  72166. */
  72167. constructor(
  72168. /** Defines the number of bounces */
  72169. bounces?: number,
  72170. /** Defines the amplitude of the bounce */
  72171. bounciness?: number);
  72172. /** @hidden */
  72173. easeInCore(gradient: number): number;
  72174. }
  72175. /**
  72176. * Easing function with a power of 3 shape (see link below).
  72177. * @see https://easings.net/#easeInCubic
  72178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72179. */
  72180. export class CubicEase extends EasingFunction implements IEasingFunction {
  72181. /** @hidden */
  72182. easeInCore(gradient: number): number;
  72183. }
  72184. /**
  72185. * Easing function with an elastic shape (see link below).
  72186. * @see https://easings.net/#easeInElastic
  72187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72188. */
  72189. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72190. /** Defines the number of oscillations*/
  72191. oscillations: number;
  72192. /** Defines the amplitude of the oscillations*/
  72193. springiness: number;
  72194. /**
  72195. * Instantiates an elastic easing function
  72196. * @see https://easings.net/#easeInElastic
  72197. * @param oscillations Defines the number of oscillations
  72198. * @param springiness Defines the amplitude of the oscillations
  72199. */
  72200. constructor(
  72201. /** Defines the number of oscillations*/
  72202. oscillations?: number,
  72203. /** Defines the amplitude of the oscillations*/
  72204. springiness?: number);
  72205. /** @hidden */
  72206. easeInCore(gradient: number): number;
  72207. }
  72208. /**
  72209. * Easing function with an exponential shape (see link below).
  72210. * @see https://easings.net/#easeInExpo
  72211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72212. */
  72213. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72214. /** Defines the exponent of the function */
  72215. exponent: number;
  72216. /**
  72217. * Instantiates an exponential easing function
  72218. * @see https://easings.net/#easeInExpo
  72219. * @param exponent Defines the exponent of the function
  72220. */
  72221. constructor(
  72222. /** Defines the exponent of the function */
  72223. exponent?: number);
  72224. /** @hidden */
  72225. easeInCore(gradient: number): number;
  72226. }
  72227. /**
  72228. * Easing function with a power shape (see link below).
  72229. * @see https://easings.net/#easeInQuad
  72230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72231. */
  72232. export class PowerEase extends EasingFunction implements IEasingFunction {
  72233. /** Defines the power of the function */
  72234. power: number;
  72235. /**
  72236. * Instantiates an power base easing function
  72237. * @see https://easings.net/#easeInQuad
  72238. * @param power Defines the power of the function
  72239. */
  72240. constructor(
  72241. /** Defines the power of the function */
  72242. power?: number);
  72243. /** @hidden */
  72244. easeInCore(gradient: number): number;
  72245. }
  72246. /**
  72247. * Easing function with a power of 2 shape (see link below).
  72248. * @see https://easings.net/#easeInQuad
  72249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72250. */
  72251. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72252. /** @hidden */
  72253. easeInCore(gradient: number): number;
  72254. }
  72255. /**
  72256. * Easing function with a power of 4 shape (see link below).
  72257. * @see https://easings.net/#easeInQuart
  72258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72259. */
  72260. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72261. /** @hidden */
  72262. easeInCore(gradient: number): number;
  72263. }
  72264. /**
  72265. * Easing function with a power of 5 shape (see link below).
  72266. * @see https://easings.net/#easeInQuint
  72267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72268. */
  72269. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72270. /** @hidden */
  72271. easeInCore(gradient: number): number;
  72272. }
  72273. /**
  72274. * Easing function with a sin shape (see link below).
  72275. * @see https://easings.net/#easeInSine
  72276. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72277. */
  72278. export class SineEase extends EasingFunction implements IEasingFunction {
  72279. /** @hidden */
  72280. easeInCore(gradient: number): number;
  72281. }
  72282. /**
  72283. * Easing function with a bezier shape (see link below).
  72284. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72286. */
  72287. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72288. /** Defines the x component of the start tangent in the bezier curve */
  72289. x1: number;
  72290. /** Defines the y component of the start tangent in the bezier curve */
  72291. y1: number;
  72292. /** Defines the x component of the end tangent in the bezier curve */
  72293. x2: number;
  72294. /** Defines the y component of the end tangent in the bezier curve */
  72295. y2: number;
  72296. /**
  72297. * Instantiates a bezier function
  72298. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72299. * @param x1 Defines the x component of the start tangent in the bezier curve
  72300. * @param y1 Defines the y component of the start tangent in the bezier curve
  72301. * @param x2 Defines the x component of the end tangent in the bezier curve
  72302. * @param y2 Defines the y component of the end tangent in the bezier curve
  72303. */
  72304. constructor(
  72305. /** Defines the x component of the start tangent in the bezier curve */
  72306. x1?: number,
  72307. /** Defines the y component of the start tangent in the bezier curve */
  72308. y1?: number,
  72309. /** Defines the x component of the end tangent in the bezier curve */
  72310. x2?: number,
  72311. /** Defines the y component of the end tangent in the bezier curve */
  72312. y2?: number);
  72313. /** @hidden */
  72314. easeInCore(gradient: number): number;
  72315. }
  72316. }
  72317. declare module BABYLON {
  72318. /**
  72319. * Class used to hold a RBG color
  72320. */
  72321. export class Color3 {
  72322. /**
  72323. * Defines the red component (between 0 and 1, default is 0)
  72324. */
  72325. r: number;
  72326. /**
  72327. * Defines the green component (between 0 and 1, default is 0)
  72328. */
  72329. g: number;
  72330. /**
  72331. * Defines the blue component (between 0 and 1, default is 0)
  72332. */
  72333. b: number;
  72334. /**
  72335. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72336. * @param r defines the red component (between 0 and 1, default is 0)
  72337. * @param g defines the green component (between 0 and 1, default is 0)
  72338. * @param b defines the blue component (between 0 and 1, default is 0)
  72339. */
  72340. constructor(
  72341. /**
  72342. * Defines the red component (between 0 and 1, default is 0)
  72343. */
  72344. r?: number,
  72345. /**
  72346. * Defines the green component (between 0 and 1, default is 0)
  72347. */
  72348. g?: number,
  72349. /**
  72350. * Defines the blue component (between 0 and 1, default is 0)
  72351. */
  72352. b?: number);
  72353. /**
  72354. * Creates a string with the Color3 current values
  72355. * @returns the string representation of the Color3 object
  72356. */
  72357. toString(): string;
  72358. /**
  72359. * Returns the string "Color3"
  72360. * @returns "Color3"
  72361. */
  72362. getClassName(): string;
  72363. /**
  72364. * Compute the Color3 hash code
  72365. * @returns an unique number that can be used to hash Color3 objects
  72366. */
  72367. getHashCode(): number;
  72368. /**
  72369. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72370. * @param array defines the array where to store the r,g,b components
  72371. * @param index defines an optional index in the target array to define where to start storing values
  72372. * @returns the current Color3 object
  72373. */
  72374. toArray(array: FloatArray, index?: number): Color3;
  72375. /**
  72376. * Returns a new Color4 object from the current Color3 and the given alpha
  72377. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72378. * @returns a new Color4 object
  72379. */
  72380. toColor4(alpha?: number): Color4;
  72381. /**
  72382. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72383. * @returns the new array
  72384. */
  72385. asArray(): number[];
  72386. /**
  72387. * Returns the luminance value
  72388. * @returns a float value
  72389. */
  72390. toLuminance(): number;
  72391. /**
  72392. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72393. * @param otherColor defines the second operand
  72394. * @returns the new Color3 object
  72395. */
  72396. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72397. /**
  72398. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72399. * @param otherColor defines the second operand
  72400. * @param result defines the Color3 object where to store the result
  72401. * @returns the current Color3
  72402. */
  72403. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72404. /**
  72405. * Determines equality between Color3 objects
  72406. * @param otherColor defines the second operand
  72407. * @returns true if the rgb values are equal to the given ones
  72408. */
  72409. equals(otherColor: DeepImmutable<Color3>): boolean;
  72410. /**
  72411. * Determines equality between the current Color3 object and a set of r,b,g values
  72412. * @param r defines the red component to check
  72413. * @param g defines the green component to check
  72414. * @param b defines the blue component to check
  72415. * @returns true if the rgb values are equal to the given ones
  72416. */
  72417. equalsFloats(r: number, g: number, b: number): boolean;
  72418. /**
  72419. * Multiplies in place each rgb value by scale
  72420. * @param scale defines the scaling factor
  72421. * @returns the updated Color3
  72422. */
  72423. scale(scale: number): Color3;
  72424. /**
  72425. * Multiplies the rgb values by scale and stores the result into "result"
  72426. * @param scale defines the scaling factor
  72427. * @param result defines the Color3 object where to store the result
  72428. * @returns the unmodified current Color3
  72429. */
  72430. scaleToRef(scale: number, result: Color3): Color3;
  72431. /**
  72432. * Scale the current Color3 values by a factor and add the result to a given Color3
  72433. * @param scale defines the scale factor
  72434. * @param result defines color to store the result into
  72435. * @returns the unmodified current Color3
  72436. */
  72437. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72438. /**
  72439. * Clamps the rgb values by the min and max values and stores the result into "result"
  72440. * @param min defines minimum clamping value (default is 0)
  72441. * @param max defines maximum clamping value (default is 1)
  72442. * @param result defines color to store the result into
  72443. * @returns the original Color3
  72444. */
  72445. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72446. /**
  72447. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72448. * @param otherColor defines the second operand
  72449. * @returns the new Color3
  72450. */
  72451. add(otherColor: DeepImmutable<Color3>): Color3;
  72452. /**
  72453. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72454. * @param otherColor defines the second operand
  72455. * @param result defines Color3 object to store the result into
  72456. * @returns the unmodified current Color3
  72457. */
  72458. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72459. /**
  72460. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72461. * @param otherColor defines the second operand
  72462. * @returns the new Color3
  72463. */
  72464. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72465. /**
  72466. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72467. * @param otherColor defines the second operand
  72468. * @param result defines Color3 object to store the result into
  72469. * @returns the unmodified current Color3
  72470. */
  72471. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72472. /**
  72473. * Copy the current object
  72474. * @returns a new Color3 copied the current one
  72475. */
  72476. clone(): Color3;
  72477. /**
  72478. * Copies the rgb values from the source in the current Color3
  72479. * @param source defines the source Color3 object
  72480. * @returns the updated Color3 object
  72481. */
  72482. copyFrom(source: DeepImmutable<Color3>): Color3;
  72483. /**
  72484. * Updates the Color3 rgb values from the given floats
  72485. * @param r defines the red component to read from
  72486. * @param g defines the green component to read from
  72487. * @param b defines the blue component to read from
  72488. * @returns the current Color3 object
  72489. */
  72490. copyFromFloats(r: number, g: number, b: number): Color3;
  72491. /**
  72492. * Updates the Color3 rgb values from the given floats
  72493. * @param r defines the red component to read from
  72494. * @param g defines the green component to read from
  72495. * @param b defines the blue component to read from
  72496. * @returns the current Color3 object
  72497. */
  72498. set(r: number, g: number, b: number): Color3;
  72499. /**
  72500. * Compute the Color3 hexadecimal code as a string
  72501. * @returns a string containing the hexadecimal representation of the Color3 object
  72502. */
  72503. toHexString(): string;
  72504. /**
  72505. * Computes a new Color3 converted from the current one to linear space
  72506. * @returns a new Color3 object
  72507. */
  72508. toLinearSpace(): Color3;
  72509. /**
  72510. * Converts current color in rgb space to HSV values
  72511. * @returns a new color3 representing the HSV values
  72512. */
  72513. toHSV(): Color3;
  72514. /**
  72515. * Converts current color in rgb space to HSV values
  72516. * @param result defines the Color3 where to store the HSV values
  72517. */
  72518. toHSVToRef(result: Color3): void;
  72519. /**
  72520. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72521. * @param convertedColor defines the Color3 object where to store the linear space version
  72522. * @returns the unmodified Color3
  72523. */
  72524. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72525. /**
  72526. * Computes a new Color3 converted from the current one to gamma space
  72527. * @returns a new Color3 object
  72528. */
  72529. toGammaSpace(): Color3;
  72530. /**
  72531. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72532. * @param convertedColor defines the Color3 object where to store the gamma space version
  72533. * @returns the unmodified Color3
  72534. */
  72535. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72536. private static _BlackReadOnly;
  72537. /**
  72538. * Convert Hue, saturation and value to a Color3 (RGB)
  72539. * @param hue defines the hue
  72540. * @param saturation defines the saturation
  72541. * @param value defines the value
  72542. * @param result defines the Color3 where to store the RGB values
  72543. */
  72544. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72545. /**
  72546. * Creates a new Color3 from the string containing valid hexadecimal values
  72547. * @param hex defines a string containing valid hexadecimal values
  72548. * @returns a new Color3 object
  72549. */
  72550. static FromHexString(hex: string): Color3;
  72551. /**
  72552. * Creates a new Color3 from the starting index of the given array
  72553. * @param array defines the source array
  72554. * @param offset defines an offset in the source array
  72555. * @returns a new Color3 object
  72556. */
  72557. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72558. /**
  72559. * Creates a new Color3 from integer values (< 256)
  72560. * @param r defines the red component to read from (value between 0 and 255)
  72561. * @param g defines the green component to read from (value between 0 and 255)
  72562. * @param b defines the blue component to read from (value between 0 and 255)
  72563. * @returns a new Color3 object
  72564. */
  72565. static FromInts(r: number, g: number, b: number): Color3;
  72566. /**
  72567. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72568. * @param start defines the start Color3 value
  72569. * @param end defines the end Color3 value
  72570. * @param amount defines the gradient value between start and end
  72571. * @returns a new Color3 object
  72572. */
  72573. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72574. /**
  72575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72576. * @param left defines the start value
  72577. * @param right defines the end value
  72578. * @param amount defines the gradient factor
  72579. * @param result defines the Color3 object where to store the result
  72580. */
  72581. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72582. /**
  72583. * Returns a Color3 value containing a red color
  72584. * @returns a new Color3 object
  72585. */
  72586. static Red(): Color3;
  72587. /**
  72588. * Returns a Color3 value containing a green color
  72589. * @returns a new Color3 object
  72590. */
  72591. static Green(): Color3;
  72592. /**
  72593. * Returns a Color3 value containing a blue color
  72594. * @returns a new Color3 object
  72595. */
  72596. static Blue(): Color3;
  72597. /**
  72598. * Returns a Color3 value containing a black color
  72599. * @returns a new Color3 object
  72600. */
  72601. static Black(): Color3;
  72602. /**
  72603. * Gets a Color3 value containing a black color that must not be updated
  72604. */
  72605. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72606. /**
  72607. * Returns a Color3 value containing a white color
  72608. * @returns a new Color3 object
  72609. */
  72610. static White(): Color3;
  72611. /**
  72612. * Returns a Color3 value containing a purple color
  72613. * @returns a new Color3 object
  72614. */
  72615. static Purple(): Color3;
  72616. /**
  72617. * Returns a Color3 value containing a magenta color
  72618. * @returns a new Color3 object
  72619. */
  72620. static Magenta(): Color3;
  72621. /**
  72622. * Returns a Color3 value containing a yellow color
  72623. * @returns a new Color3 object
  72624. */
  72625. static Yellow(): Color3;
  72626. /**
  72627. * Returns a Color3 value containing a gray color
  72628. * @returns a new Color3 object
  72629. */
  72630. static Gray(): Color3;
  72631. /**
  72632. * Returns a Color3 value containing a teal color
  72633. * @returns a new Color3 object
  72634. */
  72635. static Teal(): Color3;
  72636. /**
  72637. * Returns a Color3 value containing a random color
  72638. * @returns a new Color3 object
  72639. */
  72640. static Random(): Color3;
  72641. }
  72642. /**
  72643. * Class used to hold a RBGA color
  72644. */
  72645. export class Color4 {
  72646. /**
  72647. * Defines the red component (between 0 and 1, default is 0)
  72648. */
  72649. r: number;
  72650. /**
  72651. * Defines the green component (between 0 and 1, default is 0)
  72652. */
  72653. g: number;
  72654. /**
  72655. * Defines the blue component (between 0 and 1, default is 0)
  72656. */
  72657. b: number;
  72658. /**
  72659. * Defines the alpha component (between 0 and 1, default is 1)
  72660. */
  72661. a: number;
  72662. /**
  72663. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72664. * @param r defines the red component (between 0 and 1, default is 0)
  72665. * @param g defines the green component (between 0 and 1, default is 0)
  72666. * @param b defines the blue component (between 0 and 1, default is 0)
  72667. * @param a defines the alpha component (between 0 and 1, default is 1)
  72668. */
  72669. constructor(
  72670. /**
  72671. * Defines the red component (between 0 and 1, default is 0)
  72672. */
  72673. r?: number,
  72674. /**
  72675. * Defines the green component (between 0 and 1, default is 0)
  72676. */
  72677. g?: number,
  72678. /**
  72679. * Defines the blue component (between 0 and 1, default is 0)
  72680. */
  72681. b?: number,
  72682. /**
  72683. * Defines the alpha component (between 0 and 1, default is 1)
  72684. */
  72685. a?: number);
  72686. /**
  72687. * Adds in place the given Color4 values to the current Color4 object
  72688. * @param right defines the second operand
  72689. * @returns the current updated Color4 object
  72690. */
  72691. addInPlace(right: DeepImmutable<Color4>): Color4;
  72692. /**
  72693. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72694. * @returns the new array
  72695. */
  72696. asArray(): number[];
  72697. /**
  72698. * Stores from the starting index in the given array the Color4 successive values
  72699. * @param array defines the array where to store the r,g,b components
  72700. * @param index defines an optional index in the target array to define where to start storing values
  72701. * @returns the current Color4 object
  72702. */
  72703. toArray(array: number[], index?: number): Color4;
  72704. /**
  72705. * Determines equality between Color4 objects
  72706. * @param otherColor defines the second operand
  72707. * @returns true if the rgba values are equal to the given ones
  72708. */
  72709. equals(otherColor: DeepImmutable<Color4>): boolean;
  72710. /**
  72711. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72712. * @param right defines the second operand
  72713. * @returns a new Color4 object
  72714. */
  72715. add(right: DeepImmutable<Color4>): Color4;
  72716. /**
  72717. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72718. * @param right defines the second operand
  72719. * @returns a new Color4 object
  72720. */
  72721. subtract(right: DeepImmutable<Color4>): Color4;
  72722. /**
  72723. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72724. * @param right defines the second operand
  72725. * @param result defines the Color4 object where to store the result
  72726. * @returns the current Color4 object
  72727. */
  72728. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72729. /**
  72730. * Creates a new Color4 with the current Color4 values multiplied by scale
  72731. * @param scale defines the scaling factor to apply
  72732. * @returns a new Color4 object
  72733. */
  72734. scale(scale: number): Color4;
  72735. /**
  72736. * Multiplies the current Color4 values by scale and stores the result in "result"
  72737. * @param scale defines the scaling factor to apply
  72738. * @param result defines the Color4 object where to store the result
  72739. * @returns the current unmodified Color4
  72740. */
  72741. scaleToRef(scale: number, result: Color4): Color4;
  72742. /**
  72743. * Scale the current Color4 values by a factor and add the result to a given Color4
  72744. * @param scale defines the scale factor
  72745. * @param result defines the Color4 object where to store the result
  72746. * @returns the unmodified current Color4
  72747. */
  72748. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72749. /**
  72750. * Clamps the rgb values by the min and max values and stores the result into "result"
  72751. * @param min defines minimum clamping value (default is 0)
  72752. * @param max defines maximum clamping value (default is 1)
  72753. * @param result defines color to store the result into.
  72754. * @returns the cuurent Color4
  72755. */
  72756. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72757. /**
  72758. * Multipy an Color4 value by another and return a new Color4 object
  72759. * @param color defines the Color4 value to multiply by
  72760. * @returns a new Color4 object
  72761. */
  72762. multiply(color: Color4): Color4;
  72763. /**
  72764. * Multipy a Color4 value by another and push the result in a reference value
  72765. * @param color defines the Color4 value to multiply by
  72766. * @param result defines the Color4 to fill the result in
  72767. * @returns the result Color4
  72768. */
  72769. multiplyToRef(color: Color4, result: Color4): Color4;
  72770. /**
  72771. * Creates a string with the Color4 current values
  72772. * @returns the string representation of the Color4 object
  72773. */
  72774. toString(): string;
  72775. /**
  72776. * Returns the string "Color4"
  72777. * @returns "Color4"
  72778. */
  72779. getClassName(): string;
  72780. /**
  72781. * Compute the Color4 hash code
  72782. * @returns an unique number that can be used to hash Color4 objects
  72783. */
  72784. getHashCode(): number;
  72785. /**
  72786. * Creates a new Color4 copied from the current one
  72787. * @returns a new Color4 object
  72788. */
  72789. clone(): Color4;
  72790. /**
  72791. * Copies the given Color4 values into the current one
  72792. * @param source defines the source Color4 object
  72793. * @returns the current updated Color4 object
  72794. */
  72795. copyFrom(source: Color4): Color4;
  72796. /**
  72797. * Copies the given float values into the current one
  72798. * @param r defines the red component to read from
  72799. * @param g defines the green component to read from
  72800. * @param b defines the blue component to read from
  72801. * @param a defines the alpha component to read from
  72802. * @returns the current updated Color4 object
  72803. */
  72804. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72805. /**
  72806. * Copies the given float values into the current one
  72807. * @param r defines the red component to read from
  72808. * @param g defines the green component to read from
  72809. * @param b defines the blue component to read from
  72810. * @param a defines the alpha component to read from
  72811. * @returns the current updated Color4 object
  72812. */
  72813. set(r: number, g: number, b: number, a: number): Color4;
  72814. /**
  72815. * Compute the Color4 hexadecimal code as a string
  72816. * @returns a string containing the hexadecimal representation of the Color4 object
  72817. */
  72818. toHexString(): string;
  72819. /**
  72820. * Computes a new Color4 converted from the current one to linear space
  72821. * @returns a new Color4 object
  72822. */
  72823. toLinearSpace(): Color4;
  72824. /**
  72825. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72826. * @param convertedColor defines the Color4 object where to store the linear space version
  72827. * @returns the unmodified Color4
  72828. */
  72829. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72830. /**
  72831. * Computes a new Color4 converted from the current one to gamma space
  72832. * @returns a new Color4 object
  72833. */
  72834. toGammaSpace(): Color4;
  72835. /**
  72836. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72837. * @param convertedColor defines the Color4 object where to store the gamma space version
  72838. * @returns the unmodified Color4
  72839. */
  72840. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72841. /**
  72842. * Creates a new Color4 from the string containing valid hexadecimal values
  72843. * @param hex defines a string containing valid hexadecimal values
  72844. * @returns a new Color4 object
  72845. */
  72846. static FromHexString(hex: string): Color4;
  72847. /**
  72848. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72849. * @param left defines the start value
  72850. * @param right defines the end value
  72851. * @param amount defines the gradient factor
  72852. * @returns a new Color4 object
  72853. */
  72854. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72855. /**
  72856. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72857. * @param left defines the start value
  72858. * @param right defines the end value
  72859. * @param amount defines the gradient factor
  72860. * @param result defines the Color4 object where to store data
  72861. */
  72862. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72863. /**
  72864. * Creates a new Color4 from a Color3 and an alpha value
  72865. * @param color3 defines the source Color3 to read from
  72866. * @param alpha defines the alpha component (1.0 by default)
  72867. * @returns a new Color4 object
  72868. */
  72869. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72870. /**
  72871. * Creates a new Color4 from the starting index element of the given array
  72872. * @param array defines the source array to read from
  72873. * @param offset defines the offset in the source array
  72874. * @returns a new Color4 object
  72875. */
  72876. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72877. /**
  72878. * Creates a new Color3 from integer values (< 256)
  72879. * @param r defines the red component to read from (value between 0 and 255)
  72880. * @param g defines the green component to read from (value between 0 and 255)
  72881. * @param b defines the blue component to read from (value between 0 and 255)
  72882. * @param a defines the alpha component to read from (value between 0 and 255)
  72883. * @returns a new Color3 object
  72884. */
  72885. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72886. /**
  72887. * Check the content of a given array and convert it to an array containing RGBA data
  72888. * If the original array was already containing count * 4 values then it is returned directly
  72889. * @param colors defines the array to check
  72890. * @param count defines the number of RGBA data to expect
  72891. * @returns an array containing count * 4 values (RGBA)
  72892. */
  72893. static CheckColors4(colors: number[], count: number): number[];
  72894. }
  72895. /**
  72896. * @hidden
  72897. */
  72898. export class TmpColors {
  72899. static Color3: Color3[];
  72900. static Color4: Color4[];
  72901. }
  72902. }
  72903. declare module BABYLON {
  72904. /**
  72905. * Defines an interface which represents an animation key frame
  72906. */
  72907. export interface IAnimationKey {
  72908. /**
  72909. * Frame of the key frame
  72910. */
  72911. frame: number;
  72912. /**
  72913. * Value at the specifies key frame
  72914. */
  72915. value: any;
  72916. /**
  72917. * The input tangent for the cubic hermite spline
  72918. */
  72919. inTangent?: any;
  72920. /**
  72921. * The output tangent for the cubic hermite spline
  72922. */
  72923. outTangent?: any;
  72924. /**
  72925. * The animation interpolation type
  72926. */
  72927. interpolation?: AnimationKeyInterpolation;
  72928. }
  72929. /**
  72930. * Enum for the animation key frame interpolation type
  72931. */
  72932. export enum AnimationKeyInterpolation {
  72933. /**
  72934. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72935. */
  72936. STEP = 1
  72937. }
  72938. }
  72939. declare module BABYLON {
  72940. /**
  72941. * Represents the range of an animation
  72942. */
  72943. export class AnimationRange {
  72944. /**The name of the animation range**/
  72945. name: string;
  72946. /**The starting frame of the animation */
  72947. from: number;
  72948. /**The ending frame of the animation*/
  72949. to: number;
  72950. /**
  72951. * Initializes the range of an animation
  72952. * @param name The name of the animation range
  72953. * @param from The starting frame of the animation
  72954. * @param to The ending frame of the animation
  72955. */
  72956. constructor(
  72957. /**The name of the animation range**/
  72958. name: string,
  72959. /**The starting frame of the animation */
  72960. from: number,
  72961. /**The ending frame of the animation*/
  72962. to: number);
  72963. /**
  72964. * Makes a copy of the animation range
  72965. * @returns A copy of the animation range
  72966. */
  72967. clone(): AnimationRange;
  72968. }
  72969. }
  72970. declare module BABYLON {
  72971. /**
  72972. * Composed of a frame, and an action function
  72973. */
  72974. export class AnimationEvent {
  72975. /** The frame for which the event is triggered **/
  72976. frame: number;
  72977. /** The event to perform when triggered **/
  72978. action: (currentFrame: number) => void;
  72979. /** Specifies if the event should be triggered only once**/
  72980. onlyOnce?: boolean | undefined;
  72981. /**
  72982. * Specifies if the animation event is done
  72983. */
  72984. isDone: boolean;
  72985. /**
  72986. * Initializes the animation event
  72987. * @param frame The frame for which the event is triggered
  72988. * @param action The event to perform when triggered
  72989. * @param onlyOnce Specifies if the event should be triggered only once
  72990. */
  72991. constructor(
  72992. /** The frame for which the event is triggered **/
  72993. frame: number,
  72994. /** The event to perform when triggered **/
  72995. action: (currentFrame: number) => void,
  72996. /** Specifies if the event should be triggered only once**/
  72997. onlyOnce?: boolean | undefined);
  72998. /** @hidden */
  72999. _clone(): AnimationEvent;
  73000. }
  73001. }
  73002. declare module BABYLON {
  73003. /**
  73004. * Interface used to define a behavior
  73005. */
  73006. export interface Behavior<T> {
  73007. /** gets or sets behavior's name */
  73008. name: string;
  73009. /**
  73010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73011. */
  73012. init(): void;
  73013. /**
  73014. * Called when the behavior is attached to a target
  73015. * @param target defines the target where the behavior is attached to
  73016. */
  73017. attach(target: T): void;
  73018. /**
  73019. * Called when the behavior is detached from its target
  73020. */
  73021. detach(): void;
  73022. }
  73023. /**
  73024. * Interface implemented by classes supporting behaviors
  73025. */
  73026. export interface IBehaviorAware<T> {
  73027. /**
  73028. * Attach a behavior
  73029. * @param behavior defines the behavior to attach
  73030. * @returns the current host
  73031. */
  73032. addBehavior(behavior: Behavior<T>): T;
  73033. /**
  73034. * Remove a behavior from the current object
  73035. * @param behavior defines the behavior to detach
  73036. * @returns the current host
  73037. */
  73038. removeBehavior(behavior: Behavior<T>): T;
  73039. /**
  73040. * Gets a behavior using its name to search
  73041. * @param name defines the name to search
  73042. * @returns the behavior or null if not found
  73043. */
  73044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73045. }
  73046. }
  73047. declare module BABYLON {
  73048. /**
  73049. * Defines an array and its length.
  73050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73051. */
  73052. export interface ISmartArrayLike<T> {
  73053. /**
  73054. * The data of the array.
  73055. */
  73056. data: Array<T>;
  73057. /**
  73058. * The active length of the array.
  73059. */
  73060. length: number;
  73061. }
  73062. /**
  73063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73064. */
  73065. export class SmartArray<T> implements ISmartArrayLike<T> {
  73066. /**
  73067. * The full set of data from the array.
  73068. */
  73069. data: Array<T>;
  73070. /**
  73071. * The active length of the array.
  73072. */
  73073. length: number;
  73074. protected _id: number;
  73075. /**
  73076. * Instantiates a Smart Array.
  73077. * @param capacity defines the default capacity of the array.
  73078. */
  73079. constructor(capacity: number);
  73080. /**
  73081. * Pushes a value at the end of the active data.
  73082. * @param value defines the object to push in the array.
  73083. */
  73084. push(value: T): void;
  73085. /**
  73086. * Iterates over the active data and apply the lambda to them.
  73087. * @param func defines the action to apply on each value.
  73088. */
  73089. forEach(func: (content: T) => void): void;
  73090. /**
  73091. * Sorts the full sets of data.
  73092. * @param compareFn defines the comparison function to apply.
  73093. */
  73094. sort(compareFn: (a: T, b: T) => number): void;
  73095. /**
  73096. * Resets the active data to an empty array.
  73097. */
  73098. reset(): void;
  73099. /**
  73100. * Releases all the data from the array as well as the array.
  73101. */
  73102. dispose(): void;
  73103. /**
  73104. * Concats the active data with a given array.
  73105. * @param array defines the data to concatenate with.
  73106. */
  73107. concat(array: any): void;
  73108. /**
  73109. * Returns the position of a value in the active data.
  73110. * @param value defines the value to find the index for
  73111. * @returns the index if found in the active data otherwise -1
  73112. */
  73113. indexOf(value: T): number;
  73114. /**
  73115. * Returns whether an element is part of the active data.
  73116. * @param value defines the value to look for
  73117. * @returns true if found in the active data otherwise false
  73118. */
  73119. contains(value: T): boolean;
  73120. private static _GlobalId;
  73121. }
  73122. /**
  73123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73124. * The data in this array can only be present once
  73125. */
  73126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73127. private _duplicateId;
  73128. /**
  73129. * Pushes a value at the end of the active data.
  73130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73131. * @param value defines the object to push in the array.
  73132. */
  73133. push(value: T): void;
  73134. /**
  73135. * Pushes a value at the end of the active data.
  73136. * If the data is already present, it won t be added again
  73137. * @param value defines the object to push in the array.
  73138. * @returns true if added false if it was already present
  73139. */
  73140. pushNoDuplicate(value: T): boolean;
  73141. /**
  73142. * Resets the active data to an empty array.
  73143. */
  73144. reset(): void;
  73145. /**
  73146. * Concats the active data with a given array.
  73147. * This ensures no dupplicate will be present in the result.
  73148. * @param array defines the data to concatenate with.
  73149. */
  73150. concatWithNoDuplicate(array: any): void;
  73151. }
  73152. }
  73153. declare module BABYLON {
  73154. /**
  73155. * @ignore
  73156. * This is a list of all the different input types that are available in the application.
  73157. * Fo instance: ArcRotateCameraGamepadInput...
  73158. */
  73159. export var CameraInputTypes: {};
  73160. /**
  73161. * This is the contract to implement in order to create a new input class.
  73162. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73163. */
  73164. export interface ICameraInput<TCamera extends Camera> {
  73165. /**
  73166. * Defines the camera the input is attached to.
  73167. */
  73168. camera: Nullable<TCamera>;
  73169. /**
  73170. * Gets the class name of the current intput.
  73171. * @returns the class name
  73172. */
  73173. getClassName(): string;
  73174. /**
  73175. * Get the friendly name associated with the input class.
  73176. * @returns the input friendly name
  73177. */
  73178. getSimpleName(): string;
  73179. /**
  73180. * Attach the input controls to a specific dom element to get the input from.
  73181. * @param element Defines the element the controls should be listened from
  73182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73183. */
  73184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73185. /**
  73186. * Detach the current controls from the specified dom element.
  73187. * @param element Defines the element to stop listening the inputs from
  73188. */
  73189. detachControl(element: Nullable<HTMLElement>): void;
  73190. /**
  73191. * Update the current camera state depending on the inputs that have been used this frame.
  73192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73193. */
  73194. checkInputs?: () => void;
  73195. }
  73196. /**
  73197. * Represents a map of input types to input instance or input index to input instance.
  73198. */
  73199. export interface CameraInputsMap<TCamera extends Camera> {
  73200. /**
  73201. * Accessor to the input by input type.
  73202. */
  73203. [name: string]: ICameraInput<TCamera>;
  73204. /**
  73205. * Accessor to the input by input index.
  73206. */
  73207. [idx: number]: ICameraInput<TCamera>;
  73208. }
  73209. /**
  73210. * This represents the input manager used within a camera.
  73211. * It helps dealing with all the different kind of input attached to a camera.
  73212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73213. */
  73214. export class CameraInputsManager<TCamera extends Camera> {
  73215. /**
  73216. * Defines the list of inputs attahed to the camera.
  73217. */
  73218. attached: CameraInputsMap<TCamera>;
  73219. /**
  73220. * Defines the dom element the camera is collecting inputs from.
  73221. * This is null if the controls have not been attached.
  73222. */
  73223. attachedElement: Nullable<HTMLElement>;
  73224. /**
  73225. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73226. */
  73227. noPreventDefault: boolean;
  73228. /**
  73229. * Defined the camera the input manager belongs to.
  73230. */
  73231. camera: TCamera;
  73232. /**
  73233. * Update the current camera state depending on the inputs that have been used this frame.
  73234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73235. */
  73236. checkInputs: () => void;
  73237. /**
  73238. * Instantiate a new Camera Input Manager.
  73239. * @param camera Defines the camera the input manager blongs to
  73240. */
  73241. constructor(camera: TCamera);
  73242. /**
  73243. * Add an input method to a camera
  73244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73245. * @param input camera input method
  73246. */
  73247. add(input: ICameraInput<TCamera>): void;
  73248. /**
  73249. * Remove a specific input method from a camera
  73250. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73251. * @param inputToRemove camera input method
  73252. */
  73253. remove(inputToRemove: ICameraInput<TCamera>): void;
  73254. /**
  73255. * Remove a specific input type from a camera
  73256. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73257. * @param inputType the type of the input to remove
  73258. */
  73259. removeByType(inputType: string): void;
  73260. private _addCheckInputs;
  73261. /**
  73262. * Attach the input controls to the currently attached dom element to listen the events from.
  73263. * @param input Defines the input to attach
  73264. */
  73265. attachInput(input: ICameraInput<TCamera>): void;
  73266. /**
  73267. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73268. * @param element Defines the dom element to collect the events from
  73269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73270. */
  73271. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73272. /**
  73273. * Detach the current manager inputs controls from a specific dom element.
  73274. * @param element Defines the dom element to collect the events from
  73275. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73276. */
  73277. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73278. /**
  73279. * Rebuild the dynamic inputCheck function from the current list of
  73280. * defined inputs in the manager.
  73281. */
  73282. rebuildInputCheck(): void;
  73283. /**
  73284. * Remove all attached input methods from a camera
  73285. */
  73286. clear(): void;
  73287. /**
  73288. * Serialize the current input manager attached to a camera.
  73289. * This ensures than once parsed,
  73290. * the input associated to the camera will be identical to the current ones
  73291. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73292. */
  73293. serialize(serializedCamera: any): void;
  73294. /**
  73295. * Parses an input manager serialized JSON to restore the previous list of inputs
  73296. * and states associated to a camera.
  73297. * @param parsedCamera Defines the JSON to parse
  73298. */
  73299. parse(parsedCamera: any): void;
  73300. }
  73301. }
  73302. declare module BABYLON {
  73303. /**
  73304. * Class used to store data that will be store in GPU memory
  73305. */
  73306. export class Buffer {
  73307. private _engine;
  73308. private _buffer;
  73309. /** @hidden */
  73310. _data: Nullable<DataArray>;
  73311. private _updatable;
  73312. private _instanced;
  73313. /**
  73314. * Gets the byte stride.
  73315. */
  73316. readonly byteStride: number;
  73317. /**
  73318. * Constructor
  73319. * @param engine the engine
  73320. * @param data the data to use for this buffer
  73321. * @param updatable whether the data is updatable
  73322. * @param stride the stride (optional)
  73323. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73324. * @param instanced whether the buffer is instanced (optional)
  73325. * @param useBytes set to true if the stride in in bytes (optional)
  73326. */
  73327. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  73328. /**
  73329. * Create a new VertexBuffer based on the current buffer
  73330. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73331. * @param offset defines offset in the buffer (0 by default)
  73332. * @param size defines the size in floats of attributes (position is 3 for instance)
  73333. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73334. * @param instanced defines if the vertex buffer contains indexed data
  73335. * @param useBytes defines if the offset and stride are in bytes
  73336. * @returns the new vertex buffer
  73337. */
  73338. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  73339. /**
  73340. * Gets a boolean indicating if the Buffer is updatable?
  73341. * @returns true if the buffer is updatable
  73342. */
  73343. isUpdatable(): boolean;
  73344. /**
  73345. * Gets current buffer's data
  73346. * @returns a DataArray or null
  73347. */
  73348. getData(): Nullable<DataArray>;
  73349. /**
  73350. * Gets underlying native buffer
  73351. * @returns underlying native buffer
  73352. */
  73353. getBuffer(): Nullable<DataBuffer>;
  73354. /**
  73355. * Gets the stride in float32 units (i.e. byte stride / 4).
  73356. * May not be an integer if the byte stride is not divisible by 4.
  73357. * DEPRECATED. Use byteStride instead.
  73358. * @returns the stride in float32 units
  73359. */
  73360. getStrideSize(): number;
  73361. /**
  73362. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73363. * @param data defines the data to store
  73364. */
  73365. create(data?: Nullable<DataArray>): void;
  73366. /** @hidden */
  73367. _rebuild(): void;
  73368. /**
  73369. * Update current buffer data
  73370. * @param data defines the data to store
  73371. */
  73372. update(data: DataArray): void;
  73373. /**
  73374. * Updates the data directly.
  73375. * @param data the new data
  73376. * @param offset the new offset
  73377. * @param vertexCount the vertex count (optional)
  73378. * @param useBytes set to true if the offset is in bytes
  73379. */
  73380. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73381. /**
  73382. * Release all resources
  73383. */
  73384. dispose(): void;
  73385. }
  73386. /**
  73387. * Specialized buffer used to store vertex data
  73388. */
  73389. export class VertexBuffer {
  73390. /** @hidden */
  73391. _buffer: Buffer;
  73392. private _kind;
  73393. private _size;
  73394. private _ownsBuffer;
  73395. private _instanced;
  73396. private _instanceDivisor;
  73397. /**
  73398. * The byte type.
  73399. */
  73400. static readonly BYTE: number;
  73401. /**
  73402. * The unsigned byte type.
  73403. */
  73404. static readonly UNSIGNED_BYTE: number;
  73405. /**
  73406. * The short type.
  73407. */
  73408. static readonly SHORT: number;
  73409. /**
  73410. * The unsigned short type.
  73411. */
  73412. static readonly UNSIGNED_SHORT: number;
  73413. /**
  73414. * The integer type.
  73415. */
  73416. static readonly INT: number;
  73417. /**
  73418. * The unsigned integer type.
  73419. */
  73420. static readonly UNSIGNED_INT: number;
  73421. /**
  73422. * The float type.
  73423. */
  73424. static readonly FLOAT: number;
  73425. /**
  73426. * Gets or sets the instance divisor when in instanced mode
  73427. */
  73428. instanceDivisor: number;
  73429. /**
  73430. * Gets the byte stride.
  73431. */
  73432. readonly byteStride: number;
  73433. /**
  73434. * Gets the byte offset.
  73435. */
  73436. readonly byteOffset: number;
  73437. /**
  73438. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73439. */
  73440. readonly normalized: boolean;
  73441. /**
  73442. * Gets the data type of each component in the array.
  73443. */
  73444. readonly type: number;
  73445. /**
  73446. * Constructor
  73447. * @param engine the engine
  73448. * @param data the data to use for this vertex buffer
  73449. * @param kind the vertex buffer kind
  73450. * @param updatable whether the data is updatable
  73451. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73452. * @param stride the stride (optional)
  73453. * @param instanced whether the buffer is instanced (optional)
  73454. * @param offset the offset of the data (optional)
  73455. * @param size the number of components (optional)
  73456. * @param type the type of the component (optional)
  73457. * @param normalized whether the data contains normalized data (optional)
  73458. * @param useBytes set to true if stride and offset are in bytes (optional)
  73459. */
  73460. 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);
  73461. /** @hidden */
  73462. _rebuild(): void;
  73463. /**
  73464. * Returns the kind of the VertexBuffer (string)
  73465. * @returns a string
  73466. */
  73467. getKind(): string;
  73468. /**
  73469. * Gets a boolean indicating if the VertexBuffer is updatable?
  73470. * @returns true if the buffer is updatable
  73471. */
  73472. isUpdatable(): boolean;
  73473. /**
  73474. * Gets current buffer's data
  73475. * @returns a DataArray or null
  73476. */
  73477. getData(): Nullable<DataArray>;
  73478. /**
  73479. * Gets underlying native buffer
  73480. * @returns underlying native buffer
  73481. */
  73482. getBuffer(): Nullable<DataBuffer>;
  73483. /**
  73484. * Gets the stride in float32 units (i.e. byte stride / 4).
  73485. * May not be an integer if the byte stride is not divisible by 4.
  73486. * DEPRECATED. Use byteStride instead.
  73487. * @returns the stride in float32 units
  73488. */
  73489. getStrideSize(): number;
  73490. /**
  73491. * Returns the offset as a multiple of the type byte length.
  73492. * DEPRECATED. Use byteOffset instead.
  73493. * @returns the offset in bytes
  73494. */
  73495. getOffset(): number;
  73496. /**
  73497. * Returns the number of components per vertex attribute (integer)
  73498. * @returns the size in float
  73499. */
  73500. getSize(): number;
  73501. /**
  73502. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73503. * @returns true if this buffer is instanced
  73504. */
  73505. getIsInstanced(): boolean;
  73506. /**
  73507. * Returns the instancing divisor, zero for non-instanced (integer).
  73508. * @returns a number
  73509. */
  73510. getInstanceDivisor(): number;
  73511. /**
  73512. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73513. * @param data defines the data to store
  73514. */
  73515. create(data?: DataArray): void;
  73516. /**
  73517. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73518. * This function will create a new buffer if the current one is not updatable
  73519. * @param data defines the data to store
  73520. */
  73521. update(data: DataArray): void;
  73522. /**
  73523. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73524. * Returns the directly updated WebGLBuffer.
  73525. * @param data the new data
  73526. * @param offset the new offset
  73527. * @param useBytes set to true if the offset is in bytes
  73528. */
  73529. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73530. /**
  73531. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73532. */
  73533. dispose(): void;
  73534. /**
  73535. * Enumerates each value of this vertex buffer as numbers.
  73536. * @param count the number of values to enumerate
  73537. * @param callback the callback function called for each value
  73538. */
  73539. forEach(count: number, callback: (value: number, index: number) => void): void;
  73540. /**
  73541. * Positions
  73542. */
  73543. static readonly PositionKind: string;
  73544. /**
  73545. * Normals
  73546. */
  73547. static readonly NormalKind: string;
  73548. /**
  73549. * Tangents
  73550. */
  73551. static readonly TangentKind: string;
  73552. /**
  73553. * Texture coordinates
  73554. */
  73555. static readonly UVKind: string;
  73556. /**
  73557. * Texture coordinates 2
  73558. */
  73559. static readonly UV2Kind: string;
  73560. /**
  73561. * Texture coordinates 3
  73562. */
  73563. static readonly UV3Kind: string;
  73564. /**
  73565. * Texture coordinates 4
  73566. */
  73567. static readonly UV4Kind: string;
  73568. /**
  73569. * Texture coordinates 5
  73570. */
  73571. static readonly UV5Kind: string;
  73572. /**
  73573. * Texture coordinates 6
  73574. */
  73575. static readonly UV6Kind: string;
  73576. /**
  73577. * Colors
  73578. */
  73579. static readonly ColorKind: string;
  73580. /**
  73581. * Matrix indices (for bones)
  73582. */
  73583. static readonly MatricesIndicesKind: string;
  73584. /**
  73585. * Matrix weights (for bones)
  73586. */
  73587. static readonly MatricesWeightsKind: string;
  73588. /**
  73589. * Additional matrix indices (for bones)
  73590. */
  73591. static readonly MatricesIndicesExtraKind: string;
  73592. /**
  73593. * Additional matrix weights (for bones)
  73594. */
  73595. static readonly MatricesWeightsExtraKind: string;
  73596. /**
  73597. * Deduces the stride given a kind.
  73598. * @param kind The kind string to deduce
  73599. * @returns The deduced stride
  73600. */
  73601. static DeduceStride(kind: string): number;
  73602. /**
  73603. * Gets the byte length of the given type.
  73604. * @param type the type
  73605. * @returns the number of bytes
  73606. */
  73607. static GetTypeByteLength(type: number): number;
  73608. /**
  73609. * Enumerates each value of the given parameters as numbers.
  73610. * @param data the data to enumerate
  73611. * @param byteOffset the byte offset of the data
  73612. * @param byteStride the byte stride of the data
  73613. * @param componentCount the number of components per element
  73614. * @param componentType the type of the component
  73615. * @param count the number of values to enumerate
  73616. * @param normalized whether the data is normalized
  73617. * @param callback the callback function called for each value
  73618. */
  73619. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73620. private static _GetFloatValue;
  73621. }
  73622. }
  73623. declare module BABYLON {
  73624. /**
  73625. * @hidden
  73626. */
  73627. export class IntersectionInfo {
  73628. bu: Nullable<number>;
  73629. bv: Nullable<number>;
  73630. distance: number;
  73631. faceId: number;
  73632. subMeshId: number;
  73633. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73634. }
  73635. }
  73636. declare module BABYLON {
  73637. /**
  73638. * Represens a plane by the equation ax + by + cz + d = 0
  73639. */
  73640. export class Plane {
  73641. private static _TmpMatrix;
  73642. /**
  73643. * Normal of the plane (a,b,c)
  73644. */
  73645. normal: Vector3;
  73646. /**
  73647. * d component of the plane
  73648. */
  73649. d: number;
  73650. /**
  73651. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73652. * @param a a component of the plane
  73653. * @param b b component of the plane
  73654. * @param c c component of the plane
  73655. * @param d d component of the plane
  73656. */
  73657. constructor(a: number, b: number, c: number, d: number);
  73658. /**
  73659. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73660. */
  73661. asArray(): number[];
  73662. /**
  73663. * @returns a new plane copied from the current Plane.
  73664. */
  73665. clone(): Plane;
  73666. /**
  73667. * @returns the string "Plane".
  73668. */
  73669. getClassName(): string;
  73670. /**
  73671. * @returns the Plane hash code.
  73672. */
  73673. getHashCode(): number;
  73674. /**
  73675. * Normalize the current Plane in place.
  73676. * @returns the updated Plane.
  73677. */
  73678. normalize(): Plane;
  73679. /**
  73680. * Applies a transformation the plane and returns the result
  73681. * @param transformation the transformation matrix to be applied to the plane
  73682. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73683. */
  73684. transform(transformation: DeepImmutable<Matrix>): Plane;
  73685. /**
  73686. * Calcualtte the dot product between the point and the plane normal
  73687. * @param point point to calculate the dot product with
  73688. * @returns the dot product (float) of the point coordinates and the plane normal.
  73689. */
  73690. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73691. /**
  73692. * Updates the current Plane from the plane defined by the three given points.
  73693. * @param point1 one of the points used to contruct the plane
  73694. * @param point2 one of the points used to contruct the plane
  73695. * @param point3 one of the points used to contruct the plane
  73696. * @returns the updated Plane.
  73697. */
  73698. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73699. /**
  73700. * Checks if the plane is facing a given direction
  73701. * @param direction the direction to check if the plane is facing
  73702. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73703. * @returns True is the vector "direction" is the same side than the plane normal.
  73704. */
  73705. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73706. /**
  73707. * Calculates the distance to a point
  73708. * @param point point to calculate distance to
  73709. * @returns the signed distance (float) from the given point to the Plane.
  73710. */
  73711. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73712. /**
  73713. * Creates a plane from an array
  73714. * @param array the array to create a plane from
  73715. * @returns a new Plane from the given array.
  73716. */
  73717. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73718. /**
  73719. * Creates a plane from three points
  73720. * @param point1 point used to create the plane
  73721. * @param point2 point used to create the plane
  73722. * @param point3 point used to create the plane
  73723. * @returns a new Plane defined by the three given points.
  73724. */
  73725. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73726. /**
  73727. * Creates a plane from an origin point and a normal
  73728. * @param origin origin of the plane to be constructed
  73729. * @param normal normal of the plane to be constructed
  73730. * @returns a new Plane the normal vector to this plane at the given origin point.
  73731. * Note : the vector "normal" is updated because normalized.
  73732. */
  73733. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73734. /**
  73735. * Calculates the distance from a plane and a point
  73736. * @param origin origin of the plane to be constructed
  73737. * @param normal normal of the plane to be constructed
  73738. * @param point point to calculate distance to
  73739. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73740. */
  73741. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73742. }
  73743. }
  73744. declare module BABYLON {
  73745. /**
  73746. * Class used to store bounding sphere information
  73747. */
  73748. export class BoundingSphere {
  73749. /**
  73750. * Gets the center of the bounding sphere in local space
  73751. */
  73752. readonly center: Vector3;
  73753. /**
  73754. * Radius of the bounding sphere in local space
  73755. */
  73756. radius: number;
  73757. /**
  73758. * Gets the center of the bounding sphere in world space
  73759. */
  73760. readonly centerWorld: Vector3;
  73761. /**
  73762. * Radius of the bounding sphere in world space
  73763. */
  73764. radiusWorld: number;
  73765. /**
  73766. * Gets the minimum vector in local space
  73767. */
  73768. readonly minimum: Vector3;
  73769. /**
  73770. * Gets the maximum vector in local space
  73771. */
  73772. readonly maximum: Vector3;
  73773. private _worldMatrix;
  73774. private static readonly TmpVector3;
  73775. /**
  73776. * Creates a new bounding sphere
  73777. * @param min defines the minimum vector (in local space)
  73778. * @param max defines the maximum vector (in local space)
  73779. * @param worldMatrix defines the new world matrix
  73780. */
  73781. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73782. /**
  73783. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73784. * @param min defines the new minimum vector (in local space)
  73785. * @param max defines the new maximum vector (in local space)
  73786. * @param worldMatrix defines the new world matrix
  73787. */
  73788. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73789. /**
  73790. * Scale the current bounding sphere by applying a scale factor
  73791. * @param factor defines the scale factor to apply
  73792. * @returns the current bounding box
  73793. */
  73794. scale(factor: number): BoundingSphere;
  73795. /**
  73796. * Gets the world matrix of the bounding box
  73797. * @returns a matrix
  73798. */
  73799. getWorldMatrix(): DeepImmutable<Matrix>;
  73800. /** @hidden */
  73801. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73802. /**
  73803. * Tests if the bounding sphere is intersecting the frustum planes
  73804. * @param frustumPlanes defines the frustum planes to test
  73805. * @returns true if there is an intersection
  73806. */
  73807. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73808. /**
  73809. * Tests if the bounding sphere center is in between the frustum planes.
  73810. * Used for optimistic fast inclusion.
  73811. * @param frustumPlanes defines the frustum planes to test
  73812. * @returns true if the sphere center is in between the frustum planes
  73813. */
  73814. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73815. /**
  73816. * Tests if a point is inside the bounding sphere
  73817. * @param point defines the point to test
  73818. * @returns true if the point is inside the bounding sphere
  73819. */
  73820. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73821. /**
  73822. * Checks if two sphere intersct
  73823. * @param sphere0 sphere 0
  73824. * @param sphere1 sphere 1
  73825. * @returns true if the speres intersect
  73826. */
  73827. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73828. }
  73829. }
  73830. declare module BABYLON {
  73831. /**
  73832. * Class used to store bounding box information
  73833. */
  73834. export class BoundingBox implements ICullable {
  73835. /**
  73836. * Gets the 8 vectors representing the bounding box in local space
  73837. */
  73838. readonly vectors: Vector3[];
  73839. /**
  73840. * Gets the center of the bounding box in local space
  73841. */
  73842. readonly center: Vector3;
  73843. /**
  73844. * Gets the center of the bounding box in world space
  73845. */
  73846. readonly centerWorld: Vector3;
  73847. /**
  73848. * Gets the extend size in local space
  73849. */
  73850. readonly extendSize: Vector3;
  73851. /**
  73852. * Gets the extend size in world space
  73853. */
  73854. readonly extendSizeWorld: Vector3;
  73855. /**
  73856. * Gets the OBB (object bounding box) directions
  73857. */
  73858. readonly directions: Vector3[];
  73859. /**
  73860. * Gets the 8 vectors representing the bounding box in world space
  73861. */
  73862. readonly vectorsWorld: Vector3[];
  73863. /**
  73864. * Gets the minimum vector in world space
  73865. */
  73866. readonly minimumWorld: Vector3;
  73867. /**
  73868. * Gets the maximum vector in world space
  73869. */
  73870. readonly maximumWorld: Vector3;
  73871. /**
  73872. * Gets the minimum vector in local space
  73873. */
  73874. readonly minimum: Vector3;
  73875. /**
  73876. * Gets the maximum vector in local space
  73877. */
  73878. readonly maximum: Vector3;
  73879. private _worldMatrix;
  73880. private static readonly TmpVector3;
  73881. /**
  73882. * @hidden
  73883. */
  73884. _tag: number;
  73885. /**
  73886. * Creates a new bounding box
  73887. * @param min defines the minimum vector (in local space)
  73888. * @param max defines the maximum vector (in local space)
  73889. * @param worldMatrix defines the new world matrix
  73890. */
  73891. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73892. /**
  73893. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73894. * @param min defines the new minimum vector (in local space)
  73895. * @param max defines the new maximum vector (in local space)
  73896. * @param worldMatrix defines the new world matrix
  73897. */
  73898. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73899. /**
  73900. * Scale the current bounding box by applying a scale factor
  73901. * @param factor defines the scale factor to apply
  73902. * @returns the current bounding box
  73903. */
  73904. scale(factor: number): BoundingBox;
  73905. /**
  73906. * Gets the world matrix of the bounding box
  73907. * @returns a matrix
  73908. */
  73909. getWorldMatrix(): DeepImmutable<Matrix>;
  73910. /** @hidden */
  73911. _update(world: DeepImmutable<Matrix>): void;
  73912. /**
  73913. * Tests if the bounding box is intersecting the frustum planes
  73914. * @param frustumPlanes defines the frustum planes to test
  73915. * @returns true if there is an intersection
  73916. */
  73917. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73918. /**
  73919. * Tests if the bounding box is entirely inside the frustum planes
  73920. * @param frustumPlanes defines the frustum planes to test
  73921. * @returns true if there is an inclusion
  73922. */
  73923. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73924. /**
  73925. * Tests if a point is inside the bounding box
  73926. * @param point defines the point to test
  73927. * @returns true if the point is inside the bounding box
  73928. */
  73929. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73930. /**
  73931. * Tests if the bounding box intersects with a bounding sphere
  73932. * @param sphere defines the sphere to test
  73933. * @returns true if there is an intersection
  73934. */
  73935. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73936. /**
  73937. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73938. * @param min defines the min vector to use
  73939. * @param max defines the max vector to use
  73940. * @returns true if there is an intersection
  73941. */
  73942. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73943. /**
  73944. * Tests if two bounding boxes are intersections
  73945. * @param box0 defines the first box to test
  73946. * @param box1 defines the second box to test
  73947. * @returns true if there is an intersection
  73948. */
  73949. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73950. /**
  73951. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73952. * @param minPoint defines the minimum vector of the bounding box
  73953. * @param maxPoint defines the maximum vector of the bounding box
  73954. * @param sphereCenter defines the sphere center
  73955. * @param sphereRadius defines the sphere radius
  73956. * @returns true if there is an intersection
  73957. */
  73958. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73959. /**
  73960. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73961. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73962. * @param frustumPlanes defines the frustum planes to test
  73963. * @return true if there is an inclusion
  73964. */
  73965. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73966. /**
  73967. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73968. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73969. * @param frustumPlanes defines the frustum planes to test
  73970. * @return true if there is an intersection
  73971. */
  73972. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73973. }
  73974. }
  73975. declare module BABYLON {
  73976. /** @hidden */
  73977. export class Collider {
  73978. /** Define if a collision was found */
  73979. collisionFound: boolean;
  73980. /**
  73981. * Define last intersection point in local space
  73982. */
  73983. intersectionPoint: Vector3;
  73984. /**
  73985. * Define last collided mesh
  73986. */
  73987. collidedMesh: Nullable<AbstractMesh>;
  73988. private _collisionPoint;
  73989. private _planeIntersectionPoint;
  73990. private _tempVector;
  73991. private _tempVector2;
  73992. private _tempVector3;
  73993. private _tempVector4;
  73994. private _edge;
  73995. private _baseToVertex;
  73996. private _destinationPoint;
  73997. private _slidePlaneNormal;
  73998. private _displacementVector;
  73999. /** @hidden */
  74000. _radius: Vector3;
  74001. /** @hidden */
  74002. _retry: number;
  74003. private _velocity;
  74004. private _basePoint;
  74005. private _epsilon;
  74006. /** @hidden */
  74007. _velocityWorldLength: number;
  74008. /** @hidden */
  74009. _basePointWorld: Vector3;
  74010. private _velocityWorld;
  74011. private _normalizedVelocity;
  74012. /** @hidden */
  74013. _initialVelocity: Vector3;
  74014. /** @hidden */
  74015. _initialPosition: Vector3;
  74016. private _nearestDistance;
  74017. private _collisionMask;
  74018. collisionMask: number;
  74019. /**
  74020. * Gets the plane normal used to compute the sliding response (in local space)
  74021. */
  74022. readonly slidePlaneNormal: Vector3;
  74023. /** @hidden */
  74024. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74025. /** @hidden */
  74026. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74027. /** @hidden */
  74028. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74029. /** @hidden */
  74030. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74031. /** @hidden */
  74032. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74033. /** @hidden */
  74034. _getResponse(pos: Vector3, vel: Vector3): void;
  74035. }
  74036. }
  74037. declare module BABYLON {
  74038. /**
  74039. * Interface for cullable objects
  74040. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74041. */
  74042. export interface ICullable {
  74043. /**
  74044. * Checks if the object or part of the object is in the frustum
  74045. * @param frustumPlanes Camera near/planes
  74046. * @returns true if the object is in frustum otherwise false
  74047. */
  74048. isInFrustum(frustumPlanes: Plane[]): boolean;
  74049. /**
  74050. * Checks if a cullable object (mesh...) is in the camera frustum
  74051. * Unlike isInFrustum this cheks the full bounding box
  74052. * @param frustumPlanes Camera near/planes
  74053. * @returns true if the object is in frustum otherwise false
  74054. */
  74055. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74056. }
  74057. /**
  74058. * Info for a bounding data of a mesh
  74059. */
  74060. export class BoundingInfo implements ICullable {
  74061. /**
  74062. * Bounding box for the mesh
  74063. */
  74064. readonly boundingBox: BoundingBox;
  74065. /**
  74066. * Bounding sphere for the mesh
  74067. */
  74068. readonly boundingSphere: BoundingSphere;
  74069. private _isLocked;
  74070. private static readonly TmpVector3;
  74071. /**
  74072. * Constructs bounding info
  74073. * @param minimum min vector of the bounding box/sphere
  74074. * @param maximum max vector of the bounding box/sphere
  74075. * @param worldMatrix defines the new world matrix
  74076. */
  74077. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74078. /**
  74079. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74080. * @param min defines the new minimum vector (in local space)
  74081. * @param max defines the new maximum vector (in local space)
  74082. * @param worldMatrix defines the new world matrix
  74083. */
  74084. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74085. /**
  74086. * min vector of the bounding box/sphere
  74087. */
  74088. readonly minimum: Vector3;
  74089. /**
  74090. * max vector of the bounding box/sphere
  74091. */
  74092. readonly maximum: Vector3;
  74093. /**
  74094. * If the info is locked and won't be updated to avoid perf overhead
  74095. */
  74096. isLocked: boolean;
  74097. /**
  74098. * Updates the bounding sphere and box
  74099. * @param world world matrix to be used to update
  74100. */
  74101. update(world: DeepImmutable<Matrix>): void;
  74102. /**
  74103. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74104. * @param center New center of the bounding info
  74105. * @param extend New extend of the bounding info
  74106. * @returns the current bounding info
  74107. */
  74108. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74109. /**
  74110. * Scale the current bounding info by applying a scale factor
  74111. * @param factor defines the scale factor to apply
  74112. * @returns the current bounding info
  74113. */
  74114. scale(factor: number): BoundingInfo;
  74115. /**
  74116. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74117. * @param frustumPlanes defines the frustum to test
  74118. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74119. * @returns true if the bounding info is in the frustum planes
  74120. */
  74121. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74122. /**
  74123. * Gets the world distance between the min and max points of the bounding box
  74124. */
  74125. readonly diagonalLength: number;
  74126. /**
  74127. * Checks if a cullable object (mesh...) is in the camera frustum
  74128. * Unlike isInFrustum this cheks the full bounding box
  74129. * @param frustumPlanes Camera near/planes
  74130. * @returns true if the object is in frustum otherwise false
  74131. */
  74132. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74133. /** @hidden */
  74134. _checkCollision(collider: Collider): boolean;
  74135. /**
  74136. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74137. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74138. * @param point the point to check intersection with
  74139. * @returns if the point intersects
  74140. */
  74141. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74142. /**
  74143. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74144. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74145. * @param boundingInfo the bounding info to check intersection with
  74146. * @param precise if the intersection should be done using OBB
  74147. * @returns if the bounding info intersects
  74148. */
  74149. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74150. }
  74151. }
  74152. declare module BABYLON {
  74153. /**
  74154. * Extracts minimum and maximum values from a list of indexed positions
  74155. * @param positions defines the positions to use
  74156. * @param indices defines the indices to the positions
  74157. * @param indexStart defines the start index
  74158. * @param indexCount defines the end index
  74159. * @param bias defines bias value to add to the result
  74160. * @return minimum and maximum values
  74161. */
  74162. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74163. minimum: Vector3;
  74164. maximum: Vector3;
  74165. };
  74166. /**
  74167. * Extracts minimum and maximum values from a list of positions
  74168. * @param positions defines the positions to use
  74169. * @param start defines the start index in the positions array
  74170. * @param count defines the number of positions to handle
  74171. * @param bias defines bias value to add to the result
  74172. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74173. * @return minimum and maximum values
  74174. */
  74175. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74176. minimum: Vector3;
  74177. maximum: Vector3;
  74178. };
  74179. }
  74180. declare module BABYLON {
  74181. /** @hidden */
  74182. export class WebGLDataBuffer extends DataBuffer {
  74183. private _buffer;
  74184. constructor(resource: WebGLBuffer);
  74185. readonly underlyingResource: any;
  74186. }
  74187. }
  74188. declare module BABYLON {
  74189. /** @hidden */
  74190. export class WebGLPipelineContext implements IPipelineContext {
  74191. engine: ThinEngine;
  74192. program: Nullable<WebGLProgram>;
  74193. context?: WebGLRenderingContext;
  74194. vertexShader?: WebGLShader;
  74195. fragmentShader?: WebGLShader;
  74196. isParallelCompiled: boolean;
  74197. onCompiled?: () => void;
  74198. transformFeedback?: WebGLTransformFeedback | null;
  74199. readonly isAsync: boolean;
  74200. readonly isReady: boolean;
  74201. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74202. }
  74203. }
  74204. declare module BABYLON {
  74205. interface ThinEngine {
  74206. /**
  74207. * Create an uniform buffer
  74208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74209. * @param elements defines the content of the uniform buffer
  74210. * @returns the webGL uniform buffer
  74211. */
  74212. createUniformBuffer(elements: FloatArray): DataBuffer;
  74213. /**
  74214. * Create a dynamic uniform buffer
  74215. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74216. * @param elements defines the content of the uniform buffer
  74217. * @returns the webGL uniform buffer
  74218. */
  74219. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74220. /**
  74221. * Update an existing uniform buffer
  74222. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74223. * @param uniformBuffer defines the target uniform buffer
  74224. * @param elements defines the content to update
  74225. * @param offset defines the offset in the uniform buffer where update should start
  74226. * @param count defines the size of the data to update
  74227. */
  74228. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74229. /**
  74230. * Bind an uniform buffer to the current webGL context
  74231. * @param buffer defines the buffer to bind
  74232. */
  74233. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74234. /**
  74235. * Bind a buffer to the current webGL context at a given location
  74236. * @param buffer defines the buffer to bind
  74237. * @param location defines the index where to bind the buffer
  74238. */
  74239. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74240. /**
  74241. * Bind a specific block at a given index in a specific shader program
  74242. * @param pipelineContext defines the pipeline context to use
  74243. * @param blockName defines the block name
  74244. * @param index defines the index where to bind the block
  74245. */
  74246. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74247. }
  74248. }
  74249. declare module BABYLON {
  74250. /**
  74251. * Uniform buffer objects.
  74252. *
  74253. * Handles blocks of uniform on the GPU.
  74254. *
  74255. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74256. *
  74257. * For more information, please refer to :
  74258. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74259. */
  74260. export class UniformBuffer {
  74261. private _engine;
  74262. private _buffer;
  74263. private _data;
  74264. private _bufferData;
  74265. private _dynamic?;
  74266. private _uniformLocations;
  74267. private _uniformSizes;
  74268. private _uniformLocationPointer;
  74269. private _needSync;
  74270. private _noUBO;
  74271. private _currentEffect;
  74272. private static _MAX_UNIFORM_SIZE;
  74273. private static _tempBuffer;
  74274. /**
  74275. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74276. * This is dynamic to allow compat with webgl 1 and 2.
  74277. * You will need to pass the name of the uniform as well as the value.
  74278. */
  74279. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74280. /**
  74281. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74282. * This is dynamic to allow compat with webgl 1 and 2.
  74283. * You will need to pass the name of the uniform as well as the value.
  74284. */
  74285. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74286. /**
  74287. * Lambda to Update a single float in a uniform buffer.
  74288. * This is dynamic to allow compat with webgl 1 and 2.
  74289. * You will need to pass the name of the uniform as well as the value.
  74290. */
  74291. updateFloat: (name: string, x: number) => void;
  74292. /**
  74293. * Lambda to Update a vec2 of float in a uniform buffer.
  74294. * This is dynamic to allow compat with webgl 1 and 2.
  74295. * You will need to pass the name of the uniform as well as the value.
  74296. */
  74297. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74298. /**
  74299. * Lambda to Update a vec3 of float in a uniform buffer.
  74300. * This is dynamic to allow compat with webgl 1 and 2.
  74301. * You will need to pass the name of the uniform as well as the value.
  74302. */
  74303. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74304. /**
  74305. * Lambda to Update a vec4 of float in a uniform buffer.
  74306. * This is dynamic to allow compat with webgl 1 and 2.
  74307. * You will need to pass the name of the uniform as well as the value.
  74308. */
  74309. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74310. /**
  74311. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74312. * This is dynamic to allow compat with webgl 1 and 2.
  74313. * You will need to pass the name of the uniform as well as the value.
  74314. */
  74315. updateMatrix: (name: string, mat: Matrix) => void;
  74316. /**
  74317. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74318. * This is dynamic to allow compat with webgl 1 and 2.
  74319. * You will need to pass the name of the uniform as well as the value.
  74320. */
  74321. updateVector3: (name: string, vector: Vector3) => void;
  74322. /**
  74323. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74324. * This is dynamic to allow compat with webgl 1 and 2.
  74325. * You will need to pass the name of the uniform as well as the value.
  74326. */
  74327. updateVector4: (name: string, vector: Vector4) => void;
  74328. /**
  74329. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74330. * This is dynamic to allow compat with webgl 1 and 2.
  74331. * You will need to pass the name of the uniform as well as the value.
  74332. */
  74333. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74334. /**
  74335. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74336. * This is dynamic to allow compat with webgl 1 and 2.
  74337. * You will need to pass the name of the uniform as well as the value.
  74338. */
  74339. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74340. /**
  74341. * Instantiates a new Uniform buffer objects.
  74342. *
  74343. * Handles blocks of uniform on the GPU.
  74344. *
  74345. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74346. *
  74347. * For more information, please refer to :
  74348. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74349. * @param engine Define the engine the buffer is associated with
  74350. * @param data Define the data contained in the buffer
  74351. * @param dynamic Define if the buffer is updatable
  74352. */
  74353. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74354. /**
  74355. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74356. * or just falling back on setUniformXXX calls.
  74357. */
  74358. readonly useUbo: boolean;
  74359. /**
  74360. * Indicates if the WebGL underlying uniform buffer is in sync
  74361. * with the javascript cache data.
  74362. */
  74363. readonly isSync: boolean;
  74364. /**
  74365. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74366. * Also, a dynamic UniformBuffer will disable cache verification and always
  74367. * update the underlying WebGL uniform buffer to the GPU.
  74368. * @returns if Dynamic, otherwise false
  74369. */
  74370. isDynamic(): boolean;
  74371. /**
  74372. * The data cache on JS side.
  74373. * @returns the underlying data as a float array
  74374. */
  74375. getData(): Float32Array;
  74376. /**
  74377. * The underlying WebGL Uniform buffer.
  74378. * @returns the webgl buffer
  74379. */
  74380. getBuffer(): Nullable<DataBuffer>;
  74381. /**
  74382. * std140 layout specifies how to align data within an UBO structure.
  74383. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74384. * for specs.
  74385. */
  74386. private _fillAlignment;
  74387. /**
  74388. * Adds an uniform in the buffer.
  74389. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74390. * for the layout to be correct !
  74391. * @param name Name of the uniform, as used in the uniform block in the shader.
  74392. * @param size Data size, or data directly.
  74393. */
  74394. addUniform(name: string, size: number | number[]): void;
  74395. /**
  74396. * Adds a Matrix 4x4 to the uniform buffer.
  74397. * @param name Name of the uniform, as used in the uniform block in the shader.
  74398. * @param mat A 4x4 matrix.
  74399. */
  74400. addMatrix(name: string, mat: Matrix): void;
  74401. /**
  74402. * Adds a vec2 to the uniform buffer.
  74403. * @param name Name of the uniform, as used in the uniform block in the shader.
  74404. * @param x Define the x component value of the vec2
  74405. * @param y Define the y component value of the vec2
  74406. */
  74407. addFloat2(name: string, x: number, y: number): void;
  74408. /**
  74409. * Adds a vec3 to the uniform buffer.
  74410. * @param name Name of the uniform, as used in the uniform block in the shader.
  74411. * @param x Define the x component value of the vec3
  74412. * @param y Define the y component value of the vec3
  74413. * @param z Define the z component value of the vec3
  74414. */
  74415. addFloat3(name: string, x: number, y: number, z: number): void;
  74416. /**
  74417. * Adds a vec3 to the uniform buffer.
  74418. * @param name Name of the uniform, as used in the uniform block in the shader.
  74419. * @param color Define the vec3 from a Color
  74420. */
  74421. addColor3(name: string, color: Color3): void;
  74422. /**
  74423. * Adds a vec4 to the uniform buffer.
  74424. * @param name Name of the uniform, as used in the uniform block in the shader.
  74425. * @param color Define the rgb components from a Color
  74426. * @param alpha Define the a component of the vec4
  74427. */
  74428. addColor4(name: string, color: Color3, alpha: number): void;
  74429. /**
  74430. * Adds a vec3 to the uniform buffer.
  74431. * @param name Name of the uniform, as used in the uniform block in the shader.
  74432. * @param vector Define the vec3 components from a Vector
  74433. */
  74434. addVector3(name: string, vector: Vector3): void;
  74435. /**
  74436. * Adds a Matrix 3x3 to the uniform buffer.
  74437. * @param name Name of the uniform, as used in the uniform block in the shader.
  74438. */
  74439. addMatrix3x3(name: string): void;
  74440. /**
  74441. * Adds a Matrix 2x2 to the uniform buffer.
  74442. * @param name Name of the uniform, as used in the uniform block in the shader.
  74443. */
  74444. addMatrix2x2(name: string): void;
  74445. /**
  74446. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74447. */
  74448. create(): void;
  74449. /** @hidden */
  74450. _rebuild(): void;
  74451. /**
  74452. * Updates the WebGL Uniform Buffer on the GPU.
  74453. * If the `dynamic` flag is set to true, no cache comparison is done.
  74454. * Otherwise, the buffer will be updated only if the cache differs.
  74455. */
  74456. update(): void;
  74457. /**
  74458. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74459. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74460. * @param data Define the flattened data
  74461. * @param size Define the size of the data.
  74462. */
  74463. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74464. private _valueCache;
  74465. private _cacheMatrix;
  74466. private _updateMatrix3x3ForUniform;
  74467. private _updateMatrix3x3ForEffect;
  74468. private _updateMatrix2x2ForEffect;
  74469. private _updateMatrix2x2ForUniform;
  74470. private _updateFloatForEffect;
  74471. private _updateFloatForUniform;
  74472. private _updateFloat2ForEffect;
  74473. private _updateFloat2ForUniform;
  74474. private _updateFloat3ForEffect;
  74475. private _updateFloat3ForUniform;
  74476. private _updateFloat4ForEffect;
  74477. private _updateFloat4ForUniform;
  74478. private _updateMatrixForEffect;
  74479. private _updateMatrixForUniform;
  74480. private _updateVector3ForEffect;
  74481. private _updateVector3ForUniform;
  74482. private _updateVector4ForEffect;
  74483. private _updateVector4ForUniform;
  74484. private _updateColor3ForEffect;
  74485. private _updateColor3ForUniform;
  74486. private _updateColor4ForEffect;
  74487. private _updateColor4ForUniform;
  74488. /**
  74489. * Sets a sampler uniform on the effect.
  74490. * @param name Define the name of the sampler.
  74491. * @param texture Define the texture to set in the sampler
  74492. */
  74493. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74494. /**
  74495. * Directly updates the value of the uniform in the cache AND on the GPU.
  74496. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74497. * @param data Define the flattened data
  74498. */
  74499. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74500. /**
  74501. * Binds this uniform buffer to an effect.
  74502. * @param effect Define the effect to bind the buffer to
  74503. * @param name Name of the uniform block in the shader.
  74504. */
  74505. bindToEffect(effect: Effect, name: string): void;
  74506. /**
  74507. * Disposes the uniform buffer.
  74508. */
  74509. dispose(): void;
  74510. }
  74511. }
  74512. declare module BABYLON {
  74513. /**
  74514. * Enum that determines the text-wrapping mode to use.
  74515. */
  74516. export enum InspectableType {
  74517. /**
  74518. * Checkbox for booleans
  74519. */
  74520. Checkbox = 0,
  74521. /**
  74522. * Sliders for numbers
  74523. */
  74524. Slider = 1,
  74525. /**
  74526. * Vector3
  74527. */
  74528. Vector3 = 2,
  74529. /**
  74530. * Quaternions
  74531. */
  74532. Quaternion = 3,
  74533. /**
  74534. * Color3
  74535. */
  74536. Color3 = 4,
  74537. /**
  74538. * String
  74539. */
  74540. String = 5
  74541. }
  74542. /**
  74543. * Interface used to define custom inspectable properties.
  74544. * This interface is used by the inspector to display custom property grids
  74545. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74546. */
  74547. export interface IInspectable {
  74548. /**
  74549. * Gets the label to display
  74550. */
  74551. label: string;
  74552. /**
  74553. * Gets the name of the property to edit
  74554. */
  74555. propertyName: string;
  74556. /**
  74557. * Gets the type of the editor to use
  74558. */
  74559. type: InspectableType;
  74560. /**
  74561. * Gets the minimum value of the property when using in "slider" mode
  74562. */
  74563. min?: number;
  74564. /**
  74565. * Gets the maximum value of the property when using in "slider" mode
  74566. */
  74567. max?: number;
  74568. /**
  74569. * Gets the setp to use when using in "slider" mode
  74570. */
  74571. step?: number;
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /**
  74576. * Class used to provide helper for timing
  74577. */
  74578. export class TimingTools {
  74579. /**
  74580. * Polyfill for setImmediate
  74581. * @param action defines the action to execute after the current execution block
  74582. */
  74583. static SetImmediate(action: () => void): void;
  74584. }
  74585. }
  74586. declare module BABYLON {
  74587. /**
  74588. * Class used to enable instatition of objects by class name
  74589. */
  74590. export class InstantiationTools {
  74591. /**
  74592. * Use this object to register external classes like custom textures or material
  74593. * to allow the laoders to instantiate them
  74594. */
  74595. static RegisteredExternalClasses: {
  74596. [key: string]: Object;
  74597. };
  74598. /**
  74599. * Tries to instantiate a new object from a given class name
  74600. * @param className defines the class name to instantiate
  74601. * @returns the new object or null if the system was not able to do the instantiation
  74602. */
  74603. static Instantiate(className: string): any;
  74604. }
  74605. }
  74606. declare module BABYLON {
  74607. /**
  74608. * Define options used to create a depth texture
  74609. */
  74610. export class DepthTextureCreationOptions {
  74611. /** Specifies whether or not a stencil should be allocated in the texture */
  74612. generateStencil?: boolean;
  74613. /** Specifies whether or not bilinear filtering is enable on the texture */
  74614. bilinearFiltering?: boolean;
  74615. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74616. comparisonFunction?: number;
  74617. /** Specifies if the created texture is a cube texture */
  74618. isCube?: boolean;
  74619. }
  74620. }
  74621. declare module BABYLON {
  74622. interface ThinEngine {
  74623. /**
  74624. * Creates a depth stencil cube texture.
  74625. * This is only available in WebGL 2.
  74626. * @param size The size of face edge in the cube texture.
  74627. * @param options The options defining the cube texture.
  74628. * @returns The cube texture
  74629. */
  74630. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74631. /**
  74632. * Creates a cube texture
  74633. * @param rootUrl defines the url where the files to load is located
  74634. * @param scene defines the current scene
  74635. * @param files defines the list of files to load (1 per face)
  74636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74637. * @param onLoad defines an optional callback raised when the texture is loaded
  74638. * @param onError defines an optional callback raised if there is an issue to load the texture
  74639. * @param format defines the format of the data
  74640. * @param forcedExtension defines the extension to use to pick the right loader
  74641. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74642. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74643. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74644. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74645. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74646. * @returns the cube texture as an InternalTexture
  74647. */
  74648. 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;
  74649. /**
  74650. * Creates a cube texture
  74651. * @param rootUrl defines the url where the files to load is located
  74652. * @param scene defines the current scene
  74653. * @param files defines the list of files to load (1 per face)
  74654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74655. * @param onLoad defines an optional callback raised when the texture is loaded
  74656. * @param onError defines an optional callback raised if there is an issue to load the texture
  74657. * @param format defines the format of the data
  74658. * @param forcedExtension defines the extension to use to pick the right loader
  74659. * @returns the cube texture as an InternalTexture
  74660. */
  74661. 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;
  74662. /**
  74663. * Creates a cube texture
  74664. * @param rootUrl defines the url where the files to load is located
  74665. * @param scene defines the current scene
  74666. * @param files defines the list of files to load (1 per face)
  74667. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74668. * @param onLoad defines an optional callback raised when the texture is loaded
  74669. * @param onError defines an optional callback raised if there is an issue to load the texture
  74670. * @param format defines the format of the data
  74671. * @param forcedExtension defines the extension to use to pick the right loader
  74672. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74673. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74674. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74675. * @returns the cube texture as an InternalTexture
  74676. */
  74677. 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;
  74678. /** @hidden */
  74679. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74680. /** @hidden */
  74681. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74682. /** @hidden */
  74683. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74684. /** @hidden */
  74685. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74686. }
  74687. }
  74688. declare module BABYLON {
  74689. /**
  74690. * Class for creating a cube texture
  74691. */
  74692. export class CubeTexture extends BaseTexture {
  74693. private _delayedOnLoad;
  74694. /**
  74695. * The url of the texture
  74696. */
  74697. url: string;
  74698. /**
  74699. * Gets or sets the center of the bounding box associated with the cube texture.
  74700. * It must define where the camera used to render the texture was set
  74701. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74702. */
  74703. boundingBoxPosition: Vector3;
  74704. private _boundingBoxSize;
  74705. /**
  74706. * Gets or sets the size of the bounding box associated with the cube texture
  74707. * When defined, the cubemap will switch to local mode
  74708. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74709. * @example https://www.babylonjs-playground.com/#RNASML
  74710. */
  74711. /**
  74712. * Returns the bounding box size
  74713. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74714. */
  74715. boundingBoxSize: Vector3;
  74716. protected _rotationY: number;
  74717. /**
  74718. * Sets texture matrix rotation angle around Y axis in radians.
  74719. */
  74720. /**
  74721. * Gets texture matrix rotation angle around Y axis radians.
  74722. */
  74723. rotationY: number;
  74724. /**
  74725. * Are mip maps generated for this texture or not.
  74726. */
  74727. readonly noMipmap: boolean;
  74728. private _noMipmap;
  74729. private _files;
  74730. protected _forcedExtension: Nullable<string>;
  74731. private _extensions;
  74732. private _textureMatrix;
  74733. private _format;
  74734. private _createPolynomials;
  74735. /** @hidden */
  74736. _prefiltered: boolean;
  74737. /**
  74738. * Creates a cube texture from an array of image urls
  74739. * @param files defines an array of image urls
  74740. * @param scene defines the hosting scene
  74741. * @param noMipmap specifies if mip maps are not used
  74742. * @returns a cube texture
  74743. */
  74744. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74745. /**
  74746. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74747. * @param url defines the url of the prefiltered texture
  74748. * @param scene defines the scene the texture is attached to
  74749. * @param forcedExtension defines the extension of the file if different from the url
  74750. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74751. * @return the prefiltered texture
  74752. */
  74753. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74754. /**
  74755. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74756. * as prefiltered data.
  74757. * @param rootUrl defines the url of the texture or the root name of the six images
  74758. * @param scene defines the scene the texture is attached to
  74759. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74760. * @param noMipmap defines if mipmaps should be created or not
  74761. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74762. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74763. * @param onError defines a callback triggered in case of error during load
  74764. * @param format defines the internal format to use for the texture once loaded
  74765. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74766. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74767. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74770. * @return the cube texture
  74771. */
  74772. 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);
  74773. /**
  74774. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74775. */
  74776. readonly isPrefiltered: boolean;
  74777. /**
  74778. * Get the current class name of the texture useful for serialization or dynamic coding.
  74779. * @returns "CubeTexture"
  74780. */
  74781. getClassName(): string;
  74782. /**
  74783. * Update the url (and optional buffer) of this texture if url was null during construction.
  74784. * @param url the url of the texture
  74785. * @param forcedExtension defines the extension to use
  74786. * @param onLoad callback called when the texture is loaded (defaults to null)
  74787. */
  74788. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74789. /**
  74790. * Delays loading of the cube texture
  74791. * @param forcedExtension defines the extension to use
  74792. */
  74793. delayLoad(forcedExtension?: string): void;
  74794. /**
  74795. * Returns the reflection texture matrix
  74796. * @returns the reflection texture matrix
  74797. */
  74798. getReflectionTextureMatrix(): Matrix;
  74799. /**
  74800. * Sets the reflection texture matrix
  74801. * @param value Reflection texture matrix
  74802. */
  74803. setReflectionTextureMatrix(value: Matrix): void;
  74804. /**
  74805. * Parses text to create a cube texture
  74806. * @param parsedTexture define the serialized text to read from
  74807. * @param scene defines the hosting scene
  74808. * @param rootUrl defines the root url of the cube texture
  74809. * @returns a cube texture
  74810. */
  74811. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74812. /**
  74813. * Makes a clone, or deep copy, of the cube texture
  74814. * @returns a new cube texture
  74815. */
  74816. clone(): CubeTexture;
  74817. }
  74818. }
  74819. declare module BABYLON {
  74820. /**
  74821. * Manages the defines for the Material
  74822. */
  74823. export class MaterialDefines {
  74824. /** @hidden */
  74825. protected _keys: string[];
  74826. private _isDirty;
  74827. /** @hidden */
  74828. _renderId: number;
  74829. /** @hidden */
  74830. _areLightsDirty: boolean;
  74831. /** @hidden */
  74832. _areLightsDisposed: boolean;
  74833. /** @hidden */
  74834. _areAttributesDirty: boolean;
  74835. /** @hidden */
  74836. _areTexturesDirty: boolean;
  74837. /** @hidden */
  74838. _areFresnelDirty: boolean;
  74839. /** @hidden */
  74840. _areMiscDirty: boolean;
  74841. /** @hidden */
  74842. _areImageProcessingDirty: boolean;
  74843. /** @hidden */
  74844. _normals: boolean;
  74845. /** @hidden */
  74846. _uvs: boolean;
  74847. /** @hidden */
  74848. _needNormals: boolean;
  74849. /** @hidden */
  74850. _needUVs: boolean;
  74851. [id: string]: any;
  74852. /**
  74853. * Specifies if the material needs to be re-calculated
  74854. */
  74855. readonly isDirty: boolean;
  74856. /**
  74857. * Marks the material to indicate that it has been re-calculated
  74858. */
  74859. markAsProcessed(): void;
  74860. /**
  74861. * Marks the material to indicate that it needs to be re-calculated
  74862. */
  74863. markAsUnprocessed(): void;
  74864. /**
  74865. * Marks the material to indicate all of its defines need to be re-calculated
  74866. */
  74867. markAllAsDirty(): void;
  74868. /**
  74869. * Marks the material to indicate that image processing needs to be re-calculated
  74870. */
  74871. markAsImageProcessingDirty(): void;
  74872. /**
  74873. * Marks the material to indicate the lights need to be re-calculated
  74874. * @param disposed Defines whether the light is dirty due to dispose or not
  74875. */
  74876. markAsLightDirty(disposed?: boolean): void;
  74877. /**
  74878. * Marks the attribute state as changed
  74879. */
  74880. markAsAttributesDirty(): void;
  74881. /**
  74882. * Marks the texture state as changed
  74883. */
  74884. markAsTexturesDirty(): void;
  74885. /**
  74886. * Marks the fresnel state as changed
  74887. */
  74888. markAsFresnelDirty(): void;
  74889. /**
  74890. * Marks the misc state as changed
  74891. */
  74892. markAsMiscDirty(): void;
  74893. /**
  74894. * Rebuilds the material defines
  74895. */
  74896. rebuild(): void;
  74897. /**
  74898. * Specifies if two material defines are equal
  74899. * @param other - A material define instance to compare to
  74900. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74901. */
  74902. isEqual(other: MaterialDefines): boolean;
  74903. /**
  74904. * Clones this instance's defines to another instance
  74905. * @param other - material defines to clone values to
  74906. */
  74907. cloneTo(other: MaterialDefines): void;
  74908. /**
  74909. * Resets the material define values
  74910. */
  74911. reset(): void;
  74912. /**
  74913. * Converts the material define values to a string
  74914. * @returns - String of material define information
  74915. */
  74916. toString(): string;
  74917. }
  74918. }
  74919. declare module BABYLON {
  74920. /**
  74921. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74922. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74923. * 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;
  74924. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74925. */
  74926. export class ColorCurves {
  74927. private _dirty;
  74928. private _tempColor;
  74929. private _globalCurve;
  74930. private _highlightsCurve;
  74931. private _midtonesCurve;
  74932. private _shadowsCurve;
  74933. private _positiveCurve;
  74934. private _negativeCurve;
  74935. private _globalHue;
  74936. private _globalDensity;
  74937. private _globalSaturation;
  74938. private _globalExposure;
  74939. /**
  74940. * Gets the global Hue value.
  74941. * 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).
  74942. */
  74943. /**
  74944. * Sets the global Hue value.
  74945. * 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).
  74946. */
  74947. globalHue: number;
  74948. /**
  74949. * Gets the global Density value.
  74950. * 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.
  74951. * Values less than zero provide a filter of opposite hue.
  74952. */
  74953. /**
  74954. * Sets the global Density value.
  74955. * 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.
  74956. * Values less than zero provide a filter of opposite hue.
  74957. */
  74958. globalDensity: number;
  74959. /**
  74960. * Gets the global Saturation value.
  74961. * 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.
  74962. */
  74963. /**
  74964. * Sets the global Saturation value.
  74965. * 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.
  74966. */
  74967. globalSaturation: number;
  74968. /**
  74969. * Gets the global Exposure value.
  74970. * 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.
  74971. */
  74972. /**
  74973. * Sets the global Exposure value.
  74974. * 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.
  74975. */
  74976. globalExposure: number;
  74977. private _highlightsHue;
  74978. private _highlightsDensity;
  74979. private _highlightsSaturation;
  74980. private _highlightsExposure;
  74981. /**
  74982. * Gets the highlights Hue value.
  74983. * 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).
  74984. */
  74985. /**
  74986. * Sets the highlights Hue value.
  74987. * 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).
  74988. */
  74989. highlightsHue: number;
  74990. /**
  74991. * Gets the highlights Density value.
  74992. * 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.
  74993. * Values less than zero provide a filter of opposite hue.
  74994. */
  74995. /**
  74996. * Sets the highlights Density value.
  74997. * 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.
  74998. * Values less than zero provide a filter of opposite hue.
  74999. */
  75000. highlightsDensity: number;
  75001. /**
  75002. * Gets the highlights Saturation value.
  75003. * 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.
  75004. */
  75005. /**
  75006. * Sets the highlights Saturation value.
  75007. * 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.
  75008. */
  75009. highlightsSaturation: number;
  75010. /**
  75011. * Gets the highlights Exposure value.
  75012. * 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.
  75013. */
  75014. /**
  75015. * Sets the highlights Exposure value.
  75016. * 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.
  75017. */
  75018. highlightsExposure: number;
  75019. private _midtonesHue;
  75020. private _midtonesDensity;
  75021. private _midtonesSaturation;
  75022. private _midtonesExposure;
  75023. /**
  75024. * Gets the midtones Hue value.
  75025. * 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).
  75026. */
  75027. /**
  75028. * Sets the midtones Hue value.
  75029. * 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).
  75030. */
  75031. midtonesHue: number;
  75032. /**
  75033. * Gets the midtones Density value.
  75034. * 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.
  75035. * Values less than zero provide a filter of opposite hue.
  75036. */
  75037. /**
  75038. * Sets the midtones Density value.
  75039. * 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.
  75040. * Values less than zero provide a filter of opposite hue.
  75041. */
  75042. midtonesDensity: number;
  75043. /**
  75044. * Gets the midtones Saturation value.
  75045. * 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.
  75046. */
  75047. /**
  75048. * Sets the midtones Saturation value.
  75049. * 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.
  75050. */
  75051. midtonesSaturation: number;
  75052. /**
  75053. * Gets the midtones Exposure value.
  75054. * 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.
  75055. */
  75056. /**
  75057. * Sets the midtones Exposure value.
  75058. * 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.
  75059. */
  75060. midtonesExposure: number;
  75061. private _shadowsHue;
  75062. private _shadowsDensity;
  75063. private _shadowsSaturation;
  75064. private _shadowsExposure;
  75065. /**
  75066. * Gets the shadows Hue value.
  75067. * 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).
  75068. */
  75069. /**
  75070. * Sets the shadows Hue value.
  75071. * 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).
  75072. */
  75073. shadowsHue: number;
  75074. /**
  75075. * Gets the shadows Density value.
  75076. * 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.
  75077. * Values less than zero provide a filter of opposite hue.
  75078. */
  75079. /**
  75080. * Sets the shadows Density value.
  75081. * 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.
  75082. * Values less than zero provide a filter of opposite hue.
  75083. */
  75084. shadowsDensity: number;
  75085. /**
  75086. * Gets the shadows Saturation value.
  75087. * 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.
  75088. */
  75089. /**
  75090. * Sets the shadows Saturation value.
  75091. * 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.
  75092. */
  75093. shadowsSaturation: number;
  75094. /**
  75095. * Gets the shadows Exposure value.
  75096. * 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.
  75097. */
  75098. /**
  75099. * Sets the shadows Exposure value.
  75100. * 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.
  75101. */
  75102. shadowsExposure: number;
  75103. /**
  75104. * Returns the class name
  75105. * @returns The class name
  75106. */
  75107. getClassName(): string;
  75108. /**
  75109. * Binds the color curves to the shader.
  75110. * @param colorCurves The color curve to bind
  75111. * @param effect The effect to bind to
  75112. * @param positiveUniform The positive uniform shader parameter
  75113. * @param neutralUniform The neutral uniform shader parameter
  75114. * @param negativeUniform The negative uniform shader parameter
  75115. */
  75116. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75117. /**
  75118. * Prepare the list of uniforms associated with the ColorCurves effects.
  75119. * @param uniformsList The list of uniforms used in the effect
  75120. */
  75121. static PrepareUniforms(uniformsList: string[]): void;
  75122. /**
  75123. * Returns color grading data based on a hue, density, saturation and exposure value.
  75124. * @param filterHue The hue of the color filter.
  75125. * @param filterDensity The density of the color filter.
  75126. * @param saturation The saturation.
  75127. * @param exposure The exposure.
  75128. * @param result The result data container.
  75129. */
  75130. private getColorGradingDataToRef;
  75131. /**
  75132. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75133. * @param value The input slider value in range [-100,100].
  75134. * @returns Adjusted value.
  75135. */
  75136. private static applyColorGradingSliderNonlinear;
  75137. /**
  75138. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75139. * @param hue The hue (H) input.
  75140. * @param saturation The saturation (S) input.
  75141. * @param brightness The brightness (B) input.
  75142. * @result An RGBA color represented as Vector4.
  75143. */
  75144. private static fromHSBToRef;
  75145. /**
  75146. * Returns a value clamped between min and max
  75147. * @param value The value to clamp
  75148. * @param min The minimum of value
  75149. * @param max The maximum of value
  75150. * @returns The clamped value.
  75151. */
  75152. private static clamp;
  75153. /**
  75154. * Clones the current color curve instance.
  75155. * @return The cloned curves
  75156. */
  75157. clone(): ColorCurves;
  75158. /**
  75159. * Serializes the current color curve instance to a json representation.
  75160. * @return a JSON representation
  75161. */
  75162. serialize(): any;
  75163. /**
  75164. * Parses the color curve from a json representation.
  75165. * @param source the JSON source to parse
  75166. * @return The parsed curves
  75167. */
  75168. static Parse(source: any): ColorCurves;
  75169. }
  75170. }
  75171. declare module BABYLON {
  75172. /**
  75173. * Interface to follow in your material defines to integrate easily the
  75174. * Image proccessing functions.
  75175. * @hidden
  75176. */
  75177. export interface IImageProcessingConfigurationDefines {
  75178. IMAGEPROCESSING: boolean;
  75179. VIGNETTE: boolean;
  75180. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75181. VIGNETTEBLENDMODEOPAQUE: boolean;
  75182. TONEMAPPING: boolean;
  75183. TONEMAPPING_ACES: boolean;
  75184. CONTRAST: boolean;
  75185. EXPOSURE: boolean;
  75186. COLORCURVES: boolean;
  75187. COLORGRADING: boolean;
  75188. COLORGRADING3D: boolean;
  75189. SAMPLER3DGREENDEPTH: boolean;
  75190. SAMPLER3DBGRMAP: boolean;
  75191. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75192. }
  75193. /**
  75194. * @hidden
  75195. */
  75196. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75197. IMAGEPROCESSING: boolean;
  75198. VIGNETTE: boolean;
  75199. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75200. VIGNETTEBLENDMODEOPAQUE: boolean;
  75201. TONEMAPPING: boolean;
  75202. TONEMAPPING_ACES: boolean;
  75203. CONTRAST: boolean;
  75204. COLORCURVES: boolean;
  75205. COLORGRADING: boolean;
  75206. COLORGRADING3D: boolean;
  75207. SAMPLER3DGREENDEPTH: boolean;
  75208. SAMPLER3DBGRMAP: boolean;
  75209. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75210. EXPOSURE: boolean;
  75211. constructor();
  75212. }
  75213. /**
  75214. * This groups together the common properties used for image processing either in direct forward pass
  75215. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75216. * or not.
  75217. */
  75218. export class ImageProcessingConfiguration {
  75219. /**
  75220. * Default tone mapping applied in BabylonJS.
  75221. */
  75222. static readonly TONEMAPPING_STANDARD: number;
  75223. /**
  75224. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75225. * to other engines rendering to increase portability.
  75226. */
  75227. static readonly TONEMAPPING_ACES: number;
  75228. /**
  75229. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75230. */
  75231. colorCurves: Nullable<ColorCurves>;
  75232. private _colorCurvesEnabled;
  75233. /**
  75234. * Gets wether the color curves effect is enabled.
  75235. */
  75236. /**
  75237. * Sets wether the color curves effect is enabled.
  75238. */
  75239. colorCurvesEnabled: boolean;
  75240. private _colorGradingTexture;
  75241. /**
  75242. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75243. */
  75244. /**
  75245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75246. */
  75247. colorGradingTexture: Nullable<BaseTexture>;
  75248. private _colorGradingEnabled;
  75249. /**
  75250. * Gets wether the color grading effect is enabled.
  75251. */
  75252. /**
  75253. * Sets wether the color grading effect is enabled.
  75254. */
  75255. colorGradingEnabled: boolean;
  75256. private _colorGradingWithGreenDepth;
  75257. /**
  75258. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75259. */
  75260. /**
  75261. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75262. */
  75263. colorGradingWithGreenDepth: boolean;
  75264. private _colorGradingBGR;
  75265. /**
  75266. * Gets wether the color grading texture contains BGR values.
  75267. */
  75268. /**
  75269. * Sets wether the color grading texture contains BGR values.
  75270. */
  75271. colorGradingBGR: boolean;
  75272. /** @hidden */
  75273. _exposure: number;
  75274. /**
  75275. * Gets the Exposure used in the effect.
  75276. */
  75277. /**
  75278. * Sets the Exposure used in the effect.
  75279. */
  75280. exposure: number;
  75281. private _toneMappingEnabled;
  75282. /**
  75283. * Gets wether the tone mapping effect is enabled.
  75284. */
  75285. /**
  75286. * Sets wether the tone mapping effect is enabled.
  75287. */
  75288. toneMappingEnabled: boolean;
  75289. private _toneMappingType;
  75290. /**
  75291. * Gets the type of tone mapping effect.
  75292. */
  75293. /**
  75294. * Sets the type of tone mapping effect used in BabylonJS.
  75295. */
  75296. toneMappingType: number;
  75297. protected _contrast: number;
  75298. /**
  75299. * Gets the contrast used in the effect.
  75300. */
  75301. /**
  75302. * Sets the contrast used in the effect.
  75303. */
  75304. contrast: number;
  75305. /**
  75306. * Vignette stretch size.
  75307. */
  75308. vignetteStretch: number;
  75309. /**
  75310. * Vignette centre X Offset.
  75311. */
  75312. vignetteCentreX: number;
  75313. /**
  75314. * Vignette centre Y Offset.
  75315. */
  75316. vignetteCentreY: number;
  75317. /**
  75318. * Vignette weight or intensity of the vignette effect.
  75319. */
  75320. vignetteWeight: number;
  75321. /**
  75322. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75323. * if vignetteEnabled is set to true.
  75324. */
  75325. vignetteColor: Color4;
  75326. /**
  75327. * Camera field of view used by the Vignette effect.
  75328. */
  75329. vignetteCameraFov: number;
  75330. private _vignetteBlendMode;
  75331. /**
  75332. * Gets the vignette blend mode allowing different kind of effect.
  75333. */
  75334. /**
  75335. * Sets the vignette blend mode allowing different kind of effect.
  75336. */
  75337. vignetteBlendMode: number;
  75338. private _vignetteEnabled;
  75339. /**
  75340. * Gets wether the vignette effect is enabled.
  75341. */
  75342. /**
  75343. * Sets wether the vignette effect is enabled.
  75344. */
  75345. vignetteEnabled: boolean;
  75346. private _applyByPostProcess;
  75347. /**
  75348. * Gets wether the image processing is applied through a post process or not.
  75349. */
  75350. /**
  75351. * Sets wether the image processing is applied through a post process or not.
  75352. */
  75353. applyByPostProcess: boolean;
  75354. private _isEnabled;
  75355. /**
  75356. * Gets wether the image processing is enabled or not.
  75357. */
  75358. /**
  75359. * Sets wether the image processing is enabled or not.
  75360. */
  75361. isEnabled: boolean;
  75362. /**
  75363. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75364. */
  75365. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75366. /**
  75367. * Method called each time the image processing information changes requires to recompile the effect.
  75368. */
  75369. protected _updateParameters(): void;
  75370. /**
  75371. * Gets the current class name.
  75372. * @return "ImageProcessingConfiguration"
  75373. */
  75374. getClassName(): string;
  75375. /**
  75376. * Prepare the list of uniforms associated with the Image Processing effects.
  75377. * @param uniforms The list of uniforms used in the effect
  75378. * @param defines the list of defines currently in use
  75379. */
  75380. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75381. /**
  75382. * Prepare the list of samplers associated with the Image Processing effects.
  75383. * @param samplersList The list of uniforms used in the effect
  75384. * @param defines the list of defines currently in use
  75385. */
  75386. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75387. /**
  75388. * Prepare the list of defines associated to the shader.
  75389. * @param defines the list of defines to complete
  75390. * @param forPostProcess Define if we are currently in post process mode or not
  75391. */
  75392. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75393. /**
  75394. * Returns true if all the image processing information are ready.
  75395. * @returns True if ready, otherwise, false
  75396. */
  75397. isReady(): boolean;
  75398. /**
  75399. * Binds the image processing to the shader.
  75400. * @param effect The effect to bind to
  75401. * @param aspectRatio Define the current aspect ratio of the effect
  75402. */
  75403. bind(effect: Effect, aspectRatio?: number): void;
  75404. /**
  75405. * Clones the current image processing instance.
  75406. * @return The cloned image processing
  75407. */
  75408. clone(): ImageProcessingConfiguration;
  75409. /**
  75410. * Serializes the current image processing instance to a json representation.
  75411. * @return a JSON representation
  75412. */
  75413. serialize(): any;
  75414. /**
  75415. * Parses the image processing from a json representation.
  75416. * @param source the JSON source to parse
  75417. * @return The parsed image processing
  75418. */
  75419. static Parse(source: any): ImageProcessingConfiguration;
  75420. private static _VIGNETTEMODE_MULTIPLY;
  75421. private static _VIGNETTEMODE_OPAQUE;
  75422. /**
  75423. * Used to apply the vignette as a mix with the pixel color.
  75424. */
  75425. static readonly VIGNETTEMODE_MULTIPLY: number;
  75426. /**
  75427. * Used to apply the vignette as a replacement of the pixel color.
  75428. */
  75429. static readonly VIGNETTEMODE_OPAQUE: number;
  75430. }
  75431. }
  75432. declare module BABYLON {
  75433. /** @hidden */
  75434. export var postprocessVertexShader: {
  75435. name: string;
  75436. shader: string;
  75437. };
  75438. }
  75439. declare module BABYLON {
  75440. interface ThinEngine {
  75441. /**
  75442. * Creates a new render target texture
  75443. * @param size defines the size of the texture
  75444. * @param options defines the options used to create the texture
  75445. * @returns a new render target texture stored in an InternalTexture
  75446. */
  75447. createRenderTargetTexture(size: number | {
  75448. width: number;
  75449. height: number;
  75450. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75451. }
  75452. }
  75453. declare module BABYLON {
  75454. /** Defines supported spaces */
  75455. export enum Space {
  75456. /** Local (object) space */
  75457. LOCAL = 0,
  75458. /** World space */
  75459. WORLD = 1,
  75460. /** Bone space */
  75461. BONE = 2
  75462. }
  75463. /** Defines the 3 main axes */
  75464. export class Axis {
  75465. /** X axis */
  75466. static X: Vector3;
  75467. /** Y axis */
  75468. static Y: Vector3;
  75469. /** Z axis */
  75470. static Z: Vector3;
  75471. }
  75472. }
  75473. declare module BABYLON {
  75474. /**
  75475. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75476. * This is the base of the follow, arc rotate cameras and Free camera
  75477. * @see http://doc.babylonjs.com/features/cameras
  75478. */
  75479. export class TargetCamera extends Camera {
  75480. private static _RigCamTransformMatrix;
  75481. private static _TargetTransformMatrix;
  75482. private static _TargetFocalPoint;
  75483. /**
  75484. * Define the current direction the camera is moving to
  75485. */
  75486. cameraDirection: Vector3;
  75487. /**
  75488. * Define the current rotation the camera is rotating to
  75489. */
  75490. cameraRotation: Vector2;
  75491. /**
  75492. * When set, the up vector of the camera will be updated by the rotation of the camera
  75493. */
  75494. updateUpVectorFromRotation: boolean;
  75495. private _tmpQuaternion;
  75496. /**
  75497. * Define the current rotation of the camera
  75498. */
  75499. rotation: Vector3;
  75500. /**
  75501. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75502. */
  75503. rotationQuaternion: Quaternion;
  75504. /**
  75505. * Define the current speed of the camera
  75506. */
  75507. speed: number;
  75508. /**
  75509. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75510. * around all axis.
  75511. */
  75512. noRotationConstraint: boolean;
  75513. /**
  75514. * Define the current target of the camera as an object or a position.
  75515. */
  75516. lockedTarget: any;
  75517. /** @hidden */
  75518. _currentTarget: Vector3;
  75519. /** @hidden */
  75520. _initialFocalDistance: number;
  75521. /** @hidden */
  75522. _viewMatrix: Matrix;
  75523. /** @hidden */
  75524. _camMatrix: Matrix;
  75525. /** @hidden */
  75526. _cameraTransformMatrix: Matrix;
  75527. /** @hidden */
  75528. _cameraRotationMatrix: Matrix;
  75529. /** @hidden */
  75530. _referencePoint: Vector3;
  75531. /** @hidden */
  75532. _transformedReferencePoint: Vector3;
  75533. protected _globalCurrentTarget: Vector3;
  75534. protected _globalCurrentUpVector: Vector3;
  75535. /** @hidden */
  75536. _reset: () => void;
  75537. private _defaultUp;
  75538. /**
  75539. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75540. * This is the base of the follow, arc rotate cameras and Free camera
  75541. * @see http://doc.babylonjs.com/features/cameras
  75542. * @param name Defines the name of the camera in the scene
  75543. * @param position Defines the start position of the camera in the scene
  75544. * @param scene Defines the scene the camera belongs to
  75545. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75546. */
  75547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75548. /**
  75549. * Gets the position in front of the camera at a given distance.
  75550. * @param distance The distance from the camera we want the position to be
  75551. * @returns the position
  75552. */
  75553. getFrontPosition(distance: number): Vector3;
  75554. /** @hidden */
  75555. _getLockedTargetPosition(): Nullable<Vector3>;
  75556. private _storedPosition;
  75557. private _storedRotation;
  75558. private _storedRotationQuaternion;
  75559. /**
  75560. * Store current camera state of the camera (fov, position, rotation, etc..)
  75561. * @returns the camera
  75562. */
  75563. storeState(): Camera;
  75564. /**
  75565. * Restored camera state. You must call storeState() first
  75566. * @returns whether it was successful or not
  75567. * @hidden
  75568. */
  75569. _restoreStateValues(): boolean;
  75570. /** @hidden */
  75571. _initCache(): void;
  75572. /** @hidden */
  75573. _updateCache(ignoreParentClass?: boolean): void;
  75574. /** @hidden */
  75575. _isSynchronizedViewMatrix(): boolean;
  75576. /** @hidden */
  75577. _computeLocalCameraSpeed(): number;
  75578. /**
  75579. * Defines the target the camera should look at.
  75580. * @param target Defines the new target as a Vector or a mesh
  75581. */
  75582. setTarget(target: Vector3): void;
  75583. /**
  75584. * Return the current target position of the camera. This value is expressed in local space.
  75585. * @returns the target position
  75586. */
  75587. getTarget(): Vector3;
  75588. /** @hidden */
  75589. _decideIfNeedsToMove(): boolean;
  75590. /** @hidden */
  75591. _updatePosition(): void;
  75592. /** @hidden */
  75593. _checkInputs(): void;
  75594. protected _updateCameraRotationMatrix(): void;
  75595. /**
  75596. * 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)
  75597. * @returns the current camera
  75598. */
  75599. private _rotateUpVectorWithCameraRotationMatrix;
  75600. private _cachedRotationZ;
  75601. private _cachedQuaternionRotationZ;
  75602. /** @hidden */
  75603. _getViewMatrix(): Matrix;
  75604. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75605. /**
  75606. * @hidden
  75607. */
  75608. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75609. /**
  75610. * @hidden
  75611. */
  75612. _updateRigCameras(): void;
  75613. private _getRigCamPositionAndTarget;
  75614. /**
  75615. * Gets the current object class name.
  75616. * @return the class name
  75617. */
  75618. getClassName(): string;
  75619. }
  75620. }
  75621. declare module BABYLON {
  75622. /**
  75623. * Gather the list of keyboard event types as constants.
  75624. */
  75625. export class KeyboardEventTypes {
  75626. /**
  75627. * The keydown event is fired when a key becomes active (pressed).
  75628. */
  75629. static readonly KEYDOWN: number;
  75630. /**
  75631. * The keyup event is fired when a key has been released.
  75632. */
  75633. static readonly KEYUP: number;
  75634. }
  75635. /**
  75636. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75637. */
  75638. export class KeyboardInfo {
  75639. /**
  75640. * Defines the type of event (KeyboardEventTypes)
  75641. */
  75642. type: number;
  75643. /**
  75644. * Defines the related dom event
  75645. */
  75646. event: KeyboardEvent;
  75647. /**
  75648. * Instantiates a new keyboard info.
  75649. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75650. * @param type Defines the type of event (KeyboardEventTypes)
  75651. * @param event Defines the related dom event
  75652. */
  75653. constructor(
  75654. /**
  75655. * Defines the type of event (KeyboardEventTypes)
  75656. */
  75657. type: number,
  75658. /**
  75659. * Defines the related dom event
  75660. */
  75661. event: KeyboardEvent);
  75662. }
  75663. /**
  75664. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75665. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75666. */
  75667. export class KeyboardInfoPre extends KeyboardInfo {
  75668. /**
  75669. * Defines the type of event (KeyboardEventTypes)
  75670. */
  75671. type: number;
  75672. /**
  75673. * Defines the related dom event
  75674. */
  75675. event: KeyboardEvent;
  75676. /**
  75677. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75678. */
  75679. skipOnPointerObservable: boolean;
  75680. /**
  75681. * Instantiates a new keyboard pre info.
  75682. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75683. * @param type Defines the type of event (KeyboardEventTypes)
  75684. * @param event Defines the related dom event
  75685. */
  75686. constructor(
  75687. /**
  75688. * Defines the type of event (KeyboardEventTypes)
  75689. */
  75690. type: number,
  75691. /**
  75692. * Defines the related dom event
  75693. */
  75694. event: KeyboardEvent);
  75695. }
  75696. }
  75697. declare module BABYLON {
  75698. /**
  75699. * Manage the keyboard inputs to control the movement of a free camera.
  75700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75701. */
  75702. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75703. /**
  75704. * Defines the camera the input is attached to.
  75705. */
  75706. camera: FreeCamera;
  75707. /**
  75708. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75709. */
  75710. keysUp: number[];
  75711. /**
  75712. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75713. */
  75714. keysDown: number[];
  75715. /**
  75716. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75717. */
  75718. keysLeft: number[];
  75719. /**
  75720. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75721. */
  75722. keysRight: number[];
  75723. private _keys;
  75724. private _onCanvasBlurObserver;
  75725. private _onKeyboardObserver;
  75726. private _engine;
  75727. private _scene;
  75728. /**
  75729. * Attach the input controls to a specific dom element to get the input from.
  75730. * @param element Defines the element the controls should be listened from
  75731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75732. */
  75733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75734. /**
  75735. * Detach the current controls from the specified dom element.
  75736. * @param element Defines the element to stop listening the inputs from
  75737. */
  75738. detachControl(element: Nullable<HTMLElement>): void;
  75739. /**
  75740. * Update the current camera state depending on the inputs that have been used this frame.
  75741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75742. */
  75743. checkInputs(): void;
  75744. /**
  75745. * Gets the class name of the current intput.
  75746. * @returns the class name
  75747. */
  75748. getClassName(): string;
  75749. /** @hidden */
  75750. _onLostFocus(): void;
  75751. /**
  75752. * Get the friendly name associated with the input class.
  75753. * @returns the input friendly name
  75754. */
  75755. getSimpleName(): string;
  75756. }
  75757. }
  75758. declare module BABYLON {
  75759. /**
  75760. * Interface describing all the common properties and methods a shadow light needs to implement.
  75761. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75762. * as well as binding the different shadow properties to the effects.
  75763. */
  75764. export interface IShadowLight extends Light {
  75765. /**
  75766. * The light id in the scene (used in scene.findLighById for instance)
  75767. */
  75768. id: string;
  75769. /**
  75770. * The position the shdow will be casted from.
  75771. */
  75772. position: Vector3;
  75773. /**
  75774. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75775. */
  75776. direction: Vector3;
  75777. /**
  75778. * The transformed position. Position of the light in world space taking parenting in account.
  75779. */
  75780. transformedPosition: Vector3;
  75781. /**
  75782. * The transformed direction. Direction of the light in world space taking parenting in account.
  75783. */
  75784. transformedDirection: Vector3;
  75785. /**
  75786. * The friendly name of the light in the scene.
  75787. */
  75788. name: string;
  75789. /**
  75790. * Defines the shadow projection clipping minimum z value.
  75791. */
  75792. shadowMinZ: number;
  75793. /**
  75794. * Defines the shadow projection clipping maximum z value.
  75795. */
  75796. shadowMaxZ: number;
  75797. /**
  75798. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75799. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75800. */
  75801. computeTransformedInformation(): boolean;
  75802. /**
  75803. * Gets the scene the light belongs to.
  75804. * @returns The scene
  75805. */
  75806. getScene(): Scene;
  75807. /**
  75808. * Callback defining a custom Projection Matrix Builder.
  75809. * This can be used to override the default projection matrix computation.
  75810. */
  75811. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75812. /**
  75813. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75814. * @param matrix The materix to updated with the projection information
  75815. * @param viewMatrix The transform matrix of the light
  75816. * @param renderList The list of mesh to render in the map
  75817. * @returns The current light
  75818. */
  75819. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75820. /**
  75821. * Gets the current depth scale used in ESM.
  75822. * @returns The scale
  75823. */
  75824. getDepthScale(): number;
  75825. /**
  75826. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75827. * @returns true if a cube texture needs to be use
  75828. */
  75829. needCube(): boolean;
  75830. /**
  75831. * Detects if the projection matrix requires to be recomputed this frame.
  75832. * @returns true if it requires to be recomputed otherwise, false.
  75833. */
  75834. needProjectionMatrixCompute(): boolean;
  75835. /**
  75836. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75837. */
  75838. forceProjectionMatrixCompute(): void;
  75839. /**
  75840. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75841. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75842. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75843. */
  75844. getShadowDirection(faceIndex?: number): Vector3;
  75845. /**
  75846. * Gets the minZ used for shadow according to both the scene and the light.
  75847. * @param activeCamera The camera we are returning the min for
  75848. * @returns the depth min z
  75849. */
  75850. getDepthMinZ(activeCamera: Camera): number;
  75851. /**
  75852. * Gets the maxZ used for shadow according to both the scene and the light.
  75853. * @param activeCamera The camera we are returning the max for
  75854. * @returns the depth max z
  75855. */
  75856. getDepthMaxZ(activeCamera: Camera): number;
  75857. }
  75858. /**
  75859. * Base implementation IShadowLight
  75860. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75861. */
  75862. export abstract class ShadowLight extends Light implements IShadowLight {
  75863. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75864. protected _position: Vector3;
  75865. protected _setPosition(value: Vector3): void;
  75866. /**
  75867. * Sets the position the shadow will be casted from. Also use as the light position for both
  75868. * point and spot lights.
  75869. */
  75870. /**
  75871. * Sets the position the shadow will be casted from. Also use as the light position for both
  75872. * point and spot lights.
  75873. */
  75874. position: Vector3;
  75875. protected _direction: Vector3;
  75876. protected _setDirection(value: Vector3): void;
  75877. /**
  75878. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75879. * Also use as the light direction on spot and directional lights.
  75880. */
  75881. /**
  75882. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75883. * Also use as the light direction on spot and directional lights.
  75884. */
  75885. direction: Vector3;
  75886. private _shadowMinZ;
  75887. /**
  75888. * Gets the shadow projection clipping minimum z value.
  75889. */
  75890. /**
  75891. * Sets the shadow projection clipping minimum z value.
  75892. */
  75893. shadowMinZ: number;
  75894. private _shadowMaxZ;
  75895. /**
  75896. * Sets the shadow projection clipping maximum z value.
  75897. */
  75898. /**
  75899. * Gets the shadow projection clipping maximum z value.
  75900. */
  75901. shadowMaxZ: number;
  75902. /**
  75903. * Callback defining a custom Projection Matrix Builder.
  75904. * This can be used to override the default projection matrix computation.
  75905. */
  75906. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75907. /**
  75908. * The transformed position. Position of the light in world space taking parenting in account.
  75909. */
  75910. transformedPosition: Vector3;
  75911. /**
  75912. * The transformed direction. Direction of the light in world space taking parenting in account.
  75913. */
  75914. transformedDirection: Vector3;
  75915. private _needProjectionMatrixCompute;
  75916. /**
  75917. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75918. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75919. */
  75920. computeTransformedInformation(): boolean;
  75921. /**
  75922. * Return the depth scale used for the shadow map.
  75923. * @returns the depth scale.
  75924. */
  75925. getDepthScale(): number;
  75926. /**
  75927. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75928. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75929. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75930. */
  75931. getShadowDirection(faceIndex?: number): Vector3;
  75932. /**
  75933. * Returns the ShadowLight absolute position in the World.
  75934. * @returns the position vector in world space
  75935. */
  75936. getAbsolutePosition(): Vector3;
  75937. /**
  75938. * Sets the ShadowLight direction toward the passed target.
  75939. * @param target The point to target in local space
  75940. * @returns the updated ShadowLight direction
  75941. */
  75942. setDirectionToTarget(target: Vector3): Vector3;
  75943. /**
  75944. * Returns the light rotation in euler definition.
  75945. * @returns the x y z rotation in local space.
  75946. */
  75947. getRotation(): Vector3;
  75948. /**
  75949. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75950. * @returns true if a cube texture needs to be use
  75951. */
  75952. needCube(): boolean;
  75953. /**
  75954. * Detects if the projection matrix requires to be recomputed this frame.
  75955. * @returns true if it requires to be recomputed otherwise, false.
  75956. */
  75957. needProjectionMatrixCompute(): boolean;
  75958. /**
  75959. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75960. */
  75961. forceProjectionMatrixCompute(): void;
  75962. /** @hidden */
  75963. _initCache(): void;
  75964. /** @hidden */
  75965. _isSynchronized(): boolean;
  75966. /**
  75967. * Computes the world matrix of the node
  75968. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75969. * @returns the world matrix
  75970. */
  75971. computeWorldMatrix(force?: boolean): Matrix;
  75972. /**
  75973. * Gets the minZ used for shadow according to both the scene and the light.
  75974. * @param activeCamera The camera we are returning the min for
  75975. * @returns the depth min z
  75976. */
  75977. getDepthMinZ(activeCamera: Camera): number;
  75978. /**
  75979. * Gets the maxZ used for shadow according to both the scene and the light.
  75980. * @param activeCamera The camera we are returning the max for
  75981. * @returns the depth max z
  75982. */
  75983. getDepthMaxZ(activeCamera: Camera): number;
  75984. /**
  75985. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75986. * @param matrix The materix to updated with the projection information
  75987. * @param viewMatrix The transform matrix of the light
  75988. * @param renderList The list of mesh to render in the map
  75989. * @returns The current light
  75990. */
  75991. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75992. }
  75993. }
  75994. declare module BABYLON {
  75995. /**
  75996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75998. */
  75999. export class EffectFallbacks implements IEffectFallbacks {
  76000. private _defines;
  76001. private _currentRank;
  76002. private _maxRank;
  76003. private _mesh;
  76004. /**
  76005. * Removes the fallback from the bound mesh.
  76006. */
  76007. unBindMesh(): void;
  76008. /**
  76009. * Adds a fallback on the specified property.
  76010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76011. * @param define The name of the define in the shader
  76012. */
  76013. addFallback(rank: number, define: string): void;
  76014. /**
  76015. * Sets the mesh to use CPU skinning when needing to fallback.
  76016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76017. * @param mesh The mesh to use the fallbacks.
  76018. */
  76019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76020. /**
  76021. * Checks to see if more fallbacks are still availible.
  76022. */
  76023. readonly hasMoreFallbacks: boolean;
  76024. /**
  76025. * Removes the defines that should be removed when falling back.
  76026. * @param currentDefines defines the current define statements for the shader.
  76027. * @param effect defines the current effect we try to compile
  76028. * @returns The resulting defines with defines of the current rank removed.
  76029. */
  76030. reduce(currentDefines: string, effect: Effect): string;
  76031. }
  76032. }
  76033. declare module BABYLON {
  76034. /**
  76035. * "Static Class" containing the most commonly used helper while dealing with material for
  76036. * rendering purpose.
  76037. *
  76038. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76039. *
  76040. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76041. */
  76042. export class MaterialHelper {
  76043. /**
  76044. * Bind the current view position to an effect.
  76045. * @param effect The effect to be bound
  76046. * @param scene The scene the eyes position is used from
  76047. */
  76048. static BindEyePosition(effect: Effect, scene: Scene): void;
  76049. /**
  76050. * Helps preparing the defines values about the UVs in used in the effect.
  76051. * UVs are shared as much as we can accross channels in the shaders.
  76052. * @param texture The texture we are preparing the UVs for
  76053. * @param defines The defines to update
  76054. * @param key The channel key "diffuse", "specular"... used in the shader
  76055. */
  76056. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76057. /**
  76058. * Binds a texture matrix value to its corrsponding uniform
  76059. * @param texture The texture to bind the matrix for
  76060. * @param uniformBuffer The uniform buffer receivin the data
  76061. * @param key The channel key "diffuse", "specular"... used in the shader
  76062. */
  76063. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76064. /**
  76065. * Gets the current status of the fog (should it be enabled?)
  76066. * @param mesh defines the mesh to evaluate for fog support
  76067. * @param scene defines the hosting scene
  76068. * @returns true if fog must be enabled
  76069. */
  76070. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76071. /**
  76072. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76073. * @param mesh defines the current mesh
  76074. * @param scene defines the current scene
  76075. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76076. * @param pointsCloud defines if point cloud rendering has to be turned on
  76077. * @param fogEnabled defines if fog has to be turned on
  76078. * @param alphaTest defines if alpha testing has to be turned on
  76079. * @param defines defines the current list of defines
  76080. */
  76081. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76082. /**
  76083. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76084. * @param scene defines the current scene
  76085. * @param engine defines the current engine
  76086. * @param defines specifies the list of active defines
  76087. * @param useInstances defines if instances have to be turned on
  76088. * @param useClipPlane defines if clip plane have to be turned on
  76089. */
  76090. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76091. /**
  76092. * Prepares the defines for bones
  76093. * @param mesh The mesh containing the geometry data we will draw
  76094. * @param defines The defines to update
  76095. */
  76096. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76097. /**
  76098. * Prepares the defines for morph targets
  76099. * @param mesh The mesh containing the geometry data we will draw
  76100. * @param defines The defines to update
  76101. */
  76102. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76103. /**
  76104. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76105. * @param mesh The mesh containing the geometry data we will draw
  76106. * @param defines The defines to update
  76107. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76108. * @param useBones Precise whether bones should be used or not (override mesh info)
  76109. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76110. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76111. * @returns false if defines are considered not dirty and have not been checked
  76112. */
  76113. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76114. /**
  76115. * Prepares the defines related to multiview
  76116. * @param scene The scene we are intending to draw
  76117. * @param defines The defines to update
  76118. */
  76119. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76120. /**
  76121. * Prepares the defines related to the light information passed in parameter
  76122. * @param scene The scene we are intending to draw
  76123. * @param mesh The mesh the effect is compiling for
  76124. * @param light The light the effect is compiling for
  76125. * @param lightIndex The index of the light
  76126. * @param defines The defines to update
  76127. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76128. * @param state Defines the current state regarding what is needed (normals, etc...)
  76129. */
  76130. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76131. needNormals: boolean;
  76132. needRebuild: boolean;
  76133. shadowEnabled: boolean;
  76134. specularEnabled: boolean;
  76135. lightmapMode: boolean;
  76136. }): void;
  76137. /**
  76138. * Prepares the defines related to the light information passed in parameter
  76139. * @param scene The scene we are intending to draw
  76140. * @param mesh The mesh the effect is compiling for
  76141. * @param defines The defines to update
  76142. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76143. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76144. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76145. * @returns true if normals will be required for the rest of the effect
  76146. */
  76147. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76148. /**
  76149. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76150. * @param lightIndex defines the light index
  76151. * @param uniformsList The uniform list
  76152. * @param samplersList The sampler list
  76153. * @param projectedLightTexture defines if projected texture must be used
  76154. * @param uniformBuffersList defines an optional list of uniform buffers
  76155. */
  76156. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76157. /**
  76158. * Prepares the uniforms and samplers list to be used in the effect
  76159. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76160. * @param samplersList The sampler list
  76161. * @param defines The defines helping in the list generation
  76162. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76163. */
  76164. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76165. /**
  76166. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76167. * @param defines The defines to update while falling back
  76168. * @param fallbacks The authorized effect fallbacks
  76169. * @param maxSimultaneousLights The maximum number of lights allowed
  76170. * @param rank the current rank of the Effect
  76171. * @returns The newly affected rank
  76172. */
  76173. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76174. private static _TmpMorphInfluencers;
  76175. /**
  76176. * Prepares the list of attributes required for morph targets according to the effect defines.
  76177. * @param attribs The current list of supported attribs
  76178. * @param mesh The mesh to prepare the morph targets attributes for
  76179. * @param influencers The number of influencers
  76180. */
  76181. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76182. /**
  76183. * Prepares the list of attributes required for morph targets according to the effect defines.
  76184. * @param attribs The current list of supported attribs
  76185. * @param mesh The mesh to prepare the morph targets attributes for
  76186. * @param defines The current Defines of the effect
  76187. */
  76188. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76189. /**
  76190. * Prepares the list of attributes required for bones according to the effect defines.
  76191. * @param attribs The current list of supported attribs
  76192. * @param mesh The mesh to prepare the bones attributes for
  76193. * @param defines The current Defines of the effect
  76194. * @param fallbacks The current efffect fallback strategy
  76195. */
  76196. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76197. /**
  76198. * Check and prepare the list of attributes required for instances according to the effect defines.
  76199. * @param attribs The current list of supported attribs
  76200. * @param defines The current MaterialDefines of the effect
  76201. */
  76202. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76203. /**
  76204. * Add the list of attributes required for instances to the attribs array.
  76205. * @param attribs The current list of supported attribs
  76206. */
  76207. static PushAttributesForInstances(attribs: string[]): void;
  76208. /**
  76209. * Binds the light shadow information to the effect for the given mesh.
  76210. * @param light The light containing the generator
  76211. * @param scene The scene the lights belongs to
  76212. * @param mesh The mesh we are binding the information to render
  76213. * @param lightIndex The light index in the effect used to render the mesh
  76214. * @param effect The effect we are binding the data to
  76215. */
  76216. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  76217. /**
  76218. * Binds the light information to the effect.
  76219. * @param light The light containing the generator
  76220. * @param effect The effect we are binding the data to
  76221. * @param lightIndex The light index in the effect used to render
  76222. */
  76223. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76224. /**
  76225. * Binds the lights information from the scene to the effect for the given mesh.
  76226. * @param light Light to bind
  76227. * @param lightIndex Light index
  76228. * @param scene The scene where the light belongs to
  76229. * @param mesh The mesh we are binding the information to render
  76230. * @param effect The effect we are binding the data to
  76231. * @param useSpecular Defines if specular is supported
  76232. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76233. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76234. */
  76235. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76236. /**
  76237. * Binds the lights information from the scene to the effect for the given mesh.
  76238. * @param scene The scene the lights belongs to
  76239. * @param mesh The mesh we are binding the information to render
  76240. * @param effect The effect we are binding the data to
  76241. * @param defines The generated defines for the effect
  76242. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76243. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76244. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76245. */
  76246. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76247. private static _tempFogColor;
  76248. /**
  76249. * Binds the fog information from the scene to the effect for the given mesh.
  76250. * @param scene The scene the lights belongs to
  76251. * @param mesh The mesh we are binding the information to render
  76252. * @param effect The effect we are binding the data to
  76253. * @param linearSpace Defines if the fog effect is applied in linear space
  76254. */
  76255. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76256. /**
  76257. * Binds the bones information from the mesh to the effect.
  76258. * @param mesh The mesh we are binding the information to render
  76259. * @param effect The effect we are binding the data to
  76260. */
  76261. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76262. /**
  76263. * Binds the morph targets information from the mesh to the effect.
  76264. * @param abstractMesh The mesh we are binding the information to render
  76265. * @param effect The effect we are binding the data to
  76266. */
  76267. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76268. /**
  76269. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76270. * @param defines The generated defines used in the effect
  76271. * @param effect The effect we are binding the data to
  76272. * @param scene The scene we are willing to render with logarithmic scale for
  76273. */
  76274. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76275. /**
  76276. * Binds the clip plane information from the scene to the effect.
  76277. * @param scene The scene the clip plane information are extracted from
  76278. * @param effect The effect we are binding the data to
  76279. */
  76280. static BindClipPlane(effect: Effect, scene: Scene): void;
  76281. }
  76282. }
  76283. declare module BABYLON {
  76284. /** @hidden */
  76285. export var packingFunctions: {
  76286. name: string;
  76287. shader: string;
  76288. };
  76289. }
  76290. declare module BABYLON {
  76291. /** @hidden */
  76292. export var shadowMapPixelShader: {
  76293. name: string;
  76294. shader: string;
  76295. };
  76296. }
  76297. declare module BABYLON {
  76298. /** @hidden */
  76299. export var bonesDeclaration: {
  76300. name: string;
  76301. shader: string;
  76302. };
  76303. }
  76304. declare module BABYLON {
  76305. /** @hidden */
  76306. export var morphTargetsVertexGlobalDeclaration: {
  76307. name: string;
  76308. shader: string;
  76309. };
  76310. }
  76311. declare module BABYLON {
  76312. /** @hidden */
  76313. export var morphTargetsVertexDeclaration: {
  76314. name: string;
  76315. shader: string;
  76316. };
  76317. }
  76318. declare module BABYLON {
  76319. /** @hidden */
  76320. export var instancesDeclaration: {
  76321. name: string;
  76322. shader: string;
  76323. };
  76324. }
  76325. declare module BABYLON {
  76326. /** @hidden */
  76327. export var helperFunctions: {
  76328. name: string;
  76329. shader: string;
  76330. };
  76331. }
  76332. declare module BABYLON {
  76333. /** @hidden */
  76334. export var morphTargetsVertex: {
  76335. name: string;
  76336. shader: string;
  76337. };
  76338. }
  76339. declare module BABYLON {
  76340. /** @hidden */
  76341. export var instancesVertex: {
  76342. name: string;
  76343. shader: string;
  76344. };
  76345. }
  76346. declare module BABYLON {
  76347. /** @hidden */
  76348. export var bonesVertex: {
  76349. name: string;
  76350. shader: string;
  76351. };
  76352. }
  76353. declare module BABYLON {
  76354. /** @hidden */
  76355. export var shadowMapVertexShader: {
  76356. name: string;
  76357. shader: string;
  76358. };
  76359. }
  76360. declare module BABYLON {
  76361. /** @hidden */
  76362. export var depthBoxBlurPixelShader: {
  76363. name: string;
  76364. shader: string;
  76365. };
  76366. }
  76367. declare module BABYLON {
  76368. /**
  76369. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76370. */
  76371. export interface ICustomShaderOptions {
  76372. /**
  76373. * Gets or sets the custom shader name to use
  76374. */
  76375. shaderName: string;
  76376. /**
  76377. * The list of attribute names used in the shader
  76378. */
  76379. attributes?: string[];
  76380. /**
  76381. * The list of unifrom names used in the shader
  76382. */
  76383. uniforms?: string[];
  76384. /**
  76385. * The list of sampler names used in the shader
  76386. */
  76387. samplers?: string[];
  76388. /**
  76389. * The list of defines used in the shader
  76390. */
  76391. defines?: string[];
  76392. }
  76393. /**
  76394. * Interface to implement to create a shadow generator compatible with BJS.
  76395. */
  76396. export interface IShadowGenerator {
  76397. /**
  76398. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76399. * @returns The render target texture if present otherwise, null
  76400. */
  76401. getShadowMap(): Nullable<RenderTargetTexture>;
  76402. /**
  76403. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76404. * @returns The render target texture if the shadow map is present otherwise, null
  76405. */
  76406. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76407. /**
  76408. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76409. * @param subMesh The submesh we want to render in the shadow map
  76410. * @param useInstances Defines wether will draw in the map using instances
  76411. * @returns true if ready otherwise, false
  76412. */
  76413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76414. /**
  76415. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76416. * @param defines Defines of the material we want to update
  76417. * @param lightIndex Index of the light in the enabled light list of the material
  76418. */
  76419. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76420. /**
  76421. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76422. * defined in the generator but impacting the effect).
  76423. * It implies the unifroms available on the materials are the standard BJS ones.
  76424. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76425. * @param effect The effect we are binfing the information for
  76426. */
  76427. bindShadowLight(lightIndex: string, effect: Effect): void;
  76428. /**
  76429. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76430. * (eq to shadow prjection matrix * light transform matrix)
  76431. * @returns The transform matrix used to create the shadow map
  76432. */
  76433. getTransformMatrix(): Matrix;
  76434. /**
  76435. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76436. * Cube and 2D textures for instance.
  76437. */
  76438. recreateShadowMap(): void;
  76439. /**
  76440. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76441. * @param onCompiled Callback triggered at the and of the effects compilation
  76442. * @param options Sets of optional options forcing the compilation with different modes
  76443. */
  76444. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76445. useInstances: boolean;
  76446. }>): void;
  76447. /**
  76448. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76449. * @param options Sets of optional options forcing the compilation with different modes
  76450. * @returns A promise that resolves when the compilation completes
  76451. */
  76452. forceCompilationAsync(options?: Partial<{
  76453. useInstances: boolean;
  76454. }>): Promise<void>;
  76455. /**
  76456. * Serializes the shadow generator setup to a json object.
  76457. * @returns The serialized JSON object
  76458. */
  76459. serialize(): any;
  76460. /**
  76461. * Disposes the Shadow map and related Textures and effects.
  76462. */
  76463. dispose(): void;
  76464. }
  76465. /**
  76466. * Default implementation IShadowGenerator.
  76467. * This is the main object responsible of generating shadows in the framework.
  76468. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76469. */
  76470. export class ShadowGenerator implements IShadowGenerator {
  76471. /**
  76472. * Shadow generator mode None: no filtering applied.
  76473. */
  76474. static readonly FILTER_NONE: number;
  76475. /**
  76476. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76477. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76478. */
  76479. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76480. /**
  76481. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76482. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76483. */
  76484. static readonly FILTER_POISSONSAMPLING: number;
  76485. /**
  76486. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76487. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76488. */
  76489. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76490. /**
  76491. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76492. * edge artifacts on steep falloff.
  76493. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76494. */
  76495. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76496. /**
  76497. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76498. * edge artifacts on steep falloff.
  76499. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76500. */
  76501. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76502. /**
  76503. * Shadow generator mode PCF: Percentage Closer Filtering
  76504. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76505. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76506. */
  76507. static readonly FILTER_PCF: number;
  76508. /**
  76509. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76510. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76511. * Contact Hardening
  76512. */
  76513. static readonly FILTER_PCSS: number;
  76514. /**
  76515. * Reserved for PCF and PCSS
  76516. * Highest Quality.
  76517. *
  76518. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76519. *
  76520. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76521. */
  76522. static readonly QUALITY_HIGH: number;
  76523. /**
  76524. * Reserved for PCF and PCSS
  76525. * Good tradeoff for quality/perf cross devices
  76526. *
  76527. * Execute PCF on a 3*3 kernel.
  76528. *
  76529. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76530. */
  76531. static readonly QUALITY_MEDIUM: number;
  76532. /**
  76533. * Reserved for PCF and PCSS
  76534. * The lowest quality but the fastest.
  76535. *
  76536. * Execute PCF on a 1*1 kernel.
  76537. *
  76538. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76539. */
  76540. static readonly QUALITY_LOW: number;
  76541. /** Gets or sets the custom shader name to use */
  76542. customShaderOptions: ICustomShaderOptions;
  76543. /**
  76544. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76545. */
  76546. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76547. /**
  76548. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76549. */
  76550. onAfterShadowMapRenderObservable: Observable<Effect>;
  76551. /**
  76552. * Observable triggered before a mesh is rendered in the shadow map.
  76553. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76554. */
  76555. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76556. /**
  76557. * Observable triggered after a mesh is rendered in the shadow map.
  76558. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76559. */
  76560. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76561. private _bias;
  76562. /**
  76563. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76564. */
  76565. /**
  76566. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76567. */
  76568. bias: number;
  76569. private _normalBias;
  76570. /**
  76571. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76572. */
  76573. /**
  76574. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76575. */
  76576. normalBias: number;
  76577. private _blurBoxOffset;
  76578. /**
  76579. * Gets the blur box offset: offset applied during the blur pass.
  76580. * Only useful if useKernelBlur = false
  76581. */
  76582. /**
  76583. * Sets the blur box offset: offset applied during the blur pass.
  76584. * Only useful if useKernelBlur = false
  76585. */
  76586. blurBoxOffset: number;
  76587. private _blurScale;
  76588. /**
  76589. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76590. * 2 means half of the size.
  76591. */
  76592. /**
  76593. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76594. * 2 means half of the size.
  76595. */
  76596. blurScale: number;
  76597. private _blurKernel;
  76598. /**
  76599. * Gets the blur kernel: kernel size of the blur pass.
  76600. * Only useful if useKernelBlur = true
  76601. */
  76602. /**
  76603. * Sets the blur kernel: kernel size of the blur pass.
  76604. * Only useful if useKernelBlur = true
  76605. */
  76606. blurKernel: number;
  76607. private _useKernelBlur;
  76608. /**
  76609. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76610. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76611. */
  76612. /**
  76613. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76614. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76615. */
  76616. useKernelBlur: boolean;
  76617. private _depthScale;
  76618. /**
  76619. * Gets the depth scale used in ESM mode.
  76620. */
  76621. /**
  76622. * Sets the depth scale used in ESM mode.
  76623. * This can override the scale stored on the light.
  76624. */
  76625. depthScale: number;
  76626. private _filter;
  76627. /**
  76628. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76629. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76630. */
  76631. /**
  76632. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76633. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76634. */
  76635. filter: number;
  76636. /**
  76637. * Gets if the current filter is set to Poisson Sampling.
  76638. */
  76639. /**
  76640. * Sets the current filter to Poisson Sampling.
  76641. */
  76642. usePoissonSampling: boolean;
  76643. /**
  76644. * Gets if the current filter is set to ESM.
  76645. */
  76646. /**
  76647. * Sets the current filter is to ESM.
  76648. */
  76649. useExponentialShadowMap: boolean;
  76650. /**
  76651. * Gets if the current filter is set to filtered ESM.
  76652. */
  76653. /**
  76654. * Gets if the current filter is set to filtered ESM.
  76655. */
  76656. useBlurExponentialShadowMap: boolean;
  76657. /**
  76658. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76659. * exponential to prevent steep falloff artifacts).
  76660. */
  76661. /**
  76662. * Sets the current filter to "close ESM" (using the inverse of the
  76663. * exponential to prevent steep falloff artifacts).
  76664. */
  76665. useCloseExponentialShadowMap: boolean;
  76666. /**
  76667. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76668. * exponential to prevent steep falloff artifacts).
  76669. */
  76670. /**
  76671. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76672. * exponential to prevent steep falloff artifacts).
  76673. */
  76674. useBlurCloseExponentialShadowMap: boolean;
  76675. /**
  76676. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76677. */
  76678. /**
  76679. * Sets the current filter to "PCF" (percentage closer filtering).
  76680. */
  76681. usePercentageCloserFiltering: boolean;
  76682. private _filteringQuality;
  76683. /**
  76684. * Gets the PCF or PCSS Quality.
  76685. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76686. */
  76687. /**
  76688. * Sets the PCF or PCSS Quality.
  76689. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76690. */
  76691. filteringQuality: number;
  76692. /**
  76693. * Gets if the current filter is set to "PCSS" (contact hardening).
  76694. */
  76695. /**
  76696. * Sets the current filter to "PCSS" (contact hardening).
  76697. */
  76698. useContactHardeningShadow: boolean;
  76699. private _contactHardeningLightSizeUVRatio;
  76700. /**
  76701. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76702. * Using a ratio helps keeping shape stability independently of the map size.
  76703. *
  76704. * It does not account for the light projection as it was having too much
  76705. * instability during the light setup or during light position changes.
  76706. *
  76707. * Only valid if useContactHardeningShadow is true.
  76708. */
  76709. /**
  76710. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76711. * Using a ratio helps keeping shape stability independently of the map size.
  76712. *
  76713. * It does not account for the light projection as it was having too much
  76714. * instability during the light setup or during light position changes.
  76715. *
  76716. * Only valid if useContactHardeningShadow is true.
  76717. */
  76718. contactHardeningLightSizeUVRatio: number;
  76719. private _darkness;
  76720. /** Gets or sets the actual darkness of a shadow */
  76721. darkness: number;
  76722. /**
  76723. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76724. * 0 means strongest and 1 would means no shadow.
  76725. * @returns the darkness.
  76726. */
  76727. getDarkness(): number;
  76728. /**
  76729. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76730. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76731. * @returns the shadow generator allowing fluent coding.
  76732. */
  76733. setDarkness(darkness: number): ShadowGenerator;
  76734. private _transparencyShadow;
  76735. /** Gets or sets the ability to have transparent shadow */
  76736. transparencyShadow: boolean;
  76737. /**
  76738. * Sets the ability to have transparent shadow (boolean).
  76739. * @param transparent True if transparent else False
  76740. * @returns the shadow generator allowing fluent coding
  76741. */
  76742. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76743. private _shadowMap;
  76744. private _shadowMap2;
  76745. /**
  76746. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76747. * @returns The render target texture if present otherwise, null
  76748. */
  76749. getShadowMap(): Nullable<RenderTargetTexture>;
  76750. /**
  76751. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76752. * @returns The render target texture if the shadow map is present otherwise, null
  76753. */
  76754. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76755. /**
  76756. * Gets the class name of that object
  76757. * @returns "ShadowGenerator"
  76758. */
  76759. getClassName(): string;
  76760. /**
  76761. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76762. * @param mesh Mesh to add
  76763. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76764. * @returns the Shadow Generator itself
  76765. */
  76766. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76767. /**
  76768. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76769. * @param mesh Mesh to remove
  76770. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76771. * @returns the Shadow Generator itself
  76772. */
  76773. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76774. /**
  76775. * Controls the extent to which the shadows fade out at the edge of the frustum
  76776. * Used only by directionals and spots
  76777. */
  76778. frustumEdgeFalloff: number;
  76779. private _light;
  76780. /**
  76781. * Returns the associated light object.
  76782. * @returns the light generating the shadow
  76783. */
  76784. getLight(): IShadowLight;
  76785. /**
  76786. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76787. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76788. * It might on the other hand introduce peter panning.
  76789. */
  76790. forceBackFacesOnly: boolean;
  76791. private _scene;
  76792. private _lightDirection;
  76793. private _effect;
  76794. private _viewMatrix;
  76795. private _projectionMatrix;
  76796. private _transformMatrix;
  76797. private _cachedPosition;
  76798. private _cachedDirection;
  76799. private _cachedDefines;
  76800. private _currentRenderID;
  76801. private _boxBlurPostprocess;
  76802. private _kernelBlurXPostprocess;
  76803. private _kernelBlurYPostprocess;
  76804. private _blurPostProcesses;
  76805. private _mapSize;
  76806. private _currentFaceIndex;
  76807. private _currentFaceIndexCache;
  76808. private _textureType;
  76809. private _defaultTextureMatrix;
  76810. private _storedUniqueId;
  76811. /** @hidden */
  76812. static _SceneComponentInitialization: (scene: Scene) => void;
  76813. /**
  76814. * Creates a ShadowGenerator object.
  76815. * A ShadowGenerator is the required tool to use the shadows.
  76816. * Each light casting shadows needs to use its own ShadowGenerator.
  76817. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76818. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76819. * @param light The light object generating the shadows.
  76820. * @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.
  76821. */
  76822. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76823. private _initializeGenerator;
  76824. private _initializeShadowMap;
  76825. private _initializeBlurRTTAndPostProcesses;
  76826. private _renderForShadowMap;
  76827. private _renderSubMeshForShadowMap;
  76828. private _applyFilterValues;
  76829. /**
  76830. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76831. * @param onCompiled Callback triggered at the and of the effects compilation
  76832. * @param options Sets of optional options forcing the compilation with different modes
  76833. */
  76834. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76835. useInstances: boolean;
  76836. }>): void;
  76837. /**
  76838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76839. * @param options Sets of optional options forcing the compilation with different modes
  76840. * @returns A promise that resolves when the compilation completes
  76841. */
  76842. forceCompilationAsync(options?: Partial<{
  76843. useInstances: boolean;
  76844. }>): Promise<void>;
  76845. /**
  76846. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76847. * @param subMesh The submesh we want to render in the shadow map
  76848. * @param useInstances Defines wether will draw in the map using instances
  76849. * @returns true if ready otherwise, false
  76850. */
  76851. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76852. /**
  76853. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76854. * @param defines Defines of the material we want to update
  76855. * @param lightIndex Index of the light in the enabled light list of the material
  76856. */
  76857. prepareDefines(defines: any, lightIndex: number): void;
  76858. /**
  76859. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76860. * defined in the generator but impacting the effect).
  76861. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76862. * @param effect The effect we are binfing the information for
  76863. */
  76864. bindShadowLight(lightIndex: string, effect: Effect): void;
  76865. /**
  76866. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76867. * (eq to shadow prjection matrix * light transform matrix)
  76868. * @returns The transform matrix used to create the shadow map
  76869. */
  76870. getTransformMatrix(): Matrix;
  76871. /**
  76872. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76873. * Cube and 2D textures for instance.
  76874. */
  76875. recreateShadowMap(): void;
  76876. private _disposeBlurPostProcesses;
  76877. private _disposeRTTandPostProcesses;
  76878. /**
  76879. * Disposes the ShadowGenerator.
  76880. * Returns nothing.
  76881. */
  76882. dispose(): void;
  76883. /**
  76884. * Serializes the shadow generator setup to a json object.
  76885. * @returns The serialized JSON object
  76886. */
  76887. serialize(): any;
  76888. /**
  76889. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76890. * @param parsedShadowGenerator The JSON object to parse
  76891. * @param scene The scene to create the shadow map for
  76892. * @returns The parsed shadow generator
  76893. */
  76894. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76895. }
  76896. }
  76897. declare module BABYLON {
  76898. /**
  76899. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76900. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76901. * 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.
  76902. */
  76903. export abstract class Light extends Node {
  76904. /**
  76905. * Falloff Default: light is falling off following the material specification:
  76906. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76907. */
  76908. static readonly FALLOFF_DEFAULT: number;
  76909. /**
  76910. * Falloff Physical: light is falling off following the inverse squared distance law.
  76911. */
  76912. static readonly FALLOFF_PHYSICAL: number;
  76913. /**
  76914. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76915. * to enhance interoperability with other engines.
  76916. */
  76917. static readonly FALLOFF_GLTF: number;
  76918. /**
  76919. * Falloff Standard: light is falling off like in the standard material
  76920. * to enhance interoperability with other materials.
  76921. */
  76922. static readonly FALLOFF_STANDARD: number;
  76923. /**
  76924. * If every light affecting the material is in this lightmapMode,
  76925. * material.lightmapTexture adds or multiplies
  76926. * (depends on material.useLightmapAsShadowmap)
  76927. * after every other light calculations.
  76928. */
  76929. static readonly LIGHTMAP_DEFAULT: number;
  76930. /**
  76931. * material.lightmapTexture as only diffuse lighting from this light
  76932. * adds only specular lighting from this light
  76933. * adds dynamic shadows
  76934. */
  76935. static readonly LIGHTMAP_SPECULAR: number;
  76936. /**
  76937. * material.lightmapTexture as only lighting
  76938. * no light calculation from this light
  76939. * only adds dynamic shadows from this light
  76940. */
  76941. static readonly LIGHTMAP_SHADOWSONLY: number;
  76942. /**
  76943. * Each light type uses the default quantity according to its type:
  76944. * point/spot lights use luminous intensity
  76945. * directional lights use illuminance
  76946. */
  76947. static readonly INTENSITYMODE_AUTOMATIC: number;
  76948. /**
  76949. * lumen (lm)
  76950. */
  76951. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76952. /**
  76953. * candela (lm/sr)
  76954. */
  76955. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76956. /**
  76957. * lux (lm/m^2)
  76958. */
  76959. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76960. /**
  76961. * nit (cd/m^2)
  76962. */
  76963. static readonly INTENSITYMODE_LUMINANCE: number;
  76964. /**
  76965. * Light type const id of the point light.
  76966. */
  76967. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76968. /**
  76969. * Light type const id of the directional light.
  76970. */
  76971. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76972. /**
  76973. * Light type const id of the spot light.
  76974. */
  76975. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76976. /**
  76977. * Light type const id of the hemispheric light.
  76978. */
  76979. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76980. /**
  76981. * Diffuse gives the basic color to an object.
  76982. */
  76983. diffuse: Color3;
  76984. /**
  76985. * Specular produces a highlight color on an object.
  76986. * Note: This is note affecting PBR materials.
  76987. */
  76988. specular: Color3;
  76989. /**
  76990. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76991. * falling off base on range or angle.
  76992. * This can be set to any values in Light.FALLOFF_x.
  76993. *
  76994. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76995. * other types of materials.
  76996. */
  76997. falloffType: number;
  76998. /**
  76999. * Strength of the light.
  77000. * Note: By default it is define in the framework own unit.
  77001. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77002. */
  77003. intensity: number;
  77004. private _range;
  77005. protected _inverseSquaredRange: number;
  77006. /**
  77007. * Defines how far from the source the light is impacting in scene units.
  77008. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77009. */
  77010. /**
  77011. * Defines how far from the source the light is impacting in scene units.
  77012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77013. */
  77014. range: number;
  77015. /**
  77016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77017. * of light.
  77018. */
  77019. private _photometricScale;
  77020. private _intensityMode;
  77021. /**
  77022. * Gets the photometric scale used to interpret the intensity.
  77023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77024. */
  77025. /**
  77026. * Sets the photometric scale used to interpret the intensity.
  77027. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77028. */
  77029. intensityMode: number;
  77030. private _radius;
  77031. /**
  77032. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77033. */
  77034. /**
  77035. * sets the light radius used by PBR Materials to simulate soft area lights.
  77036. */
  77037. radius: number;
  77038. private _renderPriority;
  77039. /**
  77040. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77041. * exceeding the number allowed of the materials.
  77042. */
  77043. renderPriority: number;
  77044. private _shadowEnabled;
  77045. /**
  77046. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77047. * the current shadow generator.
  77048. */
  77049. /**
  77050. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77051. * the current shadow generator.
  77052. */
  77053. shadowEnabled: boolean;
  77054. private _includedOnlyMeshes;
  77055. /**
  77056. * Gets the only meshes impacted by this light.
  77057. */
  77058. /**
  77059. * Sets the only meshes impacted by this light.
  77060. */
  77061. includedOnlyMeshes: AbstractMesh[];
  77062. private _excludedMeshes;
  77063. /**
  77064. * Gets the meshes not impacted by this light.
  77065. */
  77066. /**
  77067. * Sets the meshes not impacted by this light.
  77068. */
  77069. excludedMeshes: AbstractMesh[];
  77070. private _excludeWithLayerMask;
  77071. /**
  77072. * Gets the layer id use to find what meshes are not impacted by the light.
  77073. * Inactive if 0
  77074. */
  77075. /**
  77076. * Sets the layer id use to find what meshes are not impacted by the light.
  77077. * Inactive if 0
  77078. */
  77079. excludeWithLayerMask: number;
  77080. private _includeOnlyWithLayerMask;
  77081. /**
  77082. * Gets the layer id use to find what meshes are impacted by the light.
  77083. * Inactive if 0
  77084. */
  77085. /**
  77086. * Sets the layer id use to find what meshes are impacted by the light.
  77087. * Inactive if 0
  77088. */
  77089. includeOnlyWithLayerMask: number;
  77090. private _lightmapMode;
  77091. /**
  77092. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77093. */
  77094. /**
  77095. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77096. */
  77097. lightmapMode: number;
  77098. /**
  77099. * Shadow generator associted to the light.
  77100. * @hidden Internal use only.
  77101. */
  77102. _shadowGenerator: Nullable<IShadowGenerator>;
  77103. /**
  77104. * @hidden Internal use only.
  77105. */
  77106. _excludedMeshesIds: string[];
  77107. /**
  77108. * @hidden Internal use only.
  77109. */
  77110. _includedOnlyMeshesIds: string[];
  77111. /**
  77112. * The current light unifom buffer.
  77113. * @hidden Internal use only.
  77114. */
  77115. _uniformBuffer: UniformBuffer;
  77116. /**
  77117. * Creates a Light object in the scene.
  77118. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77119. * @param name The firendly name of the light
  77120. * @param scene The scene the light belongs too
  77121. */
  77122. constructor(name: string, scene: Scene);
  77123. protected abstract _buildUniformLayout(): void;
  77124. /**
  77125. * Sets the passed Effect "effect" with the Light information.
  77126. * @param effect The effect to update
  77127. * @param lightIndex The index of the light in the effect to update
  77128. * @returns The light
  77129. */
  77130. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77131. /**
  77132. * Sets the passed Effect "effect" with the Light information.
  77133. * @param effect The effect to update
  77134. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77135. * @returns The light
  77136. */
  77137. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77138. /**
  77139. * Returns the string "Light".
  77140. * @returns the class name
  77141. */
  77142. getClassName(): string;
  77143. /** @hidden */
  77144. readonly _isLight: boolean;
  77145. /**
  77146. * Converts the light information to a readable string for debug purpose.
  77147. * @param fullDetails Supports for multiple levels of logging within scene loading
  77148. * @returns the human readable light info
  77149. */
  77150. toString(fullDetails?: boolean): string;
  77151. /** @hidden */
  77152. protected _syncParentEnabledState(): void;
  77153. /**
  77154. * Set the enabled state of this node.
  77155. * @param value - the new enabled state
  77156. */
  77157. setEnabled(value: boolean): void;
  77158. /**
  77159. * Returns the Light associated shadow generator if any.
  77160. * @return the associated shadow generator.
  77161. */
  77162. getShadowGenerator(): Nullable<IShadowGenerator>;
  77163. /**
  77164. * Returns a Vector3, the absolute light position in the World.
  77165. * @returns the world space position of the light
  77166. */
  77167. getAbsolutePosition(): Vector3;
  77168. /**
  77169. * Specifies if the light will affect the passed mesh.
  77170. * @param mesh The mesh to test against the light
  77171. * @return true the mesh is affected otherwise, false.
  77172. */
  77173. canAffectMesh(mesh: AbstractMesh): boolean;
  77174. /**
  77175. * Sort function to order lights for rendering.
  77176. * @param a First Light object to compare to second.
  77177. * @param b Second Light object to compare first.
  77178. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77179. */
  77180. static CompareLightsPriority(a: Light, b: Light): number;
  77181. /**
  77182. * Releases resources associated with this node.
  77183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77185. */
  77186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77187. /**
  77188. * Returns the light type ID (integer).
  77189. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77190. */
  77191. getTypeID(): number;
  77192. /**
  77193. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77194. * @returns the scaled intensity in intensity mode unit
  77195. */
  77196. getScaledIntensity(): number;
  77197. /**
  77198. * Returns a new Light object, named "name", from the current one.
  77199. * @param name The name of the cloned light
  77200. * @returns the new created light
  77201. */
  77202. clone(name: string): Nullable<Light>;
  77203. /**
  77204. * Serializes the current light into a Serialization object.
  77205. * @returns the serialized object.
  77206. */
  77207. serialize(): any;
  77208. /**
  77209. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77210. * This new light is named "name" and added to the passed scene.
  77211. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77212. * @param name The friendly name of the light
  77213. * @param scene The scene the new light will belong to
  77214. * @returns the constructor function
  77215. */
  77216. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77217. /**
  77218. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77219. * @param parsedLight The JSON representation of the light
  77220. * @param scene The scene to create the parsed light in
  77221. * @returns the created light after parsing
  77222. */
  77223. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77224. private _hookArrayForExcluded;
  77225. private _hookArrayForIncludedOnly;
  77226. private _resyncMeshes;
  77227. /**
  77228. * Forces the meshes to update their light related information in their rendering used effects
  77229. * @hidden Internal Use Only
  77230. */
  77231. _markMeshesAsLightDirty(): void;
  77232. /**
  77233. * Recomputes the cached photometric scale if needed.
  77234. */
  77235. private _computePhotometricScale;
  77236. /**
  77237. * Returns the Photometric Scale according to the light type and intensity mode.
  77238. */
  77239. private _getPhotometricScale;
  77240. /**
  77241. * Reorder the light in the scene according to their defined priority.
  77242. * @hidden Internal Use Only
  77243. */
  77244. _reorderLightsInScene(): void;
  77245. /**
  77246. * Prepares the list of defines specific to the light type.
  77247. * @param defines the list of defines
  77248. * @param lightIndex defines the index of the light for the effect
  77249. */
  77250. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77251. }
  77252. }
  77253. declare module BABYLON {
  77254. /**
  77255. * Interface used to define Action
  77256. */
  77257. export interface IAction {
  77258. /**
  77259. * Trigger for the action
  77260. */
  77261. trigger: number;
  77262. /** Options of the trigger */
  77263. triggerOptions: any;
  77264. /**
  77265. * Gets the trigger parameters
  77266. * @returns the trigger parameters
  77267. */
  77268. getTriggerParameter(): any;
  77269. /**
  77270. * Internal only - executes current action event
  77271. * @hidden
  77272. */
  77273. _executeCurrent(evt?: ActionEvent): void;
  77274. /**
  77275. * Serialize placeholder for child classes
  77276. * @param parent of child
  77277. * @returns the serialized object
  77278. */
  77279. serialize(parent: any): any;
  77280. /**
  77281. * Internal only
  77282. * @hidden
  77283. */
  77284. _prepare(): void;
  77285. /**
  77286. * Internal only - manager for action
  77287. * @hidden
  77288. */
  77289. _actionManager: AbstractActionManager;
  77290. /**
  77291. * Adds action to chain of actions, may be a DoNothingAction
  77292. * @param action defines the next action to execute
  77293. * @returns The action passed in
  77294. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77295. */
  77296. then(action: IAction): IAction;
  77297. }
  77298. /**
  77299. * The action to be carried out following a trigger
  77300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77301. */
  77302. export class Action implements IAction {
  77303. /** the trigger, with or without parameters, for the action */
  77304. triggerOptions: any;
  77305. /**
  77306. * Trigger for the action
  77307. */
  77308. trigger: number;
  77309. /**
  77310. * Internal only - manager for action
  77311. * @hidden
  77312. */
  77313. _actionManager: ActionManager;
  77314. private _nextActiveAction;
  77315. private _child;
  77316. private _condition?;
  77317. private _triggerParameter;
  77318. /**
  77319. * An event triggered prior to action being executed.
  77320. */
  77321. onBeforeExecuteObservable: Observable<Action>;
  77322. /**
  77323. * Creates a new Action
  77324. * @param triggerOptions the trigger, with or without parameters, for the action
  77325. * @param condition an optional determinant of action
  77326. */
  77327. constructor(
  77328. /** the trigger, with or without parameters, for the action */
  77329. triggerOptions: any, condition?: Condition);
  77330. /**
  77331. * Internal only
  77332. * @hidden
  77333. */
  77334. _prepare(): void;
  77335. /**
  77336. * Gets the trigger parameters
  77337. * @returns the trigger parameters
  77338. */
  77339. getTriggerParameter(): any;
  77340. /**
  77341. * Internal only - executes current action event
  77342. * @hidden
  77343. */
  77344. _executeCurrent(evt?: ActionEvent): void;
  77345. /**
  77346. * Execute placeholder for child classes
  77347. * @param evt optional action event
  77348. */
  77349. execute(evt?: ActionEvent): void;
  77350. /**
  77351. * Skips to next active action
  77352. */
  77353. skipToNextActiveAction(): void;
  77354. /**
  77355. * Adds action to chain of actions, may be a DoNothingAction
  77356. * @param action defines the next action to execute
  77357. * @returns The action passed in
  77358. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77359. */
  77360. then(action: Action): Action;
  77361. /**
  77362. * Internal only
  77363. * @hidden
  77364. */
  77365. _getProperty(propertyPath: string): string;
  77366. /**
  77367. * Internal only
  77368. * @hidden
  77369. */
  77370. _getEffectiveTarget(target: any, propertyPath: string): any;
  77371. /**
  77372. * Serialize placeholder for child classes
  77373. * @param parent of child
  77374. * @returns the serialized object
  77375. */
  77376. serialize(parent: any): any;
  77377. /**
  77378. * Internal only called by serialize
  77379. * @hidden
  77380. */
  77381. protected _serialize(serializedAction: any, parent?: any): any;
  77382. /**
  77383. * Internal only
  77384. * @hidden
  77385. */
  77386. static _SerializeValueAsString: (value: any) => string;
  77387. /**
  77388. * Internal only
  77389. * @hidden
  77390. */
  77391. static _GetTargetProperty: (target: Node | Scene) => {
  77392. name: string;
  77393. targetType: string;
  77394. value: string;
  77395. };
  77396. }
  77397. }
  77398. declare module BABYLON {
  77399. /**
  77400. * A Condition applied to an Action
  77401. */
  77402. export class Condition {
  77403. /**
  77404. * Internal only - manager for action
  77405. * @hidden
  77406. */
  77407. _actionManager: ActionManager;
  77408. /**
  77409. * Internal only
  77410. * @hidden
  77411. */
  77412. _evaluationId: number;
  77413. /**
  77414. * Internal only
  77415. * @hidden
  77416. */
  77417. _currentResult: boolean;
  77418. /**
  77419. * Creates a new Condition
  77420. * @param actionManager the manager of the action the condition is applied to
  77421. */
  77422. constructor(actionManager: ActionManager);
  77423. /**
  77424. * Check if the current condition is valid
  77425. * @returns a boolean
  77426. */
  77427. isValid(): boolean;
  77428. /**
  77429. * Internal only
  77430. * @hidden
  77431. */
  77432. _getProperty(propertyPath: string): string;
  77433. /**
  77434. * Internal only
  77435. * @hidden
  77436. */
  77437. _getEffectiveTarget(target: any, propertyPath: string): any;
  77438. /**
  77439. * Serialize placeholder for child classes
  77440. * @returns the serialized object
  77441. */
  77442. serialize(): any;
  77443. /**
  77444. * Internal only
  77445. * @hidden
  77446. */
  77447. protected _serialize(serializedCondition: any): any;
  77448. }
  77449. /**
  77450. * Defines specific conditional operators as extensions of Condition
  77451. */
  77452. export class ValueCondition extends Condition {
  77453. /** path to specify the property of the target the conditional operator uses */
  77454. propertyPath: string;
  77455. /** the value compared by the conditional operator against the current value of the property */
  77456. value: any;
  77457. /** the conditional operator, default ValueCondition.IsEqual */
  77458. operator: number;
  77459. /**
  77460. * Internal only
  77461. * @hidden
  77462. */
  77463. private static _IsEqual;
  77464. /**
  77465. * Internal only
  77466. * @hidden
  77467. */
  77468. private static _IsDifferent;
  77469. /**
  77470. * Internal only
  77471. * @hidden
  77472. */
  77473. private static _IsGreater;
  77474. /**
  77475. * Internal only
  77476. * @hidden
  77477. */
  77478. private static _IsLesser;
  77479. /**
  77480. * returns the number for IsEqual
  77481. */
  77482. static readonly IsEqual: number;
  77483. /**
  77484. * Returns the number for IsDifferent
  77485. */
  77486. static readonly IsDifferent: number;
  77487. /**
  77488. * Returns the number for IsGreater
  77489. */
  77490. static readonly IsGreater: number;
  77491. /**
  77492. * Returns the number for IsLesser
  77493. */
  77494. static readonly IsLesser: number;
  77495. /**
  77496. * Internal only The action manager for the condition
  77497. * @hidden
  77498. */
  77499. _actionManager: ActionManager;
  77500. /**
  77501. * Internal only
  77502. * @hidden
  77503. */
  77504. private _target;
  77505. /**
  77506. * Internal only
  77507. * @hidden
  77508. */
  77509. private _effectiveTarget;
  77510. /**
  77511. * Internal only
  77512. * @hidden
  77513. */
  77514. private _property;
  77515. /**
  77516. * Creates a new ValueCondition
  77517. * @param actionManager manager for the action the condition applies to
  77518. * @param target for the action
  77519. * @param propertyPath path to specify the property of the target the conditional operator uses
  77520. * @param value the value compared by the conditional operator against the current value of the property
  77521. * @param operator the conditional operator, default ValueCondition.IsEqual
  77522. */
  77523. constructor(actionManager: ActionManager, target: any,
  77524. /** path to specify the property of the target the conditional operator uses */
  77525. propertyPath: string,
  77526. /** the value compared by the conditional operator against the current value of the property */
  77527. value: any,
  77528. /** the conditional operator, default ValueCondition.IsEqual */
  77529. operator?: number);
  77530. /**
  77531. * Compares the given value with the property value for the specified conditional operator
  77532. * @returns the result of the comparison
  77533. */
  77534. isValid(): boolean;
  77535. /**
  77536. * Serialize the ValueCondition into a JSON compatible object
  77537. * @returns serialization object
  77538. */
  77539. serialize(): any;
  77540. /**
  77541. * Gets the name of the conditional operator for the ValueCondition
  77542. * @param operator the conditional operator
  77543. * @returns the name
  77544. */
  77545. static GetOperatorName(operator: number): string;
  77546. }
  77547. /**
  77548. * Defines a predicate condition as an extension of Condition
  77549. */
  77550. export class PredicateCondition extends Condition {
  77551. /** defines the predicate function used to validate the condition */
  77552. predicate: () => boolean;
  77553. /**
  77554. * Internal only - manager for action
  77555. * @hidden
  77556. */
  77557. _actionManager: ActionManager;
  77558. /**
  77559. * Creates a new PredicateCondition
  77560. * @param actionManager manager for the action the condition applies to
  77561. * @param predicate defines the predicate function used to validate the condition
  77562. */
  77563. constructor(actionManager: ActionManager,
  77564. /** defines the predicate function used to validate the condition */
  77565. predicate: () => boolean);
  77566. /**
  77567. * @returns the validity of the predicate condition
  77568. */
  77569. isValid(): boolean;
  77570. }
  77571. /**
  77572. * Defines a state condition as an extension of Condition
  77573. */
  77574. export class StateCondition extends Condition {
  77575. /** Value to compare with target state */
  77576. value: string;
  77577. /**
  77578. * Internal only - manager for action
  77579. * @hidden
  77580. */
  77581. _actionManager: ActionManager;
  77582. /**
  77583. * Internal only
  77584. * @hidden
  77585. */
  77586. private _target;
  77587. /**
  77588. * Creates a new StateCondition
  77589. * @param actionManager manager for the action the condition applies to
  77590. * @param target of the condition
  77591. * @param value to compare with target state
  77592. */
  77593. constructor(actionManager: ActionManager, target: any,
  77594. /** Value to compare with target state */
  77595. value: string);
  77596. /**
  77597. * Gets a boolean indicating if the current condition is met
  77598. * @returns the validity of the state
  77599. */
  77600. isValid(): boolean;
  77601. /**
  77602. * Serialize the StateCondition into a JSON compatible object
  77603. * @returns serialization object
  77604. */
  77605. serialize(): any;
  77606. }
  77607. }
  77608. declare module BABYLON {
  77609. /**
  77610. * This defines an action responsible to toggle a boolean once triggered.
  77611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77612. */
  77613. export class SwitchBooleanAction extends Action {
  77614. /**
  77615. * The path to the boolean property in the target object
  77616. */
  77617. propertyPath: string;
  77618. private _target;
  77619. private _effectiveTarget;
  77620. private _property;
  77621. /**
  77622. * Instantiate the action
  77623. * @param triggerOptions defines the trigger options
  77624. * @param target defines the object containing the boolean
  77625. * @param propertyPath defines the path to the boolean property in the target object
  77626. * @param condition defines the trigger related conditions
  77627. */
  77628. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77629. /** @hidden */
  77630. _prepare(): void;
  77631. /**
  77632. * Execute the action toggle the boolean value.
  77633. */
  77634. execute(): void;
  77635. /**
  77636. * Serializes the actions and its related information.
  77637. * @param parent defines the object to serialize in
  77638. * @returns the serialized object
  77639. */
  77640. serialize(parent: any): any;
  77641. }
  77642. /**
  77643. * This defines an action responsible to set a the state field of the target
  77644. * to a desired value once triggered.
  77645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77646. */
  77647. export class SetStateAction extends Action {
  77648. /**
  77649. * The value to store in the state field.
  77650. */
  77651. value: string;
  77652. private _target;
  77653. /**
  77654. * Instantiate the action
  77655. * @param triggerOptions defines the trigger options
  77656. * @param target defines the object containing the state property
  77657. * @param value defines the value to store in the state field
  77658. * @param condition defines the trigger related conditions
  77659. */
  77660. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77661. /**
  77662. * Execute the action and store the value on the target state property.
  77663. */
  77664. execute(): void;
  77665. /**
  77666. * Serializes the actions and its related information.
  77667. * @param parent defines the object to serialize in
  77668. * @returns the serialized object
  77669. */
  77670. serialize(parent: any): any;
  77671. }
  77672. /**
  77673. * This defines an action responsible to set a property of the target
  77674. * to a desired value once triggered.
  77675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77676. */
  77677. export class SetValueAction extends Action {
  77678. /**
  77679. * The path of the property to set in the target.
  77680. */
  77681. propertyPath: string;
  77682. /**
  77683. * The value to set in the property
  77684. */
  77685. value: any;
  77686. private _target;
  77687. private _effectiveTarget;
  77688. private _property;
  77689. /**
  77690. * Instantiate the action
  77691. * @param triggerOptions defines the trigger options
  77692. * @param target defines the object containing the property
  77693. * @param propertyPath defines the path of the property to set in the target
  77694. * @param value defines the value to set in the property
  77695. * @param condition defines the trigger related conditions
  77696. */
  77697. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77698. /** @hidden */
  77699. _prepare(): void;
  77700. /**
  77701. * Execute the action and set the targetted property to the desired value.
  77702. */
  77703. execute(): void;
  77704. /**
  77705. * Serializes the actions and its related information.
  77706. * @param parent defines the object to serialize in
  77707. * @returns the serialized object
  77708. */
  77709. serialize(parent: any): any;
  77710. }
  77711. /**
  77712. * This defines an action responsible to increment the target value
  77713. * to a desired value once triggered.
  77714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77715. */
  77716. export class IncrementValueAction extends Action {
  77717. /**
  77718. * The path of the property to increment in the target.
  77719. */
  77720. propertyPath: string;
  77721. /**
  77722. * The value we should increment the property by.
  77723. */
  77724. value: any;
  77725. private _target;
  77726. private _effectiveTarget;
  77727. private _property;
  77728. /**
  77729. * Instantiate the action
  77730. * @param triggerOptions defines the trigger options
  77731. * @param target defines the object containing the property
  77732. * @param propertyPath defines the path of the property to increment in the target
  77733. * @param value defines the value value we should increment the property by
  77734. * @param condition defines the trigger related conditions
  77735. */
  77736. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77737. /** @hidden */
  77738. _prepare(): void;
  77739. /**
  77740. * Execute the action and increment the target of the value amount.
  77741. */
  77742. execute(): void;
  77743. /**
  77744. * Serializes the actions and its related information.
  77745. * @param parent defines the object to serialize in
  77746. * @returns the serialized object
  77747. */
  77748. serialize(parent: any): any;
  77749. }
  77750. /**
  77751. * This defines an action responsible to start an animation once triggered.
  77752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77753. */
  77754. export class PlayAnimationAction extends Action {
  77755. /**
  77756. * Where the animation should start (animation frame)
  77757. */
  77758. from: number;
  77759. /**
  77760. * Where the animation should stop (animation frame)
  77761. */
  77762. to: number;
  77763. /**
  77764. * Define if the animation should loop or stop after the first play.
  77765. */
  77766. loop?: boolean;
  77767. private _target;
  77768. /**
  77769. * Instantiate the action
  77770. * @param triggerOptions defines the trigger options
  77771. * @param target defines the target animation or animation name
  77772. * @param from defines from where the animation should start (animation frame)
  77773. * @param end defines where the animation should stop (animation frame)
  77774. * @param loop defines if the animation should loop or stop after the first play
  77775. * @param condition defines the trigger related conditions
  77776. */
  77777. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77778. /** @hidden */
  77779. _prepare(): void;
  77780. /**
  77781. * Execute the action and play the animation.
  77782. */
  77783. execute(): void;
  77784. /**
  77785. * Serializes the actions and its related information.
  77786. * @param parent defines the object to serialize in
  77787. * @returns the serialized object
  77788. */
  77789. serialize(parent: any): any;
  77790. }
  77791. /**
  77792. * This defines an action responsible to stop an animation once triggered.
  77793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77794. */
  77795. export class StopAnimationAction extends Action {
  77796. private _target;
  77797. /**
  77798. * Instantiate the action
  77799. * @param triggerOptions defines the trigger options
  77800. * @param target defines the target animation or animation name
  77801. * @param condition defines the trigger related conditions
  77802. */
  77803. constructor(triggerOptions: any, target: any, condition?: Condition);
  77804. /** @hidden */
  77805. _prepare(): void;
  77806. /**
  77807. * Execute the action and stop the animation.
  77808. */
  77809. execute(): void;
  77810. /**
  77811. * Serializes the actions and its related information.
  77812. * @param parent defines the object to serialize in
  77813. * @returns the serialized object
  77814. */
  77815. serialize(parent: any): any;
  77816. }
  77817. /**
  77818. * This defines an action responsible that does nothing once triggered.
  77819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77820. */
  77821. export class DoNothingAction extends Action {
  77822. /**
  77823. * Instantiate the action
  77824. * @param triggerOptions defines the trigger options
  77825. * @param condition defines the trigger related conditions
  77826. */
  77827. constructor(triggerOptions?: any, condition?: Condition);
  77828. /**
  77829. * Execute the action and do nothing.
  77830. */
  77831. execute(): void;
  77832. /**
  77833. * Serializes the actions and its related information.
  77834. * @param parent defines the object to serialize in
  77835. * @returns the serialized object
  77836. */
  77837. serialize(parent: any): any;
  77838. }
  77839. /**
  77840. * This defines an action responsible to trigger several actions once triggered.
  77841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77842. */
  77843. export class CombineAction extends Action {
  77844. /**
  77845. * The list of aggregated animations to run.
  77846. */
  77847. children: Action[];
  77848. /**
  77849. * Instantiate the action
  77850. * @param triggerOptions defines the trigger options
  77851. * @param children defines the list of aggregated animations to run
  77852. * @param condition defines the trigger related conditions
  77853. */
  77854. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77855. /** @hidden */
  77856. _prepare(): void;
  77857. /**
  77858. * Execute the action and executes all the aggregated actions.
  77859. */
  77860. execute(evt: ActionEvent): void;
  77861. /**
  77862. * Serializes the actions and its related information.
  77863. * @param parent defines the object to serialize in
  77864. * @returns the serialized object
  77865. */
  77866. serialize(parent: any): any;
  77867. }
  77868. /**
  77869. * This defines an action responsible to run code (external event) once triggered.
  77870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77871. */
  77872. export class ExecuteCodeAction extends Action {
  77873. /**
  77874. * The callback function to run.
  77875. */
  77876. func: (evt: ActionEvent) => void;
  77877. /**
  77878. * Instantiate the action
  77879. * @param triggerOptions defines the trigger options
  77880. * @param func defines the callback function to run
  77881. * @param condition defines the trigger related conditions
  77882. */
  77883. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77884. /**
  77885. * Execute the action and run the attached code.
  77886. */
  77887. execute(evt: ActionEvent): void;
  77888. }
  77889. /**
  77890. * This defines an action responsible to set the parent property of the target once triggered.
  77891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77892. */
  77893. export class SetParentAction extends Action {
  77894. private _parent;
  77895. private _target;
  77896. /**
  77897. * Instantiate the action
  77898. * @param triggerOptions defines the trigger options
  77899. * @param target defines the target containing the parent property
  77900. * @param parent defines from where the animation should start (animation frame)
  77901. * @param condition defines the trigger related conditions
  77902. */
  77903. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77904. /** @hidden */
  77905. _prepare(): void;
  77906. /**
  77907. * Execute the action and set the parent property.
  77908. */
  77909. execute(): void;
  77910. /**
  77911. * Serializes the actions and its related information.
  77912. * @param parent defines the object to serialize in
  77913. * @returns the serialized object
  77914. */
  77915. serialize(parent: any): any;
  77916. }
  77917. }
  77918. declare module BABYLON {
  77919. /**
  77920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77923. */
  77924. export class ActionManager extends AbstractActionManager {
  77925. /**
  77926. * Nothing
  77927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77928. */
  77929. static readonly NothingTrigger: number;
  77930. /**
  77931. * On pick
  77932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77933. */
  77934. static readonly OnPickTrigger: number;
  77935. /**
  77936. * On left pick
  77937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77938. */
  77939. static readonly OnLeftPickTrigger: number;
  77940. /**
  77941. * On right pick
  77942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77943. */
  77944. static readonly OnRightPickTrigger: number;
  77945. /**
  77946. * On center pick
  77947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77948. */
  77949. static readonly OnCenterPickTrigger: number;
  77950. /**
  77951. * On pick down
  77952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77953. */
  77954. static readonly OnPickDownTrigger: number;
  77955. /**
  77956. * On double pick
  77957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77958. */
  77959. static readonly OnDoublePickTrigger: number;
  77960. /**
  77961. * On pick up
  77962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77963. */
  77964. static readonly OnPickUpTrigger: number;
  77965. /**
  77966. * On pick out.
  77967. * This trigger will only be raised if you also declared a OnPickDown
  77968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77969. */
  77970. static readonly OnPickOutTrigger: number;
  77971. /**
  77972. * On long press
  77973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77974. */
  77975. static readonly OnLongPressTrigger: number;
  77976. /**
  77977. * On pointer over
  77978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77979. */
  77980. static readonly OnPointerOverTrigger: number;
  77981. /**
  77982. * On pointer out
  77983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77984. */
  77985. static readonly OnPointerOutTrigger: number;
  77986. /**
  77987. * On every frame
  77988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77989. */
  77990. static readonly OnEveryFrameTrigger: number;
  77991. /**
  77992. * On intersection enter
  77993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77994. */
  77995. static readonly OnIntersectionEnterTrigger: number;
  77996. /**
  77997. * On intersection exit
  77998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77999. */
  78000. static readonly OnIntersectionExitTrigger: number;
  78001. /**
  78002. * On key down
  78003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78004. */
  78005. static readonly OnKeyDownTrigger: number;
  78006. /**
  78007. * On key up
  78008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78009. */
  78010. static readonly OnKeyUpTrigger: number;
  78011. private _scene;
  78012. /**
  78013. * Creates a new action manager
  78014. * @param scene defines the hosting scene
  78015. */
  78016. constructor(scene: Scene);
  78017. /**
  78018. * Releases all associated resources
  78019. */
  78020. dispose(): void;
  78021. /**
  78022. * Gets hosting scene
  78023. * @returns the hosting scene
  78024. */
  78025. getScene(): Scene;
  78026. /**
  78027. * Does this action manager handles actions of any of the given triggers
  78028. * @param triggers defines the triggers to be tested
  78029. * @return a boolean indicating whether one (or more) of the triggers is handled
  78030. */
  78031. hasSpecificTriggers(triggers: number[]): boolean;
  78032. /**
  78033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78034. * speed.
  78035. * @param triggerA defines the trigger to be tested
  78036. * @param triggerB defines the trigger to be tested
  78037. * @return a boolean indicating whether one (or more) of the triggers is handled
  78038. */
  78039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78040. /**
  78041. * Does this action manager handles actions of a given trigger
  78042. * @param trigger defines the trigger to be tested
  78043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78044. * @return whether the trigger is handled
  78045. */
  78046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78047. /**
  78048. * Does this action manager has pointer triggers
  78049. */
  78050. readonly hasPointerTriggers: boolean;
  78051. /**
  78052. * Does this action manager has pick triggers
  78053. */
  78054. readonly hasPickTriggers: boolean;
  78055. /**
  78056. * Registers an action to this action manager
  78057. * @param action defines the action to be registered
  78058. * @return the action amended (prepared) after registration
  78059. */
  78060. registerAction(action: IAction): Nullable<IAction>;
  78061. /**
  78062. * Unregisters an action to this action manager
  78063. * @param action defines the action to be unregistered
  78064. * @return a boolean indicating whether the action has been unregistered
  78065. */
  78066. unregisterAction(action: IAction): Boolean;
  78067. /**
  78068. * Process a specific trigger
  78069. * @param trigger defines the trigger to process
  78070. * @param evt defines the event details to be processed
  78071. */
  78072. processTrigger(trigger: number, evt?: IActionEvent): void;
  78073. /** @hidden */
  78074. _getEffectiveTarget(target: any, propertyPath: string): any;
  78075. /** @hidden */
  78076. _getProperty(propertyPath: string): string;
  78077. /**
  78078. * Serialize this manager to a JSON object
  78079. * @param name defines the property name to store this manager
  78080. * @returns a JSON representation of this manager
  78081. */
  78082. serialize(name: string): any;
  78083. /**
  78084. * Creates a new ActionManager from a JSON data
  78085. * @param parsedActions defines the JSON data to read from
  78086. * @param object defines the hosting mesh
  78087. * @param scene defines the hosting scene
  78088. */
  78089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78090. /**
  78091. * Get a trigger name by index
  78092. * @param trigger defines the trigger index
  78093. * @returns a trigger name
  78094. */
  78095. static GetTriggerName(trigger: number): string;
  78096. }
  78097. }
  78098. declare module BABYLON {
  78099. /**
  78100. * Class representing a ray with position and direction
  78101. */
  78102. export class Ray {
  78103. /** origin point */
  78104. origin: Vector3;
  78105. /** direction */
  78106. direction: Vector3;
  78107. /** length of the ray */
  78108. length: number;
  78109. private static readonly TmpVector3;
  78110. private _tmpRay;
  78111. /**
  78112. * Creates a new ray
  78113. * @param origin origin point
  78114. * @param direction direction
  78115. * @param length length of the ray
  78116. */
  78117. constructor(
  78118. /** origin point */
  78119. origin: Vector3,
  78120. /** direction */
  78121. direction: Vector3,
  78122. /** length of the ray */
  78123. length?: number);
  78124. /**
  78125. * Checks if the ray intersects a box
  78126. * @param minimum bound of the box
  78127. * @param maximum bound of the box
  78128. * @param intersectionTreshold extra extend to be added to the box in all direction
  78129. * @returns if the box was hit
  78130. */
  78131. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78132. /**
  78133. * Checks if the ray intersects a box
  78134. * @param box the bounding box to check
  78135. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78136. * @returns if the box was hit
  78137. */
  78138. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78139. /**
  78140. * If the ray hits a sphere
  78141. * @param sphere the bounding sphere to check
  78142. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78143. * @returns true if it hits the sphere
  78144. */
  78145. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78146. /**
  78147. * If the ray hits a triange
  78148. * @param vertex0 triangle vertex
  78149. * @param vertex1 triangle vertex
  78150. * @param vertex2 triangle vertex
  78151. * @returns intersection information if hit
  78152. */
  78153. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78154. /**
  78155. * Checks if ray intersects a plane
  78156. * @param plane the plane to check
  78157. * @returns the distance away it was hit
  78158. */
  78159. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78160. /**
  78161. * Calculate the intercept of a ray on a given axis
  78162. * @param axis to check 'x' | 'y' | 'z'
  78163. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78164. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78165. */
  78166. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78167. /**
  78168. * Checks if ray intersects a mesh
  78169. * @param mesh the mesh to check
  78170. * @param fastCheck if only the bounding box should checked
  78171. * @returns picking info of the intersecton
  78172. */
  78173. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78174. /**
  78175. * Checks if ray intersects a mesh
  78176. * @param meshes the meshes to check
  78177. * @param fastCheck if only the bounding box should checked
  78178. * @param results array to store result in
  78179. * @returns Array of picking infos
  78180. */
  78181. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78182. private _comparePickingInfo;
  78183. private static smallnum;
  78184. private static rayl;
  78185. /**
  78186. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78187. * @param sega the first point of the segment to test the intersection against
  78188. * @param segb the second point of the segment to test the intersection against
  78189. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78190. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78191. */
  78192. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78193. /**
  78194. * Update the ray from viewport position
  78195. * @param x position
  78196. * @param y y position
  78197. * @param viewportWidth viewport width
  78198. * @param viewportHeight viewport height
  78199. * @param world world matrix
  78200. * @param view view matrix
  78201. * @param projection projection matrix
  78202. * @returns this ray updated
  78203. */
  78204. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78205. /**
  78206. * Creates a ray with origin and direction of 0,0,0
  78207. * @returns the new ray
  78208. */
  78209. static Zero(): Ray;
  78210. /**
  78211. * Creates a new ray from screen space and viewport
  78212. * @param x position
  78213. * @param y y position
  78214. * @param viewportWidth viewport width
  78215. * @param viewportHeight viewport height
  78216. * @param world world matrix
  78217. * @param view view matrix
  78218. * @param projection projection matrix
  78219. * @returns new ray
  78220. */
  78221. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78222. /**
  78223. * 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
  78224. * transformed to the given world matrix.
  78225. * @param origin The origin point
  78226. * @param end The end point
  78227. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78228. * @returns the new ray
  78229. */
  78230. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78231. /**
  78232. * Transforms a ray by a matrix
  78233. * @param ray ray to transform
  78234. * @param matrix matrix to apply
  78235. * @returns the resulting new ray
  78236. */
  78237. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78238. /**
  78239. * Transforms a ray by a matrix
  78240. * @param ray ray to transform
  78241. * @param matrix matrix to apply
  78242. * @param result ray to store result in
  78243. */
  78244. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78245. /**
  78246. * Unproject a ray from screen space to object space
  78247. * @param sourceX defines the screen space x coordinate to use
  78248. * @param sourceY defines the screen space y coordinate to use
  78249. * @param viewportWidth defines the current width of the viewport
  78250. * @param viewportHeight defines the current height of the viewport
  78251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78252. * @param view defines the view matrix to use
  78253. * @param projection defines the projection matrix to use
  78254. */
  78255. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78256. }
  78257. /**
  78258. * Type used to define predicate used to select faces when a mesh intersection is detected
  78259. */
  78260. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78261. interface Scene {
  78262. /** @hidden */
  78263. _tempPickingRay: Nullable<Ray>;
  78264. /** @hidden */
  78265. _cachedRayForTransform: Ray;
  78266. /** @hidden */
  78267. _pickWithRayInverseMatrix: Matrix;
  78268. /** @hidden */
  78269. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78270. /** @hidden */
  78271. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78272. }
  78273. }
  78274. declare module BABYLON {
  78275. /**
  78276. * Groups all the scene component constants in one place to ease maintenance.
  78277. * @hidden
  78278. */
  78279. export class SceneComponentConstants {
  78280. static readonly NAME_EFFECTLAYER: string;
  78281. static readonly NAME_LAYER: string;
  78282. static readonly NAME_LENSFLARESYSTEM: string;
  78283. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78284. static readonly NAME_PARTICLESYSTEM: string;
  78285. static readonly NAME_GAMEPAD: string;
  78286. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78287. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78288. static readonly NAME_DEPTHRENDERER: string;
  78289. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78290. static readonly NAME_SPRITE: string;
  78291. static readonly NAME_OUTLINERENDERER: string;
  78292. static readonly NAME_PROCEDURALTEXTURE: string;
  78293. static readonly NAME_SHADOWGENERATOR: string;
  78294. static readonly NAME_OCTREE: string;
  78295. static readonly NAME_PHYSICSENGINE: string;
  78296. static readonly NAME_AUDIO: string;
  78297. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78298. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78299. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78300. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78301. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78302. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78303. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78304. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78305. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78306. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78307. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78308. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78309. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78310. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78311. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78312. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78313. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78314. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78315. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78316. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78317. static readonly STEP_AFTERRENDER_AUDIO: number;
  78318. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78319. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78320. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78321. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78322. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78323. static readonly STEP_POINTERMOVE_SPRITE: number;
  78324. static readonly STEP_POINTERDOWN_SPRITE: number;
  78325. static readonly STEP_POINTERUP_SPRITE: number;
  78326. }
  78327. /**
  78328. * This represents a scene component.
  78329. *
  78330. * This is used to decouple the dependency the scene is having on the different workloads like
  78331. * layers, post processes...
  78332. */
  78333. export interface ISceneComponent {
  78334. /**
  78335. * The name of the component. Each component must have a unique name.
  78336. */
  78337. name: string;
  78338. /**
  78339. * The scene the component belongs to.
  78340. */
  78341. scene: Scene;
  78342. /**
  78343. * Register the component to one instance of a scene.
  78344. */
  78345. register(): void;
  78346. /**
  78347. * Rebuilds the elements related to this component in case of
  78348. * context lost for instance.
  78349. */
  78350. rebuild(): void;
  78351. /**
  78352. * Disposes the component and the associated ressources.
  78353. */
  78354. dispose(): void;
  78355. }
  78356. /**
  78357. * This represents a SERIALIZABLE scene component.
  78358. *
  78359. * This extends Scene Component to add Serialization methods on top.
  78360. */
  78361. export interface ISceneSerializableComponent extends ISceneComponent {
  78362. /**
  78363. * Adds all the elements from the container to the scene
  78364. * @param container the container holding the elements
  78365. */
  78366. addFromContainer(container: AbstractScene): void;
  78367. /**
  78368. * Removes all the elements in the container from the scene
  78369. * @param container contains the elements to remove
  78370. * @param dispose if the removed element should be disposed (default: false)
  78371. */
  78372. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78373. /**
  78374. * Serializes the component data to the specified json object
  78375. * @param serializationObject The object to serialize to
  78376. */
  78377. serialize(serializationObject: any): void;
  78378. }
  78379. /**
  78380. * Strong typing of a Mesh related stage step action
  78381. */
  78382. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78383. /**
  78384. * Strong typing of a Evaluate Sub Mesh related stage step action
  78385. */
  78386. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78387. /**
  78388. * Strong typing of a Active Mesh related stage step action
  78389. */
  78390. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78391. /**
  78392. * Strong typing of a Camera related stage step action
  78393. */
  78394. export type CameraStageAction = (camera: Camera) => void;
  78395. /**
  78396. * Strong typing of a Camera Frame buffer related stage step action
  78397. */
  78398. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78399. /**
  78400. * Strong typing of a Render Target related stage step action
  78401. */
  78402. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78403. /**
  78404. * Strong typing of a RenderingGroup related stage step action
  78405. */
  78406. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78407. /**
  78408. * Strong typing of a Mesh Render related stage step action
  78409. */
  78410. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78411. /**
  78412. * Strong typing of a simple stage step action
  78413. */
  78414. export type SimpleStageAction = () => void;
  78415. /**
  78416. * Strong typing of a render target action.
  78417. */
  78418. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78419. /**
  78420. * Strong typing of a pointer move action.
  78421. */
  78422. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78423. /**
  78424. * Strong typing of a pointer up/down action.
  78425. */
  78426. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78427. /**
  78428. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78429. * @hidden
  78430. */
  78431. export class Stage<T extends Function> extends Array<{
  78432. index: number;
  78433. component: ISceneComponent;
  78434. action: T;
  78435. }> {
  78436. /**
  78437. * Hide ctor from the rest of the world.
  78438. * @param items The items to add.
  78439. */
  78440. private constructor();
  78441. /**
  78442. * Creates a new Stage.
  78443. * @returns A new instance of a Stage
  78444. */
  78445. static Create<T extends Function>(): Stage<T>;
  78446. /**
  78447. * Registers a step in an ordered way in the targeted stage.
  78448. * @param index Defines the position to register the step in
  78449. * @param component Defines the component attached to the step
  78450. * @param action Defines the action to launch during the step
  78451. */
  78452. registerStep(index: number, component: ISceneComponent, action: T): void;
  78453. /**
  78454. * Clears all the steps from the stage.
  78455. */
  78456. clear(): void;
  78457. }
  78458. }
  78459. declare module BABYLON {
  78460. interface Scene {
  78461. /** @hidden */
  78462. _pointerOverSprite: Nullable<Sprite>;
  78463. /** @hidden */
  78464. _pickedDownSprite: Nullable<Sprite>;
  78465. /** @hidden */
  78466. _tempSpritePickingRay: Nullable<Ray>;
  78467. /**
  78468. * All of the sprite managers added to this scene
  78469. * @see http://doc.babylonjs.com/babylon101/sprites
  78470. */
  78471. spriteManagers: Array<ISpriteManager>;
  78472. /**
  78473. * An event triggered when sprites rendering is about to start
  78474. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78475. */
  78476. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78477. /**
  78478. * An event triggered when sprites rendering is done
  78479. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78480. */
  78481. onAfterSpritesRenderingObservable: Observable<Scene>;
  78482. /** @hidden */
  78483. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78484. /** Launch a ray to try to pick a sprite in the scene
  78485. * @param x position on screen
  78486. * @param y position on screen
  78487. * @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
  78488. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78489. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78490. * @returns a PickingInfo
  78491. */
  78492. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78493. /** Use the given ray to pick a sprite in the scene
  78494. * @param ray The ray (in world space) to use to pick meshes
  78495. * @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
  78496. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78497. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78498. * @returns a PickingInfo
  78499. */
  78500. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78501. /** @hidden */
  78502. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78503. /** Launch a ray to try to pick sprites in the scene
  78504. * @param x position on screen
  78505. * @param y position on screen
  78506. * @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
  78507. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78508. * @returns a PickingInfo array
  78509. */
  78510. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78511. /** Use the given ray to pick sprites in the scene
  78512. * @param ray The ray (in world space) to use to pick meshes
  78513. * @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
  78514. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78515. * @returns a PickingInfo array
  78516. */
  78517. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78518. /**
  78519. * Force the sprite under the pointer
  78520. * @param sprite defines the sprite to use
  78521. */
  78522. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78523. /**
  78524. * Gets the sprite under the pointer
  78525. * @returns a Sprite or null if no sprite is under the pointer
  78526. */
  78527. getPointerOverSprite(): Nullable<Sprite>;
  78528. }
  78529. /**
  78530. * Defines the sprite scene component responsible to manage sprites
  78531. * in a given scene.
  78532. */
  78533. export class SpriteSceneComponent implements ISceneComponent {
  78534. /**
  78535. * The component name helpfull to identify the component in the list of scene components.
  78536. */
  78537. readonly name: string;
  78538. /**
  78539. * The scene the component belongs to.
  78540. */
  78541. scene: Scene;
  78542. /** @hidden */
  78543. private _spritePredicate;
  78544. /**
  78545. * Creates a new instance of the component for the given scene
  78546. * @param scene Defines the scene to register the component in
  78547. */
  78548. constructor(scene: Scene);
  78549. /**
  78550. * Registers the component in a given scene
  78551. */
  78552. register(): void;
  78553. /**
  78554. * Rebuilds the elements related to this component in case of
  78555. * context lost for instance.
  78556. */
  78557. rebuild(): void;
  78558. /**
  78559. * Disposes the component and the associated ressources.
  78560. */
  78561. dispose(): void;
  78562. private _pickSpriteButKeepRay;
  78563. private _pointerMove;
  78564. private _pointerDown;
  78565. private _pointerUp;
  78566. }
  78567. }
  78568. declare module BABYLON {
  78569. /** @hidden */
  78570. export var fogFragmentDeclaration: {
  78571. name: string;
  78572. shader: string;
  78573. };
  78574. }
  78575. declare module BABYLON {
  78576. /** @hidden */
  78577. export var fogFragment: {
  78578. name: string;
  78579. shader: string;
  78580. };
  78581. }
  78582. declare module BABYLON {
  78583. /** @hidden */
  78584. export var spritesPixelShader: {
  78585. name: string;
  78586. shader: string;
  78587. };
  78588. }
  78589. declare module BABYLON {
  78590. /** @hidden */
  78591. export var fogVertexDeclaration: {
  78592. name: string;
  78593. shader: string;
  78594. };
  78595. }
  78596. declare module BABYLON {
  78597. /** @hidden */
  78598. export var spritesVertexShader: {
  78599. name: string;
  78600. shader: string;
  78601. };
  78602. }
  78603. declare module BABYLON {
  78604. /**
  78605. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78606. */
  78607. export interface ISpriteManager extends IDisposable {
  78608. /**
  78609. * Restricts the camera to viewing objects with the same layerMask.
  78610. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78611. */
  78612. layerMask: number;
  78613. /**
  78614. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78615. */
  78616. isPickable: boolean;
  78617. /**
  78618. * Specifies the rendering group id for this mesh (0 by default)
  78619. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78620. */
  78621. renderingGroupId: number;
  78622. /**
  78623. * Defines the list of sprites managed by the manager.
  78624. */
  78625. sprites: Array<Sprite>;
  78626. /**
  78627. * Tests the intersection of a sprite with a specific ray.
  78628. * @param ray The ray we are sending to test the collision
  78629. * @param camera The camera space we are sending rays in
  78630. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78631. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78632. * @returns picking info or null.
  78633. */
  78634. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78635. /**
  78636. * Intersects the sprites with a ray
  78637. * @param ray defines the ray to intersect with
  78638. * @param camera defines the current active camera
  78639. * @param predicate defines a predicate used to select candidate sprites
  78640. * @returns null if no hit or a PickingInfo array
  78641. */
  78642. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78643. /**
  78644. * Renders the list of sprites on screen.
  78645. */
  78646. render(): void;
  78647. }
  78648. /**
  78649. * Class used to manage multiple sprites on the same spritesheet
  78650. * @see http://doc.babylonjs.com/babylon101/sprites
  78651. */
  78652. export class SpriteManager implements ISpriteManager {
  78653. /** defines the manager's name */
  78654. name: string;
  78655. /** Gets the list of sprites */
  78656. sprites: Sprite[];
  78657. /** Gets or sets the rendering group id (0 by default) */
  78658. renderingGroupId: number;
  78659. /** Gets or sets camera layer mask */
  78660. layerMask: number;
  78661. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78662. fogEnabled: boolean;
  78663. /** Gets or sets a boolean indicating if the sprites are pickable */
  78664. isPickable: boolean;
  78665. /** Defines the default width of a cell in the spritesheet */
  78666. cellWidth: number;
  78667. /** Defines the default height of a cell in the spritesheet */
  78668. cellHeight: number;
  78669. /** Associative array from JSON sprite data file */
  78670. private _cellData;
  78671. /** Array of sprite names from JSON sprite data file */
  78672. private _spriteMap;
  78673. /** True when packed cell data from JSON file is ready*/
  78674. private _packedAndReady;
  78675. /**
  78676. * An event triggered when the manager is disposed.
  78677. */
  78678. onDisposeObservable: Observable<SpriteManager>;
  78679. private _onDisposeObserver;
  78680. /**
  78681. * Callback called when the manager is disposed
  78682. */
  78683. onDispose: () => void;
  78684. private _capacity;
  78685. private _fromPacked;
  78686. private _spriteTexture;
  78687. private _epsilon;
  78688. private _scene;
  78689. private _vertexData;
  78690. private _buffer;
  78691. private _vertexBuffers;
  78692. private _indexBuffer;
  78693. private _effectBase;
  78694. private _effectFog;
  78695. /**
  78696. * Gets or sets the spritesheet texture
  78697. */
  78698. texture: Texture;
  78699. /**
  78700. * Creates a new sprite manager
  78701. * @param name defines the manager's name
  78702. * @param imgUrl defines the sprite sheet url
  78703. * @param capacity defines the maximum allowed number of sprites
  78704. * @param cellSize defines the size of a sprite cell
  78705. * @param scene defines the hosting scene
  78706. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78707. * @param samplingMode defines the smapling mode to use with spritesheet
  78708. * @param fromPacked set to false; do not alter
  78709. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78710. */
  78711. constructor(
  78712. /** defines the manager's name */
  78713. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78714. private _makePacked;
  78715. private _appendSpriteVertex;
  78716. /**
  78717. * Intersects the sprites with a ray
  78718. * @param ray defines the ray to intersect with
  78719. * @param camera defines the current active camera
  78720. * @param predicate defines a predicate used to select candidate sprites
  78721. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78722. * @returns null if no hit or a PickingInfo
  78723. */
  78724. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78725. /**
  78726. * Intersects the sprites with a ray
  78727. * @param ray defines the ray to intersect with
  78728. * @param camera defines the current active camera
  78729. * @param predicate defines a predicate used to select candidate sprites
  78730. * @returns null if no hit or a PickingInfo array
  78731. */
  78732. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78733. /**
  78734. * Render all child sprites
  78735. */
  78736. render(): void;
  78737. /**
  78738. * Release associated resources
  78739. */
  78740. dispose(): void;
  78741. }
  78742. }
  78743. declare module BABYLON {
  78744. /**
  78745. * Class used to represent a sprite
  78746. * @see http://doc.babylonjs.com/babylon101/sprites
  78747. */
  78748. export class Sprite {
  78749. /** defines the name */
  78750. name: string;
  78751. /** Gets or sets the current world position */
  78752. position: Vector3;
  78753. /** Gets or sets the main color */
  78754. color: Color4;
  78755. /** Gets or sets the width */
  78756. width: number;
  78757. /** Gets or sets the height */
  78758. height: number;
  78759. /** Gets or sets rotation angle */
  78760. angle: number;
  78761. /** Gets or sets the cell index in the sprite sheet */
  78762. cellIndex: number;
  78763. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78764. cellRef: string;
  78765. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78766. invertU: number;
  78767. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78768. invertV: number;
  78769. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78770. disposeWhenFinishedAnimating: boolean;
  78771. /** Gets the list of attached animations */
  78772. animations: Animation[];
  78773. /** Gets or sets a boolean indicating if the sprite can be picked */
  78774. isPickable: boolean;
  78775. /**
  78776. * Gets or sets the associated action manager
  78777. */
  78778. actionManager: Nullable<ActionManager>;
  78779. private _animationStarted;
  78780. private _loopAnimation;
  78781. private _fromIndex;
  78782. private _toIndex;
  78783. private _delay;
  78784. private _direction;
  78785. private _manager;
  78786. private _time;
  78787. private _onAnimationEnd;
  78788. /**
  78789. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78790. */
  78791. isVisible: boolean;
  78792. /**
  78793. * Gets or sets the sprite size
  78794. */
  78795. size: number;
  78796. /**
  78797. * Creates a new Sprite
  78798. * @param name defines the name
  78799. * @param manager defines the manager
  78800. */
  78801. constructor(
  78802. /** defines the name */
  78803. name: string, manager: ISpriteManager);
  78804. /**
  78805. * Starts an animation
  78806. * @param from defines the initial key
  78807. * @param to defines the end key
  78808. * @param loop defines if the animation must loop
  78809. * @param delay defines the start delay (in ms)
  78810. * @param onAnimationEnd defines a callback to call when animation ends
  78811. */
  78812. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78813. /** Stops current animation (if any) */
  78814. stopAnimation(): void;
  78815. /** @hidden */
  78816. _animate(deltaTime: number): void;
  78817. /** Release associated resources */
  78818. dispose(): void;
  78819. }
  78820. }
  78821. declare module BABYLON {
  78822. /**
  78823. * Information about the result of picking within a scene
  78824. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78825. */
  78826. export class PickingInfo {
  78827. /** @hidden */
  78828. _pickingUnavailable: boolean;
  78829. /**
  78830. * If the pick collided with an object
  78831. */
  78832. hit: boolean;
  78833. /**
  78834. * Distance away where the pick collided
  78835. */
  78836. distance: number;
  78837. /**
  78838. * The location of pick collision
  78839. */
  78840. pickedPoint: Nullable<Vector3>;
  78841. /**
  78842. * The mesh corresponding the the pick collision
  78843. */
  78844. pickedMesh: Nullable<AbstractMesh>;
  78845. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78846. bu: number;
  78847. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78848. bv: number;
  78849. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78850. faceId: number;
  78851. /** Id of the the submesh that was picked */
  78852. subMeshId: number;
  78853. /** If a sprite was picked, this will be the sprite the pick collided with */
  78854. pickedSprite: Nullable<Sprite>;
  78855. /**
  78856. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78857. */
  78858. originMesh: Nullable<AbstractMesh>;
  78859. /**
  78860. * The ray that was used to perform the picking.
  78861. */
  78862. ray: Nullable<Ray>;
  78863. /**
  78864. * Gets the normal correspodning to the face the pick collided with
  78865. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78866. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78867. * @returns The normal correspodning to the face the pick collided with
  78868. */
  78869. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78870. /**
  78871. * Gets the texture coordinates of where the pick occured
  78872. * @returns the vector containing the coordnates of the texture
  78873. */
  78874. getTextureCoordinates(): Nullable<Vector2>;
  78875. }
  78876. }
  78877. declare module BABYLON {
  78878. /**
  78879. * Gather the list of pointer event types as constants.
  78880. */
  78881. export class PointerEventTypes {
  78882. /**
  78883. * 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.
  78884. */
  78885. static readonly POINTERDOWN: number;
  78886. /**
  78887. * The pointerup event is fired when a pointer is no longer active.
  78888. */
  78889. static readonly POINTERUP: number;
  78890. /**
  78891. * The pointermove event is fired when a pointer changes coordinates.
  78892. */
  78893. static readonly POINTERMOVE: number;
  78894. /**
  78895. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78896. */
  78897. static readonly POINTERWHEEL: number;
  78898. /**
  78899. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78900. */
  78901. static readonly POINTERPICK: number;
  78902. /**
  78903. * The pointertap event is fired when a the object has been touched and released without drag.
  78904. */
  78905. static readonly POINTERTAP: number;
  78906. /**
  78907. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78908. */
  78909. static readonly POINTERDOUBLETAP: number;
  78910. }
  78911. /**
  78912. * Base class of pointer info types.
  78913. */
  78914. export class PointerInfoBase {
  78915. /**
  78916. * Defines the type of event (PointerEventTypes)
  78917. */
  78918. type: number;
  78919. /**
  78920. * Defines the related dom event
  78921. */
  78922. event: PointerEvent | MouseWheelEvent;
  78923. /**
  78924. * Instantiates the base class of pointers info.
  78925. * @param type Defines the type of event (PointerEventTypes)
  78926. * @param event Defines the related dom event
  78927. */
  78928. constructor(
  78929. /**
  78930. * Defines the type of event (PointerEventTypes)
  78931. */
  78932. type: number,
  78933. /**
  78934. * Defines the related dom event
  78935. */
  78936. event: PointerEvent | MouseWheelEvent);
  78937. }
  78938. /**
  78939. * This class is used to store pointer related info for the onPrePointerObservable event.
  78940. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78941. */
  78942. export class PointerInfoPre extends PointerInfoBase {
  78943. /**
  78944. * Ray from a pointer if availible (eg. 6dof controller)
  78945. */
  78946. ray: Nullable<Ray>;
  78947. /**
  78948. * Defines the local position of the pointer on the canvas.
  78949. */
  78950. localPosition: Vector2;
  78951. /**
  78952. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78953. */
  78954. skipOnPointerObservable: boolean;
  78955. /**
  78956. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78957. * @param type Defines the type of event (PointerEventTypes)
  78958. * @param event Defines the related dom event
  78959. * @param localX Defines the local x coordinates of the pointer when the event occured
  78960. * @param localY Defines the local y coordinates of the pointer when the event occured
  78961. */
  78962. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78963. }
  78964. /**
  78965. * This type contains all the data related to a pointer event in Babylon.js.
  78966. * 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.
  78967. */
  78968. export class PointerInfo extends PointerInfoBase {
  78969. /**
  78970. * Defines the picking info associated to the info (if any)\
  78971. */
  78972. pickInfo: Nullable<PickingInfo>;
  78973. /**
  78974. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78975. * @param type Defines the type of event (PointerEventTypes)
  78976. * @param event Defines the related dom event
  78977. * @param pickInfo Defines the picking info associated to the info (if any)\
  78978. */
  78979. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78980. /**
  78981. * Defines the picking info associated to the info (if any)\
  78982. */
  78983. pickInfo: Nullable<PickingInfo>);
  78984. }
  78985. /**
  78986. * Data relating to a touch event on the screen.
  78987. */
  78988. export interface PointerTouch {
  78989. /**
  78990. * X coordinate of touch.
  78991. */
  78992. x: number;
  78993. /**
  78994. * Y coordinate of touch.
  78995. */
  78996. y: number;
  78997. /**
  78998. * Id of touch. Unique for each finger.
  78999. */
  79000. pointerId: number;
  79001. /**
  79002. * Event type passed from DOM.
  79003. */
  79004. type: any;
  79005. }
  79006. }
  79007. declare module BABYLON {
  79008. /**
  79009. * Manage the mouse inputs to control the movement of a free camera.
  79010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79011. */
  79012. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79013. /**
  79014. * Define if touch is enabled in the mouse input
  79015. */
  79016. touchEnabled: boolean;
  79017. /**
  79018. * Defines the camera the input is attached to.
  79019. */
  79020. camera: FreeCamera;
  79021. /**
  79022. * Defines the buttons associated with the input to handle camera move.
  79023. */
  79024. buttons: number[];
  79025. /**
  79026. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79027. */
  79028. angularSensibility: number;
  79029. private _pointerInput;
  79030. private _onMouseMove;
  79031. private _observer;
  79032. private previousPosition;
  79033. /**
  79034. * Observable for when a pointer move event occurs containing the move offset
  79035. */
  79036. onPointerMovedObservable: Observable<{
  79037. offsetX: number;
  79038. offsetY: number;
  79039. }>;
  79040. /**
  79041. * @hidden
  79042. * If the camera should be rotated automatically based on pointer movement
  79043. */
  79044. _allowCameraRotation: boolean;
  79045. /**
  79046. * Manage the mouse inputs to control the movement of a free camera.
  79047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79048. * @param touchEnabled Defines if touch is enabled or not
  79049. */
  79050. constructor(
  79051. /**
  79052. * Define if touch is enabled in the mouse input
  79053. */
  79054. touchEnabled?: boolean);
  79055. /**
  79056. * Attach the input controls to a specific dom element to get the input from.
  79057. * @param element Defines the element the controls should be listened from
  79058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79059. */
  79060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79061. /**
  79062. * Called on JS contextmenu event.
  79063. * Override this method to provide functionality.
  79064. */
  79065. protected onContextMenu(evt: PointerEvent): void;
  79066. /**
  79067. * Detach the current controls from the specified dom element.
  79068. * @param element Defines the element to stop listening the inputs from
  79069. */
  79070. detachControl(element: Nullable<HTMLElement>): void;
  79071. /**
  79072. * Gets the class name of the current intput.
  79073. * @returns the class name
  79074. */
  79075. getClassName(): string;
  79076. /**
  79077. * Get the friendly name associated with the input class.
  79078. * @returns the input friendly name
  79079. */
  79080. getSimpleName(): string;
  79081. }
  79082. }
  79083. declare module BABYLON {
  79084. /**
  79085. * Manage the touch inputs to control the movement of a free camera.
  79086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79087. */
  79088. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79089. /**
  79090. * Defines the camera the input is attached to.
  79091. */
  79092. camera: FreeCamera;
  79093. /**
  79094. * Defines the touch sensibility for rotation.
  79095. * The higher the faster.
  79096. */
  79097. touchAngularSensibility: number;
  79098. /**
  79099. * Defines the touch sensibility for move.
  79100. * The higher the faster.
  79101. */
  79102. touchMoveSensibility: number;
  79103. private _offsetX;
  79104. private _offsetY;
  79105. private _pointerPressed;
  79106. private _pointerInput;
  79107. private _observer;
  79108. private _onLostFocus;
  79109. /**
  79110. * Attach the input controls to a specific dom element to get the input from.
  79111. * @param element Defines the element the controls should be listened from
  79112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79113. */
  79114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79115. /**
  79116. * Detach the current controls from the specified dom element.
  79117. * @param element Defines the element to stop listening the inputs from
  79118. */
  79119. detachControl(element: Nullable<HTMLElement>): void;
  79120. /**
  79121. * Update the current camera state depending on the inputs that have been used this frame.
  79122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79123. */
  79124. checkInputs(): void;
  79125. /**
  79126. * Gets the class name of the current intput.
  79127. * @returns the class name
  79128. */
  79129. getClassName(): string;
  79130. /**
  79131. * Get the friendly name associated with the input class.
  79132. * @returns the input friendly name
  79133. */
  79134. getSimpleName(): string;
  79135. }
  79136. }
  79137. declare module BABYLON {
  79138. /**
  79139. * Default Inputs manager for the FreeCamera.
  79140. * It groups all the default supported inputs for ease of use.
  79141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79142. */
  79143. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79144. /**
  79145. * @hidden
  79146. */
  79147. _mouseInput: Nullable<FreeCameraMouseInput>;
  79148. /**
  79149. * Instantiates a new FreeCameraInputsManager.
  79150. * @param camera Defines the camera the inputs belong to
  79151. */
  79152. constructor(camera: FreeCamera);
  79153. /**
  79154. * Add keyboard input support to the input manager.
  79155. * @returns the current input manager
  79156. */
  79157. addKeyboard(): FreeCameraInputsManager;
  79158. /**
  79159. * Add mouse input support to the input manager.
  79160. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79161. * @returns the current input manager
  79162. */
  79163. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79164. /**
  79165. * Removes the mouse input support from the manager
  79166. * @returns the current input manager
  79167. */
  79168. removeMouse(): FreeCameraInputsManager;
  79169. /**
  79170. * Add touch input support to the input manager.
  79171. * @returns the current input manager
  79172. */
  79173. addTouch(): FreeCameraInputsManager;
  79174. /**
  79175. * Remove all attached input methods from a camera
  79176. */
  79177. clear(): void;
  79178. }
  79179. }
  79180. declare module BABYLON {
  79181. /**
  79182. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79183. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79184. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79185. */
  79186. export class FreeCamera extends TargetCamera {
  79187. /**
  79188. * Define the collision ellipsoid of the camera.
  79189. * This is helpful to simulate a camera body like the player body around the camera
  79190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79191. */
  79192. ellipsoid: Vector3;
  79193. /**
  79194. * Define an offset for the position of the ellipsoid around the camera.
  79195. * This can be helpful to determine the center of the body near the gravity center of the body
  79196. * instead of its head.
  79197. */
  79198. ellipsoidOffset: Vector3;
  79199. /**
  79200. * Enable or disable collisions of the camera with the rest of the scene objects.
  79201. */
  79202. checkCollisions: boolean;
  79203. /**
  79204. * Enable or disable gravity on the camera.
  79205. */
  79206. applyGravity: boolean;
  79207. /**
  79208. * Define the input manager associated to the camera.
  79209. */
  79210. inputs: FreeCameraInputsManager;
  79211. /**
  79212. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79213. * Higher values reduce sensitivity.
  79214. */
  79215. /**
  79216. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79217. * Higher values reduce sensitivity.
  79218. */
  79219. angularSensibility: number;
  79220. /**
  79221. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79222. */
  79223. keysUp: number[];
  79224. /**
  79225. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79226. */
  79227. keysDown: number[];
  79228. /**
  79229. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79230. */
  79231. keysLeft: number[];
  79232. /**
  79233. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79234. */
  79235. keysRight: number[];
  79236. /**
  79237. * Event raised when the camera collide with a mesh in the scene.
  79238. */
  79239. onCollide: (collidedMesh: AbstractMesh) => void;
  79240. private _collider;
  79241. private _needMoveForGravity;
  79242. private _oldPosition;
  79243. private _diffPosition;
  79244. private _newPosition;
  79245. /** @hidden */
  79246. _localDirection: Vector3;
  79247. /** @hidden */
  79248. _transformedDirection: Vector3;
  79249. /**
  79250. * Instantiates a Free Camera.
  79251. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79252. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79254. * @param name Define the name of the camera in the scene
  79255. * @param position Define the start position of the camera in the scene
  79256. * @param scene Define the scene the camera belongs to
  79257. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79258. */
  79259. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79260. /**
  79261. * Attached controls to the current camera.
  79262. * @param element Defines the element the controls should be listened from
  79263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79264. */
  79265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79266. /**
  79267. * Detach the current controls from the camera.
  79268. * The camera will stop reacting to inputs.
  79269. * @param element Defines the element to stop listening the inputs from
  79270. */
  79271. detachControl(element: HTMLElement): void;
  79272. private _collisionMask;
  79273. /**
  79274. * Define a collision mask to limit the list of object the camera can collide with
  79275. */
  79276. collisionMask: number;
  79277. /** @hidden */
  79278. _collideWithWorld(displacement: Vector3): void;
  79279. private _onCollisionPositionChange;
  79280. /** @hidden */
  79281. _checkInputs(): void;
  79282. /** @hidden */
  79283. _decideIfNeedsToMove(): boolean;
  79284. /** @hidden */
  79285. _updatePosition(): void;
  79286. /**
  79287. * Destroy the camera and release the current resources hold by it.
  79288. */
  79289. dispose(): void;
  79290. /**
  79291. * Gets the current object class name.
  79292. * @return the class name
  79293. */
  79294. getClassName(): string;
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. /**
  79299. * Represents a gamepad control stick position
  79300. */
  79301. export class StickValues {
  79302. /**
  79303. * The x component of the control stick
  79304. */
  79305. x: number;
  79306. /**
  79307. * The y component of the control stick
  79308. */
  79309. y: number;
  79310. /**
  79311. * Initializes the gamepad x and y control stick values
  79312. * @param x The x component of the gamepad control stick value
  79313. * @param y The y component of the gamepad control stick value
  79314. */
  79315. constructor(
  79316. /**
  79317. * The x component of the control stick
  79318. */
  79319. x: number,
  79320. /**
  79321. * The y component of the control stick
  79322. */
  79323. y: number);
  79324. }
  79325. /**
  79326. * An interface which manages callbacks for gamepad button changes
  79327. */
  79328. export interface GamepadButtonChanges {
  79329. /**
  79330. * Called when a gamepad has been changed
  79331. */
  79332. changed: boolean;
  79333. /**
  79334. * Called when a gamepad press event has been triggered
  79335. */
  79336. pressChanged: boolean;
  79337. /**
  79338. * Called when a touch event has been triggered
  79339. */
  79340. touchChanged: boolean;
  79341. /**
  79342. * Called when a value has changed
  79343. */
  79344. valueChanged: boolean;
  79345. }
  79346. /**
  79347. * Represents a gamepad
  79348. */
  79349. export class Gamepad {
  79350. /**
  79351. * The id of the gamepad
  79352. */
  79353. id: string;
  79354. /**
  79355. * The index of the gamepad
  79356. */
  79357. index: number;
  79358. /**
  79359. * The browser gamepad
  79360. */
  79361. browserGamepad: any;
  79362. /**
  79363. * Specifies what type of gamepad this represents
  79364. */
  79365. type: number;
  79366. private _leftStick;
  79367. private _rightStick;
  79368. /** @hidden */
  79369. _isConnected: boolean;
  79370. private _leftStickAxisX;
  79371. private _leftStickAxisY;
  79372. private _rightStickAxisX;
  79373. private _rightStickAxisY;
  79374. /**
  79375. * Triggered when the left control stick has been changed
  79376. */
  79377. private _onleftstickchanged;
  79378. /**
  79379. * Triggered when the right control stick has been changed
  79380. */
  79381. private _onrightstickchanged;
  79382. /**
  79383. * Represents a gamepad controller
  79384. */
  79385. static GAMEPAD: number;
  79386. /**
  79387. * Represents a generic controller
  79388. */
  79389. static GENERIC: number;
  79390. /**
  79391. * Represents an XBox controller
  79392. */
  79393. static XBOX: number;
  79394. /**
  79395. * Represents a pose-enabled controller
  79396. */
  79397. static POSE_ENABLED: number;
  79398. /**
  79399. * Represents an Dual Shock controller
  79400. */
  79401. static DUALSHOCK: number;
  79402. /**
  79403. * Specifies whether the left control stick should be Y-inverted
  79404. */
  79405. protected _invertLeftStickY: boolean;
  79406. /**
  79407. * Specifies if the gamepad has been connected
  79408. */
  79409. readonly isConnected: boolean;
  79410. /**
  79411. * Initializes the gamepad
  79412. * @param id The id of the gamepad
  79413. * @param index The index of the gamepad
  79414. * @param browserGamepad The browser gamepad
  79415. * @param leftStickX The x component of the left joystick
  79416. * @param leftStickY The y component of the left joystick
  79417. * @param rightStickX The x component of the right joystick
  79418. * @param rightStickY The y component of the right joystick
  79419. */
  79420. constructor(
  79421. /**
  79422. * The id of the gamepad
  79423. */
  79424. id: string,
  79425. /**
  79426. * The index of the gamepad
  79427. */
  79428. index: number,
  79429. /**
  79430. * The browser gamepad
  79431. */
  79432. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79433. /**
  79434. * Callback triggered when the left joystick has changed
  79435. * @param callback
  79436. */
  79437. onleftstickchanged(callback: (values: StickValues) => void): void;
  79438. /**
  79439. * Callback triggered when the right joystick has changed
  79440. * @param callback
  79441. */
  79442. onrightstickchanged(callback: (values: StickValues) => void): void;
  79443. /**
  79444. * Gets the left joystick
  79445. */
  79446. /**
  79447. * Sets the left joystick values
  79448. */
  79449. leftStick: StickValues;
  79450. /**
  79451. * Gets the right joystick
  79452. */
  79453. /**
  79454. * Sets the right joystick value
  79455. */
  79456. rightStick: StickValues;
  79457. /**
  79458. * Updates the gamepad joystick positions
  79459. */
  79460. update(): void;
  79461. /**
  79462. * Disposes the gamepad
  79463. */
  79464. dispose(): void;
  79465. }
  79466. /**
  79467. * Represents a generic gamepad
  79468. */
  79469. export class GenericPad extends Gamepad {
  79470. private _buttons;
  79471. private _onbuttondown;
  79472. private _onbuttonup;
  79473. /**
  79474. * Observable triggered when a button has been pressed
  79475. */
  79476. onButtonDownObservable: Observable<number>;
  79477. /**
  79478. * Observable triggered when a button has been released
  79479. */
  79480. onButtonUpObservable: Observable<number>;
  79481. /**
  79482. * Callback triggered when a button has been pressed
  79483. * @param callback Called when a button has been pressed
  79484. */
  79485. onbuttondown(callback: (buttonPressed: number) => void): void;
  79486. /**
  79487. * Callback triggered when a button has been released
  79488. * @param callback Called when a button has been released
  79489. */
  79490. onbuttonup(callback: (buttonReleased: number) => void): void;
  79491. /**
  79492. * Initializes the generic gamepad
  79493. * @param id The id of the generic gamepad
  79494. * @param index The index of the generic gamepad
  79495. * @param browserGamepad The browser gamepad
  79496. */
  79497. constructor(id: string, index: number, browserGamepad: any);
  79498. private _setButtonValue;
  79499. /**
  79500. * Updates the generic gamepad
  79501. */
  79502. update(): void;
  79503. /**
  79504. * Disposes the generic gamepad
  79505. */
  79506. dispose(): void;
  79507. }
  79508. }
  79509. declare module BABYLON {
  79510. interface Engine {
  79511. /**
  79512. * Creates a raw texture
  79513. * @param data defines the data to store in the texture
  79514. * @param width defines the width of the texture
  79515. * @param height defines the height of the texture
  79516. * @param format defines the format of the data
  79517. * @param generateMipMaps defines if the engine should generate the mip levels
  79518. * @param invertY defines if data must be stored with Y axis inverted
  79519. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79520. * @param compression defines the compression used (null by default)
  79521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79522. * @returns the raw texture inside an InternalTexture
  79523. */
  79524. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79525. /**
  79526. * Update a raw texture
  79527. * @param texture defines the texture to update
  79528. * @param data defines the data to store in the texture
  79529. * @param format defines the format of the data
  79530. * @param invertY defines if data must be stored with Y axis inverted
  79531. */
  79532. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79533. /**
  79534. * Update a raw texture
  79535. * @param texture defines the texture to update
  79536. * @param data defines the data to store in the texture
  79537. * @param format defines the format of the data
  79538. * @param invertY defines if data must be stored with Y axis inverted
  79539. * @param compression defines the compression used (null by default)
  79540. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79541. */
  79542. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79543. /**
  79544. * Creates a new raw cube texture
  79545. * @param data defines the array of data to use to create each face
  79546. * @param size defines the size of the textures
  79547. * @param format defines the format of the data
  79548. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79549. * @param generateMipMaps defines if the engine should generate the mip levels
  79550. * @param invertY defines if data must be stored with Y axis inverted
  79551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79552. * @param compression defines the compression used (null by default)
  79553. * @returns the cube texture as an InternalTexture
  79554. */
  79555. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79556. /**
  79557. * Update a raw cube texture
  79558. * @param texture defines the texture to udpdate
  79559. * @param data defines the data to store
  79560. * @param format defines the data format
  79561. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79562. * @param invertY defines if data must be stored with Y axis inverted
  79563. */
  79564. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79565. /**
  79566. * Update a raw cube texture
  79567. * @param texture defines the texture to udpdate
  79568. * @param data defines the data to store
  79569. * @param format defines the data format
  79570. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79571. * @param invertY defines if data must be stored with Y axis inverted
  79572. * @param compression defines the compression used (null by default)
  79573. */
  79574. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79575. /**
  79576. * Update a raw cube texture
  79577. * @param texture defines the texture to udpdate
  79578. * @param data defines the data to store
  79579. * @param format defines the data format
  79580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79581. * @param invertY defines if data must be stored with Y axis inverted
  79582. * @param compression defines the compression used (null by default)
  79583. * @param level defines which level of the texture to update
  79584. */
  79585. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79586. /**
  79587. * Creates a new raw cube texture from a specified url
  79588. * @param url defines the url where the data is located
  79589. * @param scene defines the current scene
  79590. * @param size defines the size of the textures
  79591. * @param format defines the format of the data
  79592. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79593. * @param noMipmap defines if the engine should avoid generating the mip levels
  79594. * @param callback defines a callback used to extract texture data from loaded data
  79595. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79596. * @param onLoad defines a callback called when texture is loaded
  79597. * @param onError defines a callback called if there is an error
  79598. * @returns the cube texture as an InternalTexture
  79599. */
  79600. 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;
  79601. /**
  79602. * Creates a new raw cube texture from a specified url
  79603. * @param url defines the url where the data is located
  79604. * @param scene defines the current scene
  79605. * @param size defines the size of the textures
  79606. * @param format defines the format of the data
  79607. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79608. * @param noMipmap defines if the engine should avoid generating the mip levels
  79609. * @param callback defines a callback used to extract texture data from loaded data
  79610. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79611. * @param onLoad defines a callback called when texture is loaded
  79612. * @param onError defines a callback called if there is an error
  79613. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79614. * @param invertY defines if data must be stored with Y axis inverted
  79615. * @returns the cube texture as an InternalTexture
  79616. */
  79617. 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;
  79618. /**
  79619. * Creates a new raw 3D texture
  79620. * @param data defines the data used to create the texture
  79621. * @param width defines the width of the texture
  79622. * @param height defines the height of the texture
  79623. * @param depth defines the depth of the texture
  79624. * @param format defines the format of the texture
  79625. * @param generateMipMaps defines if the engine must generate mip levels
  79626. * @param invertY defines if data must be stored with Y axis inverted
  79627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79628. * @param compression defines the compressed used (can be null)
  79629. * @param textureType defines the compressed used (can be null)
  79630. * @returns a new raw 3D texture (stored in an InternalTexture)
  79631. */
  79632. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79633. /**
  79634. * Update a raw 3D texture
  79635. * @param texture defines the texture to update
  79636. * @param data defines the data to store
  79637. * @param format defines the data format
  79638. * @param invertY defines if data must be stored with Y axis inverted
  79639. */
  79640. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79641. /**
  79642. * Update a raw 3D texture
  79643. * @param texture defines the texture to update
  79644. * @param data defines the data to store
  79645. * @param format defines the data format
  79646. * @param invertY defines if data must be stored with Y axis inverted
  79647. * @param compression defines the used compression (can be null)
  79648. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79649. */
  79650. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79651. }
  79652. }
  79653. declare module BABYLON {
  79654. /**
  79655. * Raw texture can help creating a texture directly from an array of data.
  79656. * This can be super useful if you either get the data from an uncompressed source or
  79657. * if you wish to create your texture pixel by pixel.
  79658. */
  79659. export class RawTexture extends Texture {
  79660. /**
  79661. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79662. */
  79663. format: number;
  79664. private _engine;
  79665. /**
  79666. * Instantiates a new RawTexture.
  79667. * Raw texture can help creating a texture directly from an array of data.
  79668. * This can be super useful if you either get the data from an uncompressed source or
  79669. * if you wish to create your texture pixel by pixel.
  79670. * @param data define the array of data to use to create the texture
  79671. * @param width define the width of the texture
  79672. * @param height define the height of the texture
  79673. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79674. * @param scene define the scene the texture belongs to
  79675. * @param generateMipMaps define whether mip maps should be generated or not
  79676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79679. */
  79680. constructor(data: ArrayBufferView, width: number, height: number,
  79681. /**
  79682. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79683. */
  79684. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79685. /**
  79686. * Updates the texture underlying data.
  79687. * @param data Define the new data of the texture
  79688. */
  79689. update(data: ArrayBufferView): void;
  79690. /**
  79691. * Creates a luminance texture from some data.
  79692. * @param data Define the texture data
  79693. * @param width Define the width of the texture
  79694. * @param height Define the height of the texture
  79695. * @param scene Define the scene the texture belongs to
  79696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79699. * @returns the luminance texture
  79700. */
  79701. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79702. /**
  79703. * Creates a luminance alpha texture from some data.
  79704. * @param data Define the texture data
  79705. * @param width Define the width of the texture
  79706. * @param height Define the height of the texture
  79707. * @param scene Define the scene the texture belongs to
  79708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79711. * @returns the luminance alpha texture
  79712. */
  79713. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79714. /**
  79715. * Creates an alpha texture from some data.
  79716. * @param data Define the texture data
  79717. * @param width Define the width of the texture
  79718. * @param height Define the height of the texture
  79719. * @param scene Define the scene the texture belongs to
  79720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79723. * @returns the alpha texture
  79724. */
  79725. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79726. /**
  79727. * Creates a RGB texture from some data.
  79728. * @param data Define the texture data
  79729. * @param width Define the width of the texture
  79730. * @param height Define the height of the texture
  79731. * @param scene Define the scene the texture belongs to
  79732. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79733. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79734. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79735. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79736. * @returns the RGB alpha texture
  79737. */
  79738. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79739. /**
  79740. * Creates a RGBA texture from some data.
  79741. * @param data Define the texture data
  79742. * @param width Define the width of the texture
  79743. * @param height Define the height of the texture
  79744. * @param scene Define the scene the texture belongs to
  79745. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79748. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79749. * @returns the RGBA texture
  79750. */
  79751. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79752. /**
  79753. * Creates a R texture from some data.
  79754. * @param data Define the texture data
  79755. * @param width Define the width of the texture
  79756. * @param height Define the height of the texture
  79757. * @param scene Define the scene the texture belongs to
  79758. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79759. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79760. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79761. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79762. * @returns the R texture
  79763. */
  79764. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79765. }
  79766. }
  79767. declare module BABYLON {
  79768. /**
  79769. * Interface for the size containing width and height
  79770. */
  79771. export interface ISize {
  79772. /**
  79773. * Width
  79774. */
  79775. width: number;
  79776. /**
  79777. * Heighht
  79778. */
  79779. height: number;
  79780. }
  79781. /**
  79782. * Size containing widht and height
  79783. */
  79784. export class Size implements ISize {
  79785. /**
  79786. * Width
  79787. */
  79788. width: number;
  79789. /**
  79790. * Height
  79791. */
  79792. height: number;
  79793. /**
  79794. * Creates a Size object from the given width and height (floats).
  79795. * @param width width of the new size
  79796. * @param height height of the new size
  79797. */
  79798. constructor(width: number, height: number);
  79799. /**
  79800. * Returns a string with the Size width and height
  79801. * @returns a string with the Size width and height
  79802. */
  79803. toString(): string;
  79804. /**
  79805. * "Size"
  79806. * @returns the string "Size"
  79807. */
  79808. getClassName(): string;
  79809. /**
  79810. * Returns the Size hash code.
  79811. * @returns a hash code for a unique width and height
  79812. */
  79813. getHashCode(): number;
  79814. /**
  79815. * Updates the current size from the given one.
  79816. * @param src the given size
  79817. */
  79818. copyFrom(src: Size): void;
  79819. /**
  79820. * Updates in place the current Size from the given floats.
  79821. * @param width width of the new size
  79822. * @param height height of the new size
  79823. * @returns the updated Size.
  79824. */
  79825. copyFromFloats(width: number, height: number): Size;
  79826. /**
  79827. * Updates in place the current Size from the given floats.
  79828. * @param width width to set
  79829. * @param height height to set
  79830. * @returns the updated Size.
  79831. */
  79832. set(width: number, height: number): Size;
  79833. /**
  79834. * Multiplies the width and height by numbers
  79835. * @param w factor to multiple the width by
  79836. * @param h factor to multiple the height by
  79837. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79838. */
  79839. multiplyByFloats(w: number, h: number): Size;
  79840. /**
  79841. * Clones the size
  79842. * @returns a new Size copied from the given one.
  79843. */
  79844. clone(): Size;
  79845. /**
  79846. * True if the current Size and the given one width and height are strictly equal.
  79847. * @param other the other size to compare against
  79848. * @returns True if the current Size and the given one width and height are strictly equal.
  79849. */
  79850. equals(other: Size): boolean;
  79851. /**
  79852. * The surface of the Size : width * height (float).
  79853. */
  79854. readonly surface: number;
  79855. /**
  79856. * Create a new size of zero
  79857. * @returns a new Size set to (0.0, 0.0)
  79858. */
  79859. static Zero(): Size;
  79860. /**
  79861. * Sums the width and height of two sizes
  79862. * @param otherSize size to add to this size
  79863. * @returns a new Size set as the addition result of the current Size and the given one.
  79864. */
  79865. add(otherSize: Size): Size;
  79866. /**
  79867. * Subtracts the width and height of two
  79868. * @param otherSize size to subtract to this size
  79869. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79870. */
  79871. subtract(otherSize: Size): Size;
  79872. /**
  79873. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79874. * @param start starting size to lerp between
  79875. * @param end end size to lerp between
  79876. * @param amount amount to lerp between the start and end values
  79877. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79878. */
  79879. static Lerp(start: Size, end: Size, amount: number): Size;
  79880. }
  79881. }
  79882. declare module BABYLON {
  79883. /**
  79884. * Defines a runtime animation
  79885. */
  79886. export class RuntimeAnimation {
  79887. private _events;
  79888. /**
  79889. * The current frame of the runtime animation
  79890. */
  79891. private _currentFrame;
  79892. /**
  79893. * The animation used by the runtime animation
  79894. */
  79895. private _animation;
  79896. /**
  79897. * The target of the runtime animation
  79898. */
  79899. private _target;
  79900. /**
  79901. * The initiating animatable
  79902. */
  79903. private _host;
  79904. /**
  79905. * The original value of the runtime animation
  79906. */
  79907. private _originalValue;
  79908. /**
  79909. * The original blend value of the runtime animation
  79910. */
  79911. private _originalBlendValue;
  79912. /**
  79913. * The offsets cache of the runtime animation
  79914. */
  79915. private _offsetsCache;
  79916. /**
  79917. * The high limits cache of the runtime animation
  79918. */
  79919. private _highLimitsCache;
  79920. /**
  79921. * Specifies if the runtime animation has been stopped
  79922. */
  79923. private _stopped;
  79924. /**
  79925. * The blending factor of the runtime animation
  79926. */
  79927. private _blendingFactor;
  79928. /**
  79929. * The BabylonJS scene
  79930. */
  79931. private _scene;
  79932. /**
  79933. * The current value of the runtime animation
  79934. */
  79935. private _currentValue;
  79936. /** @hidden */
  79937. _animationState: _IAnimationState;
  79938. /**
  79939. * The active target of the runtime animation
  79940. */
  79941. private _activeTargets;
  79942. private _currentActiveTarget;
  79943. private _directTarget;
  79944. /**
  79945. * The target path of the runtime animation
  79946. */
  79947. private _targetPath;
  79948. /**
  79949. * The weight of the runtime animation
  79950. */
  79951. private _weight;
  79952. /**
  79953. * The ratio offset of the runtime animation
  79954. */
  79955. private _ratioOffset;
  79956. /**
  79957. * The previous delay of the runtime animation
  79958. */
  79959. private _previousDelay;
  79960. /**
  79961. * The previous ratio of the runtime animation
  79962. */
  79963. private _previousRatio;
  79964. private _enableBlending;
  79965. private _keys;
  79966. private _minFrame;
  79967. private _maxFrame;
  79968. private _minValue;
  79969. private _maxValue;
  79970. private _targetIsArray;
  79971. /**
  79972. * Gets the current frame of the runtime animation
  79973. */
  79974. readonly currentFrame: number;
  79975. /**
  79976. * Gets the weight of the runtime animation
  79977. */
  79978. readonly weight: number;
  79979. /**
  79980. * Gets the current value of the runtime animation
  79981. */
  79982. readonly currentValue: any;
  79983. /**
  79984. * Gets the target path of the runtime animation
  79985. */
  79986. readonly targetPath: string;
  79987. /**
  79988. * Gets the actual target of the runtime animation
  79989. */
  79990. readonly target: any;
  79991. /** @hidden */
  79992. _onLoop: () => void;
  79993. /**
  79994. * Create a new RuntimeAnimation object
  79995. * @param target defines the target of the animation
  79996. * @param animation defines the source animation object
  79997. * @param scene defines the hosting scene
  79998. * @param host defines the initiating Animatable
  79999. */
  80000. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80001. private _preparePath;
  80002. /**
  80003. * Gets the animation from the runtime animation
  80004. */
  80005. readonly animation: Animation;
  80006. /**
  80007. * Resets the runtime animation to the beginning
  80008. * @param restoreOriginal defines whether to restore the target property to the original value
  80009. */
  80010. reset(restoreOriginal?: boolean): void;
  80011. /**
  80012. * Specifies if the runtime animation is stopped
  80013. * @returns Boolean specifying if the runtime animation is stopped
  80014. */
  80015. isStopped(): boolean;
  80016. /**
  80017. * Disposes of the runtime animation
  80018. */
  80019. dispose(): void;
  80020. /**
  80021. * Apply the interpolated value to the target
  80022. * @param currentValue defines the value computed by the animation
  80023. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80024. */
  80025. setValue(currentValue: any, weight: number): void;
  80026. private _getOriginalValues;
  80027. private _setValue;
  80028. /**
  80029. * Gets the loop pmode of the runtime animation
  80030. * @returns Loop Mode
  80031. */
  80032. private _getCorrectLoopMode;
  80033. /**
  80034. * Move the current animation to a given frame
  80035. * @param frame defines the frame to move to
  80036. */
  80037. goToFrame(frame: number): void;
  80038. /**
  80039. * @hidden Internal use only
  80040. */
  80041. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80042. /**
  80043. * Execute the current animation
  80044. * @param delay defines the delay to add to the current frame
  80045. * @param from defines the lower bound of the animation range
  80046. * @param to defines the upper bound of the animation range
  80047. * @param loop defines if the current animation must loop
  80048. * @param speedRatio defines the current speed ratio
  80049. * @param weight defines the weight of the animation (default is -1 so no weight)
  80050. * @param onLoop optional callback called when animation loops
  80051. * @returns a boolean indicating if the animation is running
  80052. */
  80053. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80054. }
  80055. }
  80056. declare module BABYLON {
  80057. /**
  80058. * Class used to store an actual running animation
  80059. */
  80060. export class Animatable {
  80061. /** defines the target object */
  80062. target: any;
  80063. /** defines the starting frame number (default is 0) */
  80064. fromFrame: number;
  80065. /** defines the ending frame number (default is 100) */
  80066. toFrame: number;
  80067. /** defines if the animation must loop (default is false) */
  80068. loopAnimation: boolean;
  80069. /** defines a callback to call when animation ends if it is not looping */
  80070. onAnimationEnd?: (() => void) | null | undefined;
  80071. /** defines a callback to call when animation loops */
  80072. onAnimationLoop?: (() => void) | null | undefined;
  80073. private _localDelayOffset;
  80074. private _pausedDelay;
  80075. private _runtimeAnimations;
  80076. private _paused;
  80077. private _scene;
  80078. private _speedRatio;
  80079. private _weight;
  80080. private _syncRoot;
  80081. /**
  80082. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80083. * This will only apply for non looping animation (default is true)
  80084. */
  80085. disposeOnEnd: boolean;
  80086. /**
  80087. * Gets a boolean indicating if the animation has started
  80088. */
  80089. animationStarted: boolean;
  80090. /**
  80091. * Observer raised when the animation ends
  80092. */
  80093. onAnimationEndObservable: Observable<Animatable>;
  80094. /**
  80095. * Observer raised when the animation loops
  80096. */
  80097. onAnimationLoopObservable: Observable<Animatable>;
  80098. /**
  80099. * Gets the root Animatable used to synchronize and normalize animations
  80100. */
  80101. readonly syncRoot: Nullable<Animatable>;
  80102. /**
  80103. * Gets the current frame of the first RuntimeAnimation
  80104. * Used to synchronize Animatables
  80105. */
  80106. readonly masterFrame: number;
  80107. /**
  80108. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80109. */
  80110. weight: number;
  80111. /**
  80112. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80113. */
  80114. speedRatio: number;
  80115. /**
  80116. * Creates a new Animatable
  80117. * @param scene defines the hosting scene
  80118. * @param target defines the target object
  80119. * @param fromFrame defines the starting frame number (default is 0)
  80120. * @param toFrame defines the ending frame number (default is 100)
  80121. * @param loopAnimation defines if the animation must loop (default is false)
  80122. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80123. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80124. * @param animations defines a group of animation to add to the new Animatable
  80125. * @param onAnimationLoop defines a callback to call when animation loops
  80126. */
  80127. constructor(scene: Scene,
  80128. /** defines the target object */
  80129. target: any,
  80130. /** defines the starting frame number (default is 0) */
  80131. fromFrame?: number,
  80132. /** defines the ending frame number (default is 100) */
  80133. toFrame?: number,
  80134. /** defines if the animation must loop (default is false) */
  80135. loopAnimation?: boolean, speedRatio?: number,
  80136. /** defines a callback to call when animation ends if it is not looping */
  80137. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80138. /** defines a callback to call when animation loops */
  80139. onAnimationLoop?: (() => void) | null | undefined);
  80140. /**
  80141. * Synchronize and normalize current Animatable with a source Animatable
  80142. * This is useful when using animation weights and when animations are not of the same length
  80143. * @param root defines the root Animatable to synchronize with
  80144. * @returns the current Animatable
  80145. */
  80146. syncWith(root: Animatable): Animatable;
  80147. /**
  80148. * Gets the list of runtime animations
  80149. * @returns an array of RuntimeAnimation
  80150. */
  80151. getAnimations(): RuntimeAnimation[];
  80152. /**
  80153. * Adds more animations to the current animatable
  80154. * @param target defines the target of the animations
  80155. * @param animations defines the new animations to add
  80156. */
  80157. appendAnimations(target: any, animations: Animation[]): void;
  80158. /**
  80159. * Gets the source animation for a specific property
  80160. * @param property defines the propertyu to look for
  80161. * @returns null or the source animation for the given property
  80162. */
  80163. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80164. /**
  80165. * Gets the runtime animation for a specific property
  80166. * @param property defines the propertyu to look for
  80167. * @returns null or the runtime animation for the given property
  80168. */
  80169. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80170. /**
  80171. * Resets the animatable to its original state
  80172. */
  80173. reset(): void;
  80174. /**
  80175. * Allows the animatable to blend with current running animations
  80176. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80177. * @param blendingSpeed defines the blending speed to use
  80178. */
  80179. enableBlending(blendingSpeed: number): void;
  80180. /**
  80181. * Disable animation blending
  80182. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80183. */
  80184. disableBlending(): void;
  80185. /**
  80186. * Jump directly to a given frame
  80187. * @param frame defines the frame to jump to
  80188. */
  80189. goToFrame(frame: number): void;
  80190. /**
  80191. * Pause the animation
  80192. */
  80193. pause(): void;
  80194. /**
  80195. * Restart the animation
  80196. */
  80197. restart(): void;
  80198. private _raiseOnAnimationEnd;
  80199. /**
  80200. * Stop and delete the current animation
  80201. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80202. * @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)
  80203. */
  80204. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80205. /**
  80206. * Wait asynchronously for the animation to end
  80207. * @returns a promise which will be fullfilled when the animation ends
  80208. */
  80209. waitAsync(): Promise<Animatable>;
  80210. /** @hidden */
  80211. _animate(delay: number): boolean;
  80212. }
  80213. interface Scene {
  80214. /** @hidden */
  80215. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80216. /** @hidden */
  80217. _processLateAnimationBindingsForMatrices(holder: {
  80218. totalWeight: number;
  80219. animations: RuntimeAnimation[];
  80220. originalValue: Matrix;
  80221. }): any;
  80222. /** @hidden */
  80223. _processLateAnimationBindingsForQuaternions(holder: {
  80224. totalWeight: number;
  80225. animations: RuntimeAnimation[];
  80226. originalValue: Quaternion;
  80227. }, refQuaternion: Quaternion): Quaternion;
  80228. /** @hidden */
  80229. _processLateAnimationBindings(): void;
  80230. /**
  80231. * Will start the animation sequence of a given target
  80232. * @param target defines the target
  80233. * @param from defines from which frame should animation start
  80234. * @param to defines until which frame should animation run.
  80235. * @param weight defines the weight to apply to the animation (1.0 by default)
  80236. * @param loop defines if the animation loops
  80237. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80238. * @param onAnimationEnd defines the function to be executed when the animation ends
  80239. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80240. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80241. * @param onAnimationLoop defines the callback to call when an animation loops
  80242. * @returns the animatable object created for this animation
  80243. */
  80244. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80245. /**
  80246. * Will start the animation sequence of a given target
  80247. * @param target defines the target
  80248. * @param from defines from which frame should animation start
  80249. * @param to defines until which frame should animation run.
  80250. * @param loop defines if the animation loops
  80251. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80252. * @param onAnimationEnd defines the function to be executed when the animation ends
  80253. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80254. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80255. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80256. * @param onAnimationLoop defines the callback to call when an animation loops
  80257. * @returns the animatable object created for this animation
  80258. */
  80259. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80260. /**
  80261. * Will start the animation sequence of a given target and its hierarchy
  80262. * @param target defines the target
  80263. * @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.
  80264. * @param from defines from which frame should animation start
  80265. * @param to defines until which frame should animation run.
  80266. * @param loop defines if the animation loops
  80267. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80268. * @param onAnimationEnd defines the function to be executed when the animation ends
  80269. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80270. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80271. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80272. * @param onAnimationLoop defines the callback to call when an animation loops
  80273. * @returns the list of created animatables
  80274. */
  80275. 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[];
  80276. /**
  80277. * Begin a new animation on a given node
  80278. * @param target defines the target where the animation will take place
  80279. * @param animations defines the list of animations to start
  80280. * @param from defines the initial value
  80281. * @param to defines the final value
  80282. * @param loop defines if you want animation to loop (off by default)
  80283. * @param speedRatio defines the speed ratio to apply to all animations
  80284. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80285. * @param onAnimationLoop defines the callback to call when an animation loops
  80286. * @returns the list of created animatables
  80287. */
  80288. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80289. /**
  80290. * Begin a new animation on a given node and its hierarchy
  80291. * @param target defines the root node where the animation will take place
  80292. * @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.
  80293. * @param animations defines the list of animations to start
  80294. * @param from defines the initial value
  80295. * @param to defines the final value
  80296. * @param loop defines if you want animation to loop (off by default)
  80297. * @param speedRatio defines the speed ratio to apply to all animations
  80298. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80299. * @param onAnimationLoop defines the callback to call when an animation loops
  80300. * @returns the list of animatables created for all nodes
  80301. */
  80302. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80303. /**
  80304. * Gets the animatable associated with a specific target
  80305. * @param target defines the target of the animatable
  80306. * @returns the required animatable if found
  80307. */
  80308. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80309. /**
  80310. * Gets all animatables associated with a given target
  80311. * @param target defines the target to look animatables for
  80312. * @returns an array of Animatables
  80313. */
  80314. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80315. /**
  80316. * Stops and removes all animations that have been applied to the scene
  80317. */
  80318. stopAllAnimations(): void;
  80319. /**
  80320. * Gets the current delta time used by animation engine
  80321. */
  80322. deltaTime: number;
  80323. }
  80324. interface Bone {
  80325. /**
  80326. * Copy an animation range from another bone
  80327. * @param source defines the source bone
  80328. * @param rangeName defines the range name to copy
  80329. * @param frameOffset defines the frame offset
  80330. * @param rescaleAsRequired defines if rescaling must be applied if required
  80331. * @param skelDimensionsRatio defines the scaling ratio
  80332. * @returns true if operation was successful
  80333. */
  80334. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80335. }
  80336. }
  80337. declare module BABYLON {
  80338. /**
  80339. * Class used to override all child animations of a given target
  80340. */
  80341. export class AnimationPropertiesOverride {
  80342. /**
  80343. * Gets or sets a value indicating if animation blending must be used
  80344. */
  80345. enableBlending: boolean;
  80346. /**
  80347. * Gets or sets the blending speed to use when enableBlending is true
  80348. */
  80349. blendingSpeed: number;
  80350. /**
  80351. * Gets or sets the default loop mode to use
  80352. */
  80353. loopMode: number;
  80354. }
  80355. }
  80356. declare module BABYLON {
  80357. /**
  80358. * Class used to handle skinning animations
  80359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80360. */
  80361. export class Skeleton implements IAnimatable {
  80362. /** defines the skeleton name */
  80363. name: string;
  80364. /** defines the skeleton Id */
  80365. id: string;
  80366. /**
  80367. * Defines the list of child bones
  80368. */
  80369. bones: Bone[];
  80370. /**
  80371. * Defines an estimate of the dimension of the skeleton at rest
  80372. */
  80373. dimensionsAtRest: Vector3;
  80374. /**
  80375. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80376. */
  80377. needInitialSkinMatrix: boolean;
  80378. /**
  80379. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80380. */
  80381. overrideMesh: Nullable<AbstractMesh>;
  80382. /**
  80383. * Gets the list of animations attached to this skeleton
  80384. */
  80385. animations: Array<Animation>;
  80386. private _scene;
  80387. private _isDirty;
  80388. private _transformMatrices;
  80389. private _transformMatrixTexture;
  80390. private _meshesWithPoseMatrix;
  80391. private _animatables;
  80392. private _identity;
  80393. private _synchronizedWithMesh;
  80394. private _ranges;
  80395. private _lastAbsoluteTransformsUpdateId;
  80396. private _canUseTextureForBones;
  80397. private _uniqueId;
  80398. /** @hidden */
  80399. _numBonesWithLinkedTransformNode: number;
  80400. /** @hidden */
  80401. _hasWaitingData: Nullable<boolean>;
  80402. /**
  80403. * Specifies if the skeleton should be serialized
  80404. */
  80405. doNotSerialize: boolean;
  80406. private _useTextureToStoreBoneMatrices;
  80407. /**
  80408. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80409. * Please note that this option is not available if the hardware does not support it
  80410. */
  80411. useTextureToStoreBoneMatrices: boolean;
  80412. private _animationPropertiesOverride;
  80413. /**
  80414. * Gets or sets the animation properties override
  80415. */
  80416. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80417. /**
  80418. * List of inspectable custom properties (used by the Inspector)
  80419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80420. */
  80421. inspectableCustomProperties: IInspectable[];
  80422. /**
  80423. * An observable triggered before computing the skeleton's matrices
  80424. */
  80425. onBeforeComputeObservable: Observable<Skeleton>;
  80426. /**
  80427. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80428. */
  80429. readonly isUsingTextureForMatrices: boolean;
  80430. /**
  80431. * Gets the unique ID of this skeleton
  80432. */
  80433. readonly uniqueId: number;
  80434. /**
  80435. * Creates a new skeleton
  80436. * @param name defines the skeleton name
  80437. * @param id defines the skeleton Id
  80438. * @param scene defines the hosting scene
  80439. */
  80440. constructor(
  80441. /** defines the skeleton name */
  80442. name: string,
  80443. /** defines the skeleton Id */
  80444. id: string, scene: Scene);
  80445. /**
  80446. * Gets the current object class name.
  80447. * @return the class name
  80448. */
  80449. getClassName(): string;
  80450. /**
  80451. * Returns an array containing the root bones
  80452. * @returns an array containing the root bones
  80453. */
  80454. getChildren(): Array<Bone>;
  80455. /**
  80456. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80457. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80458. * @returns a Float32Array containing matrices data
  80459. */
  80460. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80461. /**
  80462. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80464. * @returns a raw texture containing the data
  80465. */
  80466. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80467. /**
  80468. * Gets the current hosting scene
  80469. * @returns a scene object
  80470. */
  80471. getScene(): Scene;
  80472. /**
  80473. * Gets a string representing the current skeleton data
  80474. * @param fullDetails defines a boolean indicating if we want a verbose version
  80475. * @returns a string representing the current skeleton data
  80476. */
  80477. toString(fullDetails?: boolean): string;
  80478. /**
  80479. * Get bone's index searching by name
  80480. * @param name defines bone's name to search for
  80481. * @return the indice of the bone. Returns -1 if not found
  80482. */
  80483. getBoneIndexByName(name: string): number;
  80484. /**
  80485. * Creater a new animation range
  80486. * @param name defines the name of the range
  80487. * @param from defines the start key
  80488. * @param to defines the end key
  80489. */
  80490. createAnimationRange(name: string, from: number, to: number): void;
  80491. /**
  80492. * Delete a specific animation range
  80493. * @param name defines the name of the range
  80494. * @param deleteFrames defines if frames must be removed as well
  80495. */
  80496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80497. /**
  80498. * Gets a specific animation range
  80499. * @param name defines the name of the range to look for
  80500. * @returns the requested animation range or null if not found
  80501. */
  80502. getAnimationRange(name: string): Nullable<AnimationRange>;
  80503. /**
  80504. * Gets the list of all animation ranges defined on this skeleton
  80505. * @returns an array
  80506. */
  80507. getAnimationRanges(): Nullable<AnimationRange>[];
  80508. /**
  80509. * Copy animation range from a source skeleton.
  80510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80511. * @param source defines the source skeleton
  80512. * @param name defines the name of the range to copy
  80513. * @param rescaleAsRequired defines if rescaling must be applied if required
  80514. * @returns true if operation was successful
  80515. */
  80516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80517. /**
  80518. * Forces the skeleton to go to rest pose
  80519. */
  80520. returnToRest(): void;
  80521. private _getHighestAnimationFrame;
  80522. /**
  80523. * Begin a specific animation range
  80524. * @param name defines the name of the range to start
  80525. * @param loop defines if looping must be turned on (false by default)
  80526. * @param speedRatio defines the speed ratio to apply (1 by default)
  80527. * @param onAnimationEnd defines a callback which will be called when animation will end
  80528. * @returns a new animatable
  80529. */
  80530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80531. /** @hidden */
  80532. _markAsDirty(): void;
  80533. /** @hidden */
  80534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80535. /** @hidden */
  80536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80537. private _computeTransformMatrices;
  80538. /**
  80539. * Build all resources required to render a skeleton
  80540. */
  80541. prepare(): void;
  80542. /**
  80543. * Gets the list of animatables currently running for this skeleton
  80544. * @returns an array of animatables
  80545. */
  80546. getAnimatables(): IAnimatable[];
  80547. /**
  80548. * Clone the current skeleton
  80549. * @param name defines the name of the new skeleton
  80550. * @param id defines the id of the new skeleton
  80551. * @returns the new skeleton
  80552. */
  80553. clone(name: string, id: string): Skeleton;
  80554. /**
  80555. * Enable animation blending for this skeleton
  80556. * @param blendingSpeed defines the blending speed to apply
  80557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80558. */
  80559. enableBlending(blendingSpeed?: number): void;
  80560. /**
  80561. * Releases all resources associated with the current skeleton
  80562. */
  80563. dispose(): void;
  80564. /**
  80565. * Serialize the skeleton in a JSON object
  80566. * @returns a JSON object
  80567. */
  80568. serialize(): any;
  80569. /**
  80570. * Creates a new skeleton from serialized data
  80571. * @param parsedSkeleton defines the serialized data
  80572. * @param scene defines the hosting scene
  80573. * @returns a new skeleton
  80574. */
  80575. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80576. /**
  80577. * Compute all node absolute transforms
  80578. * @param forceUpdate defines if computation must be done even if cache is up to date
  80579. */
  80580. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80581. /**
  80582. * Gets the root pose matrix
  80583. * @returns a matrix
  80584. */
  80585. getPoseMatrix(): Nullable<Matrix>;
  80586. /**
  80587. * Sorts bones per internal index
  80588. */
  80589. sortBones(): void;
  80590. private _sortBones;
  80591. }
  80592. }
  80593. declare module BABYLON {
  80594. /**
  80595. * Class used to store bone information
  80596. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80597. */
  80598. export class Bone extends Node {
  80599. /**
  80600. * defines the bone name
  80601. */
  80602. name: string;
  80603. private static _tmpVecs;
  80604. private static _tmpQuat;
  80605. private static _tmpMats;
  80606. /**
  80607. * Gets the list of child bones
  80608. */
  80609. children: Bone[];
  80610. /** Gets the animations associated with this bone */
  80611. animations: Animation[];
  80612. /**
  80613. * Gets or sets bone length
  80614. */
  80615. length: number;
  80616. /**
  80617. * @hidden Internal only
  80618. * Set this value to map this bone to a different index in the transform matrices
  80619. * Set this value to -1 to exclude the bone from the transform matrices
  80620. */
  80621. _index: Nullable<number>;
  80622. private _skeleton;
  80623. private _localMatrix;
  80624. private _restPose;
  80625. private _baseMatrix;
  80626. private _absoluteTransform;
  80627. private _invertedAbsoluteTransform;
  80628. private _parent;
  80629. private _scalingDeterminant;
  80630. private _worldTransform;
  80631. private _localScaling;
  80632. private _localRotation;
  80633. private _localPosition;
  80634. private _needToDecompose;
  80635. private _needToCompose;
  80636. /** @hidden */
  80637. _linkedTransformNode: Nullable<TransformNode>;
  80638. /** @hidden */
  80639. _waitingTransformNodeId: Nullable<string>;
  80640. /** @hidden */
  80641. /** @hidden */
  80642. _matrix: Matrix;
  80643. /**
  80644. * Create a new bone
  80645. * @param name defines the bone name
  80646. * @param skeleton defines the parent skeleton
  80647. * @param parentBone defines the parent (can be null if the bone is the root)
  80648. * @param localMatrix defines the local matrix
  80649. * @param restPose defines the rest pose matrix
  80650. * @param baseMatrix defines the base matrix
  80651. * @param index defines index of the bone in the hiearchy
  80652. */
  80653. constructor(
  80654. /**
  80655. * defines the bone name
  80656. */
  80657. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80658. /**
  80659. * Gets the current object class name.
  80660. * @return the class name
  80661. */
  80662. getClassName(): string;
  80663. /**
  80664. * Gets the parent skeleton
  80665. * @returns a skeleton
  80666. */
  80667. getSkeleton(): Skeleton;
  80668. /**
  80669. * Gets parent bone
  80670. * @returns a bone or null if the bone is the root of the bone hierarchy
  80671. */
  80672. getParent(): Nullable<Bone>;
  80673. /**
  80674. * Returns an array containing the root bones
  80675. * @returns an array containing the root bones
  80676. */
  80677. getChildren(): Array<Bone>;
  80678. /**
  80679. * Sets the parent bone
  80680. * @param parent defines the parent (can be null if the bone is the root)
  80681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80682. */
  80683. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80684. /**
  80685. * Gets the local matrix
  80686. * @returns a matrix
  80687. */
  80688. getLocalMatrix(): Matrix;
  80689. /**
  80690. * Gets the base matrix (initial matrix which remains unchanged)
  80691. * @returns a matrix
  80692. */
  80693. getBaseMatrix(): Matrix;
  80694. /**
  80695. * Gets the rest pose matrix
  80696. * @returns a matrix
  80697. */
  80698. getRestPose(): Matrix;
  80699. /**
  80700. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80701. */
  80702. getWorldMatrix(): Matrix;
  80703. /**
  80704. * Sets the local matrix to rest pose matrix
  80705. */
  80706. returnToRest(): void;
  80707. /**
  80708. * Gets the inverse of the absolute transform matrix.
  80709. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80710. * @returns a matrix
  80711. */
  80712. getInvertedAbsoluteTransform(): Matrix;
  80713. /**
  80714. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80715. * @returns a matrix
  80716. */
  80717. getAbsoluteTransform(): Matrix;
  80718. /**
  80719. * Links with the given transform node.
  80720. * The local matrix of this bone is copied from the transform node every frame.
  80721. * @param transformNode defines the transform node to link to
  80722. */
  80723. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80724. /**
  80725. * Gets the node used to drive the bone's transformation
  80726. * @returns a transform node or null
  80727. */
  80728. getTransformNode(): Nullable<TransformNode>;
  80729. /** Gets or sets current position (in local space) */
  80730. position: Vector3;
  80731. /** Gets or sets current rotation (in local space) */
  80732. rotation: Vector3;
  80733. /** Gets or sets current rotation quaternion (in local space) */
  80734. rotationQuaternion: Quaternion;
  80735. /** Gets or sets current scaling (in local space) */
  80736. scaling: Vector3;
  80737. /**
  80738. * Gets the animation properties override
  80739. */
  80740. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80741. private _decompose;
  80742. private _compose;
  80743. /**
  80744. * Update the base and local matrices
  80745. * @param matrix defines the new base or local matrix
  80746. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80747. * @param updateLocalMatrix defines if the local matrix should be updated
  80748. */
  80749. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80750. /** @hidden */
  80751. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80752. /**
  80753. * Flag the bone as dirty (Forcing it to update everything)
  80754. */
  80755. markAsDirty(): void;
  80756. /** @hidden */
  80757. _markAsDirtyAndCompose(): void;
  80758. private _markAsDirtyAndDecompose;
  80759. /**
  80760. * Translate the bone in local or world space
  80761. * @param vec The amount to translate the bone
  80762. * @param space The space that the translation is in
  80763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80764. */
  80765. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80766. /**
  80767. * Set the postion of the bone in local or world space
  80768. * @param position The position to set the bone
  80769. * @param space The space that the position is in
  80770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80771. */
  80772. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80773. /**
  80774. * Set the absolute position of the bone (world space)
  80775. * @param position The position to set the bone
  80776. * @param mesh The mesh that this bone is attached to
  80777. */
  80778. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80779. /**
  80780. * Scale the bone on the x, y and z axes (in local space)
  80781. * @param x The amount to scale the bone on the x axis
  80782. * @param y The amount to scale the bone on the y axis
  80783. * @param z The amount to scale the bone on the z axis
  80784. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80785. */
  80786. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80787. /**
  80788. * Set the bone scaling in local space
  80789. * @param scale defines the scaling vector
  80790. */
  80791. setScale(scale: Vector3): void;
  80792. /**
  80793. * Gets the current scaling in local space
  80794. * @returns the current scaling vector
  80795. */
  80796. getScale(): Vector3;
  80797. /**
  80798. * Gets the current scaling in local space and stores it in a target vector
  80799. * @param result defines the target vector
  80800. */
  80801. getScaleToRef(result: Vector3): void;
  80802. /**
  80803. * Set the yaw, pitch, and roll of the bone in local or world space
  80804. * @param yaw The rotation of the bone on the y axis
  80805. * @param pitch The rotation of the bone on the x axis
  80806. * @param roll The rotation of the bone on the z axis
  80807. * @param space The space that the axes of rotation are in
  80808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80809. */
  80810. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80811. /**
  80812. * Add a rotation to the bone on an axis in local or world space
  80813. * @param axis The axis to rotate the bone on
  80814. * @param amount The amount to rotate the bone
  80815. * @param space The space that the axis is in
  80816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80817. */
  80818. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80819. /**
  80820. * Set the rotation of the bone to a particular axis angle in local or world space
  80821. * @param axis The axis to rotate the bone on
  80822. * @param angle The angle that the bone should be rotated to
  80823. * @param space The space that the axis is in
  80824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80825. */
  80826. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80827. /**
  80828. * Set the euler rotation of the bone in local of world space
  80829. * @param rotation The euler rotation that the bone should be set to
  80830. * @param space The space that the rotation is in
  80831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80832. */
  80833. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80834. /**
  80835. * Set the quaternion rotation of the bone in local of world space
  80836. * @param quat The quaternion rotation that the bone should be set to
  80837. * @param space The space that the rotation is in
  80838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80839. */
  80840. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80841. /**
  80842. * Set the rotation matrix of the bone in local of world space
  80843. * @param rotMat The rotation matrix that the bone should be set to
  80844. * @param space The space that the rotation is in
  80845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80846. */
  80847. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80848. private _rotateWithMatrix;
  80849. private _getNegativeRotationToRef;
  80850. /**
  80851. * Get the position of the bone in local or world space
  80852. * @param space The space that the returned position is in
  80853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80854. * @returns The position of the bone
  80855. */
  80856. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80857. /**
  80858. * Copy the position of the bone to a vector3 in local or world space
  80859. * @param space The space that the returned position is in
  80860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80861. * @param result The vector3 to copy the position to
  80862. */
  80863. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80864. /**
  80865. * Get the absolute position of the bone (world space)
  80866. * @param mesh The mesh that this bone is attached to
  80867. * @returns The absolute position of the bone
  80868. */
  80869. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80870. /**
  80871. * Copy the absolute position of the bone (world space) to the result param
  80872. * @param mesh The mesh that this bone is attached to
  80873. * @param result The vector3 to copy the absolute position to
  80874. */
  80875. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80876. /**
  80877. * Compute the absolute transforms of this bone and its children
  80878. */
  80879. computeAbsoluteTransforms(): void;
  80880. /**
  80881. * Get the world direction from an axis that is in the local space of the bone
  80882. * @param localAxis The local direction that is used to compute the world direction
  80883. * @param mesh The mesh that this bone is attached to
  80884. * @returns The world direction
  80885. */
  80886. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80887. /**
  80888. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80889. * @param localAxis The local direction that is used to compute the world direction
  80890. * @param mesh The mesh that this bone is attached to
  80891. * @param result The vector3 that the world direction will be copied to
  80892. */
  80893. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80894. /**
  80895. * Get the euler rotation of the bone in local or world space
  80896. * @param space The space that the rotation should be in
  80897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80898. * @returns The euler rotation
  80899. */
  80900. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80901. /**
  80902. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80903. * @param space The space that the rotation should be in
  80904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80905. * @param result The vector3 that the rotation should be copied to
  80906. */
  80907. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80908. /**
  80909. * Get the quaternion rotation of the bone in either local or world space
  80910. * @param space The space that the rotation should be in
  80911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80912. * @returns The quaternion rotation
  80913. */
  80914. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80915. /**
  80916. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80917. * @param space The space that the rotation should be in
  80918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80919. * @param result The quaternion that the rotation should be copied to
  80920. */
  80921. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80922. /**
  80923. * Get the rotation matrix of the bone in local or world space
  80924. * @param space The space that the rotation should be in
  80925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80926. * @returns The rotation matrix
  80927. */
  80928. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80929. /**
  80930. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80931. * @param space The space that the rotation should be in
  80932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80933. * @param result The quaternion that the rotation should be copied to
  80934. */
  80935. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80936. /**
  80937. * Get the world position of a point that is in the local space of the bone
  80938. * @param position The local position
  80939. * @param mesh The mesh that this bone is attached to
  80940. * @returns The world position
  80941. */
  80942. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80943. /**
  80944. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80945. * @param position The local position
  80946. * @param mesh The mesh that this bone is attached to
  80947. * @param result The vector3 that the world position should be copied to
  80948. */
  80949. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80950. /**
  80951. * Get the local position of a point that is in world space
  80952. * @param position The world position
  80953. * @param mesh The mesh that this bone is attached to
  80954. * @returns The local position
  80955. */
  80956. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80957. /**
  80958. * Get the local position of a point that is in world space and copy it to the result param
  80959. * @param position The world position
  80960. * @param mesh The mesh that this bone is attached to
  80961. * @param result The vector3 that the local position should be copied to
  80962. */
  80963. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80964. }
  80965. }
  80966. declare module BABYLON {
  80967. /**
  80968. * 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.
  80969. * @see https://doc.babylonjs.com/how_to/transformnode
  80970. */
  80971. export class TransformNode extends Node {
  80972. /**
  80973. * Object will not rotate to face the camera
  80974. */
  80975. static BILLBOARDMODE_NONE: number;
  80976. /**
  80977. * Object will rotate to face the camera but only on the x axis
  80978. */
  80979. static BILLBOARDMODE_X: number;
  80980. /**
  80981. * Object will rotate to face the camera but only on the y axis
  80982. */
  80983. static BILLBOARDMODE_Y: number;
  80984. /**
  80985. * Object will rotate to face the camera but only on the z axis
  80986. */
  80987. static BILLBOARDMODE_Z: number;
  80988. /**
  80989. * Object will rotate to face the camera
  80990. */
  80991. static BILLBOARDMODE_ALL: number;
  80992. /**
  80993. * Object will rotate to face the camera's position instead of orientation
  80994. */
  80995. static BILLBOARDMODE_USE_POSITION: number;
  80996. private _forward;
  80997. private _forwardInverted;
  80998. private _up;
  80999. private _right;
  81000. private _rightInverted;
  81001. private _position;
  81002. private _rotation;
  81003. private _rotationQuaternion;
  81004. protected _scaling: Vector3;
  81005. protected _isDirty: boolean;
  81006. private _transformToBoneReferal;
  81007. private _isAbsoluteSynced;
  81008. private _billboardMode;
  81009. /**
  81010. * Gets or sets the billboard mode. Default is 0.
  81011. *
  81012. * | Value | Type | Description |
  81013. * | --- | --- | --- |
  81014. * | 0 | BILLBOARDMODE_NONE | |
  81015. * | 1 | BILLBOARDMODE_X | |
  81016. * | 2 | BILLBOARDMODE_Y | |
  81017. * | 4 | BILLBOARDMODE_Z | |
  81018. * | 7 | BILLBOARDMODE_ALL | |
  81019. *
  81020. */
  81021. billboardMode: number;
  81022. private _preserveParentRotationForBillboard;
  81023. /**
  81024. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81025. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81026. */
  81027. preserveParentRotationForBillboard: boolean;
  81028. /**
  81029. * 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
  81030. */
  81031. scalingDeterminant: number;
  81032. private _infiniteDistance;
  81033. /**
  81034. * Gets or sets the distance of the object to max, often used by skybox
  81035. */
  81036. infiniteDistance: boolean;
  81037. /**
  81038. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81039. * By default the system will update normals to compensate
  81040. */
  81041. ignoreNonUniformScaling: boolean;
  81042. /**
  81043. * 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
  81044. */
  81045. reIntegrateRotationIntoRotationQuaternion: boolean;
  81046. /** @hidden */
  81047. _poseMatrix: Nullable<Matrix>;
  81048. /** @hidden */
  81049. _localMatrix: Matrix;
  81050. private _usePivotMatrix;
  81051. private _absolutePosition;
  81052. private _absoluteScaling;
  81053. private _absoluteRotationQuaternion;
  81054. private _pivotMatrix;
  81055. private _pivotMatrixInverse;
  81056. protected _postMultiplyPivotMatrix: boolean;
  81057. protected _isWorldMatrixFrozen: boolean;
  81058. /** @hidden */
  81059. _indexInSceneTransformNodesArray: number;
  81060. /**
  81061. * An event triggered after the world matrix is updated
  81062. */
  81063. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81064. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81065. /**
  81066. * Gets a string identifying the name of the class
  81067. * @returns "TransformNode" string
  81068. */
  81069. getClassName(): string;
  81070. /**
  81071. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81072. */
  81073. position: Vector3;
  81074. /**
  81075. * 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)).
  81076. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81077. */
  81078. rotation: Vector3;
  81079. /**
  81080. * 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)).
  81081. */
  81082. scaling: Vector3;
  81083. /**
  81084. * 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).
  81085. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81086. */
  81087. rotationQuaternion: Nullable<Quaternion>;
  81088. /**
  81089. * The forward direction of that transform in world space.
  81090. */
  81091. readonly forward: Vector3;
  81092. /**
  81093. * The up direction of that transform in world space.
  81094. */
  81095. readonly up: Vector3;
  81096. /**
  81097. * The right direction of that transform in world space.
  81098. */
  81099. readonly right: Vector3;
  81100. /**
  81101. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81102. * @param matrix the matrix to copy the pose from
  81103. * @returns this TransformNode.
  81104. */
  81105. updatePoseMatrix(matrix: Matrix): TransformNode;
  81106. /**
  81107. * Returns the mesh Pose matrix.
  81108. * @returns the pose matrix
  81109. */
  81110. getPoseMatrix(): Matrix;
  81111. /** @hidden */
  81112. _isSynchronized(): boolean;
  81113. /** @hidden */
  81114. _initCache(): void;
  81115. /**
  81116. * Flag the transform node as dirty (Forcing it to update everything)
  81117. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81118. * @returns this transform node
  81119. */
  81120. markAsDirty(property: string): TransformNode;
  81121. /**
  81122. * Returns the current mesh absolute position.
  81123. * Returns a Vector3.
  81124. */
  81125. readonly absolutePosition: Vector3;
  81126. /**
  81127. * Returns the current mesh absolute scaling.
  81128. * Returns a Vector3.
  81129. */
  81130. readonly absoluteScaling: Vector3;
  81131. /**
  81132. * Returns the current mesh absolute rotation.
  81133. * Returns a Quaternion.
  81134. */
  81135. readonly absoluteRotationQuaternion: Quaternion;
  81136. /**
  81137. * Sets a new matrix to apply before all other transformation
  81138. * @param matrix defines the transform matrix
  81139. * @returns the current TransformNode
  81140. */
  81141. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81142. /**
  81143. * Sets a new pivot matrix to the current node
  81144. * @param matrix defines the new pivot matrix to use
  81145. * @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
  81146. * @returns the current TransformNode
  81147. */
  81148. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81149. /**
  81150. * Returns the mesh pivot matrix.
  81151. * Default : Identity.
  81152. * @returns the matrix
  81153. */
  81154. getPivotMatrix(): Matrix;
  81155. /**
  81156. * Instantiate (when possible) or clone that node with its hierarchy
  81157. * @param newParent defines the new parent to use for the instance (or clone)
  81158. * @returns an instance (or a clone) of the current node with its hiearchy
  81159. */
  81160. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81161. /**
  81162. * Prevents the World matrix to be computed any longer
  81163. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81164. * @returns the TransformNode.
  81165. */
  81166. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81167. /**
  81168. * Allows back the World matrix computation.
  81169. * @returns the TransformNode.
  81170. */
  81171. unfreezeWorldMatrix(): this;
  81172. /**
  81173. * True if the World matrix has been frozen.
  81174. */
  81175. readonly isWorldMatrixFrozen: boolean;
  81176. /**
  81177. * Retuns the mesh absolute position in the World.
  81178. * @returns a Vector3.
  81179. */
  81180. getAbsolutePosition(): Vector3;
  81181. /**
  81182. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81183. * @param absolutePosition the absolute position to set
  81184. * @returns the TransformNode.
  81185. */
  81186. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81187. /**
  81188. * Sets the mesh position in its local space.
  81189. * @param vector3 the position to set in localspace
  81190. * @returns the TransformNode.
  81191. */
  81192. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81193. /**
  81194. * Returns the mesh position in the local space from the current World matrix values.
  81195. * @returns a new Vector3.
  81196. */
  81197. getPositionExpressedInLocalSpace(): Vector3;
  81198. /**
  81199. * Translates the mesh along the passed Vector3 in its local space.
  81200. * @param vector3 the distance to translate in localspace
  81201. * @returns the TransformNode.
  81202. */
  81203. locallyTranslate(vector3: Vector3): TransformNode;
  81204. private static _lookAtVectorCache;
  81205. /**
  81206. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81207. * @param targetPoint the position (must be in same space as current mesh) to look at
  81208. * @param yawCor optional yaw (y-axis) correction in radians
  81209. * @param pitchCor optional pitch (x-axis) correction in radians
  81210. * @param rollCor optional roll (z-axis) correction in radians
  81211. * @param space the choosen space of the target
  81212. * @returns the TransformNode.
  81213. */
  81214. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81215. /**
  81216. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81217. * This Vector3 is expressed in the World space.
  81218. * @param localAxis axis to rotate
  81219. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81220. */
  81221. getDirection(localAxis: Vector3): Vector3;
  81222. /**
  81223. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81224. * localAxis is expressed in the mesh local space.
  81225. * result is computed in the Wordl space from the mesh World matrix.
  81226. * @param localAxis axis to rotate
  81227. * @param result the resulting transformnode
  81228. * @returns this TransformNode.
  81229. */
  81230. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81231. /**
  81232. * Sets this transform node rotation to the given local axis.
  81233. * @param localAxis the axis in local space
  81234. * @param yawCor optional yaw (y-axis) correction in radians
  81235. * @param pitchCor optional pitch (x-axis) correction in radians
  81236. * @param rollCor optional roll (z-axis) correction in radians
  81237. * @returns this TransformNode
  81238. */
  81239. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81240. /**
  81241. * Sets a new pivot point to the current node
  81242. * @param point defines the new pivot point to use
  81243. * @param space defines if the point is in world or local space (local by default)
  81244. * @returns the current TransformNode
  81245. */
  81246. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81247. /**
  81248. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81249. * @returns the pivot point
  81250. */
  81251. getPivotPoint(): Vector3;
  81252. /**
  81253. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81254. * @param result the vector3 to store the result
  81255. * @returns this TransformNode.
  81256. */
  81257. getPivotPointToRef(result: Vector3): TransformNode;
  81258. /**
  81259. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81260. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81261. */
  81262. getAbsolutePivotPoint(): Vector3;
  81263. /**
  81264. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81265. * @param result vector3 to store the result
  81266. * @returns this TransformNode.
  81267. */
  81268. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81269. /**
  81270. * Defines the passed node as the parent of the current node.
  81271. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81272. * @see https://doc.babylonjs.com/how_to/parenting
  81273. * @param node the node ot set as the parent
  81274. * @returns this TransformNode.
  81275. */
  81276. setParent(node: Nullable<Node>): TransformNode;
  81277. private _nonUniformScaling;
  81278. /**
  81279. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81280. */
  81281. readonly nonUniformScaling: boolean;
  81282. /** @hidden */
  81283. _updateNonUniformScalingState(value: boolean): boolean;
  81284. /**
  81285. * Attach the current TransformNode to another TransformNode associated with a bone
  81286. * @param bone Bone affecting the TransformNode
  81287. * @param affectedTransformNode TransformNode associated with the bone
  81288. * @returns this object
  81289. */
  81290. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81291. /**
  81292. * Detach the transform node if its associated with a bone
  81293. * @returns this object
  81294. */
  81295. detachFromBone(): TransformNode;
  81296. private static _rotationAxisCache;
  81297. /**
  81298. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81299. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81300. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81301. * The passed axis is also normalized.
  81302. * @param axis the axis to rotate around
  81303. * @param amount the amount to rotate in radians
  81304. * @param space Space to rotate in (Default: local)
  81305. * @returns the TransformNode.
  81306. */
  81307. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81308. /**
  81309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81310. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81311. * The passed axis is also normalized. .
  81312. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81313. * @param point the point to rotate around
  81314. * @param axis the axis to rotate around
  81315. * @param amount the amount to rotate in radians
  81316. * @returns the TransformNode
  81317. */
  81318. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81319. /**
  81320. * Translates the mesh along the axis vector for the passed distance in the given space.
  81321. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81322. * @param axis the axis to translate in
  81323. * @param distance the distance to translate
  81324. * @param space Space to rotate in (Default: local)
  81325. * @returns the TransformNode.
  81326. */
  81327. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81328. /**
  81329. * Adds a rotation step to the mesh current rotation.
  81330. * x, y, z are Euler angles expressed in radians.
  81331. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81332. * This means this rotation is made in the mesh local space only.
  81333. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81334. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81335. * ```javascript
  81336. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81337. * ```
  81338. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81339. * 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.
  81340. * @param x Rotation to add
  81341. * @param y Rotation to add
  81342. * @param z Rotation to add
  81343. * @returns the TransformNode.
  81344. */
  81345. addRotation(x: number, y: number, z: number): TransformNode;
  81346. /**
  81347. * @hidden
  81348. */
  81349. protected _getEffectiveParent(): Nullable<Node>;
  81350. /**
  81351. * Computes the world matrix of the node
  81352. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81353. * @returns the world matrix
  81354. */
  81355. computeWorldMatrix(force?: boolean): Matrix;
  81356. protected _afterComputeWorldMatrix(): void;
  81357. /**
  81358. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81359. * @param func callback function to add
  81360. *
  81361. * @returns the TransformNode.
  81362. */
  81363. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81364. /**
  81365. * Removes a registered callback function.
  81366. * @param func callback function to remove
  81367. * @returns the TransformNode.
  81368. */
  81369. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81370. /**
  81371. * Gets the position of the current mesh in camera space
  81372. * @param camera defines the camera to use
  81373. * @returns a position
  81374. */
  81375. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81376. /**
  81377. * Returns the distance from the mesh to the active camera
  81378. * @param camera defines the camera to use
  81379. * @returns the distance
  81380. */
  81381. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81382. /**
  81383. * Clone the current transform node
  81384. * @param name Name of the new clone
  81385. * @param newParent New parent for the clone
  81386. * @param doNotCloneChildren Do not clone children hierarchy
  81387. * @returns the new transform node
  81388. */
  81389. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81390. /**
  81391. * Serializes the objects information.
  81392. * @param currentSerializationObject defines the object to serialize in
  81393. * @returns the serialized object
  81394. */
  81395. serialize(currentSerializationObject?: any): any;
  81396. /**
  81397. * Returns a new TransformNode object parsed from the source provided.
  81398. * @param parsedTransformNode is the source.
  81399. * @param scene the scne the object belongs to
  81400. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81401. * @returns a new TransformNode object parsed from the source provided.
  81402. */
  81403. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81404. /**
  81405. * Get all child-transformNodes of this node
  81406. * @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
  81407. * @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
  81408. * @returns an array of TransformNode
  81409. */
  81410. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81411. /**
  81412. * Releases resources associated with this transform node.
  81413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81415. */
  81416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81417. /**
  81418. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81419. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81420. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81421. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81422. * @returns the current mesh
  81423. */
  81424. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81425. private _syncAbsoluteScalingAndRotation;
  81426. }
  81427. }
  81428. declare module BABYLON {
  81429. /**
  81430. * Defines the types of pose enabled controllers that are supported
  81431. */
  81432. export enum PoseEnabledControllerType {
  81433. /**
  81434. * HTC Vive
  81435. */
  81436. VIVE = 0,
  81437. /**
  81438. * Oculus Rift
  81439. */
  81440. OCULUS = 1,
  81441. /**
  81442. * Windows mixed reality
  81443. */
  81444. WINDOWS = 2,
  81445. /**
  81446. * Samsung gear VR
  81447. */
  81448. GEAR_VR = 3,
  81449. /**
  81450. * Google Daydream
  81451. */
  81452. DAYDREAM = 4,
  81453. /**
  81454. * Generic
  81455. */
  81456. GENERIC = 5
  81457. }
  81458. /**
  81459. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81460. */
  81461. export interface MutableGamepadButton {
  81462. /**
  81463. * Value of the button/trigger
  81464. */
  81465. value: number;
  81466. /**
  81467. * If the button/trigger is currently touched
  81468. */
  81469. touched: boolean;
  81470. /**
  81471. * If the button/trigger is currently pressed
  81472. */
  81473. pressed: boolean;
  81474. }
  81475. /**
  81476. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81477. * @hidden
  81478. */
  81479. export interface ExtendedGamepadButton extends GamepadButton {
  81480. /**
  81481. * If the button/trigger is currently pressed
  81482. */
  81483. readonly pressed: boolean;
  81484. /**
  81485. * If the button/trigger is currently touched
  81486. */
  81487. readonly touched: boolean;
  81488. /**
  81489. * Value of the button/trigger
  81490. */
  81491. readonly value: number;
  81492. }
  81493. /** @hidden */
  81494. export interface _GamePadFactory {
  81495. /**
  81496. * Returns wether or not the current gamepad can be created for this type of controller.
  81497. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81498. * @returns true if it can be created, otherwise false
  81499. */
  81500. canCreate(gamepadInfo: any): boolean;
  81501. /**
  81502. * Creates a new instance of the Gamepad.
  81503. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81504. * @returns the new gamepad instance
  81505. */
  81506. create(gamepadInfo: any): Gamepad;
  81507. }
  81508. /**
  81509. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81510. */
  81511. export class PoseEnabledControllerHelper {
  81512. /** @hidden */
  81513. static _ControllerFactories: _GamePadFactory[];
  81514. /** @hidden */
  81515. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81516. /**
  81517. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81518. * @param vrGamepad the gamepad to initialized
  81519. * @returns a vr controller of the type the gamepad identified as
  81520. */
  81521. static InitiateController(vrGamepad: any): Gamepad;
  81522. }
  81523. /**
  81524. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81525. */
  81526. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81527. /**
  81528. * If the controller is used in a webXR session
  81529. */
  81530. isXR: boolean;
  81531. private _deviceRoomPosition;
  81532. private _deviceRoomRotationQuaternion;
  81533. /**
  81534. * The device position in babylon space
  81535. */
  81536. devicePosition: Vector3;
  81537. /**
  81538. * The device rotation in babylon space
  81539. */
  81540. deviceRotationQuaternion: Quaternion;
  81541. /**
  81542. * The scale factor of the device in babylon space
  81543. */
  81544. deviceScaleFactor: number;
  81545. /**
  81546. * (Likely devicePosition should be used instead) The device position in its room space
  81547. */
  81548. position: Vector3;
  81549. /**
  81550. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81551. */
  81552. rotationQuaternion: Quaternion;
  81553. /**
  81554. * The type of controller (Eg. Windows mixed reality)
  81555. */
  81556. controllerType: PoseEnabledControllerType;
  81557. protected _calculatedPosition: Vector3;
  81558. private _calculatedRotation;
  81559. /**
  81560. * The raw pose from the device
  81561. */
  81562. rawPose: DevicePose;
  81563. private _trackPosition;
  81564. private _maxRotationDistFromHeadset;
  81565. private _draggedRoomRotation;
  81566. /**
  81567. * @hidden
  81568. */
  81569. _disableTrackPosition(fixedPosition: Vector3): void;
  81570. /**
  81571. * Internal, the mesh attached to the controller
  81572. * @hidden
  81573. */
  81574. _mesh: Nullable<AbstractMesh>;
  81575. private _poseControlledCamera;
  81576. private _leftHandSystemQuaternion;
  81577. /**
  81578. * Internal, matrix used to convert room space to babylon space
  81579. * @hidden
  81580. */
  81581. _deviceToWorld: Matrix;
  81582. /**
  81583. * Node to be used when casting a ray from the controller
  81584. * @hidden
  81585. */
  81586. _pointingPoseNode: Nullable<TransformNode>;
  81587. /**
  81588. * Name of the child mesh that can be used to cast a ray from the controller
  81589. */
  81590. static readonly POINTING_POSE: string;
  81591. /**
  81592. * Creates a new PoseEnabledController from a gamepad
  81593. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81594. */
  81595. constructor(browserGamepad: any);
  81596. private _workingMatrix;
  81597. /**
  81598. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81599. */
  81600. update(): void;
  81601. /**
  81602. * Updates only the pose device and mesh without doing any button event checking
  81603. */
  81604. protected _updatePoseAndMesh(): void;
  81605. /**
  81606. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81607. * @param poseData raw pose fromthe device
  81608. */
  81609. updateFromDevice(poseData: DevicePose): void;
  81610. /**
  81611. * @hidden
  81612. */
  81613. _meshAttachedObservable: Observable<AbstractMesh>;
  81614. /**
  81615. * Attaches a mesh to the controller
  81616. * @param mesh the mesh to be attached
  81617. */
  81618. attachToMesh(mesh: AbstractMesh): void;
  81619. /**
  81620. * Attaches the controllers mesh to a camera
  81621. * @param camera the camera the mesh should be attached to
  81622. */
  81623. attachToPoseControlledCamera(camera: TargetCamera): void;
  81624. /**
  81625. * Disposes of the controller
  81626. */
  81627. dispose(): void;
  81628. /**
  81629. * The mesh that is attached to the controller
  81630. */
  81631. readonly mesh: Nullable<AbstractMesh>;
  81632. /**
  81633. * Gets the ray of the controller in the direction the controller is pointing
  81634. * @param length the length the resulting ray should be
  81635. * @returns a ray in the direction the controller is pointing
  81636. */
  81637. getForwardRay(length?: number): Ray;
  81638. }
  81639. }
  81640. declare module BABYLON {
  81641. /**
  81642. * Defines the WebVRController object that represents controllers tracked in 3D space
  81643. */
  81644. export abstract class WebVRController extends PoseEnabledController {
  81645. /**
  81646. * Internal, the default controller model for the controller
  81647. */
  81648. protected _defaultModel: Nullable<AbstractMesh>;
  81649. /**
  81650. * Fired when the trigger state has changed
  81651. */
  81652. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81653. /**
  81654. * Fired when the main button state has changed
  81655. */
  81656. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81657. /**
  81658. * Fired when the secondary button state has changed
  81659. */
  81660. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81661. /**
  81662. * Fired when the pad state has changed
  81663. */
  81664. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81665. /**
  81666. * Fired when controllers stick values have changed
  81667. */
  81668. onPadValuesChangedObservable: Observable<StickValues>;
  81669. /**
  81670. * Array of button availible on the controller
  81671. */
  81672. protected _buttons: Array<MutableGamepadButton>;
  81673. private _onButtonStateChange;
  81674. /**
  81675. * Fired when a controller button's state has changed
  81676. * @param callback the callback containing the button that was modified
  81677. */
  81678. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81679. /**
  81680. * X and Y axis corresponding to the controllers joystick
  81681. */
  81682. pad: StickValues;
  81683. /**
  81684. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81685. */
  81686. hand: string;
  81687. /**
  81688. * The default controller model for the controller
  81689. */
  81690. readonly defaultModel: Nullable<AbstractMesh>;
  81691. /**
  81692. * Creates a new WebVRController from a gamepad
  81693. * @param vrGamepad the gamepad that the WebVRController should be created from
  81694. */
  81695. constructor(vrGamepad: any);
  81696. /**
  81697. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81698. */
  81699. update(): void;
  81700. /**
  81701. * Function to be called when a button is modified
  81702. */
  81703. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81704. /**
  81705. * Loads a mesh and attaches it to the controller
  81706. * @param scene the scene the mesh should be added to
  81707. * @param meshLoaded callback for when the mesh has been loaded
  81708. */
  81709. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81710. private _setButtonValue;
  81711. private _changes;
  81712. private _checkChanges;
  81713. /**
  81714. * Disposes of th webVRCOntroller
  81715. */
  81716. dispose(): void;
  81717. }
  81718. }
  81719. declare module BABYLON {
  81720. /**
  81721. * The HemisphericLight simulates the ambient environment light,
  81722. * so the passed direction is the light reflection direction, not the incoming direction.
  81723. */
  81724. export class HemisphericLight extends Light {
  81725. /**
  81726. * The groundColor is the light in the opposite direction to the one specified during creation.
  81727. * 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.
  81728. */
  81729. groundColor: Color3;
  81730. /**
  81731. * The light reflection direction, not the incoming direction.
  81732. */
  81733. direction: Vector3;
  81734. /**
  81735. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81736. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81737. * The HemisphericLight can't cast shadows.
  81738. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81739. * @param name The friendly name of the light
  81740. * @param direction The direction of the light reflection
  81741. * @param scene The scene the light belongs to
  81742. */
  81743. constructor(name: string, direction: Vector3, scene: Scene);
  81744. protected _buildUniformLayout(): void;
  81745. /**
  81746. * Returns the string "HemisphericLight".
  81747. * @return The class name
  81748. */
  81749. getClassName(): string;
  81750. /**
  81751. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81752. * Returns the updated direction.
  81753. * @param target The target the direction should point to
  81754. * @return The computed direction
  81755. */
  81756. setDirectionToTarget(target: Vector3): Vector3;
  81757. /**
  81758. * Returns the shadow generator associated to the light.
  81759. * @returns Always null for hemispheric lights because it does not support shadows.
  81760. */
  81761. getShadowGenerator(): Nullable<IShadowGenerator>;
  81762. /**
  81763. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81764. * @param effect The effect to update
  81765. * @param lightIndex The index of the light in the effect to update
  81766. * @returns The hemispheric light
  81767. */
  81768. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81769. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81770. /**
  81771. * Computes the world matrix of the node
  81772. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81773. * @param useWasUpdatedFlag defines a reserved property
  81774. * @returns the world matrix
  81775. */
  81776. computeWorldMatrix(): Matrix;
  81777. /**
  81778. * Returns the integer 3.
  81779. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81780. */
  81781. getTypeID(): number;
  81782. /**
  81783. * Prepares the list of defines specific to the light type.
  81784. * @param defines the list of defines
  81785. * @param lightIndex defines the index of the light for the effect
  81786. */
  81787. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81788. }
  81789. }
  81790. declare module BABYLON {
  81791. /** @hidden */
  81792. export var vrMultiviewToSingleviewPixelShader: {
  81793. name: string;
  81794. shader: string;
  81795. };
  81796. }
  81797. declare module BABYLON {
  81798. /**
  81799. * Renders to multiple views with a single draw call
  81800. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81801. */
  81802. export class MultiviewRenderTarget extends RenderTargetTexture {
  81803. /**
  81804. * Creates a multiview render target
  81805. * @param scene scene used with the render target
  81806. * @param size the size of the render target (used for each view)
  81807. */
  81808. constructor(scene: Scene, size?: number | {
  81809. width: number;
  81810. height: number;
  81811. } | {
  81812. ratio: number;
  81813. });
  81814. /**
  81815. * @hidden
  81816. * @param faceIndex the face index, if its a cube texture
  81817. */
  81818. _bindFrameBuffer(faceIndex?: number): void;
  81819. /**
  81820. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81821. * @returns the view count
  81822. */
  81823. getViewCount(): number;
  81824. }
  81825. }
  81826. declare module BABYLON {
  81827. /**
  81828. * Represents a camera frustum
  81829. */
  81830. export class Frustum {
  81831. /**
  81832. * Gets the planes representing the frustum
  81833. * @param transform matrix to be applied to the returned planes
  81834. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81835. */
  81836. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81837. /**
  81838. * Gets the near frustum plane transformed by the transform matrix
  81839. * @param transform transformation matrix to be applied to the resulting frustum plane
  81840. * @param frustumPlane the resuling frustum plane
  81841. */
  81842. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81843. /**
  81844. * Gets the far frustum plane transformed by the transform matrix
  81845. * @param transform transformation matrix to be applied to the resulting frustum plane
  81846. * @param frustumPlane the resuling frustum plane
  81847. */
  81848. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81849. /**
  81850. * Gets the left frustum plane transformed by the transform matrix
  81851. * @param transform transformation matrix to be applied to the resulting frustum plane
  81852. * @param frustumPlane the resuling frustum plane
  81853. */
  81854. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81855. /**
  81856. * Gets the right frustum plane transformed by the transform matrix
  81857. * @param transform transformation matrix to be applied to the resulting frustum plane
  81858. * @param frustumPlane the resuling frustum plane
  81859. */
  81860. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81861. /**
  81862. * Gets the top frustum plane transformed by the transform matrix
  81863. * @param transform transformation matrix to be applied to the resulting frustum plane
  81864. * @param frustumPlane the resuling frustum plane
  81865. */
  81866. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81867. /**
  81868. * Gets the bottom frustum plane transformed by the transform matrix
  81869. * @param transform transformation matrix to be applied to the resulting frustum plane
  81870. * @param frustumPlane the resuling frustum plane
  81871. */
  81872. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81873. /**
  81874. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81875. * @param transform transformation matrix to be applied to the resulting frustum planes
  81876. * @param frustumPlanes the resuling frustum planes
  81877. */
  81878. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81879. }
  81880. }
  81881. declare module BABYLON {
  81882. interface Engine {
  81883. /**
  81884. * Creates a new multiview render target
  81885. * @param width defines the width of the texture
  81886. * @param height defines the height of the texture
  81887. * @returns the created multiview texture
  81888. */
  81889. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81890. /**
  81891. * Binds a multiview framebuffer to be drawn to
  81892. * @param multiviewTexture texture to bind
  81893. */
  81894. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81895. }
  81896. interface Camera {
  81897. /**
  81898. * @hidden
  81899. * 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)
  81900. */
  81901. _useMultiviewToSingleView: boolean;
  81902. /**
  81903. * @hidden
  81904. * 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)
  81905. */
  81906. _multiviewTexture: Nullable<RenderTargetTexture>;
  81907. /**
  81908. * @hidden
  81909. * ensures the multiview texture of the camera exists and has the specified width/height
  81910. * @param width height to set on the multiview texture
  81911. * @param height width to set on the multiview texture
  81912. */
  81913. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81914. }
  81915. interface Scene {
  81916. /** @hidden */
  81917. _transformMatrixR: Matrix;
  81918. /** @hidden */
  81919. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81920. /** @hidden */
  81921. _createMultiviewUbo(): void;
  81922. /** @hidden */
  81923. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81924. /** @hidden */
  81925. _renderMultiviewToSingleView(camera: Camera): void;
  81926. }
  81927. }
  81928. declare module BABYLON {
  81929. /**
  81930. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81931. * This will not be used for webXR as it supports displaying texture arrays directly
  81932. */
  81933. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81934. /**
  81935. * Initializes a VRMultiviewToSingleview
  81936. * @param name name of the post process
  81937. * @param camera camera to be applied to
  81938. * @param scaleFactor scaling factor to the size of the output texture
  81939. */
  81940. constructor(name: string, camera: Camera, scaleFactor: number);
  81941. }
  81942. }
  81943. declare module BABYLON {
  81944. interface Engine {
  81945. /** @hidden */
  81946. _vrDisplay: any;
  81947. /** @hidden */
  81948. _vrSupported: boolean;
  81949. /** @hidden */
  81950. _oldSize: Size;
  81951. /** @hidden */
  81952. _oldHardwareScaleFactor: number;
  81953. /** @hidden */
  81954. _vrExclusivePointerMode: boolean;
  81955. /** @hidden */
  81956. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81957. /** @hidden */
  81958. _onVRDisplayPointerRestricted: () => void;
  81959. /** @hidden */
  81960. _onVRDisplayPointerUnrestricted: () => void;
  81961. /** @hidden */
  81962. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81963. /** @hidden */
  81964. _onVrDisplayDisconnect: Nullable<() => void>;
  81965. /** @hidden */
  81966. _onVrDisplayPresentChange: Nullable<() => void>;
  81967. /**
  81968. * Observable signaled when VR display mode changes
  81969. */
  81970. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81971. /**
  81972. * Observable signaled when VR request present is complete
  81973. */
  81974. onVRRequestPresentComplete: Observable<boolean>;
  81975. /**
  81976. * Observable signaled when VR request present starts
  81977. */
  81978. onVRRequestPresentStart: Observable<Engine>;
  81979. /**
  81980. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81981. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81982. */
  81983. isInVRExclusivePointerMode: boolean;
  81984. /**
  81985. * Gets a boolean indicating if a webVR device was detected
  81986. * @returns true if a webVR device was detected
  81987. */
  81988. isVRDevicePresent(): boolean;
  81989. /**
  81990. * Gets the current webVR device
  81991. * @returns the current webVR device (or null)
  81992. */
  81993. getVRDevice(): any;
  81994. /**
  81995. * Initializes a webVR display and starts listening to display change events
  81996. * The onVRDisplayChangedObservable will be notified upon these changes
  81997. * @returns A promise containing a VRDisplay and if vr is supported
  81998. */
  81999. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82000. /** @hidden */
  82001. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82002. /**
  82003. * Call this function to switch to webVR mode
  82004. * Will do nothing if webVR is not supported or if there is no webVR device
  82005. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82006. */
  82007. enableVR(): void;
  82008. /** @hidden */
  82009. _onVRFullScreenTriggered(): void;
  82010. }
  82011. }
  82012. declare module BABYLON {
  82013. /**
  82014. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82015. * IMPORTANT!! The data is right-hand data.
  82016. * @export
  82017. * @interface DevicePose
  82018. */
  82019. export interface DevicePose {
  82020. /**
  82021. * The position of the device, values in array are [x,y,z].
  82022. */
  82023. readonly position: Nullable<Float32Array>;
  82024. /**
  82025. * The linearVelocity of the device, values in array are [x,y,z].
  82026. */
  82027. readonly linearVelocity: Nullable<Float32Array>;
  82028. /**
  82029. * The linearAcceleration of the device, values in array are [x,y,z].
  82030. */
  82031. readonly linearAcceleration: Nullable<Float32Array>;
  82032. /**
  82033. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82034. */
  82035. readonly orientation: Nullable<Float32Array>;
  82036. /**
  82037. * The angularVelocity of the device, values in array are [x,y,z].
  82038. */
  82039. readonly angularVelocity: Nullable<Float32Array>;
  82040. /**
  82041. * The angularAcceleration of the device, values in array are [x,y,z].
  82042. */
  82043. readonly angularAcceleration: Nullable<Float32Array>;
  82044. }
  82045. /**
  82046. * Interface representing a pose controlled object in Babylon.
  82047. * A pose controlled object has both regular pose values as well as pose values
  82048. * from an external device such as a VR head mounted display
  82049. */
  82050. export interface PoseControlled {
  82051. /**
  82052. * The position of the object in babylon space.
  82053. */
  82054. position: Vector3;
  82055. /**
  82056. * The rotation quaternion of the object in babylon space.
  82057. */
  82058. rotationQuaternion: Quaternion;
  82059. /**
  82060. * The position of the device in babylon space.
  82061. */
  82062. devicePosition?: Vector3;
  82063. /**
  82064. * The rotation quaternion of the device in babylon space.
  82065. */
  82066. deviceRotationQuaternion: Quaternion;
  82067. /**
  82068. * The raw pose coming from the device.
  82069. */
  82070. rawPose: Nullable<DevicePose>;
  82071. /**
  82072. * The scale of the device to be used when translating from device space to babylon space.
  82073. */
  82074. deviceScaleFactor: number;
  82075. /**
  82076. * Updates the poseControlled values based on the input device pose.
  82077. * @param poseData the pose data to update the object with
  82078. */
  82079. updateFromDevice(poseData: DevicePose): void;
  82080. }
  82081. /**
  82082. * Set of options to customize the webVRCamera
  82083. */
  82084. export interface WebVROptions {
  82085. /**
  82086. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82087. */
  82088. trackPosition?: boolean;
  82089. /**
  82090. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82091. */
  82092. positionScale?: number;
  82093. /**
  82094. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82095. */
  82096. displayName?: string;
  82097. /**
  82098. * Should the native controller meshes be initialized. (default: true)
  82099. */
  82100. controllerMeshes?: boolean;
  82101. /**
  82102. * Creating a default HemiLight only on controllers. (default: true)
  82103. */
  82104. defaultLightingOnControllers?: boolean;
  82105. /**
  82106. * If you don't want to use the default VR button of the helper. (default: false)
  82107. */
  82108. useCustomVRButton?: boolean;
  82109. /**
  82110. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82111. */
  82112. customVRButton?: HTMLButtonElement;
  82113. /**
  82114. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82115. */
  82116. rayLength?: number;
  82117. /**
  82118. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82119. */
  82120. defaultHeight?: number;
  82121. /**
  82122. * If multiview should be used if availible (default: false)
  82123. */
  82124. useMultiview?: boolean;
  82125. }
  82126. /**
  82127. * This represents a WebVR camera.
  82128. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82129. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82130. */
  82131. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82132. private webVROptions;
  82133. /**
  82134. * @hidden
  82135. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82136. */
  82137. _vrDevice: any;
  82138. /**
  82139. * The rawPose of the vrDevice.
  82140. */
  82141. rawPose: Nullable<DevicePose>;
  82142. private _onVREnabled;
  82143. private _specsVersion;
  82144. private _attached;
  82145. private _frameData;
  82146. protected _descendants: Array<Node>;
  82147. private _deviceRoomPosition;
  82148. /** @hidden */
  82149. _deviceRoomRotationQuaternion: Quaternion;
  82150. private _standingMatrix;
  82151. /**
  82152. * Represents device position in babylon space.
  82153. */
  82154. devicePosition: Vector3;
  82155. /**
  82156. * Represents device rotation in babylon space.
  82157. */
  82158. deviceRotationQuaternion: Quaternion;
  82159. /**
  82160. * The scale of the device to be used when translating from device space to babylon space.
  82161. */
  82162. deviceScaleFactor: number;
  82163. private _deviceToWorld;
  82164. private _worldToDevice;
  82165. /**
  82166. * References to the webVR controllers for the vrDevice.
  82167. */
  82168. controllers: Array<WebVRController>;
  82169. /**
  82170. * Emits an event when a controller is attached.
  82171. */
  82172. onControllersAttachedObservable: Observable<WebVRController[]>;
  82173. /**
  82174. * Emits an event when a controller's mesh has been loaded;
  82175. */
  82176. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82177. /**
  82178. * Emits an event when the HMD's pose has been updated.
  82179. */
  82180. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82181. private _poseSet;
  82182. /**
  82183. * If the rig cameras be used as parent instead of this camera.
  82184. */
  82185. rigParenting: boolean;
  82186. private _lightOnControllers;
  82187. private _defaultHeight?;
  82188. /**
  82189. * Instantiates a WebVRFreeCamera.
  82190. * @param name The name of the WebVRFreeCamera
  82191. * @param position The starting anchor position for the camera
  82192. * @param scene The scene the camera belongs to
  82193. * @param webVROptions a set of customizable options for the webVRCamera
  82194. */
  82195. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82196. /**
  82197. * Gets the device distance from the ground in meters.
  82198. * @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.
  82199. */
  82200. deviceDistanceToRoomGround(): number;
  82201. /**
  82202. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82203. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82204. */
  82205. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82206. /**
  82207. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82208. * @returns A promise with a boolean set to if the standing matrix is supported.
  82209. */
  82210. useStandingMatrixAsync(): Promise<boolean>;
  82211. /**
  82212. * Disposes the camera
  82213. */
  82214. dispose(): void;
  82215. /**
  82216. * Gets a vrController by name.
  82217. * @param name The name of the controller to retreive
  82218. * @returns the controller matching the name specified or null if not found
  82219. */
  82220. getControllerByName(name: string): Nullable<WebVRController>;
  82221. private _leftController;
  82222. /**
  82223. * The controller corresponding to the users left hand.
  82224. */
  82225. readonly leftController: Nullable<WebVRController>;
  82226. private _rightController;
  82227. /**
  82228. * The controller corresponding to the users right hand.
  82229. */
  82230. readonly rightController: Nullable<WebVRController>;
  82231. /**
  82232. * Casts a ray forward from the vrCamera's gaze.
  82233. * @param length Length of the ray (default: 100)
  82234. * @returns the ray corresponding to the gaze
  82235. */
  82236. getForwardRay(length?: number): Ray;
  82237. /**
  82238. * @hidden
  82239. * Updates the camera based on device's frame data
  82240. */
  82241. _checkInputs(): void;
  82242. /**
  82243. * Updates the poseControlled values based on the input device pose.
  82244. * @param poseData Pose coming from the device
  82245. */
  82246. updateFromDevice(poseData: DevicePose): void;
  82247. private _htmlElementAttached;
  82248. private _detachIfAttached;
  82249. /**
  82250. * WebVR's attach control will start broadcasting frames to the device.
  82251. * Note that in certain browsers (chrome for example) this function must be called
  82252. * within a user-interaction callback. Example:
  82253. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82254. *
  82255. * @param element html element to attach the vrDevice to
  82256. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82257. */
  82258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82259. /**
  82260. * Detaches the camera from the html element and disables VR
  82261. *
  82262. * @param element html element to detach from
  82263. */
  82264. detachControl(element: HTMLElement): void;
  82265. /**
  82266. * @returns the name of this class
  82267. */
  82268. getClassName(): string;
  82269. /**
  82270. * Calls resetPose on the vrDisplay
  82271. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82272. */
  82273. resetToCurrentRotation(): void;
  82274. /**
  82275. * @hidden
  82276. * Updates the rig cameras (left and right eye)
  82277. */
  82278. _updateRigCameras(): void;
  82279. private _workingVector;
  82280. private _oneVector;
  82281. private _workingMatrix;
  82282. private updateCacheCalled;
  82283. private _correctPositionIfNotTrackPosition;
  82284. /**
  82285. * @hidden
  82286. * Updates the cached values of the camera
  82287. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82288. */
  82289. _updateCache(ignoreParentClass?: boolean): void;
  82290. /**
  82291. * @hidden
  82292. * Get current device position in babylon world
  82293. */
  82294. _computeDevicePosition(): void;
  82295. /**
  82296. * Updates the current device position and rotation in the babylon world
  82297. */
  82298. update(): void;
  82299. /**
  82300. * @hidden
  82301. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82302. * @returns an identity matrix
  82303. */
  82304. _getViewMatrix(): Matrix;
  82305. private _tmpMatrix;
  82306. /**
  82307. * This function is called by the two RIG cameras.
  82308. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82309. * @hidden
  82310. */
  82311. _getWebVRViewMatrix(): Matrix;
  82312. /** @hidden */
  82313. _getWebVRProjectionMatrix(): Matrix;
  82314. private _onGamepadConnectedObserver;
  82315. private _onGamepadDisconnectedObserver;
  82316. private _updateCacheWhenTrackingDisabledObserver;
  82317. /**
  82318. * Initializes the controllers and their meshes
  82319. */
  82320. initControllers(): void;
  82321. }
  82322. }
  82323. declare module BABYLON {
  82324. /**
  82325. * Size options for a post process
  82326. */
  82327. export type PostProcessOptions = {
  82328. width: number;
  82329. height: number;
  82330. };
  82331. /**
  82332. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82333. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82334. */
  82335. export class PostProcess {
  82336. /** Name of the PostProcess. */
  82337. name: string;
  82338. /**
  82339. * Gets or sets the unique id of the post process
  82340. */
  82341. uniqueId: number;
  82342. /**
  82343. * Width of the texture to apply the post process on
  82344. */
  82345. width: number;
  82346. /**
  82347. * Height of the texture to apply the post process on
  82348. */
  82349. height: number;
  82350. /**
  82351. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82352. * @hidden
  82353. */
  82354. _outputTexture: Nullable<InternalTexture>;
  82355. /**
  82356. * Sampling mode used by the shader
  82357. * See https://doc.babylonjs.com/classes/3.1/texture
  82358. */
  82359. renderTargetSamplingMode: number;
  82360. /**
  82361. * Clear color to use when screen clearing
  82362. */
  82363. clearColor: Color4;
  82364. /**
  82365. * If the buffer needs to be cleared before applying the post process. (default: true)
  82366. * Should be set to false if shader will overwrite all previous pixels.
  82367. */
  82368. autoClear: boolean;
  82369. /**
  82370. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82371. */
  82372. alphaMode: number;
  82373. /**
  82374. * Sets the setAlphaBlendConstants of the babylon engine
  82375. */
  82376. alphaConstants: Color4;
  82377. /**
  82378. * Animations to be used for the post processing
  82379. */
  82380. animations: Animation[];
  82381. /**
  82382. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82383. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82384. */
  82385. enablePixelPerfectMode: boolean;
  82386. /**
  82387. * Force the postprocess to be applied without taking in account viewport
  82388. */
  82389. forceFullscreenViewport: boolean;
  82390. /**
  82391. * List of inspectable custom properties (used by the Inspector)
  82392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82393. */
  82394. inspectableCustomProperties: IInspectable[];
  82395. /**
  82396. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82397. *
  82398. * | Value | Type | Description |
  82399. * | ----- | ----------------------------------- | ----------- |
  82400. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82401. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82402. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82403. *
  82404. */
  82405. scaleMode: number;
  82406. /**
  82407. * Force textures to be a power of two (default: false)
  82408. */
  82409. alwaysForcePOT: boolean;
  82410. private _samples;
  82411. /**
  82412. * Number of sample textures (default: 1)
  82413. */
  82414. samples: number;
  82415. /**
  82416. * Modify the scale of the post process to be the same as the viewport (default: false)
  82417. */
  82418. adaptScaleToCurrentViewport: boolean;
  82419. private _camera;
  82420. private _scene;
  82421. private _engine;
  82422. private _options;
  82423. private _reusable;
  82424. private _textureType;
  82425. /**
  82426. * Smart array of input and output textures for the post process.
  82427. * @hidden
  82428. */
  82429. _textures: SmartArray<InternalTexture>;
  82430. /**
  82431. * The index in _textures that corresponds to the output texture.
  82432. * @hidden
  82433. */
  82434. _currentRenderTextureInd: number;
  82435. private _effect;
  82436. private _samplers;
  82437. private _fragmentUrl;
  82438. private _vertexUrl;
  82439. private _parameters;
  82440. private _scaleRatio;
  82441. protected _indexParameters: any;
  82442. private _shareOutputWithPostProcess;
  82443. private _texelSize;
  82444. private _forcedOutputTexture;
  82445. /**
  82446. * Returns the fragment url or shader name used in the post process.
  82447. * @returns the fragment url or name in the shader store.
  82448. */
  82449. getEffectName(): string;
  82450. /**
  82451. * An event triggered when the postprocess is activated.
  82452. */
  82453. onActivateObservable: Observable<Camera>;
  82454. private _onActivateObserver;
  82455. /**
  82456. * A function that is added to the onActivateObservable
  82457. */
  82458. onActivate: Nullable<(camera: Camera) => void>;
  82459. /**
  82460. * An event triggered when the postprocess changes its size.
  82461. */
  82462. onSizeChangedObservable: Observable<PostProcess>;
  82463. private _onSizeChangedObserver;
  82464. /**
  82465. * A function that is added to the onSizeChangedObservable
  82466. */
  82467. onSizeChanged: (postProcess: PostProcess) => void;
  82468. /**
  82469. * An event triggered when the postprocess applies its effect.
  82470. */
  82471. onApplyObservable: Observable<Effect>;
  82472. private _onApplyObserver;
  82473. /**
  82474. * A function that is added to the onApplyObservable
  82475. */
  82476. onApply: (effect: Effect) => void;
  82477. /**
  82478. * An event triggered before rendering the postprocess
  82479. */
  82480. onBeforeRenderObservable: Observable<Effect>;
  82481. private _onBeforeRenderObserver;
  82482. /**
  82483. * A function that is added to the onBeforeRenderObservable
  82484. */
  82485. onBeforeRender: (effect: Effect) => void;
  82486. /**
  82487. * An event triggered after rendering the postprocess
  82488. */
  82489. onAfterRenderObservable: Observable<Effect>;
  82490. private _onAfterRenderObserver;
  82491. /**
  82492. * A function that is added to the onAfterRenderObservable
  82493. */
  82494. onAfterRender: (efect: Effect) => void;
  82495. /**
  82496. * 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
  82497. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82498. */
  82499. inputTexture: InternalTexture;
  82500. /**
  82501. * Gets the camera which post process is applied to.
  82502. * @returns The camera the post process is applied to.
  82503. */
  82504. getCamera(): Camera;
  82505. /**
  82506. * Gets the texel size of the postprocess.
  82507. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82508. */
  82509. readonly texelSize: Vector2;
  82510. /**
  82511. * Creates a new instance PostProcess
  82512. * @param name The name of the PostProcess.
  82513. * @param fragmentUrl The url of the fragment shader to be used.
  82514. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82515. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82516. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82517. * @param camera The camera to apply the render pass to.
  82518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82519. * @param engine The engine which the post process will be applied. (default: current engine)
  82520. * @param reusable If the post process can be reused on the same frame. (default: false)
  82521. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82522. * @param textureType Type of textures used when performing the post process. (default: 0)
  82523. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82524. * @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
  82525. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82526. */
  82527. constructor(
  82528. /** Name of the PostProcess. */
  82529. 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);
  82530. /**
  82531. * Gets a string idenfifying the name of the class
  82532. * @returns "PostProcess" string
  82533. */
  82534. getClassName(): string;
  82535. /**
  82536. * Gets the engine which this post process belongs to.
  82537. * @returns The engine the post process was enabled with.
  82538. */
  82539. getEngine(): Engine;
  82540. /**
  82541. * The effect that is created when initializing the post process.
  82542. * @returns The created effect corresponding the the postprocess.
  82543. */
  82544. getEffect(): Effect;
  82545. /**
  82546. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82547. * @param postProcess The post process to share the output with.
  82548. * @returns This post process.
  82549. */
  82550. shareOutputWith(postProcess: PostProcess): PostProcess;
  82551. /**
  82552. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82553. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82554. */
  82555. useOwnOutput(): void;
  82556. /**
  82557. * Updates the effect with the current post process compile time values and recompiles the shader.
  82558. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82559. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82560. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82561. * @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
  82562. * @param onCompiled Called when the shader has been compiled.
  82563. * @param onError Called if there is an error when compiling a shader.
  82564. */
  82565. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82566. /**
  82567. * The post process is reusable if it can be used multiple times within one frame.
  82568. * @returns If the post process is reusable
  82569. */
  82570. isReusable(): boolean;
  82571. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82572. markTextureDirty(): void;
  82573. /**
  82574. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82575. * 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.
  82576. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82577. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82578. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82579. * @returns The target texture that was bound to be written to.
  82580. */
  82581. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82582. /**
  82583. * If the post process is supported.
  82584. */
  82585. readonly isSupported: boolean;
  82586. /**
  82587. * The aspect ratio of the output texture.
  82588. */
  82589. readonly aspectRatio: number;
  82590. /**
  82591. * Get a value indicating if the post-process is ready to be used
  82592. * @returns true if the post-process is ready (shader is compiled)
  82593. */
  82594. isReady(): boolean;
  82595. /**
  82596. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82597. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82598. */
  82599. apply(): Nullable<Effect>;
  82600. private _disposeTextures;
  82601. /**
  82602. * Disposes the post process.
  82603. * @param camera The camera to dispose the post process on.
  82604. */
  82605. dispose(camera?: Camera): void;
  82606. }
  82607. }
  82608. declare module BABYLON {
  82609. /** @hidden */
  82610. export var kernelBlurVaryingDeclaration: {
  82611. name: string;
  82612. shader: string;
  82613. };
  82614. }
  82615. declare module BABYLON {
  82616. /** @hidden */
  82617. export var kernelBlurFragment: {
  82618. name: string;
  82619. shader: string;
  82620. };
  82621. }
  82622. declare module BABYLON {
  82623. /** @hidden */
  82624. export var kernelBlurFragment2: {
  82625. name: string;
  82626. shader: string;
  82627. };
  82628. }
  82629. declare module BABYLON {
  82630. /** @hidden */
  82631. export var kernelBlurPixelShader: {
  82632. name: string;
  82633. shader: string;
  82634. };
  82635. }
  82636. declare module BABYLON {
  82637. /** @hidden */
  82638. export var kernelBlurVertex: {
  82639. name: string;
  82640. shader: string;
  82641. };
  82642. }
  82643. declare module BABYLON {
  82644. /** @hidden */
  82645. export var kernelBlurVertexShader: {
  82646. name: string;
  82647. shader: string;
  82648. };
  82649. }
  82650. declare module BABYLON {
  82651. /**
  82652. * The Blur Post Process which blurs an image based on a kernel and direction.
  82653. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82654. */
  82655. export class BlurPostProcess extends PostProcess {
  82656. /** The direction in which to blur the image. */
  82657. direction: Vector2;
  82658. private blockCompilation;
  82659. protected _kernel: number;
  82660. protected _idealKernel: number;
  82661. protected _packedFloat: boolean;
  82662. private _staticDefines;
  82663. /**
  82664. * Sets the length in pixels of the blur sample region
  82665. */
  82666. /**
  82667. * Gets the length in pixels of the blur sample region
  82668. */
  82669. kernel: number;
  82670. /**
  82671. * Sets wether or not the blur needs to unpack/repack floats
  82672. */
  82673. /**
  82674. * Gets wether or not the blur is unpacking/repacking floats
  82675. */
  82676. packedFloat: boolean;
  82677. /**
  82678. * Creates a new instance BlurPostProcess
  82679. * @param name The name of the effect.
  82680. * @param direction The direction in which to blur the image.
  82681. * @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.
  82682. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82683. * @param camera The camera to apply the render pass to.
  82684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82685. * @param engine The engine which the post process will be applied. (default: current engine)
  82686. * @param reusable If the post process can be reused on the same frame. (default: false)
  82687. * @param textureType Type of textures used when performing the post process. (default: 0)
  82688. * @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)
  82689. */
  82690. constructor(name: string,
  82691. /** The direction in which to blur the image. */
  82692. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82693. /**
  82694. * Updates the effect with the current post process compile time values and recompiles the shader.
  82695. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82696. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82697. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82698. * @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
  82699. * @param onCompiled Called when the shader has been compiled.
  82700. * @param onError Called if there is an error when compiling a shader.
  82701. */
  82702. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82703. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82704. /**
  82705. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82706. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82707. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82708. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82709. * The gaps between physical kernels are compensated for in the weighting of the samples
  82710. * @param idealKernel Ideal blur kernel.
  82711. * @return Nearest best kernel.
  82712. */
  82713. protected _nearestBestKernel(idealKernel: number): number;
  82714. /**
  82715. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82716. * @param x The point on the Gaussian distribution to sample.
  82717. * @return the value of the Gaussian function at x.
  82718. */
  82719. protected _gaussianWeight(x: number): number;
  82720. /**
  82721. * Generates a string that can be used as a floating point number in GLSL.
  82722. * @param x Value to print.
  82723. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82724. * @return GLSL float string.
  82725. */
  82726. protected _glslFloat(x: number, decimalFigures?: number): string;
  82727. }
  82728. }
  82729. declare module BABYLON {
  82730. /**
  82731. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82732. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82733. * You can then easily use it as a reflectionTexture on a flat surface.
  82734. * In case the surface is not a plane, please consider relying on reflection probes.
  82735. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82736. */
  82737. export class MirrorTexture extends RenderTargetTexture {
  82738. private scene;
  82739. /**
  82740. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82741. * 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.
  82742. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82743. */
  82744. mirrorPlane: Plane;
  82745. /**
  82746. * Define the blur ratio used to blur the reflection if needed.
  82747. */
  82748. blurRatio: number;
  82749. /**
  82750. * Define the adaptive blur kernel used to blur the reflection if needed.
  82751. * This will autocompute the closest best match for the `blurKernel`
  82752. */
  82753. adaptiveBlurKernel: number;
  82754. /**
  82755. * Define the blur kernel used to blur the reflection if needed.
  82756. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82757. */
  82758. blurKernel: number;
  82759. /**
  82760. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82761. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82762. */
  82763. blurKernelX: number;
  82764. /**
  82765. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82767. */
  82768. blurKernelY: number;
  82769. private _autoComputeBlurKernel;
  82770. protected _onRatioRescale(): void;
  82771. private _updateGammaSpace;
  82772. private _imageProcessingConfigChangeObserver;
  82773. private _transformMatrix;
  82774. private _mirrorMatrix;
  82775. private _savedViewMatrix;
  82776. private _blurX;
  82777. private _blurY;
  82778. private _adaptiveBlurKernel;
  82779. private _blurKernelX;
  82780. private _blurKernelY;
  82781. private _blurRatio;
  82782. /**
  82783. * Instantiates a Mirror Texture.
  82784. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82785. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82786. * You can then easily use it as a reflectionTexture on a flat surface.
  82787. * In case the surface is not a plane, please consider relying on reflection probes.
  82788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82789. * @param name
  82790. * @param size
  82791. * @param scene
  82792. * @param generateMipMaps
  82793. * @param type
  82794. * @param samplingMode
  82795. * @param generateDepthBuffer
  82796. */
  82797. constructor(name: string, size: number | {
  82798. width: number;
  82799. height: number;
  82800. } | {
  82801. ratio: number;
  82802. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82803. private _preparePostProcesses;
  82804. /**
  82805. * Clone the mirror texture.
  82806. * @returns the cloned texture
  82807. */
  82808. clone(): MirrorTexture;
  82809. /**
  82810. * Serialize the texture to a JSON representation you could use in Parse later on
  82811. * @returns the serialized JSON representation
  82812. */
  82813. serialize(): any;
  82814. /**
  82815. * Dispose the texture and release its associated resources.
  82816. */
  82817. dispose(): void;
  82818. }
  82819. }
  82820. declare module BABYLON {
  82821. /**
  82822. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82823. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82824. */
  82825. export class Texture extends BaseTexture {
  82826. /**
  82827. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82828. */
  82829. static SerializeBuffers: boolean;
  82830. /** @hidden */
  82831. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82832. /** @hidden */
  82833. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82834. /** @hidden */
  82835. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82836. /** nearest is mag = nearest and min = nearest and mip = linear */
  82837. static readonly NEAREST_SAMPLINGMODE: number;
  82838. /** nearest is mag = nearest and min = nearest and mip = linear */
  82839. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82840. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82841. static readonly BILINEAR_SAMPLINGMODE: number;
  82842. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82843. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82844. /** Trilinear is mag = linear and min = linear and mip = linear */
  82845. static readonly TRILINEAR_SAMPLINGMODE: number;
  82846. /** Trilinear is mag = linear and min = linear and mip = linear */
  82847. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82848. /** mag = nearest and min = nearest and mip = nearest */
  82849. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82850. /** mag = nearest and min = linear and mip = nearest */
  82851. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82852. /** mag = nearest and min = linear and mip = linear */
  82853. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82854. /** mag = nearest and min = linear and mip = none */
  82855. static readonly NEAREST_LINEAR: number;
  82856. /** mag = nearest and min = nearest and mip = none */
  82857. static readonly NEAREST_NEAREST: number;
  82858. /** mag = linear and min = nearest and mip = nearest */
  82859. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82860. /** mag = linear and min = nearest and mip = linear */
  82861. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82862. /** mag = linear and min = linear and mip = none */
  82863. static readonly LINEAR_LINEAR: number;
  82864. /** mag = linear and min = nearest and mip = none */
  82865. static readonly LINEAR_NEAREST: number;
  82866. /** Explicit coordinates mode */
  82867. static readonly EXPLICIT_MODE: number;
  82868. /** Spherical coordinates mode */
  82869. static readonly SPHERICAL_MODE: number;
  82870. /** Planar coordinates mode */
  82871. static readonly PLANAR_MODE: number;
  82872. /** Cubic coordinates mode */
  82873. static readonly CUBIC_MODE: number;
  82874. /** Projection coordinates mode */
  82875. static readonly PROJECTION_MODE: number;
  82876. /** Inverse Cubic coordinates mode */
  82877. static readonly SKYBOX_MODE: number;
  82878. /** Inverse Cubic coordinates mode */
  82879. static readonly INVCUBIC_MODE: number;
  82880. /** Equirectangular coordinates mode */
  82881. static readonly EQUIRECTANGULAR_MODE: number;
  82882. /** Equirectangular Fixed coordinates mode */
  82883. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82884. /** Equirectangular Fixed Mirrored coordinates mode */
  82885. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82886. /** Texture is not repeating outside of 0..1 UVs */
  82887. static readonly CLAMP_ADDRESSMODE: number;
  82888. /** Texture is repeating outside of 0..1 UVs */
  82889. static readonly WRAP_ADDRESSMODE: number;
  82890. /** Texture is repeating and mirrored */
  82891. static readonly MIRROR_ADDRESSMODE: number;
  82892. /**
  82893. * 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
  82894. */
  82895. static UseSerializedUrlIfAny: boolean;
  82896. /**
  82897. * Define the url of the texture.
  82898. */
  82899. url: Nullable<string>;
  82900. /**
  82901. * Define an offset on the texture to offset the u coordinates of the UVs
  82902. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82903. */
  82904. uOffset: number;
  82905. /**
  82906. * Define an offset on the texture to offset the v coordinates of the UVs
  82907. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82908. */
  82909. vOffset: number;
  82910. /**
  82911. * Define an offset on the texture to scale the u coordinates of the UVs
  82912. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82913. */
  82914. uScale: number;
  82915. /**
  82916. * Define an offset on the texture to scale the v coordinates of the UVs
  82917. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82918. */
  82919. vScale: number;
  82920. /**
  82921. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82922. * @see http://doc.babylonjs.com/how_to/more_materials
  82923. */
  82924. uAng: number;
  82925. /**
  82926. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82927. * @see http://doc.babylonjs.com/how_to/more_materials
  82928. */
  82929. vAng: number;
  82930. /**
  82931. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82932. * @see http://doc.babylonjs.com/how_to/more_materials
  82933. */
  82934. wAng: number;
  82935. /**
  82936. * Defines the center of rotation (U)
  82937. */
  82938. uRotationCenter: number;
  82939. /**
  82940. * Defines the center of rotation (V)
  82941. */
  82942. vRotationCenter: number;
  82943. /**
  82944. * Defines the center of rotation (W)
  82945. */
  82946. wRotationCenter: number;
  82947. /**
  82948. * Are mip maps generated for this texture or not.
  82949. */
  82950. readonly noMipmap: boolean;
  82951. /**
  82952. * List of inspectable custom properties (used by the Inspector)
  82953. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82954. */
  82955. inspectableCustomProperties: Nullable<IInspectable[]>;
  82956. private _noMipmap;
  82957. /** @hidden */
  82958. _invertY: boolean;
  82959. private _rowGenerationMatrix;
  82960. private _cachedTextureMatrix;
  82961. private _projectionModeMatrix;
  82962. private _t0;
  82963. private _t1;
  82964. private _t2;
  82965. private _cachedUOffset;
  82966. private _cachedVOffset;
  82967. private _cachedUScale;
  82968. private _cachedVScale;
  82969. private _cachedUAng;
  82970. private _cachedVAng;
  82971. private _cachedWAng;
  82972. private _cachedProjectionMatrixId;
  82973. private _cachedCoordinatesMode;
  82974. /** @hidden */
  82975. protected _initialSamplingMode: number;
  82976. /** @hidden */
  82977. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82978. private _deleteBuffer;
  82979. protected _format: Nullable<number>;
  82980. private _delayedOnLoad;
  82981. private _delayedOnError;
  82982. private _mimeType?;
  82983. /**
  82984. * Observable triggered once the texture has been loaded.
  82985. */
  82986. onLoadObservable: Observable<Texture>;
  82987. protected _isBlocking: boolean;
  82988. /**
  82989. * Is the texture preventing material to render while loading.
  82990. * If false, a default texture will be used instead of the loading one during the preparation step.
  82991. */
  82992. isBlocking: boolean;
  82993. /**
  82994. * Get the current sampling mode associated with the texture.
  82995. */
  82996. readonly samplingMode: number;
  82997. /**
  82998. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82999. */
  83000. readonly invertY: boolean;
  83001. /**
  83002. * Instantiates a new texture.
  83003. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83004. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83005. * @param url defines the url of the picture to load as a texture
  83006. * @param scene defines the scene or engine the texture will belong to
  83007. * @param noMipmap defines if the texture will require mip maps or not
  83008. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83009. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83010. * @param onLoad defines a callback triggered when the texture has been loaded
  83011. * @param onError defines a callback triggered when an error occurred during the loading session
  83012. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83013. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83014. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83015. * @param mimeType defines an optional mime type information
  83016. */
  83017. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83018. /**
  83019. * Update the url (and optional buffer) of this texture if url was null during construction.
  83020. * @param url the url of the texture
  83021. * @param buffer the buffer of the texture (defaults to null)
  83022. * @param onLoad callback called when the texture is loaded (defaults to null)
  83023. */
  83024. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83025. /**
  83026. * Finish the loading sequence of a texture flagged as delayed load.
  83027. * @hidden
  83028. */
  83029. delayLoad(): void;
  83030. private _prepareRowForTextureGeneration;
  83031. /**
  83032. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83033. * @returns the transform matrix of the texture.
  83034. */
  83035. getTextureMatrix(): Matrix;
  83036. /**
  83037. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83038. * @returns The reflection texture transform
  83039. */
  83040. getReflectionTextureMatrix(): Matrix;
  83041. /**
  83042. * Clones the texture.
  83043. * @returns the cloned texture
  83044. */
  83045. clone(): Texture;
  83046. /**
  83047. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83048. * @returns The JSON representation of the texture
  83049. */
  83050. serialize(): any;
  83051. /**
  83052. * Get the current class name of the texture useful for serialization or dynamic coding.
  83053. * @returns "Texture"
  83054. */
  83055. getClassName(): string;
  83056. /**
  83057. * Dispose the texture and release its associated resources.
  83058. */
  83059. dispose(): void;
  83060. /**
  83061. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83062. * @param parsedTexture Define the JSON representation of the texture
  83063. * @param scene Define the scene the parsed texture should be instantiated in
  83064. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83065. * @returns The parsed texture if successful
  83066. */
  83067. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83068. /**
  83069. * Creates a texture from its base 64 representation.
  83070. * @param data Define the base64 payload without the data: prefix
  83071. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83072. * @param scene Define the scene the texture should belong to
  83073. * @param noMipmap Forces the texture to not create mip map information if true
  83074. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83075. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83076. * @param onLoad define a callback triggered when the texture has been loaded
  83077. * @param onError define a callback triggered when an error occurred during the loading session
  83078. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83079. * @returns the created texture
  83080. */
  83081. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83082. /**
  83083. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83084. * @param data Define the base64 payload without the data: prefix
  83085. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83086. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83087. * @param scene Define the scene the texture should belong to
  83088. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83089. * @param noMipmap Forces the texture to not create mip map information if true
  83090. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83091. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83092. * @param onLoad define a callback triggered when the texture has been loaded
  83093. * @param onError define a callback triggered when an error occurred during the loading session
  83094. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83095. * @returns the created texture
  83096. */
  83097. 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;
  83098. }
  83099. }
  83100. declare module BABYLON {
  83101. /**
  83102. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83103. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83104. */
  83105. export class PostProcessManager {
  83106. private _scene;
  83107. private _indexBuffer;
  83108. private _vertexBuffers;
  83109. /**
  83110. * Creates a new instance PostProcess
  83111. * @param scene The scene that the post process is associated with.
  83112. */
  83113. constructor(scene: Scene);
  83114. private _prepareBuffers;
  83115. private _buildIndexBuffer;
  83116. /**
  83117. * Rebuilds the vertex buffers of the manager.
  83118. * @hidden
  83119. */
  83120. _rebuild(): void;
  83121. /**
  83122. * Prepares a frame to be run through a post process.
  83123. * @param sourceTexture The input texture to the post procesess. (default: null)
  83124. * @param postProcesses An array of post processes to be run. (default: null)
  83125. * @returns True if the post processes were able to be run.
  83126. * @hidden
  83127. */
  83128. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83129. /**
  83130. * Manually render a set of post processes to a texture.
  83131. * @param postProcesses An array of post processes to be run.
  83132. * @param targetTexture The target texture to render to.
  83133. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83134. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83135. * @param lodLevel defines which lod of the texture to render to
  83136. */
  83137. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83138. /**
  83139. * Finalize the result of the output of the postprocesses.
  83140. * @param doNotPresent If true the result will not be displayed to the screen.
  83141. * @param targetTexture The target texture to render to.
  83142. * @param faceIndex The index of the face to bind the target texture to.
  83143. * @param postProcesses The array of post processes to render.
  83144. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83145. * @hidden
  83146. */
  83147. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83148. /**
  83149. * Disposes of the post process manager.
  83150. */
  83151. dispose(): void;
  83152. }
  83153. }
  83154. declare module BABYLON {
  83155. /** Interface used by value gradients (color, factor, ...) */
  83156. export interface IValueGradient {
  83157. /**
  83158. * Gets or sets the gradient value (between 0 and 1)
  83159. */
  83160. gradient: number;
  83161. }
  83162. /** Class used to store color4 gradient */
  83163. export class ColorGradient implements IValueGradient {
  83164. /**
  83165. * Gets or sets the gradient value (between 0 and 1)
  83166. */
  83167. gradient: number;
  83168. /**
  83169. * Gets or sets first associated color
  83170. */
  83171. color1: Color4;
  83172. /**
  83173. * Gets or sets second associated color
  83174. */
  83175. color2?: Color4;
  83176. /**
  83177. * Will get a color picked randomly between color1 and color2.
  83178. * If color2 is undefined then color1 will be used
  83179. * @param result defines the target Color4 to store the result in
  83180. */
  83181. getColorToRef(result: Color4): void;
  83182. }
  83183. /** Class used to store color 3 gradient */
  83184. export class Color3Gradient implements IValueGradient {
  83185. /**
  83186. * Gets or sets the gradient value (between 0 and 1)
  83187. */
  83188. gradient: number;
  83189. /**
  83190. * Gets or sets the associated color
  83191. */
  83192. color: Color3;
  83193. }
  83194. /** Class used to store factor gradient */
  83195. export class FactorGradient implements IValueGradient {
  83196. /**
  83197. * Gets or sets the gradient value (between 0 and 1)
  83198. */
  83199. gradient: number;
  83200. /**
  83201. * Gets or sets first associated factor
  83202. */
  83203. factor1: number;
  83204. /**
  83205. * Gets or sets second associated factor
  83206. */
  83207. factor2?: number;
  83208. /**
  83209. * Will get a number picked randomly between factor1 and factor2.
  83210. * If factor2 is undefined then factor1 will be used
  83211. * @returns the picked number
  83212. */
  83213. getFactor(): number;
  83214. }
  83215. /**
  83216. * Helper used to simplify some generic gradient tasks
  83217. */
  83218. export class GradientHelper {
  83219. /**
  83220. * Gets the current gradient from an array of IValueGradient
  83221. * @param ratio defines the current ratio to get
  83222. * @param gradients defines the array of IValueGradient
  83223. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83224. */
  83225. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83226. }
  83227. }
  83228. declare module BABYLON {
  83229. interface ThinEngine {
  83230. /**
  83231. * Creates a dynamic texture
  83232. * @param width defines the width of the texture
  83233. * @param height defines the height of the texture
  83234. * @param generateMipMaps defines if the engine should generate the mip levels
  83235. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83236. * @returns the dynamic texture inside an InternalTexture
  83237. */
  83238. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83239. /**
  83240. * Update the content of a dynamic texture
  83241. * @param texture defines the texture to update
  83242. * @param canvas defines the canvas containing the source
  83243. * @param invertY defines if data must be stored with Y axis inverted
  83244. * @param premulAlpha defines if alpha is stored as premultiplied
  83245. * @param format defines the format of the data
  83246. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83247. */
  83248. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83249. }
  83250. }
  83251. declare module BABYLON {
  83252. /**
  83253. * A class extending Texture allowing drawing on a texture
  83254. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83255. */
  83256. export class DynamicTexture extends Texture {
  83257. private _generateMipMaps;
  83258. private _canvas;
  83259. private _context;
  83260. private _engine;
  83261. /**
  83262. * Creates a DynamicTexture
  83263. * @param name defines the name of the texture
  83264. * @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
  83265. * @param scene defines the scene where you want the texture
  83266. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83267. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83268. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83269. */
  83270. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83271. /**
  83272. * Get the current class name of the texture useful for serialization or dynamic coding.
  83273. * @returns "DynamicTexture"
  83274. */
  83275. getClassName(): string;
  83276. /**
  83277. * Gets the current state of canRescale
  83278. */
  83279. readonly canRescale: boolean;
  83280. private _recreate;
  83281. /**
  83282. * Scales the texture
  83283. * @param ratio the scale factor to apply to both width and height
  83284. */
  83285. scale(ratio: number): void;
  83286. /**
  83287. * Resizes the texture
  83288. * @param width the new width
  83289. * @param height the new height
  83290. */
  83291. scaleTo(width: number, height: number): void;
  83292. /**
  83293. * Gets the context of the canvas used by the texture
  83294. * @returns the canvas context of the dynamic texture
  83295. */
  83296. getContext(): CanvasRenderingContext2D;
  83297. /**
  83298. * Clears the texture
  83299. */
  83300. clear(): void;
  83301. /**
  83302. * Updates the texture
  83303. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83304. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83305. */
  83306. update(invertY?: boolean, premulAlpha?: boolean): void;
  83307. /**
  83308. * Draws text onto the texture
  83309. * @param text defines the text to be drawn
  83310. * @param x defines the placement of the text from the left
  83311. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83312. * @param font defines the font to be used with font-style, font-size, font-name
  83313. * @param color defines the color used for the text
  83314. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83315. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83316. * @param update defines whether texture is immediately update (default is true)
  83317. */
  83318. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83319. /**
  83320. * Clones the texture
  83321. * @returns the clone of the texture.
  83322. */
  83323. clone(): DynamicTexture;
  83324. /**
  83325. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83326. * @returns a serialized dynamic texture object
  83327. */
  83328. serialize(): any;
  83329. /** @hidden */
  83330. _rebuild(): void;
  83331. }
  83332. }
  83333. declare module BABYLON {
  83334. interface AbstractScene {
  83335. /**
  83336. * The list of procedural textures added to the scene
  83337. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83338. */
  83339. proceduralTextures: Array<ProceduralTexture>;
  83340. }
  83341. /**
  83342. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83343. * in a given scene.
  83344. */
  83345. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83346. /**
  83347. * The component name helpfull to identify the component in the list of scene components.
  83348. */
  83349. readonly name: string;
  83350. /**
  83351. * The scene the component belongs to.
  83352. */
  83353. scene: Scene;
  83354. /**
  83355. * Creates a new instance of the component for the given scene
  83356. * @param scene Defines the scene to register the component in
  83357. */
  83358. constructor(scene: Scene);
  83359. /**
  83360. * Registers the component in a given scene
  83361. */
  83362. register(): void;
  83363. /**
  83364. * Rebuilds the elements related to this component in case of
  83365. * context lost for instance.
  83366. */
  83367. rebuild(): void;
  83368. /**
  83369. * Disposes the component and the associated ressources.
  83370. */
  83371. dispose(): void;
  83372. private _beforeClear;
  83373. }
  83374. }
  83375. declare module BABYLON {
  83376. interface ThinEngine {
  83377. /**
  83378. * Creates a new render target cube texture
  83379. * @param size defines the size of the texture
  83380. * @param options defines the options used to create the texture
  83381. * @returns a new render target cube texture stored in an InternalTexture
  83382. */
  83383. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83384. }
  83385. }
  83386. declare module BABYLON {
  83387. /** @hidden */
  83388. export var proceduralVertexShader: {
  83389. name: string;
  83390. shader: string;
  83391. };
  83392. }
  83393. declare module BABYLON {
  83394. /**
  83395. * 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.
  83396. * This is the base class of any Procedural texture and contains most of the shareable code.
  83397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83398. */
  83399. export class ProceduralTexture extends Texture {
  83400. isCube: boolean;
  83401. /**
  83402. * Define if the texture is enabled or not (disabled texture will not render)
  83403. */
  83404. isEnabled: boolean;
  83405. /**
  83406. * Define if the texture must be cleared before rendering (default is true)
  83407. */
  83408. autoClear: boolean;
  83409. /**
  83410. * Callback called when the texture is generated
  83411. */
  83412. onGenerated: () => void;
  83413. /**
  83414. * Event raised when the texture is generated
  83415. */
  83416. onGeneratedObservable: Observable<ProceduralTexture>;
  83417. /** @hidden */
  83418. _generateMipMaps: boolean;
  83419. /** @hidden **/
  83420. _effect: Effect;
  83421. /** @hidden */
  83422. _textures: {
  83423. [key: string]: Texture;
  83424. };
  83425. private _size;
  83426. private _currentRefreshId;
  83427. private _refreshRate;
  83428. private _vertexBuffers;
  83429. private _indexBuffer;
  83430. private _uniforms;
  83431. private _samplers;
  83432. private _fragment;
  83433. private _floats;
  83434. private _ints;
  83435. private _floatsArrays;
  83436. private _colors3;
  83437. private _colors4;
  83438. private _vectors2;
  83439. private _vectors3;
  83440. private _matrices;
  83441. private _fallbackTexture;
  83442. private _fallbackTextureUsed;
  83443. private _engine;
  83444. private _cachedDefines;
  83445. private _contentUpdateId;
  83446. private _contentData;
  83447. /**
  83448. * Instantiates a new procedural texture.
  83449. * 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.
  83450. * This is the base class of any Procedural texture and contains most of the shareable code.
  83451. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83452. * @param name Define the name of the texture
  83453. * @param size Define the size of the texture to create
  83454. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83455. * @param scene Define the scene the texture belongs to
  83456. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83457. * @param generateMipMaps Define if the texture should creates mip maps or not
  83458. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83459. */
  83460. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83461. /**
  83462. * The effect that is created when initializing the post process.
  83463. * @returns The created effect corresponding the the postprocess.
  83464. */
  83465. getEffect(): Effect;
  83466. /**
  83467. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83468. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83469. */
  83470. getContent(): Nullable<ArrayBufferView>;
  83471. private _createIndexBuffer;
  83472. /** @hidden */
  83473. _rebuild(): void;
  83474. /**
  83475. * Resets the texture in order to recreate its associated resources.
  83476. * This can be called in case of context loss
  83477. */
  83478. reset(): void;
  83479. protected _getDefines(): string;
  83480. /**
  83481. * Is the texture ready to be used ? (rendered at least once)
  83482. * @returns true if ready, otherwise, false.
  83483. */
  83484. isReady(): boolean;
  83485. /**
  83486. * Resets the refresh counter of the texture and start bak from scratch.
  83487. * Could be useful to regenerate the texture if it is setup to render only once.
  83488. */
  83489. resetRefreshCounter(): void;
  83490. /**
  83491. * Set the fragment shader to use in order to render the texture.
  83492. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83493. */
  83494. setFragment(fragment: any): void;
  83495. /**
  83496. * Define the refresh rate of the texture or the rendering frequency.
  83497. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83498. */
  83499. refreshRate: number;
  83500. /** @hidden */
  83501. _shouldRender(): boolean;
  83502. /**
  83503. * Get the size the texture is rendering at.
  83504. * @returns the size (texture is always squared)
  83505. */
  83506. getRenderSize(): number;
  83507. /**
  83508. * Resize the texture to new value.
  83509. * @param size Define the new size the texture should have
  83510. * @param generateMipMaps Define whether the new texture should create mip maps
  83511. */
  83512. resize(size: number, generateMipMaps: boolean): void;
  83513. private _checkUniform;
  83514. /**
  83515. * Set a texture in the shader program used to render.
  83516. * @param name Define the name of the uniform samplers as defined in the shader
  83517. * @param texture Define the texture to bind to this sampler
  83518. * @return the texture itself allowing "fluent" like uniform updates
  83519. */
  83520. setTexture(name: string, texture: Texture): ProceduralTexture;
  83521. /**
  83522. * Set a float in the shader.
  83523. * @param name Define the name of the uniform as defined in the shader
  83524. * @param value Define the value to give to the uniform
  83525. * @return the texture itself allowing "fluent" like uniform updates
  83526. */
  83527. setFloat(name: string, value: number): ProceduralTexture;
  83528. /**
  83529. * Set a int in the shader.
  83530. * @param name Define the name of the uniform as defined in the shader
  83531. * @param value Define the value to give to the uniform
  83532. * @return the texture itself allowing "fluent" like uniform updates
  83533. */
  83534. setInt(name: string, value: number): ProceduralTexture;
  83535. /**
  83536. * Set an array of floats in the shader.
  83537. * @param name Define the name of the uniform as defined in the shader
  83538. * @param value Define the value to give to the uniform
  83539. * @return the texture itself allowing "fluent" like uniform updates
  83540. */
  83541. setFloats(name: string, value: number[]): ProceduralTexture;
  83542. /**
  83543. * Set a vec3 in the shader from a Color3.
  83544. * @param name Define the name of the uniform as defined in the shader
  83545. * @param value Define the value to give to the uniform
  83546. * @return the texture itself allowing "fluent" like uniform updates
  83547. */
  83548. setColor3(name: string, value: Color3): ProceduralTexture;
  83549. /**
  83550. * Set a vec4 in the shader from a Color4.
  83551. * @param name Define the name of the uniform as defined in the shader
  83552. * @param value Define the value to give to the uniform
  83553. * @return the texture itself allowing "fluent" like uniform updates
  83554. */
  83555. setColor4(name: string, value: Color4): ProceduralTexture;
  83556. /**
  83557. * Set a vec2 in the shader from a Vector2.
  83558. * @param name Define the name of the uniform as defined in the shader
  83559. * @param value Define the value to give to the uniform
  83560. * @return the texture itself allowing "fluent" like uniform updates
  83561. */
  83562. setVector2(name: string, value: Vector2): ProceduralTexture;
  83563. /**
  83564. * Set a vec3 in the shader from a Vector3.
  83565. * @param name Define the name of the uniform as defined in the shader
  83566. * @param value Define the value to give to the uniform
  83567. * @return the texture itself allowing "fluent" like uniform updates
  83568. */
  83569. setVector3(name: string, value: Vector3): ProceduralTexture;
  83570. /**
  83571. * Set a mat4 in the shader from a MAtrix.
  83572. * @param name Define the name of the uniform as defined in the shader
  83573. * @param value Define the value to give to the uniform
  83574. * @return the texture itself allowing "fluent" like uniform updates
  83575. */
  83576. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83577. /**
  83578. * Render the texture to its associated render target.
  83579. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83580. */
  83581. render(useCameraPostProcess?: boolean): void;
  83582. /**
  83583. * Clone the texture.
  83584. * @returns the cloned texture
  83585. */
  83586. clone(): ProceduralTexture;
  83587. /**
  83588. * Dispose the texture and release its asoociated resources.
  83589. */
  83590. dispose(): void;
  83591. }
  83592. }
  83593. declare module BABYLON {
  83594. /**
  83595. * This represents the base class for particle system in Babylon.
  83596. * 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.
  83597. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83598. * @example https://doc.babylonjs.com/babylon101/particles
  83599. */
  83600. export class BaseParticleSystem {
  83601. /**
  83602. * Source color is added to the destination color without alpha affecting the result
  83603. */
  83604. static BLENDMODE_ONEONE: number;
  83605. /**
  83606. * Blend current color and particle color using particle’s alpha
  83607. */
  83608. static BLENDMODE_STANDARD: number;
  83609. /**
  83610. * Add current color and particle color multiplied by particle’s alpha
  83611. */
  83612. static BLENDMODE_ADD: number;
  83613. /**
  83614. * Multiply current color with particle color
  83615. */
  83616. static BLENDMODE_MULTIPLY: number;
  83617. /**
  83618. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83619. */
  83620. static BLENDMODE_MULTIPLYADD: number;
  83621. /**
  83622. * List of animations used by the particle system.
  83623. */
  83624. animations: Animation[];
  83625. /**
  83626. * The id of the Particle system.
  83627. */
  83628. id: string;
  83629. /**
  83630. * The friendly name of the Particle system.
  83631. */
  83632. name: string;
  83633. /**
  83634. * The rendering group used by the Particle system to chose when to render.
  83635. */
  83636. renderingGroupId: number;
  83637. /**
  83638. * The emitter represents the Mesh or position we are attaching the particle system to.
  83639. */
  83640. emitter: Nullable<AbstractMesh | Vector3>;
  83641. /**
  83642. * The maximum number of particles to emit per frame
  83643. */
  83644. emitRate: number;
  83645. /**
  83646. * If you want to launch only a few particles at once, that can be done, as well.
  83647. */
  83648. manualEmitCount: number;
  83649. /**
  83650. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83651. */
  83652. updateSpeed: number;
  83653. /**
  83654. * The amount of time the particle system is running (depends of the overall update speed).
  83655. */
  83656. targetStopDuration: number;
  83657. /**
  83658. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83659. */
  83660. disposeOnStop: boolean;
  83661. /**
  83662. * Minimum power of emitting particles.
  83663. */
  83664. minEmitPower: number;
  83665. /**
  83666. * Maximum power of emitting particles.
  83667. */
  83668. maxEmitPower: number;
  83669. /**
  83670. * Minimum life time of emitting particles.
  83671. */
  83672. minLifeTime: number;
  83673. /**
  83674. * Maximum life time of emitting particles.
  83675. */
  83676. maxLifeTime: number;
  83677. /**
  83678. * Minimum Size of emitting particles.
  83679. */
  83680. minSize: number;
  83681. /**
  83682. * Maximum Size of emitting particles.
  83683. */
  83684. maxSize: number;
  83685. /**
  83686. * Minimum scale of emitting particles on X axis.
  83687. */
  83688. minScaleX: number;
  83689. /**
  83690. * Maximum scale of emitting particles on X axis.
  83691. */
  83692. maxScaleX: number;
  83693. /**
  83694. * Minimum scale of emitting particles on Y axis.
  83695. */
  83696. minScaleY: number;
  83697. /**
  83698. * Maximum scale of emitting particles on Y axis.
  83699. */
  83700. maxScaleY: number;
  83701. /**
  83702. * Gets or sets the minimal initial rotation in radians.
  83703. */
  83704. minInitialRotation: number;
  83705. /**
  83706. * Gets or sets the maximal initial rotation in radians.
  83707. */
  83708. maxInitialRotation: number;
  83709. /**
  83710. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83711. */
  83712. minAngularSpeed: number;
  83713. /**
  83714. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83715. */
  83716. maxAngularSpeed: number;
  83717. /**
  83718. * The texture used to render each particle. (this can be a spritesheet)
  83719. */
  83720. particleTexture: Nullable<Texture>;
  83721. /**
  83722. * The layer mask we are rendering the particles through.
  83723. */
  83724. layerMask: number;
  83725. /**
  83726. * This can help using your own shader to render the particle system.
  83727. * The according effect will be created
  83728. */
  83729. customShader: any;
  83730. /**
  83731. * By default particle system starts as soon as they are created. This prevents the
  83732. * automatic start to happen and let you decide when to start emitting particles.
  83733. */
  83734. preventAutoStart: boolean;
  83735. private _noiseTexture;
  83736. /**
  83737. * Gets or sets a texture used to add random noise to particle positions
  83738. */
  83739. noiseTexture: Nullable<ProceduralTexture>;
  83740. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83741. noiseStrength: Vector3;
  83742. /**
  83743. * Callback triggered when the particle animation is ending.
  83744. */
  83745. onAnimationEnd: Nullable<() => void>;
  83746. /**
  83747. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83748. */
  83749. blendMode: number;
  83750. /**
  83751. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83752. * to override the particles.
  83753. */
  83754. forceDepthWrite: boolean;
  83755. /** 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 */
  83756. preWarmCycles: number;
  83757. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83758. preWarmStepOffset: number;
  83759. /**
  83760. * 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)
  83761. */
  83762. spriteCellChangeSpeed: number;
  83763. /**
  83764. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83765. */
  83766. startSpriteCellID: number;
  83767. /**
  83768. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83769. */
  83770. endSpriteCellID: number;
  83771. /**
  83772. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83773. */
  83774. spriteCellWidth: number;
  83775. /**
  83776. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83777. */
  83778. spriteCellHeight: number;
  83779. /**
  83780. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83781. */
  83782. spriteRandomStartCell: boolean;
  83783. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83784. translationPivot: Vector2;
  83785. /** @hidden */
  83786. protected _isAnimationSheetEnabled: boolean;
  83787. /**
  83788. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83789. */
  83790. beginAnimationOnStart: boolean;
  83791. /**
  83792. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83793. */
  83794. beginAnimationFrom: number;
  83795. /**
  83796. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83797. */
  83798. beginAnimationTo: number;
  83799. /**
  83800. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83801. */
  83802. beginAnimationLoop: boolean;
  83803. /**
  83804. * Gets or sets a world offset applied to all particles
  83805. */
  83806. worldOffset: Vector3;
  83807. /**
  83808. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83809. */
  83810. isAnimationSheetEnabled: boolean;
  83811. /**
  83812. * Get hosting scene
  83813. * @returns the scene
  83814. */
  83815. getScene(): Scene;
  83816. /**
  83817. * You can use gravity if you want to give an orientation to your particles.
  83818. */
  83819. gravity: Vector3;
  83820. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83821. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83822. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83823. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83824. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83825. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83826. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83827. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83828. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83829. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83830. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83831. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83832. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83833. /**
  83834. * Defines the delay in milliseconds before starting the system (0 by default)
  83835. */
  83836. startDelay: number;
  83837. /**
  83838. * Gets the current list of drag gradients.
  83839. * You must use addDragGradient and removeDragGradient to udpate this list
  83840. * @returns the list of drag gradients
  83841. */
  83842. getDragGradients(): Nullable<Array<FactorGradient>>;
  83843. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83844. limitVelocityDamping: number;
  83845. /**
  83846. * Gets the current list of limit velocity gradients.
  83847. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83848. * @returns the list of limit velocity gradients
  83849. */
  83850. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83851. /**
  83852. * Gets the current list of color gradients.
  83853. * You must use addColorGradient and removeColorGradient to udpate this list
  83854. * @returns the list of color gradients
  83855. */
  83856. getColorGradients(): Nullable<Array<ColorGradient>>;
  83857. /**
  83858. * Gets the current list of size gradients.
  83859. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83860. * @returns the list of size gradients
  83861. */
  83862. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83863. /**
  83864. * Gets the current list of color remap gradients.
  83865. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83866. * @returns the list of color remap gradients
  83867. */
  83868. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83869. /**
  83870. * Gets the current list of alpha remap gradients.
  83871. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83872. * @returns the list of alpha remap gradients
  83873. */
  83874. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83875. /**
  83876. * Gets the current list of life time gradients.
  83877. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83878. * @returns the list of life time gradients
  83879. */
  83880. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83881. /**
  83882. * Gets the current list of angular speed gradients.
  83883. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83884. * @returns the list of angular speed gradients
  83885. */
  83886. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83887. /**
  83888. * Gets the current list of velocity gradients.
  83889. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83890. * @returns the list of velocity gradients
  83891. */
  83892. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83893. /**
  83894. * Gets the current list of start size gradients.
  83895. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83896. * @returns the list of start size gradients
  83897. */
  83898. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83899. /**
  83900. * Gets the current list of emit rate gradients.
  83901. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83902. * @returns the list of emit rate gradients
  83903. */
  83904. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83905. /**
  83906. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83907. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83908. */
  83909. direction1: Vector3;
  83910. /**
  83911. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83912. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83913. */
  83914. direction2: Vector3;
  83915. /**
  83916. * 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.
  83917. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83918. */
  83919. minEmitBox: Vector3;
  83920. /**
  83921. * 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.
  83922. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83923. */
  83924. maxEmitBox: Vector3;
  83925. /**
  83926. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83927. */
  83928. color1: Color4;
  83929. /**
  83930. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83931. */
  83932. color2: Color4;
  83933. /**
  83934. * Color the particle will have at the end of its lifetime
  83935. */
  83936. colorDead: Color4;
  83937. /**
  83938. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83939. */
  83940. textureMask: Color4;
  83941. /**
  83942. * The particle emitter type defines the emitter used by the particle system.
  83943. * It can be for example box, sphere, or cone...
  83944. */
  83945. particleEmitterType: IParticleEmitterType;
  83946. /** @hidden */
  83947. _isSubEmitter: boolean;
  83948. /**
  83949. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83950. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83951. */
  83952. billboardMode: number;
  83953. protected _isBillboardBased: boolean;
  83954. /**
  83955. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83956. */
  83957. isBillboardBased: boolean;
  83958. /**
  83959. * The scene the particle system belongs to.
  83960. */
  83961. protected _scene: Scene;
  83962. /**
  83963. * Local cache of defines for image processing.
  83964. */
  83965. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83966. /**
  83967. * Default configuration related to image processing available in the standard Material.
  83968. */
  83969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83970. /**
  83971. * Gets the image processing configuration used either in this material.
  83972. */
  83973. /**
  83974. * Sets the Default image processing configuration used either in the this material.
  83975. *
  83976. * If sets to null, the scene one is in use.
  83977. */
  83978. imageProcessingConfiguration: ImageProcessingConfiguration;
  83979. /**
  83980. * Attaches a new image processing configuration to the Standard Material.
  83981. * @param configuration
  83982. */
  83983. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83984. /** @hidden */
  83985. protected _reset(): void;
  83986. /** @hidden */
  83987. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83988. /**
  83989. * Instantiates a particle system.
  83990. * 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.
  83991. * @param name The name of the particle system
  83992. */
  83993. constructor(name: string);
  83994. /**
  83995. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83996. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83997. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83998. * @returns the emitter
  83999. */
  84000. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84001. /**
  84002. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84003. * @param radius The radius of the hemisphere to emit from
  84004. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84005. * @returns the emitter
  84006. */
  84007. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84008. /**
  84009. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84010. * @param radius The radius of the sphere to emit from
  84011. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84012. * @returns the emitter
  84013. */
  84014. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84015. /**
  84016. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84017. * @param radius The radius of the sphere to emit from
  84018. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84019. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84020. * @returns the emitter
  84021. */
  84022. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84023. /**
  84024. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84025. * @param radius The radius of the emission cylinder
  84026. * @param height The height of the emission cylinder
  84027. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84028. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84029. * @returns the emitter
  84030. */
  84031. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84032. /**
  84033. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84034. * @param radius The radius of the cylinder to emit from
  84035. * @param height The height of the emission cylinder
  84036. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84039. * @returns the emitter
  84040. */
  84041. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84042. /**
  84043. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84044. * @param radius The radius of the cone to emit from
  84045. * @param angle The base angle of the cone
  84046. * @returns the emitter
  84047. */
  84048. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84049. /**
  84050. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84051. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84052. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84053. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84054. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84055. * @returns the emitter
  84056. */
  84057. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84058. }
  84059. }
  84060. declare module BABYLON {
  84061. /**
  84062. * Type of sub emitter
  84063. */
  84064. export enum SubEmitterType {
  84065. /**
  84066. * Attached to the particle over it's lifetime
  84067. */
  84068. ATTACHED = 0,
  84069. /**
  84070. * Created when the particle dies
  84071. */
  84072. END = 1
  84073. }
  84074. /**
  84075. * Sub emitter class used to emit particles from an existing particle
  84076. */
  84077. export class SubEmitter {
  84078. /**
  84079. * the particle system to be used by the sub emitter
  84080. */
  84081. particleSystem: ParticleSystem;
  84082. /**
  84083. * Type of the submitter (Default: END)
  84084. */
  84085. type: SubEmitterType;
  84086. /**
  84087. * 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)
  84088. * Note: This only is supported when using an emitter of type Mesh
  84089. */
  84090. inheritDirection: boolean;
  84091. /**
  84092. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84093. */
  84094. inheritedVelocityAmount: number;
  84095. /**
  84096. * Creates a sub emitter
  84097. * @param particleSystem the particle system to be used by the sub emitter
  84098. */
  84099. constructor(
  84100. /**
  84101. * the particle system to be used by the sub emitter
  84102. */
  84103. particleSystem: ParticleSystem);
  84104. /**
  84105. * Clones the sub emitter
  84106. * @returns the cloned sub emitter
  84107. */
  84108. clone(): SubEmitter;
  84109. /**
  84110. * Serialize current object to a JSON object
  84111. * @returns the serialized object
  84112. */
  84113. serialize(): any;
  84114. /** @hidden */
  84115. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84116. /**
  84117. * Creates a new SubEmitter from a serialized JSON version
  84118. * @param serializationObject defines the JSON object to read from
  84119. * @param scene defines the hosting scene
  84120. * @param rootUrl defines the rootUrl for data loading
  84121. * @returns a new SubEmitter
  84122. */
  84123. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84124. /** Release associated resources */
  84125. dispose(): void;
  84126. }
  84127. }
  84128. declare module BABYLON {
  84129. /** @hidden */
  84130. export var clipPlaneFragmentDeclaration: {
  84131. name: string;
  84132. shader: string;
  84133. };
  84134. }
  84135. declare module BABYLON {
  84136. /** @hidden */
  84137. export var imageProcessingDeclaration: {
  84138. name: string;
  84139. shader: string;
  84140. };
  84141. }
  84142. declare module BABYLON {
  84143. /** @hidden */
  84144. export var imageProcessingFunctions: {
  84145. name: string;
  84146. shader: string;
  84147. };
  84148. }
  84149. declare module BABYLON {
  84150. /** @hidden */
  84151. export var clipPlaneFragment: {
  84152. name: string;
  84153. shader: string;
  84154. };
  84155. }
  84156. declare module BABYLON {
  84157. /** @hidden */
  84158. export var particlesPixelShader: {
  84159. name: string;
  84160. shader: string;
  84161. };
  84162. }
  84163. declare module BABYLON {
  84164. /** @hidden */
  84165. export var clipPlaneVertexDeclaration: {
  84166. name: string;
  84167. shader: string;
  84168. };
  84169. }
  84170. declare module BABYLON {
  84171. /** @hidden */
  84172. export var clipPlaneVertex: {
  84173. name: string;
  84174. shader: string;
  84175. };
  84176. }
  84177. declare module BABYLON {
  84178. /** @hidden */
  84179. export var particlesVertexShader: {
  84180. name: string;
  84181. shader: string;
  84182. };
  84183. }
  84184. declare module BABYLON {
  84185. /**
  84186. * This represents a particle system in Babylon.
  84187. * 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.
  84188. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84189. * @example https://doc.babylonjs.com/babylon101/particles
  84190. */
  84191. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84192. /**
  84193. * Billboard mode will only apply to Y axis
  84194. */
  84195. static readonly BILLBOARDMODE_Y: number;
  84196. /**
  84197. * Billboard mode will apply to all axes
  84198. */
  84199. static readonly BILLBOARDMODE_ALL: number;
  84200. /**
  84201. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84202. */
  84203. static readonly BILLBOARDMODE_STRETCHED: number;
  84204. /**
  84205. * This function can be defined to provide custom update for active particles.
  84206. * This function will be called instead of regular update (age, position, color, etc.).
  84207. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84208. */
  84209. updateFunction: (particles: Particle[]) => void;
  84210. private _emitterWorldMatrix;
  84211. /**
  84212. * This function can be defined to specify initial direction for every new particle.
  84213. * It by default use the emitterType defined function
  84214. */
  84215. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84216. /**
  84217. * This function can be defined to specify initial position for every new particle.
  84218. * It by default use the emitterType defined function
  84219. */
  84220. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84221. /**
  84222. * @hidden
  84223. */
  84224. _inheritedVelocityOffset: Vector3;
  84225. /**
  84226. * An event triggered when the system is disposed
  84227. */
  84228. onDisposeObservable: Observable<ParticleSystem>;
  84229. private _onDisposeObserver;
  84230. /**
  84231. * Sets a callback that will be triggered when the system is disposed
  84232. */
  84233. onDispose: () => void;
  84234. private _particles;
  84235. private _epsilon;
  84236. private _capacity;
  84237. private _stockParticles;
  84238. private _newPartsExcess;
  84239. private _vertexData;
  84240. private _vertexBuffer;
  84241. private _vertexBuffers;
  84242. private _spriteBuffer;
  84243. private _indexBuffer;
  84244. private _effect;
  84245. private _customEffect;
  84246. private _cachedDefines;
  84247. private _scaledColorStep;
  84248. private _colorDiff;
  84249. private _scaledDirection;
  84250. private _scaledGravity;
  84251. private _currentRenderId;
  84252. private _alive;
  84253. private _useInstancing;
  84254. private _started;
  84255. private _stopped;
  84256. private _actualFrame;
  84257. private _scaledUpdateSpeed;
  84258. private _vertexBufferSize;
  84259. /** @hidden */
  84260. _currentEmitRateGradient: Nullable<FactorGradient>;
  84261. /** @hidden */
  84262. _currentEmitRate1: number;
  84263. /** @hidden */
  84264. _currentEmitRate2: number;
  84265. /** @hidden */
  84266. _currentStartSizeGradient: Nullable<FactorGradient>;
  84267. /** @hidden */
  84268. _currentStartSize1: number;
  84269. /** @hidden */
  84270. _currentStartSize2: number;
  84271. private readonly _rawTextureWidth;
  84272. private _rampGradientsTexture;
  84273. private _useRampGradients;
  84274. /** Gets or sets a boolean indicating that ramp gradients must be used
  84275. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84276. */
  84277. useRampGradients: boolean;
  84278. /**
  84279. * 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.
  84280. * 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: [])
  84281. */
  84282. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84283. private _subEmitters;
  84284. /**
  84285. * @hidden
  84286. * If the particle systems emitter should be disposed when the particle system is disposed
  84287. */
  84288. _disposeEmitterOnDispose: boolean;
  84289. /**
  84290. * The current active Sub-systems, this property is used by the root particle system only.
  84291. */
  84292. activeSubSystems: Array<ParticleSystem>;
  84293. private _rootParticleSystem;
  84294. /**
  84295. * Gets the current list of active particles
  84296. */
  84297. readonly particles: Particle[];
  84298. /**
  84299. * Returns the string "ParticleSystem"
  84300. * @returns a string containing the class name
  84301. */
  84302. getClassName(): string;
  84303. /**
  84304. * Instantiates a particle system.
  84305. * 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.
  84306. * @param name The name of the particle system
  84307. * @param capacity The max number of particles alive at the same time
  84308. * @param scene The scene the particle system belongs to
  84309. * @param customEffect a custom effect used to change the way particles are rendered by default
  84310. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84311. * @param epsilon Offset used to render the particles
  84312. */
  84313. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84314. private _addFactorGradient;
  84315. private _removeFactorGradient;
  84316. /**
  84317. * Adds a new life time gradient
  84318. * @param gradient defines the gradient to use (between 0 and 1)
  84319. * @param factor defines the life time factor to affect to the specified gradient
  84320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84321. * @returns the current particle system
  84322. */
  84323. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84324. /**
  84325. * Remove a specific life time gradient
  84326. * @param gradient defines the gradient to remove
  84327. * @returns the current particle system
  84328. */
  84329. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84330. /**
  84331. * Adds a new size gradient
  84332. * @param gradient defines the gradient to use (between 0 and 1)
  84333. * @param factor defines the size factor to affect to the specified gradient
  84334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84335. * @returns the current particle system
  84336. */
  84337. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84338. /**
  84339. * Remove a specific size gradient
  84340. * @param gradient defines the gradient to remove
  84341. * @returns the current particle system
  84342. */
  84343. removeSizeGradient(gradient: number): IParticleSystem;
  84344. /**
  84345. * Adds a new color remap gradient
  84346. * @param gradient defines the gradient to use (between 0 and 1)
  84347. * @param min defines the color remap minimal range
  84348. * @param max defines the color remap maximal range
  84349. * @returns the current particle system
  84350. */
  84351. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84352. /**
  84353. * Remove a specific color remap gradient
  84354. * @param gradient defines the gradient to remove
  84355. * @returns the current particle system
  84356. */
  84357. removeColorRemapGradient(gradient: number): IParticleSystem;
  84358. /**
  84359. * Adds a new alpha remap gradient
  84360. * @param gradient defines the gradient to use (between 0 and 1)
  84361. * @param min defines the alpha remap minimal range
  84362. * @param max defines the alpha remap maximal range
  84363. * @returns the current particle system
  84364. */
  84365. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84366. /**
  84367. * Remove a specific alpha remap gradient
  84368. * @param gradient defines the gradient to remove
  84369. * @returns the current particle system
  84370. */
  84371. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84372. /**
  84373. * Adds a new angular speed gradient
  84374. * @param gradient defines the gradient to use (between 0 and 1)
  84375. * @param factor defines the angular speed to affect to the specified gradient
  84376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84377. * @returns the current particle system
  84378. */
  84379. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84380. /**
  84381. * Remove a specific angular speed gradient
  84382. * @param gradient defines the gradient to remove
  84383. * @returns the current particle system
  84384. */
  84385. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84386. /**
  84387. * Adds a new velocity gradient
  84388. * @param gradient defines the gradient to use (between 0 and 1)
  84389. * @param factor defines the velocity to affect to the specified gradient
  84390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84391. * @returns the current particle system
  84392. */
  84393. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84394. /**
  84395. * Remove a specific velocity gradient
  84396. * @param gradient defines the gradient to remove
  84397. * @returns the current particle system
  84398. */
  84399. removeVelocityGradient(gradient: number): IParticleSystem;
  84400. /**
  84401. * Adds a new limit velocity gradient
  84402. * @param gradient defines the gradient to use (between 0 and 1)
  84403. * @param factor defines the limit velocity value to affect to the specified gradient
  84404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84405. * @returns the current particle system
  84406. */
  84407. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84408. /**
  84409. * Remove a specific limit velocity gradient
  84410. * @param gradient defines the gradient to remove
  84411. * @returns the current particle system
  84412. */
  84413. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84414. /**
  84415. * Adds a new drag gradient
  84416. * @param gradient defines the gradient to use (between 0 and 1)
  84417. * @param factor defines the drag value to affect to the specified gradient
  84418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84419. * @returns the current particle system
  84420. */
  84421. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84422. /**
  84423. * Remove a specific drag gradient
  84424. * @param gradient defines the gradient to remove
  84425. * @returns the current particle system
  84426. */
  84427. removeDragGradient(gradient: number): IParticleSystem;
  84428. /**
  84429. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84430. * @param gradient defines the gradient to use (between 0 and 1)
  84431. * @param factor defines the emit rate value to affect to the specified gradient
  84432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84433. * @returns the current particle system
  84434. */
  84435. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84436. /**
  84437. * Remove a specific emit rate gradient
  84438. * @param gradient defines the gradient to remove
  84439. * @returns the current particle system
  84440. */
  84441. removeEmitRateGradient(gradient: number): IParticleSystem;
  84442. /**
  84443. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84444. * @param gradient defines the gradient to use (between 0 and 1)
  84445. * @param factor defines the start size value to affect to the specified gradient
  84446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84447. * @returns the current particle system
  84448. */
  84449. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84450. /**
  84451. * Remove a specific start size gradient
  84452. * @param gradient defines the gradient to remove
  84453. * @returns the current particle system
  84454. */
  84455. removeStartSizeGradient(gradient: number): IParticleSystem;
  84456. private _createRampGradientTexture;
  84457. /**
  84458. * Gets the current list of ramp gradients.
  84459. * You must use addRampGradient and removeRampGradient to udpate this list
  84460. * @returns the list of ramp gradients
  84461. */
  84462. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84463. /**
  84464. * Adds a new ramp gradient used to remap particle colors
  84465. * @param gradient defines the gradient to use (between 0 and 1)
  84466. * @param color defines the color to affect to the specified gradient
  84467. * @returns the current particle system
  84468. */
  84469. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84470. /**
  84471. * Remove a specific ramp gradient
  84472. * @param gradient defines the gradient to remove
  84473. * @returns the current particle system
  84474. */
  84475. removeRampGradient(gradient: number): ParticleSystem;
  84476. /**
  84477. * Adds a new color gradient
  84478. * @param gradient defines the gradient to use (between 0 and 1)
  84479. * @param color1 defines the color to affect to the specified gradient
  84480. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84481. * @returns this particle system
  84482. */
  84483. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84484. /**
  84485. * Remove a specific color gradient
  84486. * @param gradient defines the gradient to remove
  84487. * @returns this particle system
  84488. */
  84489. removeColorGradient(gradient: number): IParticleSystem;
  84490. private _fetchR;
  84491. protected _reset(): void;
  84492. private _resetEffect;
  84493. private _createVertexBuffers;
  84494. private _createIndexBuffer;
  84495. /**
  84496. * Gets the maximum number of particles active at the same time.
  84497. * @returns The max number of active particles.
  84498. */
  84499. getCapacity(): number;
  84500. /**
  84501. * Gets whether there are still active particles in the system.
  84502. * @returns True if it is alive, otherwise false.
  84503. */
  84504. isAlive(): boolean;
  84505. /**
  84506. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84507. * @returns True if it has been started, otherwise false.
  84508. */
  84509. isStarted(): boolean;
  84510. private _prepareSubEmitterInternalArray;
  84511. /**
  84512. * Starts the particle system and begins to emit
  84513. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84514. */
  84515. start(delay?: number): void;
  84516. /**
  84517. * Stops the particle system.
  84518. * @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.
  84519. */
  84520. stop(stopSubEmitters?: boolean): void;
  84521. /**
  84522. * Remove all active particles
  84523. */
  84524. reset(): void;
  84525. /**
  84526. * @hidden (for internal use only)
  84527. */
  84528. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84529. /**
  84530. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84531. * Its lifetime will start back at 0.
  84532. */
  84533. recycleParticle: (particle: Particle) => void;
  84534. private _stopSubEmitters;
  84535. private _createParticle;
  84536. private _removeFromRoot;
  84537. private _emitFromParticle;
  84538. private _update;
  84539. /** @hidden */
  84540. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84541. /** @hidden */
  84542. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84543. /** @hidden */
  84544. private _getEffect;
  84545. /**
  84546. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84547. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84548. */
  84549. animate(preWarmOnly?: boolean): void;
  84550. private _appendParticleVertices;
  84551. /**
  84552. * Rebuilds the particle system.
  84553. */
  84554. rebuild(): void;
  84555. /**
  84556. * Is this system ready to be used/rendered
  84557. * @return true if the system is ready
  84558. */
  84559. isReady(): boolean;
  84560. private _render;
  84561. /**
  84562. * Renders the particle system in its current state.
  84563. * @returns the current number of particles
  84564. */
  84565. render(): number;
  84566. /**
  84567. * Disposes the particle system and free the associated resources
  84568. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84569. */
  84570. dispose(disposeTexture?: boolean): void;
  84571. /**
  84572. * Clones the particle system.
  84573. * @param name The name of the cloned object
  84574. * @param newEmitter The new emitter to use
  84575. * @returns the cloned particle system
  84576. */
  84577. clone(name: string, newEmitter: any): ParticleSystem;
  84578. /**
  84579. * Serializes the particle system to a JSON object.
  84580. * @returns the JSON object
  84581. */
  84582. serialize(): any;
  84583. /** @hidden */
  84584. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84585. /** @hidden */
  84586. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84587. /**
  84588. * Parses a JSON object to create a particle system.
  84589. * @param parsedParticleSystem The JSON object to parse
  84590. * @param scene The scene to create the particle system in
  84591. * @param rootUrl The root url to use to load external dependencies like texture
  84592. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84593. * @returns the Parsed particle system
  84594. */
  84595. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84596. }
  84597. }
  84598. declare module BABYLON {
  84599. /**
  84600. * A particle represents one of the element emitted by a particle system.
  84601. * This is mainly define by its coordinates, direction, velocity and age.
  84602. */
  84603. export class Particle {
  84604. /**
  84605. * The particle system the particle belongs to.
  84606. */
  84607. particleSystem: ParticleSystem;
  84608. private static _Count;
  84609. /**
  84610. * Unique ID of the particle
  84611. */
  84612. id: number;
  84613. /**
  84614. * The world position of the particle in the scene.
  84615. */
  84616. position: Vector3;
  84617. /**
  84618. * The world direction of the particle in the scene.
  84619. */
  84620. direction: Vector3;
  84621. /**
  84622. * The color of the particle.
  84623. */
  84624. color: Color4;
  84625. /**
  84626. * The color change of the particle per step.
  84627. */
  84628. colorStep: Color4;
  84629. /**
  84630. * Defines how long will the life of the particle be.
  84631. */
  84632. lifeTime: number;
  84633. /**
  84634. * The current age of the particle.
  84635. */
  84636. age: number;
  84637. /**
  84638. * The current size of the particle.
  84639. */
  84640. size: number;
  84641. /**
  84642. * The current scale of the particle.
  84643. */
  84644. scale: Vector2;
  84645. /**
  84646. * The current angle of the particle.
  84647. */
  84648. angle: number;
  84649. /**
  84650. * Defines how fast is the angle changing.
  84651. */
  84652. angularSpeed: number;
  84653. /**
  84654. * Defines the cell index used by the particle to be rendered from a sprite.
  84655. */
  84656. cellIndex: number;
  84657. /**
  84658. * The information required to support color remapping
  84659. */
  84660. remapData: Vector4;
  84661. /** @hidden */
  84662. _randomCellOffset?: number;
  84663. /** @hidden */
  84664. _initialDirection: Nullable<Vector3>;
  84665. /** @hidden */
  84666. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84667. /** @hidden */
  84668. _initialStartSpriteCellID: number;
  84669. /** @hidden */
  84670. _initialEndSpriteCellID: number;
  84671. /** @hidden */
  84672. _currentColorGradient: Nullable<ColorGradient>;
  84673. /** @hidden */
  84674. _currentColor1: Color4;
  84675. /** @hidden */
  84676. _currentColor2: Color4;
  84677. /** @hidden */
  84678. _currentSizeGradient: Nullable<FactorGradient>;
  84679. /** @hidden */
  84680. _currentSize1: number;
  84681. /** @hidden */
  84682. _currentSize2: number;
  84683. /** @hidden */
  84684. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84685. /** @hidden */
  84686. _currentAngularSpeed1: number;
  84687. /** @hidden */
  84688. _currentAngularSpeed2: number;
  84689. /** @hidden */
  84690. _currentVelocityGradient: Nullable<FactorGradient>;
  84691. /** @hidden */
  84692. _currentVelocity1: number;
  84693. /** @hidden */
  84694. _currentVelocity2: number;
  84695. /** @hidden */
  84696. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84697. /** @hidden */
  84698. _currentLimitVelocity1: number;
  84699. /** @hidden */
  84700. _currentLimitVelocity2: number;
  84701. /** @hidden */
  84702. _currentDragGradient: Nullable<FactorGradient>;
  84703. /** @hidden */
  84704. _currentDrag1: number;
  84705. /** @hidden */
  84706. _currentDrag2: number;
  84707. /** @hidden */
  84708. _randomNoiseCoordinates1: Vector3;
  84709. /** @hidden */
  84710. _randomNoiseCoordinates2: Vector3;
  84711. /**
  84712. * Creates a new instance Particle
  84713. * @param particleSystem the particle system the particle belongs to
  84714. */
  84715. constructor(
  84716. /**
  84717. * The particle system the particle belongs to.
  84718. */
  84719. particleSystem: ParticleSystem);
  84720. private updateCellInfoFromSystem;
  84721. /**
  84722. * Defines how the sprite cell index is updated for the particle
  84723. */
  84724. updateCellIndex(): void;
  84725. /** @hidden */
  84726. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84727. /** @hidden */
  84728. _inheritParticleInfoToSubEmitters(): void;
  84729. /** @hidden */
  84730. _reset(): void;
  84731. /**
  84732. * Copy the properties of particle to another one.
  84733. * @param other the particle to copy the information to.
  84734. */
  84735. copyTo(other: Particle): void;
  84736. }
  84737. }
  84738. declare module BABYLON {
  84739. /**
  84740. * Particle emitter represents a volume emitting particles.
  84741. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84742. */
  84743. export interface IParticleEmitterType {
  84744. /**
  84745. * Called by the particle System when the direction is computed for the created particle.
  84746. * @param worldMatrix is the world matrix of the particle system
  84747. * @param directionToUpdate is the direction vector to update with the result
  84748. * @param particle is the particle we are computed the direction for
  84749. */
  84750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84751. /**
  84752. * Called by the particle System when the position is computed for the created particle.
  84753. * @param worldMatrix is the world matrix of the particle system
  84754. * @param positionToUpdate is the position vector to update with the result
  84755. * @param particle is the particle we are computed the position for
  84756. */
  84757. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84758. /**
  84759. * Clones the current emitter and returns a copy of it
  84760. * @returns the new emitter
  84761. */
  84762. clone(): IParticleEmitterType;
  84763. /**
  84764. * Called by the GPUParticleSystem to setup the update shader
  84765. * @param effect defines the update shader
  84766. */
  84767. applyToShader(effect: Effect): void;
  84768. /**
  84769. * Returns a string to use to update the GPU particles update shader
  84770. * @returns the effect defines string
  84771. */
  84772. getEffectDefines(): string;
  84773. /**
  84774. * Returns a string representing the class name
  84775. * @returns a string containing the class name
  84776. */
  84777. getClassName(): string;
  84778. /**
  84779. * Serializes the particle system to a JSON object.
  84780. * @returns the JSON object
  84781. */
  84782. serialize(): any;
  84783. /**
  84784. * Parse properties from a JSON object
  84785. * @param serializationObject defines the JSON object
  84786. */
  84787. parse(serializationObject: any): void;
  84788. }
  84789. }
  84790. declare module BABYLON {
  84791. /**
  84792. * Particle emitter emitting particles from the inside of a box.
  84793. * It emits the particles randomly between 2 given directions.
  84794. */
  84795. export class BoxParticleEmitter implements IParticleEmitterType {
  84796. /**
  84797. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84798. */
  84799. direction1: Vector3;
  84800. /**
  84801. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84802. */
  84803. direction2: Vector3;
  84804. /**
  84805. * 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.
  84806. */
  84807. minEmitBox: Vector3;
  84808. /**
  84809. * 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.
  84810. */
  84811. maxEmitBox: Vector3;
  84812. /**
  84813. * Creates a new instance BoxParticleEmitter
  84814. */
  84815. constructor();
  84816. /**
  84817. * Called by the particle System when the direction is computed for the created particle.
  84818. * @param worldMatrix is the world matrix of the particle system
  84819. * @param directionToUpdate is the direction vector to update with the result
  84820. * @param particle is the particle we are computed the direction for
  84821. */
  84822. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84823. /**
  84824. * Called by the particle System when the position is computed for the created particle.
  84825. * @param worldMatrix is the world matrix of the particle system
  84826. * @param positionToUpdate is the position vector to update with the result
  84827. * @param particle is the particle we are computed the position for
  84828. */
  84829. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84830. /**
  84831. * Clones the current emitter and returns a copy of it
  84832. * @returns the new emitter
  84833. */
  84834. clone(): BoxParticleEmitter;
  84835. /**
  84836. * Called by the GPUParticleSystem to setup the update shader
  84837. * @param effect defines the update shader
  84838. */
  84839. applyToShader(effect: Effect): void;
  84840. /**
  84841. * Returns a string to use to update the GPU particles update shader
  84842. * @returns a string containng the defines string
  84843. */
  84844. getEffectDefines(): string;
  84845. /**
  84846. * Returns the string "BoxParticleEmitter"
  84847. * @returns a string containing the class name
  84848. */
  84849. getClassName(): string;
  84850. /**
  84851. * Serializes the particle system to a JSON object.
  84852. * @returns the JSON object
  84853. */
  84854. serialize(): any;
  84855. /**
  84856. * Parse properties from a JSON object
  84857. * @param serializationObject defines the JSON object
  84858. */
  84859. parse(serializationObject: any): void;
  84860. }
  84861. }
  84862. declare module BABYLON {
  84863. /**
  84864. * Particle emitter emitting particles from the inside of a cone.
  84865. * It emits the particles alongside the cone volume from the base to the particle.
  84866. * The emission direction might be randomized.
  84867. */
  84868. export class ConeParticleEmitter implements IParticleEmitterType {
  84869. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84870. directionRandomizer: number;
  84871. private _radius;
  84872. private _angle;
  84873. private _height;
  84874. /**
  84875. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84876. */
  84877. radiusRange: number;
  84878. /**
  84879. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84880. */
  84881. heightRange: number;
  84882. /**
  84883. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84884. */
  84885. emitFromSpawnPointOnly: boolean;
  84886. /**
  84887. * Gets or sets the radius of the emission cone
  84888. */
  84889. radius: number;
  84890. /**
  84891. * Gets or sets the angle of the emission cone
  84892. */
  84893. angle: number;
  84894. private _buildHeight;
  84895. /**
  84896. * Creates a new instance ConeParticleEmitter
  84897. * @param radius the radius of the emission cone (1 by default)
  84898. * @param angle the cone base angle (PI by default)
  84899. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84900. */
  84901. constructor(radius?: number, angle?: number,
  84902. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84903. directionRandomizer?: number);
  84904. /**
  84905. * Called by the particle System when the direction is computed for the created particle.
  84906. * @param worldMatrix is the world matrix of the particle system
  84907. * @param directionToUpdate is the direction vector to update with the result
  84908. * @param particle is the particle we are computed the direction for
  84909. */
  84910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84911. /**
  84912. * Called by the particle System when the position is computed for the created particle.
  84913. * @param worldMatrix is the world matrix of the particle system
  84914. * @param positionToUpdate is the position vector to update with the result
  84915. * @param particle is the particle we are computed the position for
  84916. */
  84917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84918. /**
  84919. * Clones the current emitter and returns a copy of it
  84920. * @returns the new emitter
  84921. */
  84922. clone(): ConeParticleEmitter;
  84923. /**
  84924. * Called by the GPUParticleSystem to setup the update shader
  84925. * @param effect defines the update shader
  84926. */
  84927. applyToShader(effect: Effect): void;
  84928. /**
  84929. * Returns a string to use to update the GPU particles update shader
  84930. * @returns a string containng the defines string
  84931. */
  84932. getEffectDefines(): string;
  84933. /**
  84934. * Returns the string "ConeParticleEmitter"
  84935. * @returns a string containing the class name
  84936. */
  84937. getClassName(): string;
  84938. /**
  84939. * Serializes the particle system to a JSON object.
  84940. * @returns the JSON object
  84941. */
  84942. serialize(): any;
  84943. /**
  84944. * Parse properties from a JSON object
  84945. * @param serializationObject defines the JSON object
  84946. */
  84947. parse(serializationObject: any): void;
  84948. }
  84949. }
  84950. declare module BABYLON {
  84951. /**
  84952. * Particle emitter emitting particles from the inside of a cylinder.
  84953. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84954. */
  84955. export class CylinderParticleEmitter implements IParticleEmitterType {
  84956. /**
  84957. * The radius of the emission cylinder.
  84958. */
  84959. radius: number;
  84960. /**
  84961. * The height of the emission cylinder.
  84962. */
  84963. height: number;
  84964. /**
  84965. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84966. */
  84967. radiusRange: number;
  84968. /**
  84969. * How much to randomize the particle direction [0-1].
  84970. */
  84971. directionRandomizer: number;
  84972. /**
  84973. * Creates a new instance CylinderParticleEmitter
  84974. * @param radius the radius of the emission cylinder (1 by default)
  84975. * @param height the height of the emission cylinder (1 by default)
  84976. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84977. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84978. */
  84979. constructor(
  84980. /**
  84981. * The radius of the emission cylinder.
  84982. */
  84983. radius?: number,
  84984. /**
  84985. * The height of the emission cylinder.
  84986. */
  84987. height?: number,
  84988. /**
  84989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84990. */
  84991. radiusRange?: number,
  84992. /**
  84993. * How much to randomize the particle direction [0-1].
  84994. */
  84995. directionRandomizer?: number);
  84996. /**
  84997. * Called by the particle System when the direction is computed for the created particle.
  84998. * @param worldMatrix is the world matrix of the particle system
  84999. * @param directionToUpdate is the direction vector to update with the result
  85000. * @param particle is the particle we are computed the direction for
  85001. */
  85002. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85003. /**
  85004. * Called by the particle System when the position is computed for the created particle.
  85005. * @param worldMatrix is the world matrix of the particle system
  85006. * @param positionToUpdate is the position vector to update with the result
  85007. * @param particle is the particle we are computed the position for
  85008. */
  85009. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85010. /**
  85011. * Clones the current emitter and returns a copy of it
  85012. * @returns the new emitter
  85013. */
  85014. clone(): CylinderParticleEmitter;
  85015. /**
  85016. * Called by the GPUParticleSystem to setup the update shader
  85017. * @param effect defines the update shader
  85018. */
  85019. applyToShader(effect: Effect): void;
  85020. /**
  85021. * Returns a string to use to update the GPU particles update shader
  85022. * @returns a string containng the defines string
  85023. */
  85024. getEffectDefines(): string;
  85025. /**
  85026. * Returns the string "CylinderParticleEmitter"
  85027. * @returns a string containing the class name
  85028. */
  85029. getClassName(): string;
  85030. /**
  85031. * Serializes the particle system to a JSON object.
  85032. * @returns the JSON object
  85033. */
  85034. serialize(): any;
  85035. /**
  85036. * Parse properties from a JSON object
  85037. * @param serializationObject defines the JSON object
  85038. */
  85039. parse(serializationObject: any): void;
  85040. }
  85041. /**
  85042. * Particle emitter emitting particles from the inside of a cylinder.
  85043. * It emits the particles randomly between two vectors.
  85044. */
  85045. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85046. /**
  85047. * The min limit of the emission direction.
  85048. */
  85049. direction1: Vector3;
  85050. /**
  85051. * The max limit of the emission direction.
  85052. */
  85053. direction2: Vector3;
  85054. /**
  85055. * Creates a new instance CylinderDirectedParticleEmitter
  85056. * @param radius the radius of the emission cylinder (1 by default)
  85057. * @param height the height of the emission cylinder (1 by default)
  85058. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85059. * @param direction1 the min limit of the emission direction (up vector by default)
  85060. * @param direction2 the max limit of the emission direction (up vector by default)
  85061. */
  85062. constructor(radius?: number, height?: number, radiusRange?: number,
  85063. /**
  85064. * The min limit of the emission direction.
  85065. */
  85066. direction1?: Vector3,
  85067. /**
  85068. * The max limit of the emission direction.
  85069. */
  85070. direction2?: Vector3);
  85071. /**
  85072. * Called by the particle System when the direction is computed for the created particle.
  85073. * @param worldMatrix is the world matrix of the particle system
  85074. * @param directionToUpdate is the direction vector to update with the result
  85075. * @param particle is the particle we are computed the direction for
  85076. */
  85077. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85078. /**
  85079. * Clones the current emitter and returns a copy of it
  85080. * @returns the new emitter
  85081. */
  85082. clone(): CylinderDirectedParticleEmitter;
  85083. /**
  85084. * Called by the GPUParticleSystem to setup the update shader
  85085. * @param effect defines the update shader
  85086. */
  85087. applyToShader(effect: Effect): void;
  85088. /**
  85089. * Returns a string to use to update the GPU particles update shader
  85090. * @returns a string containng the defines string
  85091. */
  85092. getEffectDefines(): string;
  85093. /**
  85094. * Returns the string "CylinderDirectedParticleEmitter"
  85095. * @returns a string containing the class name
  85096. */
  85097. getClassName(): string;
  85098. /**
  85099. * Serializes the particle system to a JSON object.
  85100. * @returns the JSON object
  85101. */
  85102. serialize(): any;
  85103. /**
  85104. * Parse properties from a JSON object
  85105. * @param serializationObject defines the JSON object
  85106. */
  85107. parse(serializationObject: any): void;
  85108. }
  85109. }
  85110. declare module BABYLON {
  85111. /**
  85112. * Particle emitter emitting particles from the inside of a hemisphere.
  85113. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85114. */
  85115. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85116. /**
  85117. * The radius of the emission hemisphere.
  85118. */
  85119. radius: number;
  85120. /**
  85121. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85122. */
  85123. radiusRange: number;
  85124. /**
  85125. * How much to randomize the particle direction [0-1].
  85126. */
  85127. directionRandomizer: number;
  85128. /**
  85129. * Creates a new instance HemisphericParticleEmitter
  85130. * @param radius the radius of the emission hemisphere (1 by default)
  85131. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85132. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85133. */
  85134. constructor(
  85135. /**
  85136. * The radius of the emission hemisphere.
  85137. */
  85138. radius?: number,
  85139. /**
  85140. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85141. */
  85142. radiusRange?: number,
  85143. /**
  85144. * How much to randomize the particle direction [0-1].
  85145. */
  85146. directionRandomizer?: number);
  85147. /**
  85148. * Called by the particle System when the direction is computed for the created particle.
  85149. * @param worldMatrix is the world matrix of the particle system
  85150. * @param directionToUpdate is the direction vector to update with the result
  85151. * @param particle is the particle we are computed the direction for
  85152. */
  85153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85154. /**
  85155. * Called by the particle System when the position is computed for the created particle.
  85156. * @param worldMatrix is the world matrix of the particle system
  85157. * @param positionToUpdate is the position vector to update with the result
  85158. * @param particle is the particle we are computed the position for
  85159. */
  85160. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85161. /**
  85162. * Clones the current emitter and returns a copy of it
  85163. * @returns the new emitter
  85164. */
  85165. clone(): HemisphericParticleEmitter;
  85166. /**
  85167. * Called by the GPUParticleSystem to setup the update shader
  85168. * @param effect defines the update shader
  85169. */
  85170. applyToShader(effect: Effect): void;
  85171. /**
  85172. * Returns a string to use to update the GPU particles update shader
  85173. * @returns a string containng the defines string
  85174. */
  85175. getEffectDefines(): string;
  85176. /**
  85177. * Returns the string "HemisphericParticleEmitter"
  85178. * @returns a string containing the class name
  85179. */
  85180. getClassName(): string;
  85181. /**
  85182. * Serializes the particle system to a JSON object.
  85183. * @returns the JSON object
  85184. */
  85185. serialize(): any;
  85186. /**
  85187. * Parse properties from a JSON object
  85188. * @param serializationObject defines the JSON object
  85189. */
  85190. parse(serializationObject: any): void;
  85191. }
  85192. }
  85193. declare module BABYLON {
  85194. /**
  85195. * Particle emitter emitting particles from a point.
  85196. * It emits the particles randomly between 2 given directions.
  85197. */
  85198. export class PointParticleEmitter implements IParticleEmitterType {
  85199. /**
  85200. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85201. */
  85202. direction1: Vector3;
  85203. /**
  85204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85205. */
  85206. direction2: Vector3;
  85207. /**
  85208. * Creates a new instance PointParticleEmitter
  85209. */
  85210. constructor();
  85211. /**
  85212. * Called by the particle System when the direction is computed for the created particle.
  85213. * @param worldMatrix is the world matrix of the particle system
  85214. * @param directionToUpdate is the direction vector to update with the result
  85215. * @param particle is the particle we are computed the direction for
  85216. */
  85217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85218. /**
  85219. * Called by the particle System when the position is computed for the created particle.
  85220. * @param worldMatrix is the world matrix of the particle system
  85221. * @param positionToUpdate is the position vector to update with the result
  85222. * @param particle is the particle we are computed the position for
  85223. */
  85224. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85225. /**
  85226. * Clones the current emitter and returns a copy of it
  85227. * @returns the new emitter
  85228. */
  85229. clone(): PointParticleEmitter;
  85230. /**
  85231. * Called by the GPUParticleSystem to setup the update shader
  85232. * @param effect defines the update shader
  85233. */
  85234. applyToShader(effect: Effect): void;
  85235. /**
  85236. * Returns a string to use to update the GPU particles update shader
  85237. * @returns a string containng the defines string
  85238. */
  85239. getEffectDefines(): string;
  85240. /**
  85241. * Returns the string "PointParticleEmitter"
  85242. * @returns a string containing the class name
  85243. */
  85244. getClassName(): string;
  85245. /**
  85246. * Serializes the particle system to a JSON object.
  85247. * @returns the JSON object
  85248. */
  85249. serialize(): any;
  85250. /**
  85251. * Parse properties from a JSON object
  85252. * @param serializationObject defines the JSON object
  85253. */
  85254. parse(serializationObject: any): void;
  85255. }
  85256. }
  85257. declare module BABYLON {
  85258. /**
  85259. * Particle emitter emitting particles from the inside of a sphere.
  85260. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85261. */
  85262. export class SphereParticleEmitter implements IParticleEmitterType {
  85263. /**
  85264. * The radius of the emission sphere.
  85265. */
  85266. radius: number;
  85267. /**
  85268. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85269. */
  85270. radiusRange: number;
  85271. /**
  85272. * How much to randomize the particle direction [0-1].
  85273. */
  85274. directionRandomizer: number;
  85275. /**
  85276. * Creates a new instance SphereParticleEmitter
  85277. * @param radius the radius of the emission sphere (1 by default)
  85278. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85279. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85280. */
  85281. constructor(
  85282. /**
  85283. * The radius of the emission sphere.
  85284. */
  85285. radius?: number,
  85286. /**
  85287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85288. */
  85289. radiusRange?: number,
  85290. /**
  85291. * How much to randomize the particle direction [0-1].
  85292. */
  85293. directionRandomizer?: number);
  85294. /**
  85295. * Called by the particle System when the direction is computed for the created particle.
  85296. * @param worldMatrix is the world matrix of the particle system
  85297. * @param directionToUpdate is the direction vector to update with the result
  85298. * @param particle is the particle we are computed the direction for
  85299. */
  85300. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85301. /**
  85302. * Called by the particle System when the position is computed for the created particle.
  85303. * @param worldMatrix is the world matrix of the particle system
  85304. * @param positionToUpdate is the position vector to update with the result
  85305. * @param particle is the particle we are computed the position for
  85306. */
  85307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85308. /**
  85309. * Clones the current emitter and returns a copy of it
  85310. * @returns the new emitter
  85311. */
  85312. clone(): SphereParticleEmitter;
  85313. /**
  85314. * Called by the GPUParticleSystem to setup the update shader
  85315. * @param effect defines the update shader
  85316. */
  85317. applyToShader(effect: Effect): void;
  85318. /**
  85319. * Returns a string to use to update the GPU particles update shader
  85320. * @returns a string containng the defines string
  85321. */
  85322. getEffectDefines(): string;
  85323. /**
  85324. * Returns the string "SphereParticleEmitter"
  85325. * @returns a string containing the class name
  85326. */
  85327. getClassName(): string;
  85328. /**
  85329. * Serializes the particle system to a JSON object.
  85330. * @returns the JSON object
  85331. */
  85332. serialize(): any;
  85333. /**
  85334. * Parse properties from a JSON object
  85335. * @param serializationObject defines the JSON object
  85336. */
  85337. parse(serializationObject: any): void;
  85338. }
  85339. /**
  85340. * Particle emitter emitting particles from the inside of a sphere.
  85341. * It emits the particles randomly between two vectors.
  85342. */
  85343. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85344. /**
  85345. * The min limit of the emission direction.
  85346. */
  85347. direction1: Vector3;
  85348. /**
  85349. * The max limit of the emission direction.
  85350. */
  85351. direction2: Vector3;
  85352. /**
  85353. * Creates a new instance SphereDirectedParticleEmitter
  85354. * @param radius the radius of the emission sphere (1 by default)
  85355. * @param direction1 the min limit of the emission direction (up vector by default)
  85356. * @param direction2 the max limit of the emission direction (up vector by default)
  85357. */
  85358. constructor(radius?: number,
  85359. /**
  85360. * The min limit of the emission direction.
  85361. */
  85362. direction1?: Vector3,
  85363. /**
  85364. * The max limit of the emission direction.
  85365. */
  85366. direction2?: Vector3);
  85367. /**
  85368. * Called by the particle System when the direction is computed for the created particle.
  85369. * @param worldMatrix is the world matrix of the particle system
  85370. * @param directionToUpdate is the direction vector to update with the result
  85371. * @param particle is the particle we are computed the direction for
  85372. */
  85373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85374. /**
  85375. * Clones the current emitter and returns a copy of it
  85376. * @returns the new emitter
  85377. */
  85378. clone(): SphereDirectedParticleEmitter;
  85379. /**
  85380. * Called by the GPUParticleSystem to setup the update shader
  85381. * @param effect defines the update shader
  85382. */
  85383. applyToShader(effect: Effect): void;
  85384. /**
  85385. * Returns a string to use to update the GPU particles update shader
  85386. * @returns a string containng the defines string
  85387. */
  85388. getEffectDefines(): string;
  85389. /**
  85390. * Returns the string "SphereDirectedParticleEmitter"
  85391. * @returns a string containing the class name
  85392. */
  85393. getClassName(): string;
  85394. /**
  85395. * Serializes the particle system to a JSON object.
  85396. * @returns the JSON object
  85397. */
  85398. serialize(): any;
  85399. /**
  85400. * Parse properties from a JSON object
  85401. * @param serializationObject defines the JSON object
  85402. */
  85403. parse(serializationObject: any): void;
  85404. }
  85405. }
  85406. declare module BABYLON {
  85407. /**
  85408. * Interface representing a particle system in Babylon.js.
  85409. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85410. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85411. */
  85412. export interface IParticleSystem {
  85413. /**
  85414. * List of animations used by the particle system.
  85415. */
  85416. animations: Animation[];
  85417. /**
  85418. * The id of the Particle system.
  85419. */
  85420. id: string;
  85421. /**
  85422. * The name of the Particle system.
  85423. */
  85424. name: string;
  85425. /**
  85426. * The emitter represents the Mesh or position we are attaching the particle system to.
  85427. */
  85428. emitter: Nullable<AbstractMesh | Vector3>;
  85429. /**
  85430. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85431. */
  85432. isBillboardBased: boolean;
  85433. /**
  85434. * The rendering group used by the Particle system to chose when to render.
  85435. */
  85436. renderingGroupId: number;
  85437. /**
  85438. * The layer mask we are rendering the particles through.
  85439. */
  85440. layerMask: number;
  85441. /**
  85442. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85443. */
  85444. updateSpeed: number;
  85445. /**
  85446. * The amount of time the particle system is running (depends of the overall update speed).
  85447. */
  85448. targetStopDuration: number;
  85449. /**
  85450. * The texture used to render each particle. (this can be a spritesheet)
  85451. */
  85452. particleTexture: Nullable<Texture>;
  85453. /**
  85454. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85455. */
  85456. blendMode: number;
  85457. /**
  85458. * Minimum life time of emitting particles.
  85459. */
  85460. minLifeTime: number;
  85461. /**
  85462. * Maximum life time of emitting particles.
  85463. */
  85464. maxLifeTime: number;
  85465. /**
  85466. * Minimum Size of emitting particles.
  85467. */
  85468. minSize: number;
  85469. /**
  85470. * Maximum Size of emitting particles.
  85471. */
  85472. maxSize: number;
  85473. /**
  85474. * Minimum scale of emitting particles on X axis.
  85475. */
  85476. minScaleX: number;
  85477. /**
  85478. * Maximum scale of emitting particles on X axis.
  85479. */
  85480. maxScaleX: number;
  85481. /**
  85482. * Minimum scale of emitting particles on Y axis.
  85483. */
  85484. minScaleY: number;
  85485. /**
  85486. * Maximum scale of emitting particles on Y axis.
  85487. */
  85488. maxScaleY: number;
  85489. /**
  85490. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85491. */
  85492. color1: Color4;
  85493. /**
  85494. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85495. */
  85496. color2: Color4;
  85497. /**
  85498. * Color the particle will have at the end of its lifetime.
  85499. */
  85500. colorDead: Color4;
  85501. /**
  85502. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85503. */
  85504. emitRate: number;
  85505. /**
  85506. * You can use gravity if you want to give an orientation to your particles.
  85507. */
  85508. gravity: Vector3;
  85509. /**
  85510. * Minimum power of emitting particles.
  85511. */
  85512. minEmitPower: number;
  85513. /**
  85514. * Maximum power of emitting particles.
  85515. */
  85516. maxEmitPower: number;
  85517. /**
  85518. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85519. */
  85520. minAngularSpeed: number;
  85521. /**
  85522. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85523. */
  85524. maxAngularSpeed: number;
  85525. /**
  85526. * Gets or sets the minimal initial rotation in radians.
  85527. */
  85528. minInitialRotation: number;
  85529. /**
  85530. * Gets or sets the maximal initial rotation in radians.
  85531. */
  85532. maxInitialRotation: number;
  85533. /**
  85534. * The particle emitter type defines the emitter used by the particle system.
  85535. * It can be for example box, sphere, or cone...
  85536. */
  85537. particleEmitterType: Nullable<IParticleEmitterType>;
  85538. /**
  85539. * Defines the delay in milliseconds before starting the system (0 by default)
  85540. */
  85541. startDelay: number;
  85542. /**
  85543. * 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
  85544. */
  85545. preWarmCycles: number;
  85546. /**
  85547. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85548. */
  85549. preWarmStepOffset: number;
  85550. /**
  85551. * 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)
  85552. */
  85553. spriteCellChangeSpeed: number;
  85554. /**
  85555. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85556. */
  85557. startSpriteCellID: number;
  85558. /**
  85559. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85560. */
  85561. endSpriteCellID: number;
  85562. /**
  85563. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85564. */
  85565. spriteCellWidth: number;
  85566. /**
  85567. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85568. */
  85569. spriteCellHeight: number;
  85570. /**
  85571. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85572. */
  85573. spriteRandomStartCell: boolean;
  85574. /**
  85575. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85576. */
  85577. isAnimationSheetEnabled: boolean;
  85578. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85579. translationPivot: Vector2;
  85580. /**
  85581. * Gets or sets a texture used to add random noise to particle positions
  85582. */
  85583. noiseTexture: Nullable<BaseTexture>;
  85584. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85585. noiseStrength: Vector3;
  85586. /**
  85587. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85588. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85589. */
  85590. billboardMode: number;
  85591. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85592. limitVelocityDamping: number;
  85593. /**
  85594. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85595. */
  85596. beginAnimationOnStart: boolean;
  85597. /**
  85598. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85599. */
  85600. beginAnimationFrom: number;
  85601. /**
  85602. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85603. */
  85604. beginAnimationTo: number;
  85605. /**
  85606. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85607. */
  85608. beginAnimationLoop: boolean;
  85609. /**
  85610. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85611. */
  85612. disposeOnStop: boolean;
  85613. /**
  85614. * Gets the maximum number of particles active at the same time.
  85615. * @returns The max number of active particles.
  85616. */
  85617. getCapacity(): number;
  85618. /**
  85619. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85620. * @returns True if it has been started, otherwise false.
  85621. */
  85622. isStarted(): boolean;
  85623. /**
  85624. * Animates the particle system for this frame.
  85625. */
  85626. animate(): void;
  85627. /**
  85628. * Renders the particle system in its current state.
  85629. * @returns the current number of particles
  85630. */
  85631. render(): number;
  85632. /**
  85633. * Dispose the particle system and frees its associated resources.
  85634. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85635. */
  85636. dispose(disposeTexture?: boolean): void;
  85637. /**
  85638. * Clones the particle system.
  85639. * @param name The name of the cloned object
  85640. * @param newEmitter The new emitter to use
  85641. * @returns the cloned particle system
  85642. */
  85643. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85644. /**
  85645. * Serializes the particle system to a JSON object.
  85646. * @returns the JSON object
  85647. */
  85648. serialize(): any;
  85649. /**
  85650. * Rebuild the particle system
  85651. */
  85652. rebuild(): void;
  85653. /**
  85654. * Starts the particle system and begins to emit
  85655. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85656. */
  85657. start(delay?: number): void;
  85658. /**
  85659. * Stops the particle system.
  85660. */
  85661. stop(): void;
  85662. /**
  85663. * Remove all active particles
  85664. */
  85665. reset(): void;
  85666. /**
  85667. * Is this system ready to be used/rendered
  85668. * @return true if the system is ready
  85669. */
  85670. isReady(): boolean;
  85671. /**
  85672. * Adds a new color gradient
  85673. * @param gradient defines the gradient to use (between 0 and 1)
  85674. * @param color1 defines the color to affect to the specified gradient
  85675. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85676. * @returns the current particle system
  85677. */
  85678. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85679. /**
  85680. * Remove a specific color gradient
  85681. * @param gradient defines the gradient to remove
  85682. * @returns the current particle system
  85683. */
  85684. removeColorGradient(gradient: number): IParticleSystem;
  85685. /**
  85686. * Adds a new size gradient
  85687. * @param gradient defines the gradient to use (between 0 and 1)
  85688. * @param factor defines the size factor to affect to the specified gradient
  85689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85690. * @returns the current particle system
  85691. */
  85692. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85693. /**
  85694. * Remove a specific size gradient
  85695. * @param gradient defines the gradient to remove
  85696. * @returns the current particle system
  85697. */
  85698. removeSizeGradient(gradient: number): IParticleSystem;
  85699. /**
  85700. * Gets the current list of color gradients.
  85701. * You must use addColorGradient and removeColorGradient to udpate this list
  85702. * @returns the list of color gradients
  85703. */
  85704. getColorGradients(): Nullable<Array<ColorGradient>>;
  85705. /**
  85706. * Gets the current list of size gradients.
  85707. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85708. * @returns the list of size gradients
  85709. */
  85710. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85711. /**
  85712. * Gets the current list of angular speed gradients.
  85713. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85714. * @returns the list of angular speed gradients
  85715. */
  85716. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85717. /**
  85718. * Adds a new angular speed gradient
  85719. * @param gradient defines the gradient to use (between 0 and 1)
  85720. * @param factor defines the angular speed to affect to the specified gradient
  85721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85722. * @returns the current particle system
  85723. */
  85724. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85725. /**
  85726. * Remove a specific angular speed gradient
  85727. * @param gradient defines the gradient to remove
  85728. * @returns the current particle system
  85729. */
  85730. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85731. /**
  85732. * Gets the current list of velocity gradients.
  85733. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85734. * @returns the list of velocity gradients
  85735. */
  85736. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85737. /**
  85738. * Adds a new velocity gradient
  85739. * @param gradient defines the gradient to use (between 0 and 1)
  85740. * @param factor defines the velocity to affect to the specified gradient
  85741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85742. * @returns the current particle system
  85743. */
  85744. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85745. /**
  85746. * Remove a specific velocity gradient
  85747. * @param gradient defines the gradient to remove
  85748. * @returns the current particle system
  85749. */
  85750. removeVelocityGradient(gradient: number): IParticleSystem;
  85751. /**
  85752. * Gets the current list of limit velocity gradients.
  85753. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85754. * @returns the list of limit velocity gradients
  85755. */
  85756. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85757. /**
  85758. * Adds a new limit velocity gradient
  85759. * @param gradient defines the gradient to use (between 0 and 1)
  85760. * @param factor defines the limit velocity to affect to the specified gradient
  85761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85762. * @returns the current particle system
  85763. */
  85764. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85765. /**
  85766. * Remove a specific limit velocity gradient
  85767. * @param gradient defines the gradient to remove
  85768. * @returns the current particle system
  85769. */
  85770. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85771. /**
  85772. * Adds a new drag gradient
  85773. * @param gradient defines the gradient to use (between 0 and 1)
  85774. * @param factor defines the drag to affect to the specified gradient
  85775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85776. * @returns the current particle system
  85777. */
  85778. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85779. /**
  85780. * Remove a specific drag gradient
  85781. * @param gradient defines the gradient to remove
  85782. * @returns the current particle system
  85783. */
  85784. removeDragGradient(gradient: number): IParticleSystem;
  85785. /**
  85786. * Gets the current list of drag gradients.
  85787. * You must use addDragGradient and removeDragGradient to udpate this list
  85788. * @returns the list of drag gradients
  85789. */
  85790. getDragGradients(): Nullable<Array<FactorGradient>>;
  85791. /**
  85792. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85793. * @param gradient defines the gradient to use (between 0 and 1)
  85794. * @param factor defines the emit rate to affect to the specified gradient
  85795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85796. * @returns the current particle system
  85797. */
  85798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85799. /**
  85800. * Remove a specific emit rate gradient
  85801. * @param gradient defines the gradient to remove
  85802. * @returns the current particle system
  85803. */
  85804. removeEmitRateGradient(gradient: number): IParticleSystem;
  85805. /**
  85806. * Gets the current list of emit rate gradients.
  85807. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85808. * @returns the list of emit rate gradients
  85809. */
  85810. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85811. /**
  85812. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85813. * @param gradient defines the gradient to use (between 0 and 1)
  85814. * @param factor defines the start size to affect to the specified gradient
  85815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85816. * @returns the current particle system
  85817. */
  85818. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85819. /**
  85820. * Remove a specific start size gradient
  85821. * @param gradient defines the gradient to remove
  85822. * @returns the current particle system
  85823. */
  85824. removeStartSizeGradient(gradient: number): IParticleSystem;
  85825. /**
  85826. * Gets the current list of start size gradients.
  85827. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85828. * @returns the list of start size gradients
  85829. */
  85830. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85831. /**
  85832. * Adds a new life time gradient
  85833. * @param gradient defines the gradient to use (between 0 and 1)
  85834. * @param factor defines the life time factor to affect to the specified gradient
  85835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85836. * @returns the current particle system
  85837. */
  85838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85839. /**
  85840. * Remove a specific life time gradient
  85841. * @param gradient defines the gradient to remove
  85842. * @returns the current particle system
  85843. */
  85844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85845. /**
  85846. * Gets the current list of life time gradients.
  85847. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85848. * @returns the list of life time gradients
  85849. */
  85850. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85851. /**
  85852. * Gets the current list of color gradients.
  85853. * You must use addColorGradient and removeColorGradient to udpate this list
  85854. * @returns the list of color gradients
  85855. */
  85856. getColorGradients(): Nullable<Array<ColorGradient>>;
  85857. /**
  85858. * Adds a new ramp gradient used to remap particle colors
  85859. * @param gradient defines the gradient to use (between 0 and 1)
  85860. * @param color defines the color to affect to the specified gradient
  85861. * @returns the current particle system
  85862. */
  85863. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85864. /**
  85865. * Gets the current list of ramp gradients.
  85866. * You must use addRampGradient and removeRampGradient to udpate this list
  85867. * @returns the list of ramp gradients
  85868. */
  85869. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85870. /** Gets or sets a boolean indicating that ramp gradients must be used
  85871. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85872. */
  85873. useRampGradients: boolean;
  85874. /**
  85875. * Adds a new color remap gradient
  85876. * @param gradient defines the gradient to use (between 0 and 1)
  85877. * @param min defines the color remap minimal range
  85878. * @param max defines the color remap maximal range
  85879. * @returns the current particle system
  85880. */
  85881. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85882. /**
  85883. * Gets the current list of color remap gradients.
  85884. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85885. * @returns the list of color remap gradients
  85886. */
  85887. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85888. /**
  85889. * Adds a new alpha remap gradient
  85890. * @param gradient defines the gradient to use (between 0 and 1)
  85891. * @param min defines the alpha remap minimal range
  85892. * @param max defines the alpha remap maximal range
  85893. * @returns the current particle system
  85894. */
  85895. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85896. /**
  85897. * Gets the current list of alpha remap gradients.
  85898. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85899. * @returns the list of alpha remap gradients
  85900. */
  85901. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85902. /**
  85903. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85904. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85905. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85906. * @returns the emitter
  85907. */
  85908. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85909. /**
  85910. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85911. * @param radius The radius of the hemisphere to emit from
  85912. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85913. * @returns the emitter
  85914. */
  85915. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85916. /**
  85917. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85918. * @param radius The radius of the sphere to emit from
  85919. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85920. * @returns the emitter
  85921. */
  85922. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85923. /**
  85924. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85925. * @param radius The radius of the sphere to emit from
  85926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85928. * @returns the emitter
  85929. */
  85930. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85931. /**
  85932. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85933. * @param radius The radius of the emission cylinder
  85934. * @param height The height of the emission cylinder
  85935. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85936. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85937. * @returns the emitter
  85938. */
  85939. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85940. /**
  85941. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85942. * @param radius The radius of the cylinder to emit from
  85943. * @param height The height of the emission cylinder
  85944. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85945. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85946. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85947. * @returns the emitter
  85948. */
  85949. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85950. /**
  85951. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85952. * @param radius The radius of the cone to emit from
  85953. * @param angle The base angle of the cone
  85954. * @returns the emitter
  85955. */
  85956. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85957. /**
  85958. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85961. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85962. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85963. * @returns the emitter
  85964. */
  85965. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85966. /**
  85967. * Get hosting scene
  85968. * @returns the scene
  85969. */
  85970. getScene(): Scene;
  85971. }
  85972. }
  85973. declare module BABYLON {
  85974. /**
  85975. * Creates an instance based on a source mesh.
  85976. */
  85977. export class InstancedMesh extends AbstractMesh {
  85978. private _sourceMesh;
  85979. private _currentLOD;
  85980. /** @hidden */
  85981. _indexInSourceMeshInstanceArray: number;
  85982. constructor(name: string, source: Mesh);
  85983. /**
  85984. * Returns the string "InstancedMesh".
  85985. */
  85986. getClassName(): string;
  85987. /** Gets the list of lights affecting that mesh */
  85988. readonly lightSources: Light[];
  85989. _resyncLightSources(): void;
  85990. _resyncLighSource(light: Light): void;
  85991. _removeLightSource(light: Light, dispose: boolean): void;
  85992. /**
  85993. * If the source mesh receives shadows
  85994. */
  85995. readonly receiveShadows: boolean;
  85996. /**
  85997. * The material of the source mesh
  85998. */
  85999. readonly material: Nullable<Material>;
  86000. /**
  86001. * Visibility of the source mesh
  86002. */
  86003. readonly visibility: number;
  86004. /**
  86005. * Skeleton of the source mesh
  86006. */
  86007. readonly skeleton: Nullable<Skeleton>;
  86008. /**
  86009. * Rendering ground id of the source mesh
  86010. */
  86011. renderingGroupId: number;
  86012. /**
  86013. * Returns the total number of vertices (integer).
  86014. */
  86015. getTotalVertices(): number;
  86016. /**
  86017. * Returns a positive integer : the total number of indices in this mesh geometry.
  86018. * @returns the numner of indices or zero if the mesh has no geometry.
  86019. */
  86020. getTotalIndices(): number;
  86021. /**
  86022. * The source mesh of the instance
  86023. */
  86024. readonly sourceMesh: Mesh;
  86025. /**
  86026. * Is this node ready to be used/rendered
  86027. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86028. * @return {boolean} is it ready
  86029. */
  86030. isReady(completeCheck?: boolean): boolean;
  86031. /**
  86032. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86033. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86034. * @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.
  86035. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86036. */
  86037. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86038. /**
  86039. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86040. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86041. * The `data` are either a numeric array either a Float32Array.
  86042. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86043. * 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).
  86044. * Note that a new underlying VertexBuffer object is created each call.
  86045. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86046. *
  86047. * Possible `kind` values :
  86048. * - VertexBuffer.PositionKind
  86049. * - VertexBuffer.UVKind
  86050. * - VertexBuffer.UV2Kind
  86051. * - VertexBuffer.UV3Kind
  86052. * - VertexBuffer.UV4Kind
  86053. * - VertexBuffer.UV5Kind
  86054. * - VertexBuffer.UV6Kind
  86055. * - VertexBuffer.ColorKind
  86056. * - VertexBuffer.MatricesIndicesKind
  86057. * - VertexBuffer.MatricesIndicesExtraKind
  86058. * - VertexBuffer.MatricesWeightsKind
  86059. * - VertexBuffer.MatricesWeightsExtraKind
  86060. *
  86061. * Returns the Mesh.
  86062. */
  86063. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86064. /**
  86065. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86066. * If the mesh has no geometry, it is simply returned as it is.
  86067. * The `data` are either a numeric array either a Float32Array.
  86068. * No new underlying VertexBuffer object is created.
  86069. * 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.
  86070. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86071. *
  86072. * Possible `kind` values :
  86073. * - VertexBuffer.PositionKind
  86074. * - VertexBuffer.UVKind
  86075. * - VertexBuffer.UV2Kind
  86076. * - VertexBuffer.UV3Kind
  86077. * - VertexBuffer.UV4Kind
  86078. * - VertexBuffer.UV5Kind
  86079. * - VertexBuffer.UV6Kind
  86080. * - VertexBuffer.ColorKind
  86081. * - VertexBuffer.MatricesIndicesKind
  86082. * - VertexBuffer.MatricesIndicesExtraKind
  86083. * - VertexBuffer.MatricesWeightsKind
  86084. * - VertexBuffer.MatricesWeightsExtraKind
  86085. *
  86086. * Returns the Mesh.
  86087. */
  86088. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86089. /**
  86090. * Sets the mesh indices.
  86091. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86092. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86093. * This method creates a new index buffer each call.
  86094. * Returns the Mesh.
  86095. */
  86096. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86097. /**
  86098. * Boolean : True if the mesh owns the requested kind of data.
  86099. */
  86100. isVerticesDataPresent(kind: string): boolean;
  86101. /**
  86102. * Returns an array of indices (IndicesArray).
  86103. */
  86104. getIndices(): Nullable<IndicesArray>;
  86105. readonly _positions: Nullable<Vector3[]>;
  86106. /**
  86107. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86108. * This means the mesh underlying bounding box and sphere are recomputed.
  86109. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86110. * @returns the current mesh
  86111. */
  86112. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86113. /** @hidden */
  86114. _preActivate(): InstancedMesh;
  86115. /** @hidden */
  86116. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86117. /** @hidden */
  86118. _postActivate(): void;
  86119. getWorldMatrix(): Matrix;
  86120. readonly isAnInstance: boolean;
  86121. /**
  86122. * Returns the current associated LOD AbstractMesh.
  86123. */
  86124. getLOD(camera: Camera): AbstractMesh;
  86125. /** @hidden */
  86126. _syncSubMeshes(): InstancedMesh;
  86127. /** @hidden */
  86128. _generatePointsArray(): boolean;
  86129. /**
  86130. * Creates a new InstancedMesh from the current mesh.
  86131. * - name (string) : the cloned mesh name
  86132. * - newParent (optional Node) : the optional Node to parent the clone to.
  86133. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86134. *
  86135. * Returns the clone.
  86136. */
  86137. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86138. /**
  86139. * Disposes the InstancedMesh.
  86140. * Returns nothing.
  86141. */
  86142. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86143. }
  86144. }
  86145. declare module BABYLON {
  86146. /**
  86147. * Defines the options associated with the creation of a shader material.
  86148. */
  86149. export interface IShaderMaterialOptions {
  86150. /**
  86151. * Does the material work in alpha blend mode
  86152. */
  86153. needAlphaBlending: boolean;
  86154. /**
  86155. * Does the material work in alpha test mode
  86156. */
  86157. needAlphaTesting: boolean;
  86158. /**
  86159. * The list of attribute names used in the shader
  86160. */
  86161. attributes: string[];
  86162. /**
  86163. * The list of unifrom names used in the shader
  86164. */
  86165. uniforms: string[];
  86166. /**
  86167. * The list of UBO names used in the shader
  86168. */
  86169. uniformBuffers: string[];
  86170. /**
  86171. * The list of sampler names used in the shader
  86172. */
  86173. samplers: string[];
  86174. /**
  86175. * The list of defines used in the shader
  86176. */
  86177. defines: string[];
  86178. }
  86179. /**
  86180. * 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.
  86181. *
  86182. * This returned material effects how the mesh will look based on the code in the shaders.
  86183. *
  86184. * @see http://doc.babylonjs.com/how_to/shader_material
  86185. */
  86186. export class ShaderMaterial extends Material {
  86187. private _shaderPath;
  86188. private _options;
  86189. private _textures;
  86190. private _textureArrays;
  86191. private _floats;
  86192. private _ints;
  86193. private _floatsArrays;
  86194. private _colors3;
  86195. private _colors3Arrays;
  86196. private _colors4;
  86197. private _colors4Arrays;
  86198. private _vectors2;
  86199. private _vectors3;
  86200. private _vectors4;
  86201. private _matrices;
  86202. private _matrices3x3;
  86203. private _matrices2x2;
  86204. private _vectors2Arrays;
  86205. private _vectors3Arrays;
  86206. private _vectors4Arrays;
  86207. private _cachedWorldViewMatrix;
  86208. private _cachedWorldViewProjectionMatrix;
  86209. private _renderId;
  86210. /**
  86211. * Instantiate a new shader material.
  86212. * 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.
  86213. * This returned material effects how the mesh will look based on the code in the shaders.
  86214. * @see http://doc.babylonjs.com/how_to/shader_material
  86215. * @param name Define the name of the material in the scene
  86216. * @param scene Define the scene the material belongs to
  86217. * @param shaderPath Defines the route to the shader code in one of three ways:
  86218. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86219. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86220. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86221. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86222. * @param options Define the options used to create the shader
  86223. */
  86224. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86225. /**
  86226. * Gets the options used to compile the shader.
  86227. * They can be modified to trigger a new compilation
  86228. */
  86229. readonly options: IShaderMaterialOptions;
  86230. /**
  86231. * Gets the current class name of the material e.g. "ShaderMaterial"
  86232. * Mainly use in serialization.
  86233. * @returns the class name
  86234. */
  86235. getClassName(): string;
  86236. /**
  86237. * Specifies if the material will require alpha blending
  86238. * @returns a boolean specifying if alpha blending is needed
  86239. */
  86240. needAlphaBlending(): boolean;
  86241. /**
  86242. * Specifies if this material should be rendered in alpha test mode
  86243. * @returns a boolean specifying if an alpha test is needed.
  86244. */
  86245. needAlphaTesting(): boolean;
  86246. private _checkUniform;
  86247. /**
  86248. * Set a texture in the shader.
  86249. * @param name Define the name of the uniform samplers as defined in the shader
  86250. * @param texture Define the texture to bind to this sampler
  86251. * @return the material itself allowing "fluent" like uniform updates
  86252. */
  86253. setTexture(name: string, texture: Texture): ShaderMaterial;
  86254. /**
  86255. * Set a texture array in the shader.
  86256. * @param name Define the name of the uniform sampler array as defined in the shader
  86257. * @param textures Define the list of textures to bind to this sampler
  86258. * @return the material itself allowing "fluent" like uniform updates
  86259. */
  86260. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86261. /**
  86262. * Set a float in the shader.
  86263. * @param name Define the name of the uniform as defined in the shader
  86264. * @param value Define the value to give to the uniform
  86265. * @return the material itself allowing "fluent" like uniform updates
  86266. */
  86267. setFloat(name: string, value: number): ShaderMaterial;
  86268. /**
  86269. * Set a int in the shader.
  86270. * @param name Define the name of the uniform as defined in the shader
  86271. * @param value Define the value to give to the uniform
  86272. * @return the material itself allowing "fluent" like uniform updates
  86273. */
  86274. setInt(name: string, value: number): ShaderMaterial;
  86275. /**
  86276. * Set an array of floats in the shader.
  86277. * @param name Define the name of the uniform as defined in the shader
  86278. * @param value Define the value to give to the uniform
  86279. * @return the material itself allowing "fluent" like uniform updates
  86280. */
  86281. setFloats(name: string, value: number[]): ShaderMaterial;
  86282. /**
  86283. * Set a vec3 in the shader from a Color3.
  86284. * @param name Define the name of the uniform as defined in the shader
  86285. * @param value Define the value to give to the uniform
  86286. * @return the material itself allowing "fluent" like uniform updates
  86287. */
  86288. setColor3(name: string, value: Color3): ShaderMaterial;
  86289. /**
  86290. * Set a vec3 array in the shader from a Color3 array.
  86291. * @param name Define the name of the uniform as defined in the shader
  86292. * @param value Define the value to give to the uniform
  86293. * @return the material itself allowing "fluent" like uniform updates
  86294. */
  86295. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86296. /**
  86297. * Set a vec4 in the shader from a Color4.
  86298. * @param name Define the name of the uniform as defined in the shader
  86299. * @param value Define the value to give to the uniform
  86300. * @return the material itself allowing "fluent" like uniform updates
  86301. */
  86302. setColor4(name: string, value: Color4): ShaderMaterial;
  86303. /**
  86304. * Set a vec4 array in the shader from a Color4 array.
  86305. * @param name Define the name of the uniform as defined in the shader
  86306. * @param value Define the value to give to the uniform
  86307. * @return the material itself allowing "fluent" like uniform updates
  86308. */
  86309. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86310. /**
  86311. * Set a vec2 in the shader from a Vector2.
  86312. * @param name Define the name of the uniform as defined in the shader
  86313. * @param value Define the value to give to the uniform
  86314. * @return the material itself allowing "fluent" like uniform updates
  86315. */
  86316. setVector2(name: string, value: Vector2): ShaderMaterial;
  86317. /**
  86318. * Set a vec3 in the shader from a Vector3.
  86319. * @param name Define the name of the uniform as defined in the shader
  86320. * @param value Define the value to give to the uniform
  86321. * @return the material itself allowing "fluent" like uniform updates
  86322. */
  86323. setVector3(name: string, value: Vector3): ShaderMaterial;
  86324. /**
  86325. * Set a vec4 in the shader from a Vector4.
  86326. * @param name Define the name of the uniform as defined in the shader
  86327. * @param value Define the value to give to the uniform
  86328. * @return the material itself allowing "fluent" like uniform updates
  86329. */
  86330. setVector4(name: string, value: Vector4): ShaderMaterial;
  86331. /**
  86332. * Set a mat4 in the shader from a Matrix.
  86333. * @param name Define the name of the uniform as defined in the shader
  86334. * @param value Define the value to give to the uniform
  86335. * @return the material itself allowing "fluent" like uniform updates
  86336. */
  86337. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86338. /**
  86339. * Set a mat3 in the shader from a Float32Array.
  86340. * @param name Define the name of the uniform as defined in the shader
  86341. * @param value Define the value to give to the uniform
  86342. * @return the material itself allowing "fluent" like uniform updates
  86343. */
  86344. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86345. /**
  86346. * Set a mat2 in the shader from a Float32Array.
  86347. * @param name Define the name of the uniform as defined in the shader
  86348. * @param value Define the value to give to the uniform
  86349. * @return the material itself allowing "fluent" like uniform updates
  86350. */
  86351. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86352. /**
  86353. * Set a vec2 array in the shader from a number array.
  86354. * @param name Define the name of the uniform as defined in the shader
  86355. * @param value Define the value to give to the uniform
  86356. * @return the material itself allowing "fluent" like uniform updates
  86357. */
  86358. setArray2(name: string, value: number[]): ShaderMaterial;
  86359. /**
  86360. * Set a vec3 array in the shader from a number array.
  86361. * @param name Define the name of the uniform as defined in the shader
  86362. * @param value Define the value to give to the uniform
  86363. * @return the material itself allowing "fluent" like uniform updates
  86364. */
  86365. setArray3(name: string, value: number[]): ShaderMaterial;
  86366. /**
  86367. * Set a vec4 array in the shader from a number array.
  86368. * @param name Define the name of the uniform as defined in the shader
  86369. * @param value Define the value to give to the uniform
  86370. * @return the material itself allowing "fluent" like uniform updates
  86371. */
  86372. setArray4(name: string, value: number[]): ShaderMaterial;
  86373. private _checkCache;
  86374. /**
  86375. * Specifies that the submesh is ready to be used
  86376. * @param mesh defines the mesh to check
  86377. * @param subMesh defines which submesh to check
  86378. * @param useInstances specifies that instances should be used
  86379. * @returns a boolean indicating that the submesh is ready or not
  86380. */
  86381. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86382. /**
  86383. * Checks if the material is ready to render the requested mesh
  86384. * @param mesh Define the mesh to render
  86385. * @param useInstances Define whether or not the material is used with instances
  86386. * @returns true if ready, otherwise false
  86387. */
  86388. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86389. /**
  86390. * Binds the world matrix to the material
  86391. * @param world defines the world transformation matrix
  86392. */
  86393. bindOnlyWorldMatrix(world: Matrix): void;
  86394. /**
  86395. * Binds the material to the mesh
  86396. * @param world defines the world transformation matrix
  86397. * @param mesh defines the mesh to bind the material to
  86398. */
  86399. bind(world: Matrix, mesh?: Mesh): void;
  86400. /**
  86401. * Gets the active textures from the material
  86402. * @returns an array of textures
  86403. */
  86404. getActiveTextures(): BaseTexture[];
  86405. /**
  86406. * Specifies if the material uses a texture
  86407. * @param texture defines the texture to check against the material
  86408. * @returns a boolean specifying if the material uses the texture
  86409. */
  86410. hasTexture(texture: BaseTexture): boolean;
  86411. /**
  86412. * Makes a duplicate of the material, and gives it a new name
  86413. * @param name defines the new name for the duplicated material
  86414. * @returns the cloned material
  86415. */
  86416. clone(name: string): ShaderMaterial;
  86417. /**
  86418. * Disposes the material
  86419. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86420. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86421. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86422. */
  86423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86424. /**
  86425. * Serializes this material in a JSON representation
  86426. * @returns the serialized material object
  86427. */
  86428. serialize(): any;
  86429. /**
  86430. * Creates a shader material from parsed shader material data
  86431. * @param source defines the JSON represnetation of the material
  86432. * @param scene defines the hosting scene
  86433. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86434. * @returns a new material
  86435. */
  86436. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86437. }
  86438. }
  86439. declare module BABYLON {
  86440. /** @hidden */
  86441. export var colorPixelShader: {
  86442. name: string;
  86443. shader: string;
  86444. };
  86445. }
  86446. declare module BABYLON {
  86447. /** @hidden */
  86448. export var colorVertexShader: {
  86449. name: string;
  86450. shader: string;
  86451. };
  86452. }
  86453. declare module BABYLON {
  86454. /**
  86455. * Line mesh
  86456. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86457. */
  86458. export class LinesMesh extends Mesh {
  86459. /**
  86460. * If vertex color should be applied to the mesh
  86461. */
  86462. readonly useVertexColor?: boolean | undefined;
  86463. /**
  86464. * If vertex alpha should be applied to the mesh
  86465. */
  86466. readonly useVertexAlpha?: boolean | undefined;
  86467. /**
  86468. * Color of the line (Default: White)
  86469. */
  86470. color: Color3;
  86471. /**
  86472. * Alpha of the line (Default: 1)
  86473. */
  86474. alpha: number;
  86475. /**
  86476. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86477. * This margin is expressed in world space coordinates, so its value may vary.
  86478. * Default value is 0.1
  86479. */
  86480. intersectionThreshold: number;
  86481. private _colorShader;
  86482. private color4;
  86483. /**
  86484. * Creates a new LinesMesh
  86485. * @param name defines the name
  86486. * @param scene defines the hosting scene
  86487. * @param parent defines the parent mesh if any
  86488. * @param source defines the optional source LinesMesh used to clone data from
  86489. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86490. * When false, achieved by calling a clone(), also passing False.
  86491. * This will make creation of children, recursive.
  86492. * @param useVertexColor defines if this LinesMesh supports vertex color
  86493. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86494. */
  86495. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86496. /**
  86497. * If vertex color should be applied to the mesh
  86498. */
  86499. useVertexColor?: boolean | undefined,
  86500. /**
  86501. * If vertex alpha should be applied to the mesh
  86502. */
  86503. useVertexAlpha?: boolean | undefined);
  86504. private _addClipPlaneDefine;
  86505. private _removeClipPlaneDefine;
  86506. isReady(): boolean;
  86507. /**
  86508. * Returns the string "LineMesh"
  86509. */
  86510. getClassName(): string;
  86511. /**
  86512. * @hidden
  86513. */
  86514. /**
  86515. * @hidden
  86516. */
  86517. material: Material;
  86518. /**
  86519. * @hidden
  86520. */
  86521. readonly checkCollisions: boolean;
  86522. /** @hidden */
  86523. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86524. /** @hidden */
  86525. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86526. /**
  86527. * Disposes of the line mesh
  86528. * @param doNotRecurse If children should be disposed
  86529. */
  86530. dispose(doNotRecurse?: boolean): void;
  86531. /**
  86532. * Returns a new LineMesh object cloned from the current one.
  86533. */
  86534. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86535. /**
  86536. * Creates a new InstancedLinesMesh object from the mesh model.
  86537. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86538. * @param name defines the name of the new instance
  86539. * @returns a new InstancedLinesMesh
  86540. */
  86541. createInstance(name: string): InstancedLinesMesh;
  86542. }
  86543. /**
  86544. * Creates an instance based on a source LinesMesh
  86545. */
  86546. export class InstancedLinesMesh extends InstancedMesh {
  86547. /**
  86548. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86549. * This margin is expressed in world space coordinates, so its value may vary.
  86550. * Initilized with the intersectionThreshold value of the source LinesMesh
  86551. */
  86552. intersectionThreshold: number;
  86553. constructor(name: string, source: LinesMesh);
  86554. /**
  86555. * Returns the string "InstancedLinesMesh".
  86556. */
  86557. getClassName(): string;
  86558. }
  86559. }
  86560. declare module BABYLON {
  86561. /** @hidden */
  86562. export var linePixelShader: {
  86563. name: string;
  86564. shader: string;
  86565. };
  86566. }
  86567. declare module BABYLON {
  86568. /** @hidden */
  86569. export var lineVertexShader: {
  86570. name: string;
  86571. shader: string;
  86572. };
  86573. }
  86574. declare module BABYLON {
  86575. interface AbstractMesh {
  86576. /**
  86577. * Gets the edgesRenderer associated with the mesh
  86578. */
  86579. edgesRenderer: Nullable<EdgesRenderer>;
  86580. }
  86581. interface LinesMesh {
  86582. /**
  86583. * Enables the edge rendering mode on the mesh.
  86584. * This mode makes the mesh edges visible
  86585. * @param epsilon defines the maximal distance between two angles to detect a face
  86586. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86587. * @returns the currentAbstractMesh
  86588. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86589. */
  86590. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86591. }
  86592. interface InstancedLinesMesh {
  86593. /**
  86594. * Enables the edge rendering mode on the mesh.
  86595. * This mode makes the mesh edges visible
  86596. * @param epsilon defines the maximal distance between two angles to detect a face
  86597. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86598. * @returns the current InstancedLinesMesh
  86599. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86600. */
  86601. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86602. }
  86603. /**
  86604. * Defines the minimum contract an Edges renderer should follow.
  86605. */
  86606. export interface IEdgesRenderer extends IDisposable {
  86607. /**
  86608. * Gets or sets a boolean indicating if the edgesRenderer is active
  86609. */
  86610. isEnabled: boolean;
  86611. /**
  86612. * Renders the edges of the attached mesh,
  86613. */
  86614. render(): void;
  86615. /**
  86616. * Checks wether or not the edges renderer is ready to render.
  86617. * @return true if ready, otherwise false.
  86618. */
  86619. isReady(): boolean;
  86620. }
  86621. /**
  86622. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86623. */
  86624. export class EdgesRenderer implements IEdgesRenderer {
  86625. /**
  86626. * Define the size of the edges with an orthographic camera
  86627. */
  86628. edgesWidthScalerForOrthographic: number;
  86629. /**
  86630. * Define the size of the edges with a perspective camera
  86631. */
  86632. edgesWidthScalerForPerspective: number;
  86633. protected _source: AbstractMesh;
  86634. protected _linesPositions: number[];
  86635. protected _linesNormals: number[];
  86636. protected _linesIndices: number[];
  86637. protected _epsilon: number;
  86638. protected _indicesCount: number;
  86639. protected _lineShader: ShaderMaterial;
  86640. protected _ib: DataBuffer;
  86641. protected _buffers: {
  86642. [key: string]: Nullable<VertexBuffer>;
  86643. };
  86644. protected _checkVerticesInsteadOfIndices: boolean;
  86645. private _meshRebuildObserver;
  86646. private _meshDisposeObserver;
  86647. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86648. isEnabled: boolean;
  86649. /**
  86650. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86651. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86652. * @param source Mesh used to create edges
  86653. * @param epsilon sum of angles in adjacency to check for edge
  86654. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86655. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86656. */
  86657. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86658. protected _prepareRessources(): void;
  86659. /** @hidden */
  86660. _rebuild(): void;
  86661. /**
  86662. * Releases the required resources for the edges renderer
  86663. */
  86664. dispose(): void;
  86665. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86666. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86667. /**
  86668. * Checks if the pair of p0 and p1 is en edge
  86669. * @param faceIndex
  86670. * @param edge
  86671. * @param faceNormals
  86672. * @param p0
  86673. * @param p1
  86674. * @private
  86675. */
  86676. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86677. /**
  86678. * push line into the position, normal and index buffer
  86679. * @protected
  86680. */
  86681. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86682. /**
  86683. * Generates lines edges from adjacencjes
  86684. * @private
  86685. */
  86686. _generateEdgesLines(): void;
  86687. /**
  86688. * Checks wether or not the edges renderer is ready to render.
  86689. * @return true if ready, otherwise false.
  86690. */
  86691. isReady(): boolean;
  86692. /**
  86693. * Renders the edges of the attached mesh,
  86694. */
  86695. render(): void;
  86696. }
  86697. /**
  86698. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86699. */
  86700. export class LineEdgesRenderer extends EdgesRenderer {
  86701. /**
  86702. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86703. * @param source LineMesh used to generate edges
  86704. * @param epsilon not important (specified angle for edge detection)
  86705. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86706. */
  86707. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86708. /**
  86709. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86710. */
  86711. _generateEdgesLines(): void;
  86712. }
  86713. }
  86714. declare module BABYLON {
  86715. /**
  86716. * This represents the object necessary to create a rendering group.
  86717. * This is exclusively used and created by the rendering manager.
  86718. * To modify the behavior, you use the available helpers in your scene or meshes.
  86719. * @hidden
  86720. */
  86721. export class RenderingGroup {
  86722. index: number;
  86723. private static _zeroVector;
  86724. private _scene;
  86725. private _opaqueSubMeshes;
  86726. private _transparentSubMeshes;
  86727. private _alphaTestSubMeshes;
  86728. private _depthOnlySubMeshes;
  86729. private _particleSystems;
  86730. private _spriteManagers;
  86731. private _opaqueSortCompareFn;
  86732. private _alphaTestSortCompareFn;
  86733. private _transparentSortCompareFn;
  86734. private _renderOpaque;
  86735. private _renderAlphaTest;
  86736. private _renderTransparent;
  86737. /** @hidden */
  86738. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86739. onBeforeTransparentRendering: () => void;
  86740. /**
  86741. * Set the opaque sort comparison function.
  86742. * If null the sub meshes will be render in the order they were created
  86743. */
  86744. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86745. /**
  86746. * Set the alpha test sort comparison function.
  86747. * If null the sub meshes will be render in the order they were created
  86748. */
  86749. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86750. /**
  86751. * Set the transparent sort comparison function.
  86752. * If null the sub meshes will be render in the order they were created
  86753. */
  86754. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86755. /**
  86756. * Creates a new rendering group.
  86757. * @param index The rendering group index
  86758. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86759. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86760. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86761. */
  86762. 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>);
  86763. /**
  86764. * Render all the sub meshes contained in the group.
  86765. * @param customRenderFunction Used to override the default render behaviour of the group.
  86766. * @returns true if rendered some submeshes.
  86767. */
  86768. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86769. /**
  86770. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86771. * @param subMeshes The submeshes to render
  86772. */
  86773. private renderOpaqueSorted;
  86774. /**
  86775. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86776. * @param subMeshes The submeshes to render
  86777. */
  86778. private renderAlphaTestSorted;
  86779. /**
  86780. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86781. * @param subMeshes The submeshes to render
  86782. */
  86783. private renderTransparentSorted;
  86784. /**
  86785. * Renders the submeshes in a specified order.
  86786. * @param subMeshes The submeshes to sort before render
  86787. * @param sortCompareFn The comparison function use to sort
  86788. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86789. * @param transparent Specifies to activate blending if true
  86790. */
  86791. private static renderSorted;
  86792. /**
  86793. * Renders the submeshes in the order they were dispatched (no sort applied).
  86794. * @param subMeshes The submeshes to render
  86795. */
  86796. private static renderUnsorted;
  86797. /**
  86798. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86799. * are rendered back to front if in the same alpha index.
  86800. *
  86801. * @param a The first submesh
  86802. * @param b The second submesh
  86803. * @returns The result of the comparison
  86804. */
  86805. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86806. /**
  86807. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86808. * are rendered back to front.
  86809. *
  86810. * @param a The first submesh
  86811. * @param b The second submesh
  86812. * @returns The result of the comparison
  86813. */
  86814. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86815. /**
  86816. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86817. * are rendered front to back (prevent overdraw).
  86818. *
  86819. * @param a The first submesh
  86820. * @param b The second submesh
  86821. * @returns The result of the comparison
  86822. */
  86823. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86824. /**
  86825. * Resets the different lists of submeshes to prepare a new frame.
  86826. */
  86827. prepare(): void;
  86828. dispose(): void;
  86829. /**
  86830. * Inserts the submesh in its correct queue depending on its material.
  86831. * @param subMesh The submesh to dispatch
  86832. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86833. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86834. */
  86835. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86836. dispatchSprites(spriteManager: ISpriteManager): void;
  86837. dispatchParticles(particleSystem: IParticleSystem): void;
  86838. private _renderParticles;
  86839. private _renderSprites;
  86840. }
  86841. }
  86842. declare module BABYLON {
  86843. /**
  86844. * Interface describing the different options available in the rendering manager
  86845. * regarding Auto Clear between groups.
  86846. */
  86847. export interface IRenderingManagerAutoClearSetup {
  86848. /**
  86849. * Defines whether or not autoclear is enable.
  86850. */
  86851. autoClear: boolean;
  86852. /**
  86853. * Defines whether or not to autoclear the depth buffer.
  86854. */
  86855. depth: boolean;
  86856. /**
  86857. * Defines whether or not to autoclear the stencil buffer.
  86858. */
  86859. stencil: boolean;
  86860. }
  86861. /**
  86862. * This class is used by the onRenderingGroupObservable
  86863. */
  86864. export class RenderingGroupInfo {
  86865. /**
  86866. * The Scene that being rendered
  86867. */
  86868. scene: Scene;
  86869. /**
  86870. * The camera currently used for the rendering pass
  86871. */
  86872. camera: Nullable<Camera>;
  86873. /**
  86874. * The ID of the renderingGroup being processed
  86875. */
  86876. renderingGroupId: number;
  86877. }
  86878. /**
  86879. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86880. * It is enable to manage the different groups as well as the different necessary sort functions.
  86881. * This should not be used directly aside of the few static configurations
  86882. */
  86883. export class RenderingManager {
  86884. /**
  86885. * The max id used for rendering groups (not included)
  86886. */
  86887. static MAX_RENDERINGGROUPS: number;
  86888. /**
  86889. * The min id used for rendering groups (included)
  86890. */
  86891. static MIN_RENDERINGGROUPS: number;
  86892. /**
  86893. * Used to globally prevent autoclearing scenes.
  86894. */
  86895. static AUTOCLEAR: boolean;
  86896. /**
  86897. * @hidden
  86898. */
  86899. _useSceneAutoClearSetup: boolean;
  86900. private _scene;
  86901. private _renderingGroups;
  86902. private _depthStencilBufferAlreadyCleaned;
  86903. private _autoClearDepthStencil;
  86904. private _customOpaqueSortCompareFn;
  86905. private _customAlphaTestSortCompareFn;
  86906. private _customTransparentSortCompareFn;
  86907. private _renderingGroupInfo;
  86908. /**
  86909. * Instantiates a new rendering group for a particular scene
  86910. * @param scene Defines the scene the groups belongs to
  86911. */
  86912. constructor(scene: Scene);
  86913. private _clearDepthStencilBuffer;
  86914. /**
  86915. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86916. * @hidden
  86917. */
  86918. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86919. /**
  86920. * Resets the different information of the group to prepare a new frame
  86921. * @hidden
  86922. */
  86923. reset(): void;
  86924. /**
  86925. * Dispose and release the group and its associated resources.
  86926. * @hidden
  86927. */
  86928. dispose(): void;
  86929. /**
  86930. * Clear the info related to rendering groups preventing retention points during dispose.
  86931. */
  86932. freeRenderingGroups(): void;
  86933. private _prepareRenderingGroup;
  86934. /**
  86935. * Add a sprite manager to the rendering manager in order to render it this frame.
  86936. * @param spriteManager Define the sprite manager to render
  86937. */
  86938. dispatchSprites(spriteManager: ISpriteManager): void;
  86939. /**
  86940. * Add a particle system to the rendering manager in order to render it this frame.
  86941. * @param particleSystem Define the particle system to render
  86942. */
  86943. dispatchParticles(particleSystem: IParticleSystem): void;
  86944. /**
  86945. * Add a submesh to the manager in order to render it this frame
  86946. * @param subMesh The submesh to dispatch
  86947. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86948. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86949. */
  86950. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86951. /**
  86952. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86953. * This allowed control for front to back rendering or reversly depending of the special needs.
  86954. *
  86955. * @param renderingGroupId The rendering group id corresponding to its index
  86956. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86957. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86958. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86959. */
  86960. 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;
  86961. /**
  86962. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86963. *
  86964. * @param renderingGroupId The rendering group id corresponding to its index
  86965. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86966. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86967. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86968. */
  86969. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86970. /**
  86971. * Gets the current auto clear configuration for one rendering group of the rendering
  86972. * manager.
  86973. * @param index the rendering group index to get the information for
  86974. * @returns The auto clear setup for the requested rendering group
  86975. */
  86976. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86977. }
  86978. }
  86979. declare module BABYLON {
  86980. /**
  86981. * This Helps creating a texture that will be created from a camera in your scene.
  86982. * It is basically a dynamic texture that could be used to create special effects for instance.
  86983. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86984. */
  86985. export class RenderTargetTexture extends Texture {
  86986. isCube: boolean;
  86987. /**
  86988. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86989. */
  86990. static readonly REFRESHRATE_RENDER_ONCE: number;
  86991. /**
  86992. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86993. */
  86994. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86995. /**
  86996. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86997. * the central point of your effect and can save a lot of performances.
  86998. */
  86999. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87000. /**
  87001. * Use this predicate to dynamically define the list of mesh you want to render.
  87002. * If set, the renderList property will be overwritten.
  87003. */
  87004. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87005. private _renderList;
  87006. /**
  87007. * Use this list to define the list of mesh you want to render.
  87008. */
  87009. renderList: Nullable<Array<AbstractMesh>>;
  87010. private _hookArray;
  87011. /**
  87012. * Define if particles should be rendered in your texture.
  87013. */
  87014. renderParticles: boolean;
  87015. /**
  87016. * Define if sprites should be rendered in your texture.
  87017. */
  87018. renderSprites: boolean;
  87019. /**
  87020. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87021. */
  87022. coordinatesMode: number;
  87023. /**
  87024. * Define the camera used to render the texture.
  87025. */
  87026. activeCamera: Nullable<Camera>;
  87027. /**
  87028. * Override the render function of the texture with your own one.
  87029. */
  87030. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87031. /**
  87032. * Define if camera post processes should be use while rendering the texture.
  87033. */
  87034. useCameraPostProcesses: boolean;
  87035. /**
  87036. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87037. */
  87038. ignoreCameraViewport: boolean;
  87039. private _postProcessManager;
  87040. private _postProcesses;
  87041. private _resizeObserver;
  87042. /**
  87043. * An event triggered when the texture is unbind.
  87044. */
  87045. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87046. /**
  87047. * An event triggered when the texture is unbind.
  87048. */
  87049. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87050. private _onAfterUnbindObserver;
  87051. /**
  87052. * Set a after unbind callback in the texture.
  87053. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87054. */
  87055. onAfterUnbind: () => void;
  87056. /**
  87057. * An event triggered before rendering the texture
  87058. */
  87059. onBeforeRenderObservable: Observable<number>;
  87060. private _onBeforeRenderObserver;
  87061. /**
  87062. * Set a before render callback in the texture.
  87063. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87064. */
  87065. onBeforeRender: (faceIndex: number) => void;
  87066. /**
  87067. * An event triggered after rendering the texture
  87068. */
  87069. onAfterRenderObservable: Observable<number>;
  87070. private _onAfterRenderObserver;
  87071. /**
  87072. * Set a after render callback in the texture.
  87073. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87074. */
  87075. onAfterRender: (faceIndex: number) => void;
  87076. /**
  87077. * An event triggered after the texture clear
  87078. */
  87079. onClearObservable: Observable<Engine>;
  87080. private _onClearObserver;
  87081. /**
  87082. * Set a clear callback in the texture.
  87083. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87084. */
  87085. onClear: (Engine: Engine) => void;
  87086. /**
  87087. * An event triggered when the texture is resized.
  87088. */
  87089. onResizeObservable: Observable<RenderTargetTexture>;
  87090. /**
  87091. * Define the clear color of the Render Target if it should be different from the scene.
  87092. */
  87093. clearColor: Color4;
  87094. protected _size: number | {
  87095. width: number;
  87096. height: number;
  87097. };
  87098. protected _initialSizeParameter: number | {
  87099. width: number;
  87100. height: number;
  87101. } | {
  87102. ratio: number;
  87103. };
  87104. protected _sizeRatio: Nullable<number>;
  87105. /** @hidden */
  87106. _generateMipMaps: boolean;
  87107. protected _renderingManager: RenderingManager;
  87108. /** @hidden */
  87109. _waitingRenderList: string[];
  87110. protected _doNotChangeAspectRatio: boolean;
  87111. protected _currentRefreshId: number;
  87112. protected _refreshRate: number;
  87113. protected _textureMatrix: Matrix;
  87114. protected _samples: number;
  87115. protected _renderTargetOptions: RenderTargetCreationOptions;
  87116. /**
  87117. * Gets render target creation options that were used.
  87118. */
  87119. readonly renderTargetOptions: RenderTargetCreationOptions;
  87120. protected _engine: Engine;
  87121. protected _onRatioRescale(): void;
  87122. /**
  87123. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87124. * It must define where the camera used to render the texture is set
  87125. */
  87126. boundingBoxPosition: Vector3;
  87127. private _boundingBoxSize;
  87128. /**
  87129. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87130. * When defined, the cubemap will switch to local mode
  87131. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87132. * @example https://www.babylonjs-playground.com/#RNASML
  87133. */
  87134. boundingBoxSize: Vector3;
  87135. /**
  87136. * In case the RTT has been created with a depth texture, get the associated
  87137. * depth texture.
  87138. * Otherwise, return null.
  87139. */
  87140. depthStencilTexture: Nullable<InternalTexture>;
  87141. /**
  87142. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87143. * or used a shadow, depth texture...
  87144. * @param name The friendly name of the texture
  87145. * @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)
  87146. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87147. * @param generateMipMaps True if mip maps need to be generated after render.
  87148. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87149. * @param type The type of the buffer in the RTT (int, half float, float...)
  87150. * @param isCube True if a cube texture needs to be created
  87151. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87152. * @param generateDepthBuffer True to generate a depth buffer
  87153. * @param generateStencilBuffer True to generate a stencil buffer
  87154. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87155. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87156. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87157. */
  87158. constructor(name: string, size: number | {
  87159. width: number;
  87160. height: number;
  87161. } | {
  87162. ratio: number;
  87163. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87164. /**
  87165. * Creates a depth stencil texture.
  87166. * This is only available in WebGL 2 or with the depth texture extension available.
  87167. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87168. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87169. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87170. */
  87171. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87172. private _processSizeParameter;
  87173. /**
  87174. * Define the number of samples to use in case of MSAA.
  87175. * It defaults to one meaning no MSAA has been enabled.
  87176. */
  87177. samples: number;
  87178. /**
  87179. * Resets the refresh counter of the texture and start bak from scratch.
  87180. * Could be useful to regenerate the texture if it is setup to render only once.
  87181. */
  87182. resetRefreshCounter(): void;
  87183. /**
  87184. * Define the refresh rate of the texture or the rendering frequency.
  87185. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87186. */
  87187. refreshRate: number;
  87188. /**
  87189. * Adds a post process to the render target rendering passes.
  87190. * @param postProcess define the post process to add
  87191. */
  87192. addPostProcess(postProcess: PostProcess): void;
  87193. /**
  87194. * Clear all the post processes attached to the render target
  87195. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87196. */
  87197. clearPostProcesses(dispose?: boolean): void;
  87198. /**
  87199. * Remove one of the post process from the list of attached post processes to the texture
  87200. * @param postProcess define the post process to remove from the list
  87201. */
  87202. removePostProcess(postProcess: PostProcess): void;
  87203. /** @hidden */
  87204. _shouldRender(): boolean;
  87205. /**
  87206. * Gets the actual render size of the texture.
  87207. * @returns the width of the render size
  87208. */
  87209. getRenderSize(): number;
  87210. /**
  87211. * Gets the actual render width of the texture.
  87212. * @returns the width of the render size
  87213. */
  87214. getRenderWidth(): number;
  87215. /**
  87216. * Gets the actual render height of the texture.
  87217. * @returns the height of the render size
  87218. */
  87219. getRenderHeight(): number;
  87220. /**
  87221. * Get if the texture can be rescaled or not.
  87222. */
  87223. readonly canRescale: boolean;
  87224. /**
  87225. * Resize the texture using a ratio.
  87226. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87227. */
  87228. scale(ratio: number): void;
  87229. /**
  87230. * Get the texture reflection matrix used to rotate/transform the reflection.
  87231. * @returns the reflection matrix
  87232. */
  87233. getReflectionTextureMatrix(): Matrix;
  87234. /**
  87235. * Resize the texture to a new desired size.
  87236. * Be carrefull as it will recreate all the data in the new texture.
  87237. * @param size Define the new size. It can be:
  87238. * - a number for squared texture,
  87239. * - an object containing { width: number, height: number }
  87240. * - or an object containing a ratio { ratio: number }
  87241. */
  87242. resize(size: number | {
  87243. width: number;
  87244. height: number;
  87245. } | {
  87246. ratio: number;
  87247. }): void;
  87248. /**
  87249. * Renders all the objects from the render list into the texture.
  87250. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87251. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87252. */
  87253. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87254. private _bestReflectionRenderTargetDimension;
  87255. /**
  87256. * @hidden
  87257. * @param faceIndex face index to bind to if this is a cubetexture
  87258. */
  87259. _bindFrameBuffer(faceIndex?: number): void;
  87260. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87261. private renderToTarget;
  87262. /**
  87263. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87264. * This allowed control for front to back rendering or reversly depending of the special needs.
  87265. *
  87266. * @param renderingGroupId The rendering group id corresponding to its index
  87267. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87268. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87269. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87270. */
  87271. 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;
  87272. /**
  87273. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87274. *
  87275. * @param renderingGroupId The rendering group id corresponding to its index
  87276. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87277. */
  87278. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87279. /**
  87280. * Clones the texture.
  87281. * @returns the cloned texture
  87282. */
  87283. clone(): RenderTargetTexture;
  87284. /**
  87285. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87286. * @returns The JSON representation of the texture
  87287. */
  87288. serialize(): any;
  87289. /**
  87290. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87291. */
  87292. disposeFramebufferObjects(): void;
  87293. /**
  87294. * Dispose the texture and release its associated resources.
  87295. */
  87296. dispose(): void;
  87297. /** @hidden */
  87298. _rebuild(): void;
  87299. /**
  87300. * Clear the info related to rendering groups preventing retention point in material dispose.
  87301. */
  87302. freeRenderingGroups(): void;
  87303. /**
  87304. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87305. * @returns the view count
  87306. */
  87307. getViewCount(): number;
  87308. }
  87309. }
  87310. declare module BABYLON {
  87311. /**
  87312. * Base class for the main features of a material in Babylon.js
  87313. */
  87314. export class Material implements IAnimatable {
  87315. /**
  87316. * Returns the triangle fill mode
  87317. */
  87318. static readonly TriangleFillMode: number;
  87319. /**
  87320. * Returns the wireframe mode
  87321. */
  87322. static readonly WireFrameFillMode: number;
  87323. /**
  87324. * Returns the point fill mode
  87325. */
  87326. static readonly PointFillMode: number;
  87327. /**
  87328. * Returns the point list draw mode
  87329. */
  87330. static readonly PointListDrawMode: number;
  87331. /**
  87332. * Returns the line list draw mode
  87333. */
  87334. static readonly LineListDrawMode: number;
  87335. /**
  87336. * Returns the line loop draw mode
  87337. */
  87338. static readonly LineLoopDrawMode: number;
  87339. /**
  87340. * Returns the line strip draw mode
  87341. */
  87342. static readonly LineStripDrawMode: number;
  87343. /**
  87344. * Returns the triangle strip draw mode
  87345. */
  87346. static readonly TriangleStripDrawMode: number;
  87347. /**
  87348. * Returns the triangle fan draw mode
  87349. */
  87350. static readonly TriangleFanDrawMode: number;
  87351. /**
  87352. * Stores the clock-wise side orientation
  87353. */
  87354. static readonly ClockWiseSideOrientation: number;
  87355. /**
  87356. * Stores the counter clock-wise side orientation
  87357. */
  87358. static readonly CounterClockWiseSideOrientation: number;
  87359. /**
  87360. * The dirty texture flag value
  87361. */
  87362. static readonly TextureDirtyFlag: number;
  87363. /**
  87364. * The dirty light flag value
  87365. */
  87366. static readonly LightDirtyFlag: number;
  87367. /**
  87368. * The dirty fresnel flag value
  87369. */
  87370. static readonly FresnelDirtyFlag: number;
  87371. /**
  87372. * The dirty attribute flag value
  87373. */
  87374. static readonly AttributesDirtyFlag: number;
  87375. /**
  87376. * The dirty misc flag value
  87377. */
  87378. static readonly MiscDirtyFlag: number;
  87379. /**
  87380. * The all dirty flag value
  87381. */
  87382. static readonly AllDirtyFlag: number;
  87383. /**
  87384. * The ID of the material
  87385. */
  87386. id: string;
  87387. /**
  87388. * Gets or sets the unique id of the material
  87389. */
  87390. uniqueId: number;
  87391. /**
  87392. * The name of the material
  87393. */
  87394. name: string;
  87395. /**
  87396. * Gets or sets user defined metadata
  87397. */
  87398. metadata: any;
  87399. /**
  87400. * For internal use only. Please do not use.
  87401. */
  87402. reservedDataStore: any;
  87403. /**
  87404. * Specifies if the ready state should be checked on each call
  87405. */
  87406. checkReadyOnEveryCall: boolean;
  87407. /**
  87408. * Specifies if the ready state should be checked once
  87409. */
  87410. checkReadyOnlyOnce: boolean;
  87411. /**
  87412. * The state of the material
  87413. */
  87414. state: string;
  87415. /**
  87416. * The alpha value of the material
  87417. */
  87418. protected _alpha: number;
  87419. /**
  87420. * List of inspectable custom properties (used by the Inspector)
  87421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87422. */
  87423. inspectableCustomProperties: IInspectable[];
  87424. /**
  87425. * Sets the alpha value of the material
  87426. */
  87427. /**
  87428. * Gets the alpha value of the material
  87429. */
  87430. alpha: number;
  87431. /**
  87432. * Specifies if back face culling is enabled
  87433. */
  87434. protected _backFaceCulling: boolean;
  87435. /**
  87436. * Sets the back-face culling state
  87437. */
  87438. /**
  87439. * Gets the back-face culling state
  87440. */
  87441. backFaceCulling: boolean;
  87442. /**
  87443. * Stores the value for side orientation
  87444. */
  87445. sideOrientation: number;
  87446. /**
  87447. * Callback triggered when the material is compiled
  87448. */
  87449. onCompiled: Nullable<(effect: Effect) => void>;
  87450. /**
  87451. * Callback triggered when an error occurs
  87452. */
  87453. onError: Nullable<(effect: Effect, errors: string) => void>;
  87454. /**
  87455. * Callback triggered to get the render target textures
  87456. */
  87457. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87458. /**
  87459. * Gets a boolean indicating that current material needs to register RTT
  87460. */
  87461. readonly hasRenderTargetTextures: boolean;
  87462. /**
  87463. * Specifies if the material should be serialized
  87464. */
  87465. doNotSerialize: boolean;
  87466. /**
  87467. * @hidden
  87468. */
  87469. _storeEffectOnSubMeshes: boolean;
  87470. /**
  87471. * Stores the animations for the material
  87472. */
  87473. animations: Nullable<Array<Animation>>;
  87474. /**
  87475. * An event triggered when the material is disposed
  87476. */
  87477. onDisposeObservable: Observable<Material>;
  87478. /**
  87479. * An observer which watches for dispose events
  87480. */
  87481. private _onDisposeObserver;
  87482. private _onUnBindObservable;
  87483. /**
  87484. * Called during a dispose event
  87485. */
  87486. onDispose: () => void;
  87487. private _onBindObservable;
  87488. /**
  87489. * An event triggered when the material is bound
  87490. */
  87491. readonly onBindObservable: Observable<AbstractMesh>;
  87492. /**
  87493. * An observer which watches for bind events
  87494. */
  87495. private _onBindObserver;
  87496. /**
  87497. * Called during a bind event
  87498. */
  87499. onBind: (Mesh: AbstractMesh) => void;
  87500. /**
  87501. * An event triggered when the material is unbound
  87502. */
  87503. readonly onUnBindObservable: Observable<Material>;
  87504. /**
  87505. * Stores the value of the alpha mode
  87506. */
  87507. private _alphaMode;
  87508. /**
  87509. * Sets the value of the alpha mode.
  87510. *
  87511. * | Value | Type | Description |
  87512. * | --- | --- | --- |
  87513. * | 0 | ALPHA_DISABLE | |
  87514. * | 1 | ALPHA_ADD | |
  87515. * | 2 | ALPHA_COMBINE | |
  87516. * | 3 | ALPHA_SUBTRACT | |
  87517. * | 4 | ALPHA_MULTIPLY | |
  87518. * | 5 | ALPHA_MAXIMIZED | |
  87519. * | 6 | ALPHA_ONEONE | |
  87520. * | 7 | ALPHA_PREMULTIPLIED | |
  87521. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87522. * | 9 | ALPHA_INTERPOLATE | |
  87523. * | 10 | ALPHA_SCREENMODE | |
  87524. *
  87525. */
  87526. /**
  87527. * Gets the value of the alpha mode
  87528. */
  87529. alphaMode: number;
  87530. /**
  87531. * Stores the state of the need depth pre-pass value
  87532. */
  87533. private _needDepthPrePass;
  87534. /**
  87535. * Sets the need depth pre-pass value
  87536. */
  87537. /**
  87538. * Gets the depth pre-pass value
  87539. */
  87540. needDepthPrePass: boolean;
  87541. /**
  87542. * Specifies if depth writing should be disabled
  87543. */
  87544. disableDepthWrite: boolean;
  87545. /**
  87546. * Specifies if depth writing should be forced
  87547. */
  87548. forceDepthWrite: boolean;
  87549. /**
  87550. * Specifies if there should be a separate pass for culling
  87551. */
  87552. separateCullingPass: boolean;
  87553. /**
  87554. * Stores the state specifing if fog should be enabled
  87555. */
  87556. private _fogEnabled;
  87557. /**
  87558. * Sets the state for enabling fog
  87559. */
  87560. /**
  87561. * Gets the value of the fog enabled state
  87562. */
  87563. fogEnabled: boolean;
  87564. /**
  87565. * Stores the size of points
  87566. */
  87567. pointSize: number;
  87568. /**
  87569. * Stores the z offset value
  87570. */
  87571. zOffset: number;
  87572. /**
  87573. * Gets a value specifying if wireframe mode is enabled
  87574. */
  87575. /**
  87576. * Sets the state of wireframe mode
  87577. */
  87578. wireframe: boolean;
  87579. /**
  87580. * Gets the value specifying if point clouds are enabled
  87581. */
  87582. /**
  87583. * Sets the state of point cloud mode
  87584. */
  87585. pointsCloud: boolean;
  87586. /**
  87587. * Gets the material fill mode
  87588. */
  87589. /**
  87590. * Sets the material fill mode
  87591. */
  87592. fillMode: number;
  87593. /**
  87594. * @hidden
  87595. * Stores the effects for the material
  87596. */
  87597. _effect: Nullable<Effect>;
  87598. /**
  87599. * @hidden
  87600. * Specifies if the material was previously ready
  87601. */
  87602. _wasPreviouslyReady: boolean;
  87603. /**
  87604. * Specifies if uniform buffers should be used
  87605. */
  87606. private _useUBO;
  87607. /**
  87608. * Stores a reference to the scene
  87609. */
  87610. private _scene;
  87611. /**
  87612. * Stores the fill mode state
  87613. */
  87614. private _fillMode;
  87615. /**
  87616. * Specifies if the depth write state should be cached
  87617. */
  87618. private _cachedDepthWriteState;
  87619. /**
  87620. * Stores the uniform buffer
  87621. */
  87622. protected _uniformBuffer: UniformBuffer;
  87623. /** @hidden */
  87624. _indexInSceneMaterialArray: number;
  87625. /** @hidden */
  87626. meshMap: Nullable<{
  87627. [id: string]: AbstractMesh | undefined;
  87628. }>;
  87629. /**
  87630. * Creates a material instance
  87631. * @param name defines the name of the material
  87632. * @param scene defines the scene to reference
  87633. * @param doNotAdd specifies if the material should be added to the scene
  87634. */
  87635. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87636. /**
  87637. * Returns a string representation of the current material
  87638. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87639. * @returns a string with material information
  87640. */
  87641. toString(fullDetails?: boolean): string;
  87642. /**
  87643. * Gets the class name of the material
  87644. * @returns a string with the class name of the material
  87645. */
  87646. getClassName(): string;
  87647. /**
  87648. * Specifies if updates for the material been locked
  87649. */
  87650. readonly isFrozen: boolean;
  87651. /**
  87652. * Locks updates for the material
  87653. */
  87654. freeze(): void;
  87655. /**
  87656. * Unlocks updates for the material
  87657. */
  87658. unfreeze(): void;
  87659. /**
  87660. * Specifies if the material is ready to be used
  87661. * @param mesh defines the mesh to check
  87662. * @param useInstances specifies if instances should be used
  87663. * @returns a boolean indicating if the material is ready to be used
  87664. */
  87665. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87666. /**
  87667. * Specifies that the submesh is ready to be used
  87668. * @param mesh defines the mesh to check
  87669. * @param subMesh defines which submesh to check
  87670. * @param useInstances specifies that instances should be used
  87671. * @returns a boolean indicating that the submesh is ready or not
  87672. */
  87673. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87674. /**
  87675. * Returns the material effect
  87676. * @returns the effect associated with the material
  87677. */
  87678. getEffect(): Nullable<Effect>;
  87679. /**
  87680. * Returns the current scene
  87681. * @returns a Scene
  87682. */
  87683. getScene(): Scene;
  87684. /**
  87685. * Specifies if the material will require alpha blending
  87686. * @returns a boolean specifying if alpha blending is needed
  87687. */
  87688. needAlphaBlending(): boolean;
  87689. /**
  87690. * Specifies if the mesh will require alpha blending
  87691. * @param mesh defines the mesh to check
  87692. * @returns a boolean specifying if alpha blending is needed for the mesh
  87693. */
  87694. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87695. /**
  87696. * Specifies if this material should be rendered in alpha test mode
  87697. * @returns a boolean specifying if an alpha test is needed.
  87698. */
  87699. needAlphaTesting(): boolean;
  87700. /**
  87701. * Gets the texture used for the alpha test
  87702. * @returns the texture to use for alpha testing
  87703. */
  87704. getAlphaTestTexture(): Nullable<BaseTexture>;
  87705. /**
  87706. * Marks the material to indicate that it needs to be re-calculated
  87707. */
  87708. markDirty(): void;
  87709. /** @hidden */
  87710. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87711. /**
  87712. * Binds the material to the mesh
  87713. * @param world defines the world transformation matrix
  87714. * @param mesh defines the mesh to bind the material to
  87715. */
  87716. bind(world: Matrix, mesh?: Mesh): void;
  87717. /**
  87718. * Binds the submesh to the material
  87719. * @param world defines the world transformation matrix
  87720. * @param mesh defines the mesh containing the submesh
  87721. * @param subMesh defines the submesh to bind the material to
  87722. */
  87723. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87724. /**
  87725. * Binds the world matrix to the material
  87726. * @param world defines the world transformation matrix
  87727. */
  87728. bindOnlyWorldMatrix(world: Matrix): void;
  87729. /**
  87730. * Binds the scene's uniform buffer to the effect.
  87731. * @param effect defines the effect to bind to the scene uniform buffer
  87732. * @param sceneUbo defines the uniform buffer storing scene data
  87733. */
  87734. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87735. /**
  87736. * Binds the view matrix to the effect
  87737. * @param effect defines the effect to bind the view matrix to
  87738. */
  87739. bindView(effect: Effect): void;
  87740. /**
  87741. * Binds the view projection matrix to the effect
  87742. * @param effect defines the effect to bind the view projection matrix to
  87743. */
  87744. bindViewProjection(effect: Effect): void;
  87745. /**
  87746. * Specifies if material alpha testing should be turned on for the mesh
  87747. * @param mesh defines the mesh to check
  87748. */
  87749. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87750. /**
  87751. * Processes to execute after binding the material to a mesh
  87752. * @param mesh defines the rendered mesh
  87753. */
  87754. protected _afterBind(mesh?: Mesh): void;
  87755. /**
  87756. * Unbinds the material from the mesh
  87757. */
  87758. unbind(): void;
  87759. /**
  87760. * Gets the active textures from the material
  87761. * @returns an array of textures
  87762. */
  87763. getActiveTextures(): BaseTexture[];
  87764. /**
  87765. * Specifies if the material uses a texture
  87766. * @param texture defines the texture to check against the material
  87767. * @returns a boolean specifying if the material uses the texture
  87768. */
  87769. hasTexture(texture: BaseTexture): boolean;
  87770. /**
  87771. * Makes a duplicate of the material, and gives it a new name
  87772. * @param name defines the new name for the duplicated material
  87773. * @returns the cloned material
  87774. */
  87775. clone(name: string): Nullable<Material>;
  87776. /**
  87777. * Gets the meshes bound to the material
  87778. * @returns an array of meshes bound to the material
  87779. */
  87780. getBindedMeshes(): AbstractMesh[];
  87781. /**
  87782. * Force shader compilation
  87783. * @param mesh defines the mesh associated with this material
  87784. * @param onCompiled defines a function to execute once the material is compiled
  87785. * @param options defines the options to configure the compilation
  87786. * @param onError defines a function to execute if the material fails compiling
  87787. */
  87788. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87789. clipPlane: boolean;
  87790. }>, onError?: (reason: string) => void): void;
  87791. /**
  87792. * Force shader compilation
  87793. * @param mesh defines the mesh that will use this material
  87794. * @param options defines additional options for compiling the shaders
  87795. * @returns a promise that resolves when the compilation completes
  87796. */
  87797. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87798. clipPlane: boolean;
  87799. }>): Promise<void>;
  87800. private static readonly _AllDirtyCallBack;
  87801. private static readonly _ImageProcessingDirtyCallBack;
  87802. private static readonly _TextureDirtyCallBack;
  87803. private static readonly _FresnelDirtyCallBack;
  87804. private static readonly _MiscDirtyCallBack;
  87805. private static readonly _LightsDirtyCallBack;
  87806. private static readonly _AttributeDirtyCallBack;
  87807. private static _FresnelAndMiscDirtyCallBack;
  87808. private static _TextureAndMiscDirtyCallBack;
  87809. private static readonly _DirtyCallbackArray;
  87810. private static readonly _RunDirtyCallBacks;
  87811. /**
  87812. * Marks a define in the material to indicate that it needs to be re-computed
  87813. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87814. */
  87815. markAsDirty(flag: number): void;
  87816. /**
  87817. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87818. * @param func defines a function which checks material defines against the submeshes
  87819. */
  87820. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87821. /**
  87822. * Indicates that we need to re-calculated for all submeshes
  87823. */
  87824. protected _markAllSubMeshesAsAllDirty(): void;
  87825. /**
  87826. * Indicates that image processing needs to be re-calculated for all submeshes
  87827. */
  87828. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87829. /**
  87830. * Indicates that textures need to be re-calculated for all submeshes
  87831. */
  87832. protected _markAllSubMeshesAsTexturesDirty(): void;
  87833. /**
  87834. * Indicates that fresnel needs to be re-calculated for all submeshes
  87835. */
  87836. protected _markAllSubMeshesAsFresnelDirty(): void;
  87837. /**
  87838. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87839. */
  87840. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87841. /**
  87842. * Indicates that lights need to be re-calculated for all submeshes
  87843. */
  87844. protected _markAllSubMeshesAsLightsDirty(): void;
  87845. /**
  87846. * Indicates that attributes need to be re-calculated for all submeshes
  87847. */
  87848. protected _markAllSubMeshesAsAttributesDirty(): void;
  87849. /**
  87850. * Indicates that misc needs to be re-calculated for all submeshes
  87851. */
  87852. protected _markAllSubMeshesAsMiscDirty(): void;
  87853. /**
  87854. * Indicates that textures and misc need to be re-calculated for all submeshes
  87855. */
  87856. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87857. /**
  87858. * Disposes the material
  87859. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87860. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87861. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87862. */
  87863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87864. /** @hidden */
  87865. private releaseVertexArrayObject;
  87866. /**
  87867. * Serializes this material
  87868. * @returns the serialized material object
  87869. */
  87870. serialize(): any;
  87871. /**
  87872. * Creates a material from parsed material data
  87873. * @param parsedMaterial defines parsed material data
  87874. * @param scene defines the hosting scene
  87875. * @param rootUrl defines the root URL to use to load textures
  87876. * @returns a new material
  87877. */
  87878. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87879. }
  87880. }
  87881. declare module BABYLON {
  87882. /**
  87883. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87884. * separate meshes. This can be use to improve performances.
  87885. * @see http://doc.babylonjs.com/how_to/multi_materials
  87886. */
  87887. export class MultiMaterial extends Material {
  87888. private _subMaterials;
  87889. /**
  87890. * Gets or Sets the list of Materials used within the multi material.
  87891. * They need to be ordered according to the submeshes order in the associated mesh
  87892. */
  87893. subMaterials: Nullable<Material>[];
  87894. /**
  87895. * Function used to align with Node.getChildren()
  87896. * @returns the list of Materials used within the multi material
  87897. */
  87898. getChildren(): Nullable<Material>[];
  87899. /**
  87900. * Instantiates a new Multi Material
  87901. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87902. * separate meshes. This can be use to improve performances.
  87903. * @see http://doc.babylonjs.com/how_to/multi_materials
  87904. * @param name Define the name in the scene
  87905. * @param scene Define the scene the material belongs to
  87906. */
  87907. constructor(name: string, scene: Scene);
  87908. private _hookArray;
  87909. /**
  87910. * Get one of the submaterial by its index in the submaterials array
  87911. * @param index The index to look the sub material at
  87912. * @returns The Material if the index has been defined
  87913. */
  87914. getSubMaterial(index: number): Nullable<Material>;
  87915. /**
  87916. * Get the list of active textures for the whole sub materials list.
  87917. * @returns All the textures that will be used during the rendering
  87918. */
  87919. getActiveTextures(): BaseTexture[];
  87920. /**
  87921. * Gets the current class name of the material e.g. "MultiMaterial"
  87922. * Mainly use in serialization.
  87923. * @returns the class name
  87924. */
  87925. getClassName(): string;
  87926. /**
  87927. * Checks if the material is ready to render the requested sub mesh
  87928. * @param mesh Define the mesh the submesh belongs to
  87929. * @param subMesh Define the sub mesh to look readyness for
  87930. * @param useInstances Define whether or not the material is used with instances
  87931. * @returns true if ready, otherwise false
  87932. */
  87933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87934. /**
  87935. * Clones the current material and its related sub materials
  87936. * @param name Define the name of the newly cloned material
  87937. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87938. * @returns the cloned material
  87939. */
  87940. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87941. /**
  87942. * Serializes the materials into a JSON representation.
  87943. * @returns the JSON representation
  87944. */
  87945. serialize(): any;
  87946. /**
  87947. * Dispose the material and release its associated resources
  87948. * @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)
  87949. * @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)
  87950. * @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)
  87951. */
  87952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87953. /**
  87954. * Creates a MultiMaterial from parsed MultiMaterial data.
  87955. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87956. * @param scene defines the hosting scene
  87957. * @returns a new MultiMaterial
  87958. */
  87959. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87960. }
  87961. }
  87962. declare module BABYLON {
  87963. /**
  87964. * Base class for submeshes
  87965. */
  87966. export class BaseSubMesh {
  87967. /** @hidden */
  87968. _materialDefines: Nullable<MaterialDefines>;
  87969. /** @hidden */
  87970. _materialEffect: Nullable<Effect>;
  87971. /**
  87972. * Gets associated effect
  87973. */
  87974. readonly effect: Nullable<Effect>;
  87975. /**
  87976. * Sets associated effect (effect used to render this submesh)
  87977. * @param effect defines the effect to associate with
  87978. * @param defines defines the set of defines used to compile this effect
  87979. */
  87980. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87981. }
  87982. /**
  87983. * Defines a subdivision inside a mesh
  87984. */
  87985. export class SubMesh extends BaseSubMesh implements ICullable {
  87986. /** the material index to use */
  87987. materialIndex: number;
  87988. /** vertex index start */
  87989. verticesStart: number;
  87990. /** vertices count */
  87991. verticesCount: number;
  87992. /** index start */
  87993. indexStart: number;
  87994. /** indices count */
  87995. indexCount: number;
  87996. /** @hidden */
  87997. _linesIndexCount: number;
  87998. private _mesh;
  87999. private _renderingMesh;
  88000. private _boundingInfo;
  88001. private _linesIndexBuffer;
  88002. /** @hidden */
  88003. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88004. /** @hidden */
  88005. _trianglePlanes: Plane[];
  88006. /** @hidden */
  88007. _lastColliderTransformMatrix: Nullable<Matrix>;
  88008. /** @hidden */
  88009. _renderId: number;
  88010. /** @hidden */
  88011. _alphaIndex: number;
  88012. /** @hidden */
  88013. _distanceToCamera: number;
  88014. /** @hidden */
  88015. _id: number;
  88016. private _currentMaterial;
  88017. /**
  88018. * Add a new submesh to a mesh
  88019. * @param materialIndex defines the material index to use
  88020. * @param verticesStart defines vertex index start
  88021. * @param verticesCount defines vertices count
  88022. * @param indexStart defines index start
  88023. * @param indexCount defines indices count
  88024. * @param mesh defines the parent mesh
  88025. * @param renderingMesh defines an optional rendering mesh
  88026. * @param createBoundingBox defines if bounding box should be created for this submesh
  88027. * @returns the new submesh
  88028. */
  88029. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88030. /**
  88031. * Creates a new submesh
  88032. * @param materialIndex defines the material index to use
  88033. * @param verticesStart defines vertex index start
  88034. * @param verticesCount defines vertices count
  88035. * @param indexStart defines index start
  88036. * @param indexCount defines indices count
  88037. * @param mesh defines the parent mesh
  88038. * @param renderingMesh defines an optional rendering mesh
  88039. * @param createBoundingBox defines if bounding box should be created for this submesh
  88040. */
  88041. constructor(
  88042. /** the material index to use */
  88043. materialIndex: number,
  88044. /** vertex index start */
  88045. verticesStart: number,
  88046. /** vertices count */
  88047. verticesCount: number,
  88048. /** index start */
  88049. indexStart: number,
  88050. /** indices count */
  88051. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88052. /**
  88053. * Returns true if this submesh covers the entire parent mesh
  88054. * @ignorenaming
  88055. */
  88056. readonly IsGlobal: boolean;
  88057. /**
  88058. * Returns the submesh BoudingInfo object
  88059. * @returns current bounding info (or mesh's one if the submesh is global)
  88060. */
  88061. getBoundingInfo(): BoundingInfo;
  88062. /**
  88063. * Sets the submesh BoundingInfo
  88064. * @param boundingInfo defines the new bounding info to use
  88065. * @returns the SubMesh
  88066. */
  88067. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88068. /**
  88069. * Returns the mesh of the current submesh
  88070. * @return the parent mesh
  88071. */
  88072. getMesh(): AbstractMesh;
  88073. /**
  88074. * Returns the rendering mesh of the submesh
  88075. * @returns the rendering mesh (could be different from parent mesh)
  88076. */
  88077. getRenderingMesh(): Mesh;
  88078. /**
  88079. * Returns the submesh material
  88080. * @returns null or the current material
  88081. */
  88082. getMaterial(): Nullable<Material>;
  88083. /**
  88084. * Sets a new updated BoundingInfo object to the submesh
  88085. * @param data defines an optional position array to use to determine the bounding info
  88086. * @returns the SubMesh
  88087. */
  88088. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88089. /** @hidden */
  88090. _checkCollision(collider: Collider): boolean;
  88091. /**
  88092. * Updates the submesh BoundingInfo
  88093. * @param world defines the world matrix to use to update the bounding info
  88094. * @returns the submesh
  88095. */
  88096. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88097. /**
  88098. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88099. * @param frustumPlanes defines the frustum planes
  88100. * @returns true if the submesh is intersecting with the frustum
  88101. */
  88102. isInFrustum(frustumPlanes: Plane[]): boolean;
  88103. /**
  88104. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88105. * @param frustumPlanes defines the frustum planes
  88106. * @returns true if the submesh is inside the frustum
  88107. */
  88108. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88109. /**
  88110. * Renders the submesh
  88111. * @param enableAlphaMode defines if alpha needs to be used
  88112. * @returns the submesh
  88113. */
  88114. render(enableAlphaMode: boolean): SubMesh;
  88115. /**
  88116. * @hidden
  88117. */
  88118. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88119. /**
  88120. * Checks if the submesh intersects with a ray
  88121. * @param ray defines the ray to test
  88122. * @returns true is the passed ray intersects the submesh bounding box
  88123. */
  88124. canIntersects(ray: Ray): boolean;
  88125. /**
  88126. * Intersects current submesh with a ray
  88127. * @param ray defines the ray to test
  88128. * @param positions defines mesh's positions array
  88129. * @param indices defines mesh's indices array
  88130. * @param fastCheck defines if only bounding info should be used
  88131. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88132. * @returns intersection info or null if no intersection
  88133. */
  88134. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88135. /** @hidden */
  88136. private _intersectLines;
  88137. /** @hidden */
  88138. private _intersectUnIndexedLines;
  88139. /** @hidden */
  88140. private _intersectTriangles;
  88141. /** @hidden */
  88142. private _intersectUnIndexedTriangles;
  88143. /** @hidden */
  88144. _rebuild(): void;
  88145. /**
  88146. * Creates a new submesh from the passed mesh
  88147. * @param newMesh defines the new hosting mesh
  88148. * @param newRenderingMesh defines an optional rendering mesh
  88149. * @returns the new submesh
  88150. */
  88151. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88152. /**
  88153. * Release associated resources
  88154. */
  88155. dispose(): void;
  88156. /**
  88157. * Gets the class name
  88158. * @returns the string "SubMesh".
  88159. */
  88160. getClassName(): string;
  88161. /**
  88162. * Creates a new submesh from indices data
  88163. * @param materialIndex the index of the main mesh material
  88164. * @param startIndex the index where to start the copy in the mesh indices array
  88165. * @param indexCount the number of indices to copy then from the startIndex
  88166. * @param mesh the main mesh to create the submesh from
  88167. * @param renderingMesh the optional rendering mesh
  88168. * @returns a new submesh
  88169. */
  88170. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88171. }
  88172. }
  88173. declare module BABYLON {
  88174. /**
  88175. * Class used to represent data loading progression
  88176. */
  88177. export class SceneLoaderFlags {
  88178. private static _ForceFullSceneLoadingForIncremental;
  88179. private static _ShowLoadingScreen;
  88180. private static _CleanBoneMatrixWeights;
  88181. private static _loggingLevel;
  88182. /**
  88183. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88184. */
  88185. static ForceFullSceneLoadingForIncremental: boolean;
  88186. /**
  88187. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88188. */
  88189. static ShowLoadingScreen: boolean;
  88190. /**
  88191. * Defines the current logging level (while loading the scene)
  88192. * @ignorenaming
  88193. */
  88194. static loggingLevel: number;
  88195. /**
  88196. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88197. */
  88198. static CleanBoneMatrixWeights: boolean;
  88199. }
  88200. }
  88201. declare module BABYLON {
  88202. /**
  88203. * Class used to store geometry data (vertex buffers + index buffer)
  88204. */
  88205. export class Geometry implements IGetSetVerticesData {
  88206. /**
  88207. * Gets or sets the ID of the geometry
  88208. */
  88209. id: string;
  88210. /**
  88211. * Gets or sets the unique ID of the geometry
  88212. */
  88213. uniqueId: number;
  88214. /**
  88215. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88216. */
  88217. delayLoadState: number;
  88218. /**
  88219. * Gets the file containing the data to load when running in delay load state
  88220. */
  88221. delayLoadingFile: Nullable<string>;
  88222. /**
  88223. * Callback called when the geometry is updated
  88224. */
  88225. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88226. private _scene;
  88227. private _engine;
  88228. private _meshes;
  88229. private _totalVertices;
  88230. /** @hidden */
  88231. _indices: IndicesArray;
  88232. /** @hidden */
  88233. _vertexBuffers: {
  88234. [key: string]: VertexBuffer;
  88235. };
  88236. private _isDisposed;
  88237. private _extend;
  88238. private _boundingBias;
  88239. /** @hidden */
  88240. _delayInfo: Array<string>;
  88241. private _indexBuffer;
  88242. private _indexBufferIsUpdatable;
  88243. /** @hidden */
  88244. _boundingInfo: Nullable<BoundingInfo>;
  88245. /** @hidden */
  88246. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88247. /** @hidden */
  88248. _softwareSkinningFrameId: number;
  88249. private _vertexArrayObjects;
  88250. private _updatable;
  88251. /** @hidden */
  88252. _positions: Nullable<Vector3[]>;
  88253. /**
  88254. * 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
  88255. */
  88256. /**
  88257. * 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
  88258. */
  88259. boundingBias: Vector2;
  88260. /**
  88261. * Static function used to attach a new empty geometry to a mesh
  88262. * @param mesh defines the mesh to attach the geometry to
  88263. * @returns the new Geometry
  88264. */
  88265. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88266. /**
  88267. * Creates a new geometry
  88268. * @param id defines the unique ID
  88269. * @param scene defines the hosting scene
  88270. * @param vertexData defines the VertexData used to get geometry data
  88271. * @param updatable defines if geometry must be updatable (false by default)
  88272. * @param mesh defines the mesh that will be associated with the geometry
  88273. */
  88274. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88275. /**
  88276. * Gets the current extend of the geometry
  88277. */
  88278. readonly extend: {
  88279. minimum: Vector3;
  88280. maximum: Vector3;
  88281. };
  88282. /**
  88283. * Gets the hosting scene
  88284. * @returns the hosting Scene
  88285. */
  88286. getScene(): Scene;
  88287. /**
  88288. * Gets the hosting engine
  88289. * @returns the hosting Engine
  88290. */
  88291. getEngine(): Engine;
  88292. /**
  88293. * Defines if the geometry is ready to use
  88294. * @returns true if the geometry is ready to be used
  88295. */
  88296. isReady(): boolean;
  88297. /**
  88298. * Gets a value indicating that the geometry should not be serialized
  88299. */
  88300. readonly doNotSerialize: boolean;
  88301. /** @hidden */
  88302. _rebuild(): void;
  88303. /**
  88304. * Affects all geometry data in one call
  88305. * @param vertexData defines the geometry data
  88306. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88307. */
  88308. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88309. /**
  88310. * Set specific vertex data
  88311. * @param kind defines the data kind (Position, normal, etc...)
  88312. * @param data defines the vertex data to use
  88313. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88314. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88315. */
  88316. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88317. /**
  88318. * Removes a specific vertex data
  88319. * @param kind defines the data kind (Position, normal, etc...)
  88320. */
  88321. removeVerticesData(kind: string): void;
  88322. /**
  88323. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88324. * @param buffer defines the vertex buffer to use
  88325. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88326. */
  88327. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88328. /**
  88329. * Update a specific vertex buffer
  88330. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88331. * It will do nothing if the buffer is not updatable
  88332. * @param kind defines the data kind (Position, normal, etc...)
  88333. * @param data defines the data to use
  88334. * @param offset defines the offset in the target buffer where to store the data
  88335. * @param useBytes set to true if the offset is in bytes
  88336. */
  88337. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88338. /**
  88339. * Update a specific vertex buffer
  88340. * This function will create a new buffer if the current one is not updatable
  88341. * @param kind defines the data kind (Position, normal, etc...)
  88342. * @param data defines the data to use
  88343. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88344. */
  88345. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88346. private _updateBoundingInfo;
  88347. /** @hidden */
  88348. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88349. /**
  88350. * Gets total number of vertices
  88351. * @returns the total number of vertices
  88352. */
  88353. getTotalVertices(): number;
  88354. /**
  88355. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88356. * @param kind defines the data kind (Position, normal, etc...)
  88357. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88358. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88359. * @returns a float array containing vertex data
  88360. */
  88361. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88362. /**
  88363. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88364. * @param kind defines the data kind (Position, normal, etc...)
  88365. * @returns true if the vertex buffer with the specified kind is updatable
  88366. */
  88367. isVertexBufferUpdatable(kind: string): boolean;
  88368. /**
  88369. * Gets a specific vertex buffer
  88370. * @param kind defines the data kind (Position, normal, etc...)
  88371. * @returns a VertexBuffer
  88372. */
  88373. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88374. /**
  88375. * Returns all vertex buffers
  88376. * @return an object holding all vertex buffers indexed by kind
  88377. */
  88378. getVertexBuffers(): Nullable<{
  88379. [key: string]: VertexBuffer;
  88380. }>;
  88381. /**
  88382. * Gets a boolean indicating if specific vertex buffer is present
  88383. * @param kind defines the data kind (Position, normal, etc...)
  88384. * @returns true if data is present
  88385. */
  88386. isVerticesDataPresent(kind: string): boolean;
  88387. /**
  88388. * Gets a list of all attached data kinds (Position, normal, etc...)
  88389. * @returns a list of string containing all kinds
  88390. */
  88391. getVerticesDataKinds(): string[];
  88392. /**
  88393. * Update index buffer
  88394. * @param indices defines the indices to store in the index buffer
  88395. * @param offset defines the offset in the target buffer where to store the data
  88396. * @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)
  88397. */
  88398. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88399. /**
  88400. * Creates a new index buffer
  88401. * @param indices defines the indices to store in the index buffer
  88402. * @param totalVertices defines the total number of vertices (could be null)
  88403. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88404. */
  88405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88406. /**
  88407. * Return the total number of indices
  88408. * @returns the total number of indices
  88409. */
  88410. getTotalIndices(): number;
  88411. /**
  88412. * Gets the index buffer array
  88413. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88414. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88415. * @returns the index buffer array
  88416. */
  88417. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88418. /**
  88419. * Gets the index buffer
  88420. * @return the index buffer
  88421. */
  88422. getIndexBuffer(): Nullable<DataBuffer>;
  88423. /** @hidden */
  88424. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88425. /**
  88426. * Release the associated resources for a specific mesh
  88427. * @param mesh defines the source mesh
  88428. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88429. */
  88430. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88431. /**
  88432. * Apply current geometry to a given mesh
  88433. * @param mesh defines the mesh to apply geometry to
  88434. */
  88435. applyToMesh(mesh: Mesh): void;
  88436. private _updateExtend;
  88437. private _applyToMesh;
  88438. private notifyUpdate;
  88439. /**
  88440. * Load the geometry if it was flagged as delay loaded
  88441. * @param scene defines the hosting scene
  88442. * @param onLoaded defines a callback called when the geometry is loaded
  88443. */
  88444. load(scene: Scene, onLoaded?: () => void): void;
  88445. private _queueLoad;
  88446. /**
  88447. * Invert the geometry to move from a right handed system to a left handed one.
  88448. */
  88449. toLeftHanded(): void;
  88450. /** @hidden */
  88451. _resetPointsArrayCache(): void;
  88452. /** @hidden */
  88453. _generatePointsArray(): boolean;
  88454. /**
  88455. * Gets a value indicating if the geometry is disposed
  88456. * @returns true if the geometry was disposed
  88457. */
  88458. isDisposed(): boolean;
  88459. private _disposeVertexArrayObjects;
  88460. /**
  88461. * Free all associated resources
  88462. */
  88463. dispose(): void;
  88464. /**
  88465. * Clone the current geometry into a new geometry
  88466. * @param id defines the unique ID of the new geometry
  88467. * @returns a new geometry object
  88468. */
  88469. copy(id: string): Geometry;
  88470. /**
  88471. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88472. * @return a JSON representation of the current geometry data (without the vertices data)
  88473. */
  88474. serialize(): any;
  88475. private toNumberArray;
  88476. /**
  88477. * Serialize all vertices data into a JSON oject
  88478. * @returns a JSON representation of the current geometry data
  88479. */
  88480. serializeVerticeData(): any;
  88481. /**
  88482. * Extracts a clone of a mesh geometry
  88483. * @param mesh defines the source mesh
  88484. * @param id defines the unique ID of the new geometry object
  88485. * @returns the new geometry object
  88486. */
  88487. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88488. /**
  88489. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88490. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88491. * Be aware Math.random() could cause collisions, but:
  88492. * "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"
  88493. * @returns a string containing a new GUID
  88494. */
  88495. static RandomId(): string;
  88496. /** @hidden */
  88497. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88498. private static _CleanMatricesWeights;
  88499. /**
  88500. * Create a new geometry from persisted data (Using .babylon file format)
  88501. * @param parsedVertexData defines the persisted data
  88502. * @param scene defines the hosting scene
  88503. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88504. * @returns the new geometry object
  88505. */
  88506. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88507. }
  88508. }
  88509. declare module BABYLON {
  88510. /**
  88511. * Define an interface for all classes that will get and set the data on vertices
  88512. */
  88513. export interface IGetSetVerticesData {
  88514. /**
  88515. * Gets a boolean indicating if specific vertex data is present
  88516. * @param kind defines the vertex data kind to use
  88517. * @returns true is data kind is present
  88518. */
  88519. isVerticesDataPresent(kind: string): boolean;
  88520. /**
  88521. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88522. * @param kind defines the data kind (Position, normal, etc...)
  88523. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88525. * @returns a float array containing vertex data
  88526. */
  88527. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88528. /**
  88529. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88530. * @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.
  88531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88532. * @returns the indices array or an empty array if the mesh has no geometry
  88533. */
  88534. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88535. /**
  88536. * Set specific vertex data
  88537. * @param kind defines the data kind (Position, normal, etc...)
  88538. * @param data defines the vertex data to use
  88539. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88540. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88541. */
  88542. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88543. /**
  88544. * Update a specific associated vertex buffer
  88545. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88546. * - VertexBuffer.PositionKind
  88547. * - VertexBuffer.UVKind
  88548. * - VertexBuffer.UV2Kind
  88549. * - VertexBuffer.UV3Kind
  88550. * - VertexBuffer.UV4Kind
  88551. * - VertexBuffer.UV5Kind
  88552. * - VertexBuffer.UV6Kind
  88553. * - VertexBuffer.ColorKind
  88554. * - VertexBuffer.MatricesIndicesKind
  88555. * - VertexBuffer.MatricesIndicesExtraKind
  88556. * - VertexBuffer.MatricesWeightsKind
  88557. * - VertexBuffer.MatricesWeightsExtraKind
  88558. * @param data defines the data source
  88559. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88560. * @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)
  88561. */
  88562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88563. /**
  88564. * Creates a new index buffer
  88565. * @param indices defines the indices to store in the index buffer
  88566. * @param totalVertices defines the total number of vertices (could be null)
  88567. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88568. */
  88569. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88570. }
  88571. /**
  88572. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88573. */
  88574. export class VertexData {
  88575. /**
  88576. * Mesh side orientation : usually the external or front surface
  88577. */
  88578. static readonly FRONTSIDE: number;
  88579. /**
  88580. * Mesh side orientation : usually the internal or back surface
  88581. */
  88582. static readonly BACKSIDE: number;
  88583. /**
  88584. * Mesh side orientation : both internal and external or front and back surfaces
  88585. */
  88586. static readonly DOUBLESIDE: number;
  88587. /**
  88588. * Mesh side orientation : by default, `FRONTSIDE`
  88589. */
  88590. static readonly DEFAULTSIDE: number;
  88591. /**
  88592. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88593. */
  88594. positions: Nullable<FloatArray>;
  88595. /**
  88596. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88597. */
  88598. normals: Nullable<FloatArray>;
  88599. /**
  88600. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88601. */
  88602. tangents: Nullable<FloatArray>;
  88603. /**
  88604. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88605. */
  88606. uvs: Nullable<FloatArray>;
  88607. /**
  88608. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88609. */
  88610. uvs2: Nullable<FloatArray>;
  88611. /**
  88612. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88613. */
  88614. uvs3: Nullable<FloatArray>;
  88615. /**
  88616. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88617. */
  88618. uvs4: Nullable<FloatArray>;
  88619. /**
  88620. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88621. */
  88622. uvs5: Nullable<FloatArray>;
  88623. /**
  88624. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88625. */
  88626. uvs6: Nullable<FloatArray>;
  88627. /**
  88628. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88629. */
  88630. colors: Nullable<FloatArray>;
  88631. /**
  88632. * 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).
  88633. */
  88634. matricesIndices: Nullable<FloatArray>;
  88635. /**
  88636. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88637. */
  88638. matricesWeights: Nullable<FloatArray>;
  88639. /**
  88640. * An array extending the number of possible indices
  88641. */
  88642. matricesIndicesExtra: Nullable<FloatArray>;
  88643. /**
  88644. * An array extending the number of possible weights when the number of indices is extended
  88645. */
  88646. matricesWeightsExtra: Nullable<FloatArray>;
  88647. /**
  88648. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88649. */
  88650. indices: Nullable<IndicesArray>;
  88651. /**
  88652. * Uses the passed data array to set the set the values for the specified kind of data
  88653. * @param data a linear array of floating numbers
  88654. * @param kind the type of data that is being set, eg positions, colors etc
  88655. */
  88656. set(data: FloatArray, kind: string): void;
  88657. /**
  88658. * Associates the vertexData to the passed Mesh.
  88659. * Sets it as updatable or not (default `false`)
  88660. * @param mesh the mesh the vertexData is applied to
  88661. * @param updatable when used and having the value true allows new data to update the vertexData
  88662. * @returns the VertexData
  88663. */
  88664. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88665. /**
  88666. * Associates the vertexData to the passed Geometry.
  88667. * Sets it as updatable or not (default `false`)
  88668. * @param geometry the geometry the vertexData is applied to
  88669. * @param updatable when used and having the value true allows new data to update the vertexData
  88670. * @returns VertexData
  88671. */
  88672. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88673. /**
  88674. * Updates the associated mesh
  88675. * @param mesh the mesh to be updated
  88676. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88677. * @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
  88678. * @returns VertexData
  88679. */
  88680. updateMesh(mesh: Mesh): VertexData;
  88681. /**
  88682. * Updates the associated geometry
  88683. * @param geometry the geometry to be updated
  88684. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88685. * @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
  88686. * @returns VertexData.
  88687. */
  88688. updateGeometry(geometry: Geometry): VertexData;
  88689. private _applyTo;
  88690. private _update;
  88691. /**
  88692. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88693. * @param matrix the transforming matrix
  88694. * @returns the VertexData
  88695. */
  88696. transform(matrix: Matrix): VertexData;
  88697. /**
  88698. * Merges the passed VertexData into the current one
  88699. * @param other the VertexData to be merged into the current one
  88700. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88701. * @returns the modified VertexData
  88702. */
  88703. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88704. private _mergeElement;
  88705. private _validate;
  88706. /**
  88707. * Serializes the VertexData
  88708. * @returns a serialized object
  88709. */
  88710. serialize(): any;
  88711. /**
  88712. * Extracts the vertexData from a mesh
  88713. * @param mesh the mesh from which to extract the VertexData
  88714. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88715. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88716. * @returns the object VertexData associated to the passed mesh
  88717. */
  88718. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88719. /**
  88720. * Extracts the vertexData from the geometry
  88721. * @param geometry the geometry from which to extract the VertexData
  88722. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88723. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88724. * @returns the object VertexData associated to the passed mesh
  88725. */
  88726. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88727. private static _ExtractFrom;
  88728. /**
  88729. * Creates the VertexData for a Ribbon
  88730. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88731. * * pathArray array of paths, each of which an array of successive Vector3
  88732. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88733. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88734. * * 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
  88735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88736. * * 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)
  88737. * * 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)
  88738. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88739. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88740. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88741. * @returns the VertexData of the ribbon
  88742. */
  88743. static CreateRibbon(options: {
  88744. pathArray: Vector3[][];
  88745. closeArray?: boolean;
  88746. closePath?: boolean;
  88747. offset?: number;
  88748. sideOrientation?: number;
  88749. frontUVs?: Vector4;
  88750. backUVs?: Vector4;
  88751. invertUV?: boolean;
  88752. uvs?: Vector2[];
  88753. colors?: Color4[];
  88754. }): VertexData;
  88755. /**
  88756. * Creates the VertexData for a box
  88757. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88758. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88759. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88760. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88761. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88762. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88763. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88765. * * 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)
  88766. * * 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)
  88767. * @returns the VertexData of the box
  88768. */
  88769. static CreateBox(options: {
  88770. size?: number;
  88771. width?: number;
  88772. height?: number;
  88773. depth?: number;
  88774. faceUV?: Vector4[];
  88775. faceColors?: Color4[];
  88776. sideOrientation?: number;
  88777. frontUVs?: Vector4;
  88778. backUVs?: Vector4;
  88779. }): VertexData;
  88780. /**
  88781. * Creates the VertexData for a tiled box
  88782. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88783. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88784. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88785. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88787. * @returns the VertexData of the box
  88788. */
  88789. static CreateTiledBox(options: {
  88790. pattern?: number;
  88791. width?: number;
  88792. height?: number;
  88793. depth?: number;
  88794. tileSize?: number;
  88795. tileWidth?: number;
  88796. tileHeight?: number;
  88797. alignHorizontal?: number;
  88798. alignVertical?: number;
  88799. faceUV?: Vector4[];
  88800. faceColors?: Color4[];
  88801. sideOrientation?: number;
  88802. }): VertexData;
  88803. /**
  88804. * Creates the VertexData for a tiled plane
  88805. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88806. * * pattern a limited pattern arrangement depending on the number
  88807. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88808. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88809. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88811. * * 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)
  88812. * * 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)
  88813. * @returns the VertexData of the tiled plane
  88814. */
  88815. static CreateTiledPlane(options: {
  88816. pattern?: number;
  88817. tileSize?: number;
  88818. tileWidth?: number;
  88819. tileHeight?: number;
  88820. size?: number;
  88821. width?: number;
  88822. height?: number;
  88823. alignHorizontal?: number;
  88824. alignVertical?: number;
  88825. sideOrientation?: number;
  88826. frontUVs?: Vector4;
  88827. backUVs?: Vector4;
  88828. }): VertexData;
  88829. /**
  88830. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88831. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88832. * * segments sets the number of horizontal strips optional, default 32
  88833. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88834. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88835. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88836. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88837. * * 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
  88838. * * 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
  88839. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88840. * * 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)
  88841. * * 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)
  88842. * @returns the VertexData of the ellipsoid
  88843. */
  88844. static CreateSphere(options: {
  88845. segments?: number;
  88846. diameter?: number;
  88847. diameterX?: number;
  88848. diameterY?: number;
  88849. diameterZ?: number;
  88850. arc?: number;
  88851. slice?: number;
  88852. sideOrientation?: number;
  88853. frontUVs?: Vector4;
  88854. backUVs?: Vector4;
  88855. }): VertexData;
  88856. /**
  88857. * Creates the VertexData for a cylinder, cone or prism
  88858. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88859. * * height sets the height (y direction) of the cylinder, optional, default 2
  88860. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88861. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88862. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88863. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88864. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88865. * * 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
  88866. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88867. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88868. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88869. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88871. * * 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)
  88872. * * 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)
  88873. * @returns the VertexData of the cylinder, cone or prism
  88874. */
  88875. static CreateCylinder(options: {
  88876. height?: number;
  88877. diameterTop?: number;
  88878. diameterBottom?: number;
  88879. diameter?: number;
  88880. tessellation?: number;
  88881. subdivisions?: number;
  88882. arc?: number;
  88883. faceColors?: Color4[];
  88884. faceUV?: Vector4[];
  88885. hasRings?: boolean;
  88886. enclose?: boolean;
  88887. sideOrientation?: number;
  88888. frontUVs?: Vector4;
  88889. backUVs?: Vector4;
  88890. }): VertexData;
  88891. /**
  88892. * Creates the VertexData for a torus
  88893. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88894. * * diameter the diameter of the torus, optional default 1
  88895. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88896. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88897. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88898. * * 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)
  88899. * * 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)
  88900. * @returns the VertexData of the torus
  88901. */
  88902. static CreateTorus(options: {
  88903. diameter?: number;
  88904. thickness?: number;
  88905. tessellation?: number;
  88906. sideOrientation?: number;
  88907. frontUVs?: Vector4;
  88908. backUVs?: Vector4;
  88909. }): VertexData;
  88910. /**
  88911. * Creates the VertexData of the LineSystem
  88912. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88913. * - lines an array of lines, each line being an array of successive Vector3
  88914. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88915. * @returns the VertexData of the LineSystem
  88916. */
  88917. static CreateLineSystem(options: {
  88918. lines: Vector3[][];
  88919. colors?: Nullable<Color4[][]>;
  88920. }): VertexData;
  88921. /**
  88922. * Create the VertexData for a DashedLines
  88923. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88924. * - points an array successive Vector3
  88925. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88926. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88927. * - dashNb the intended total number of dashes, optional, default 200
  88928. * @returns the VertexData for the DashedLines
  88929. */
  88930. static CreateDashedLines(options: {
  88931. points: Vector3[];
  88932. dashSize?: number;
  88933. gapSize?: number;
  88934. dashNb?: number;
  88935. }): VertexData;
  88936. /**
  88937. * Creates the VertexData for a Ground
  88938. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88939. * - width the width (x direction) of the ground, optional, default 1
  88940. * - height the height (z direction) of the ground, optional, default 1
  88941. * - subdivisions the number of subdivisions per side, optional, default 1
  88942. * @returns the VertexData of the Ground
  88943. */
  88944. static CreateGround(options: {
  88945. width?: number;
  88946. height?: number;
  88947. subdivisions?: number;
  88948. subdivisionsX?: number;
  88949. subdivisionsY?: number;
  88950. }): VertexData;
  88951. /**
  88952. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88953. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88954. * * xmin the ground minimum X coordinate, optional, default -1
  88955. * * zmin the ground minimum Z coordinate, optional, default -1
  88956. * * xmax the ground maximum X coordinate, optional, default 1
  88957. * * zmax the ground maximum Z coordinate, optional, default 1
  88958. * * 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}
  88959. * * 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}
  88960. * @returns the VertexData of the TiledGround
  88961. */
  88962. static CreateTiledGround(options: {
  88963. xmin: number;
  88964. zmin: number;
  88965. xmax: number;
  88966. zmax: number;
  88967. subdivisions?: {
  88968. w: number;
  88969. h: number;
  88970. };
  88971. precision?: {
  88972. w: number;
  88973. h: number;
  88974. };
  88975. }): VertexData;
  88976. /**
  88977. * Creates the VertexData of the Ground designed from a heightmap
  88978. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88979. * * width the width (x direction) of the ground
  88980. * * height the height (z direction) of the ground
  88981. * * subdivisions the number of subdivisions per side
  88982. * * minHeight the minimum altitude on the ground, optional, default 0
  88983. * * maxHeight the maximum altitude on the ground, optional default 1
  88984. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88985. * * buffer the array holding the image color data
  88986. * * bufferWidth the width of image
  88987. * * bufferHeight the height of image
  88988. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88989. * @returns the VertexData of the Ground designed from a heightmap
  88990. */
  88991. static CreateGroundFromHeightMap(options: {
  88992. width: number;
  88993. height: number;
  88994. subdivisions: number;
  88995. minHeight: number;
  88996. maxHeight: number;
  88997. colorFilter: Color3;
  88998. buffer: Uint8Array;
  88999. bufferWidth: number;
  89000. bufferHeight: number;
  89001. alphaFilter: number;
  89002. }): VertexData;
  89003. /**
  89004. * Creates the VertexData for a Plane
  89005. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89006. * * size sets the width and height of the plane to the value of size, optional default 1
  89007. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89008. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89010. * * 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)
  89011. * * 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)
  89012. * @returns the VertexData of the box
  89013. */
  89014. static CreatePlane(options: {
  89015. size?: number;
  89016. width?: number;
  89017. height?: number;
  89018. sideOrientation?: number;
  89019. frontUVs?: Vector4;
  89020. backUVs?: Vector4;
  89021. }): VertexData;
  89022. /**
  89023. * Creates the VertexData of the Disc or regular Polygon
  89024. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89025. * * radius the radius of the disc, optional default 0.5
  89026. * * tessellation the number of polygon sides, optional, default 64
  89027. * * 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
  89028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89029. * * 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)
  89030. * * 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)
  89031. * @returns the VertexData of the box
  89032. */
  89033. static CreateDisc(options: {
  89034. radius?: number;
  89035. tessellation?: number;
  89036. arc?: number;
  89037. sideOrientation?: number;
  89038. frontUVs?: Vector4;
  89039. backUVs?: Vector4;
  89040. }): VertexData;
  89041. /**
  89042. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89043. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89044. * @param polygon a mesh built from polygonTriangulation.build()
  89045. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89046. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89047. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89048. * @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)
  89049. * @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)
  89050. * @returns the VertexData of the Polygon
  89051. */
  89052. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89053. /**
  89054. * Creates the VertexData of the IcoSphere
  89055. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89056. * * radius the radius of the IcoSphere, optional default 1
  89057. * * radiusX allows stretching in the x direction, optional, default radius
  89058. * * radiusY allows stretching in the y direction, optional, default radius
  89059. * * radiusZ allows stretching in the z direction, optional, default radius
  89060. * * flat when true creates a flat shaded mesh, optional, default true
  89061. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89063. * * 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)
  89064. * * 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)
  89065. * @returns the VertexData of the IcoSphere
  89066. */
  89067. static CreateIcoSphere(options: {
  89068. radius?: number;
  89069. radiusX?: number;
  89070. radiusY?: number;
  89071. radiusZ?: number;
  89072. flat?: boolean;
  89073. subdivisions?: number;
  89074. sideOrientation?: number;
  89075. frontUVs?: Vector4;
  89076. backUVs?: Vector4;
  89077. }): VertexData;
  89078. /**
  89079. * Creates the VertexData for a Polyhedron
  89080. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89081. * * type provided types are:
  89082. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89083. * * 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)
  89084. * * size the size of the IcoSphere, optional default 1
  89085. * * sizeX allows stretching in the x direction, optional, default size
  89086. * * sizeY allows stretching in the y direction, optional, default size
  89087. * * sizeZ allows stretching in the z direction, optional, default size
  89088. * * 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
  89089. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89090. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89091. * * flat when true creates a flat shaded mesh, optional, default true
  89092. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89094. * * 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)
  89095. * * 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)
  89096. * @returns the VertexData of the Polyhedron
  89097. */
  89098. static CreatePolyhedron(options: {
  89099. type?: number;
  89100. size?: number;
  89101. sizeX?: number;
  89102. sizeY?: number;
  89103. sizeZ?: number;
  89104. custom?: any;
  89105. faceUV?: Vector4[];
  89106. faceColors?: Color4[];
  89107. flat?: boolean;
  89108. sideOrientation?: number;
  89109. frontUVs?: Vector4;
  89110. backUVs?: Vector4;
  89111. }): VertexData;
  89112. /**
  89113. * Creates the VertexData for a TorusKnot
  89114. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89115. * * radius the radius of the torus knot, optional, default 2
  89116. * * tube the thickness of the tube, optional, default 0.5
  89117. * * radialSegments the number of sides on each tube segments, optional, default 32
  89118. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89119. * * p the number of windings around the z axis, optional, default 2
  89120. * * q the number of windings around the x axis, optional, default 3
  89121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89122. * * 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)
  89123. * * 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)
  89124. * @returns the VertexData of the Torus Knot
  89125. */
  89126. static CreateTorusKnot(options: {
  89127. radius?: number;
  89128. tube?: number;
  89129. radialSegments?: number;
  89130. tubularSegments?: number;
  89131. p?: number;
  89132. q?: number;
  89133. sideOrientation?: number;
  89134. frontUVs?: Vector4;
  89135. backUVs?: Vector4;
  89136. }): VertexData;
  89137. /**
  89138. * Compute normals for given positions and indices
  89139. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89140. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89141. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89142. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89143. * * facetNormals : optional array of facet normals (vector3)
  89144. * * facetPositions : optional array of facet positions (vector3)
  89145. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89146. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89147. * * bInfo : optional bounding info, required for facetPartitioning computation
  89148. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89149. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89150. * * useRightHandedSystem: optional boolean to for right handed system computation
  89151. * * depthSort : optional boolean to enable the facet depth sort computation
  89152. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89153. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89154. */
  89155. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89156. facetNormals?: any;
  89157. facetPositions?: any;
  89158. facetPartitioning?: any;
  89159. ratio?: number;
  89160. bInfo?: any;
  89161. bbSize?: Vector3;
  89162. subDiv?: any;
  89163. useRightHandedSystem?: boolean;
  89164. depthSort?: boolean;
  89165. distanceTo?: Vector3;
  89166. depthSortedFacets?: any;
  89167. }): void;
  89168. /** @hidden */
  89169. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89170. /**
  89171. * Applies VertexData created from the imported parameters to the geometry
  89172. * @param parsedVertexData the parsed data from an imported file
  89173. * @param geometry the geometry to apply the VertexData to
  89174. */
  89175. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89176. }
  89177. }
  89178. declare module BABYLON {
  89179. /**
  89180. * Defines a target to use with MorphTargetManager
  89181. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89182. */
  89183. export class MorphTarget implements IAnimatable {
  89184. /** defines the name of the target */
  89185. name: string;
  89186. /**
  89187. * Gets or sets the list of animations
  89188. */
  89189. animations: Animation[];
  89190. private _scene;
  89191. private _positions;
  89192. private _normals;
  89193. private _tangents;
  89194. private _uvs;
  89195. private _influence;
  89196. /**
  89197. * Observable raised when the influence changes
  89198. */
  89199. onInfluenceChanged: Observable<boolean>;
  89200. /** @hidden */
  89201. _onDataLayoutChanged: Observable<void>;
  89202. /**
  89203. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89204. */
  89205. influence: number;
  89206. /**
  89207. * Gets or sets the id of the morph Target
  89208. */
  89209. id: string;
  89210. private _animationPropertiesOverride;
  89211. /**
  89212. * Gets or sets the animation properties override
  89213. */
  89214. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89215. /**
  89216. * Creates a new MorphTarget
  89217. * @param name defines the name of the target
  89218. * @param influence defines the influence to use
  89219. * @param scene defines the scene the morphtarget belongs to
  89220. */
  89221. constructor(
  89222. /** defines the name of the target */
  89223. name: string, influence?: number, scene?: Nullable<Scene>);
  89224. /**
  89225. * Gets a boolean defining if the target contains position data
  89226. */
  89227. readonly hasPositions: boolean;
  89228. /**
  89229. * Gets a boolean defining if the target contains normal data
  89230. */
  89231. readonly hasNormals: boolean;
  89232. /**
  89233. * Gets a boolean defining if the target contains tangent data
  89234. */
  89235. readonly hasTangents: boolean;
  89236. /**
  89237. * Gets a boolean defining if the target contains texture coordinates data
  89238. */
  89239. readonly hasUVs: boolean;
  89240. /**
  89241. * Affects position data to this target
  89242. * @param data defines the position data to use
  89243. */
  89244. setPositions(data: Nullable<FloatArray>): void;
  89245. /**
  89246. * Gets the position data stored in this target
  89247. * @returns a FloatArray containing the position data (or null if not present)
  89248. */
  89249. getPositions(): Nullable<FloatArray>;
  89250. /**
  89251. * Affects normal data to this target
  89252. * @param data defines the normal data to use
  89253. */
  89254. setNormals(data: Nullable<FloatArray>): void;
  89255. /**
  89256. * Gets the normal data stored in this target
  89257. * @returns a FloatArray containing the normal data (or null if not present)
  89258. */
  89259. getNormals(): Nullable<FloatArray>;
  89260. /**
  89261. * Affects tangent data to this target
  89262. * @param data defines the tangent data to use
  89263. */
  89264. setTangents(data: Nullable<FloatArray>): void;
  89265. /**
  89266. * Gets the tangent data stored in this target
  89267. * @returns a FloatArray containing the tangent data (or null if not present)
  89268. */
  89269. getTangents(): Nullable<FloatArray>;
  89270. /**
  89271. * Affects texture coordinates data to this target
  89272. * @param data defines the texture coordinates data to use
  89273. */
  89274. setUVs(data: Nullable<FloatArray>): void;
  89275. /**
  89276. * Gets the texture coordinates data stored in this target
  89277. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89278. */
  89279. getUVs(): Nullable<FloatArray>;
  89280. /**
  89281. * Serializes the current target into a Serialization object
  89282. * @returns the serialized object
  89283. */
  89284. serialize(): any;
  89285. /**
  89286. * Returns the string "MorphTarget"
  89287. * @returns "MorphTarget"
  89288. */
  89289. getClassName(): string;
  89290. /**
  89291. * Creates a new target from serialized data
  89292. * @param serializationObject defines the serialized data to use
  89293. * @returns a new MorphTarget
  89294. */
  89295. static Parse(serializationObject: any): MorphTarget;
  89296. /**
  89297. * Creates a MorphTarget from mesh data
  89298. * @param mesh defines the source mesh
  89299. * @param name defines the name to use for the new target
  89300. * @param influence defines the influence to attach to the target
  89301. * @returns a new MorphTarget
  89302. */
  89303. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89304. }
  89305. }
  89306. declare module BABYLON {
  89307. /**
  89308. * This class is used to deform meshes using morphing between different targets
  89309. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89310. */
  89311. export class MorphTargetManager {
  89312. private _targets;
  89313. private _targetInfluenceChangedObservers;
  89314. private _targetDataLayoutChangedObservers;
  89315. private _activeTargets;
  89316. private _scene;
  89317. private _influences;
  89318. private _supportsNormals;
  89319. private _supportsTangents;
  89320. private _supportsUVs;
  89321. private _vertexCount;
  89322. private _uniqueId;
  89323. private _tempInfluences;
  89324. /**
  89325. * Gets or sets a boolean indicating if normals must be morphed
  89326. */
  89327. enableNormalMorphing: boolean;
  89328. /**
  89329. * Gets or sets a boolean indicating if tangents must be morphed
  89330. */
  89331. enableTangentMorphing: boolean;
  89332. /**
  89333. * Gets or sets a boolean indicating if UV must be morphed
  89334. */
  89335. enableUVMorphing: boolean;
  89336. /**
  89337. * Creates a new MorphTargetManager
  89338. * @param scene defines the current scene
  89339. */
  89340. constructor(scene?: Nullable<Scene>);
  89341. /**
  89342. * Gets the unique ID of this manager
  89343. */
  89344. readonly uniqueId: number;
  89345. /**
  89346. * Gets the number of vertices handled by this manager
  89347. */
  89348. readonly vertexCount: number;
  89349. /**
  89350. * Gets a boolean indicating if this manager supports morphing of normals
  89351. */
  89352. readonly supportsNormals: boolean;
  89353. /**
  89354. * Gets a boolean indicating if this manager supports morphing of tangents
  89355. */
  89356. readonly supportsTangents: boolean;
  89357. /**
  89358. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89359. */
  89360. readonly supportsUVs: boolean;
  89361. /**
  89362. * Gets the number of targets stored in this manager
  89363. */
  89364. readonly numTargets: number;
  89365. /**
  89366. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89367. */
  89368. readonly numInfluencers: number;
  89369. /**
  89370. * Gets the list of influences (one per target)
  89371. */
  89372. readonly influences: Float32Array;
  89373. /**
  89374. * Gets the active target at specified index. An active target is a target with an influence > 0
  89375. * @param index defines the index to check
  89376. * @returns the requested target
  89377. */
  89378. getActiveTarget(index: number): MorphTarget;
  89379. /**
  89380. * Gets the target at specified index
  89381. * @param index defines the index to check
  89382. * @returns the requested target
  89383. */
  89384. getTarget(index: number): MorphTarget;
  89385. /**
  89386. * Add a new target to this manager
  89387. * @param target defines the target to add
  89388. */
  89389. addTarget(target: MorphTarget): void;
  89390. /**
  89391. * Removes a target from the manager
  89392. * @param target defines the target to remove
  89393. */
  89394. removeTarget(target: MorphTarget): void;
  89395. /**
  89396. * Serializes the current manager into a Serialization object
  89397. * @returns the serialized object
  89398. */
  89399. serialize(): any;
  89400. private _syncActiveTargets;
  89401. /**
  89402. * Syncrhonize the targets with all the meshes using this morph target manager
  89403. */
  89404. synchronize(): void;
  89405. /**
  89406. * Creates a new MorphTargetManager from serialized data
  89407. * @param serializationObject defines the serialized data
  89408. * @param scene defines the hosting scene
  89409. * @returns the new MorphTargetManager
  89410. */
  89411. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89412. }
  89413. }
  89414. declare module BABYLON {
  89415. /**
  89416. * Class used to represent a specific level of detail of a mesh
  89417. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89418. */
  89419. export class MeshLODLevel {
  89420. /** Defines the distance where this level should start being displayed */
  89421. distance: number;
  89422. /** Defines the mesh to use to render this level */
  89423. mesh: Nullable<Mesh>;
  89424. /**
  89425. * Creates a new LOD level
  89426. * @param distance defines the distance where this level should star being displayed
  89427. * @param mesh defines the mesh to use to render this level
  89428. */
  89429. constructor(
  89430. /** Defines the distance where this level should start being displayed */
  89431. distance: number,
  89432. /** Defines the mesh to use to render this level */
  89433. mesh: Nullable<Mesh>);
  89434. }
  89435. }
  89436. declare module BABYLON {
  89437. /**
  89438. * Mesh representing the gorund
  89439. */
  89440. export class GroundMesh extends Mesh {
  89441. /** If octree should be generated */
  89442. generateOctree: boolean;
  89443. private _heightQuads;
  89444. /** @hidden */
  89445. _subdivisionsX: number;
  89446. /** @hidden */
  89447. _subdivisionsY: number;
  89448. /** @hidden */
  89449. _width: number;
  89450. /** @hidden */
  89451. _height: number;
  89452. /** @hidden */
  89453. _minX: number;
  89454. /** @hidden */
  89455. _maxX: number;
  89456. /** @hidden */
  89457. _minZ: number;
  89458. /** @hidden */
  89459. _maxZ: number;
  89460. constructor(name: string, scene: Scene);
  89461. /**
  89462. * "GroundMesh"
  89463. * @returns "GroundMesh"
  89464. */
  89465. getClassName(): string;
  89466. /**
  89467. * The minimum of x and y subdivisions
  89468. */
  89469. readonly subdivisions: number;
  89470. /**
  89471. * X subdivisions
  89472. */
  89473. readonly subdivisionsX: number;
  89474. /**
  89475. * Y subdivisions
  89476. */
  89477. readonly subdivisionsY: number;
  89478. /**
  89479. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89480. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89481. * @param chunksCount the number of subdivisions for x and y
  89482. * @param octreeBlocksSize (Default: 32)
  89483. */
  89484. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89485. /**
  89486. * Returns a height (y) value in the Worl system :
  89487. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89488. * @param x x coordinate
  89489. * @param z z coordinate
  89490. * @returns the ground y position if (x, z) are outside the ground surface.
  89491. */
  89492. getHeightAtCoordinates(x: number, z: number): number;
  89493. /**
  89494. * Returns a normalized vector (Vector3) orthogonal to the ground
  89495. * at the ground coordinates (x, z) expressed in the World system.
  89496. * @param x x coordinate
  89497. * @param z z coordinate
  89498. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89499. */
  89500. getNormalAtCoordinates(x: number, z: number): Vector3;
  89501. /**
  89502. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89503. * at the ground coordinates (x, z) expressed in the World system.
  89504. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89505. * @param x x coordinate
  89506. * @param z z coordinate
  89507. * @param ref vector to store the result
  89508. * @returns the GroundMesh.
  89509. */
  89510. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89511. /**
  89512. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89513. * if the ground has been updated.
  89514. * This can be used in the render loop.
  89515. * @returns the GroundMesh.
  89516. */
  89517. updateCoordinateHeights(): GroundMesh;
  89518. private _getFacetAt;
  89519. private _initHeightQuads;
  89520. private _computeHeightQuads;
  89521. /**
  89522. * Serializes this ground mesh
  89523. * @param serializationObject object to write serialization to
  89524. */
  89525. serialize(serializationObject: any): void;
  89526. /**
  89527. * Parses a serialized ground mesh
  89528. * @param parsedMesh the serialized mesh
  89529. * @param scene the scene to create the ground mesh in
  89530. * @returns the created ground mesh
  89531. */
  89532. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89533. }
  89534. }
  89535. declare module BABYLON {
  89536. /**
  89537. * Interface for Physics-Joint data
  89538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89539. */
  89540. export interface PhysicsJointData {
  89541. /**
  89542. * The main pivot of the joint
  89543. */
  89544. mainPivot?: Vector3;
  89545. /**
  89546. * The connected pivot of the joint
  89547. */
  89548. connectedPivot?: Vector3;
  89549. /**
  89550. * The main axis of the joint
  89551. */
  89552. mainAxis?: Vector3;
  89553. /**
  89554. * The connected axis of the joint
  89555. */
  89556. connectedAxis?: Vector3;
  89557. /**
  89558. * The collision of the joint
  89559. */
  89560. collision?: boolean;
  89561. /**
  89562. * Native Oimo/Cannon/Energy data
  89563. */
  89564. nativeParams?: any;
  89565. }
  89566. /**
  89567. * This is a holder class for the physics joint created by the physics plugin
  89568. * It holds a set of functions to control the underlying joint
  89569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89570. */
  89571. export class PhysicsJoint {
  89572. /**
  89573. * The type of the physics joint
  89574. */
  89575. type: number;
  89576. /**
  89577. * The data for the physics joint
  89578. */
  89579. jointData: PhysicsJointData;
  89580. private _physicsJoint;
  89581. protected _physicsPlugin: IPhysicsEnginePlugin;
  89582. /**
  89583. * Initializes the physics joint
  89584. * @param type The type of the physics joint
  89585. * @param jointData The data for the physics joint
  89586. */
  89587. constructor(
  89588. /**
  89589. * The type of the physics joint
  89590. */
  89591. type: number,
  89592. /**
  89593. * The data for the physics joint
  89594. */
  89595. jointData: PhysicsJointData);
  89596. /**
  89597. * Gets the physics joint
  89598. */
  89599. /**
  89600. * Sets the physics joint
  89601. */
  89602. physicsJoint: any;
  89603. /**
  89604. * Sets the physics plugin
  89605. */
  89606. physicsPlugin: IPhysicsEnginePlugin;
  89607. /**
  89608. * Execute a function that is physics-plugin specific.
  89609. * @param {Function} func the function that will be executed.
  89610. * It accepts two parameters: the physics world and the physics joint
  89611. */
  89612. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89613. /**
  89614. * Distance-Joint type
  89615. */
  89616. static DistanceJoint: number;
  89617. /**
  89618. * Hinge-Joint type
  89619. */
  89620. static HingeJoint: number;
  89621. /**
  89622. * Ball-and-Socket joint type
  89623. */
  89624. static BallAndSocketJoint: number;
  89625. /**
  89626. * Wheel-Joint type
  89627. */
  89628. static WheelJoint: number;
  89629. /**
  89630. * Slider-Joint type
  89631. */
  89632. static SliderJoint: number;
  89633. /**
  89634. * Prismatic-Joint type
  89635. */
  89636. static PrismaticJoint: number;
  89637. /**
  89638. * Universal-Joint type
  89639. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89640. */
  89641. static UniversalJoint: number;
  89642. /**
  89643. * Hinge-Joint 2 type
  89644. */
  89645. static Hinge2Joint: number;
  89646. /**
  89647. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89648. */
  89649. static PointToPointJoint: number;
  89650. /**
  89651. * Spring-Joint type
  89652. */
  89653. static SpringJoint: number;
  89654. /**
  89655. * Lock-Joint type
  89656. */
  89657. static LockJoint: number;
  89658. }
  89659. /**
  89660. * A class representing a physics distance joint
  89661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89662. */
  89663. export class DistanceJoint extends PhysicsJoint {
  89664. /**
  89665. *
  89666. * @param jointData The data for the Distance-Joint
  89667. */
  89668. constructor(jointData: DistanceJointData);
  89669. /**
  89670. * Update the predefined distance.
  89671. * @param maxDistance The maximum preferred distance
  89672. * @param minDistance The minimum preferred distance
  89673. */
  89674. updateDistance(maxDistance: number, minDistance?: number): void;
  89675. }
  89676. /**
  89677. * Represents a Motor-Enabled Joint
  89678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89679. */
  89680. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89681. /**
  89682. * Initializes the Motor-Enabled Joint
  89683. * @param type The type of the joint
  89684. * @param jointData The physica joint data for the joint
  89685. */
  89686. constructor(type: number, jointData: PhysicsJointData);
  89687. /**
  89688. * Set the motor values.
  89689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89690. * @param force the force to apply
  89691. * @param maxForce max force for this motor.
  89692. */
  89693. setMotor(force?: number, maxForce?: number): void;
  89694. /**
  89695. * Set the motor's limits.
  89696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89697. * @param upperLimit The upper limit of the motor
  89698. * @param lowerLimit The lower limit of the motor
  89699. */
  89700. setLimit(upperLimit: number, lowerLimit?: number): void;
  89701. }
  89702. /**
  89703. * This class represents a single physics Hinge-Joint
  89704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89705. */
  89706. export class HingeJoint extends MotorEnabledJoint {
  89707. /**
  89708. * Initializes the Hinge-Joint
  89709. * @param jointData The joint data for the Hinge-Joint
  89710. */
  89711. constructor(jointData: PhysicsJointData);
  89712. /**
  89713. * Set the motor values.
  89714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89715. * @param {number} force the force to apply
  89716. * @param {number} maxForce max force for this motor.
  89717. */
  89718. setMotor(force?: number, maxForce?: number): void;
  89719. /**
  89720. * Set the motor's limits.
  89721. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89722. * @param upperLimit The upper limit of the motor
  89723. * @param lowerLimit The lower limit of the motor
  89724. */
  89725. setLimit(upperLimit: number, lowerLimit?: number): void;
  89726. }
  89727. /**
  89728. * This class represents a dual hinge physics joint (same as wheel joint)
  89729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89730. */
  89731. export class Hinge2Joint extends MotorEnabledJoint {
  89732. /**
  89733. * Initializes the Hinge2-Joint
  89734. * @param jointData The joint data for the Hinge2-Joint
  89735. */
  89736. constructor(jointData: PhysicsJointData);
  89737. /**
  89738. * Set the motor values.
  89739. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89740. * @param {number} targetSpeed the speed the motor is to reach
  89741. * @param {number} maxForce max force for this motor.
  89742. * @param {motorIndex} the motor's index, 0 or 1.
  89743. */
  89744. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89745. /**
  89746. * Set the motor limits.
  89747. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89748. * @param {number} upperLimit the upper limit
  89749. * @param {number} lowerLimit lower limit
  89750. * @param {motorIndex} the motor's index, 0 or 1.
  89751. */
  89752. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89753. }
  89754. /**
  89755. * Interface for a motor enabled joint
  89756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89757. */
  89758. export interface IMotorEnabledJoint {
  89759. /**
  89760. * Physics joint
  89761. */
  89762. physicsJoint: any;
  89763. /**
  89764. * Sets the motor of the motor-enabled joint
  89765. * @param force The force of the motor
  89766. * @param maxForce The maximum force of the motor
  89767. * @param motorIndex The index of the motor
  89768. */
  89769. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89770. /**
  89771. * Sets the limit of the motor
  89772. * @param upperLimit The upper limit of the motor
  89773. * @param lowerLimit The lower limit of the motor
  89774. * @param motorIndex The index of the motor
  89775. */
  89776. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89777. }
  89778. /**
  89779. * Joint data for a Distance-Joint
  89780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89781. */
  89782. export interface DistanceJointData extends PhysicsJointData {
  89783. /**
  89784. * Max distance the 2 joint objects can be apart
  89785. */
  89786. maxDistance: number;
  89787. }
  89788. /**
  89789. * Joint data from a spring joint
  89790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89791. */
  89792. export interface SpringJointData extends PhysicsJointData {
  89793. /**
  89794. * Length of the spring
  89795. */
  89796. length: number;
  89797. /**
  89798. * Stiffness of the spring
  89799. */
  89800. stiffness: number;
  89801. /**
  89802. * Damping of the spring
  89803. */
  89804. damping: number;
  89805. /** this callback will be called when applying the force to the impostors. */
  89806. forceApplicationCallback: () => void;
  89807. }
  89808. }
  89809. declare module BABYLON {
  89810. /**
  89811. * Holds the data for the raycast result
  89812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89813. */
  89814. export class PhysicsRaycastResult {
  89815. private _hasHit;
  89816. private _hitDistance;
  89817. private _hitNormalWorld;
  89818. private _hitPointWorld;
  89819. private _rayFromWorld;
  89820. private _rayToWorld;
  89821. /**
  89822. * Gets if there was a hit
  89823. */
  89824. readonly hasHit: boolean;
  89825. /**
  89826. * Gets the distance from the hit
  89827. */
  89828. readonly hitDistance: number;
  89829. /**
  89830. * Gets the hit normal/direction in the world
  89831. */
  89832. readonly hitNormalWorld: Vector3;
  89833. /**
  89834. * Gets the hit point in the world
  89835. */
  89836. readonly hitPointWorld: Vector3;
  89837. /**
  89838. * Gets the ray "start point" of the ray in the world
  89839. */
  89840. readonly rayFromWorld: Vector3;
  89841. /**
  89842. * Gets the ray "end point" of the ray in the world
  89843. */
  89844. readonly rayToWorld: Vector3;
  89845. /**
  89846. * Sets the hit data (normal & point in world space)
  89847. * @param hitNormalWorld defines the normal in world space
  89848. * @param hitPointWorld defines the point in world space
  89849. */
  89850. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89851. /**
  89852. * Sets the distance from the start point to the hit point
  89853. * @param distance
  89854. */
  89855. setHitDistance(distance: number): void;
  89856. /**
  89857. * Calculates the distance manually
  89858. */
  89859. calculateHitDistance(): void;
  89860. /**
  89861. * Resets all the values to default
  89862. * @param from The from point on world space
  89863. * @param to The to point on world space
  89864. */
  89865. reset(from?: Vector3, to?: Vector3): void;
  89866. }
  89867. /**
  89868. * Interface for the size containing width and height
  89869. */
  89870. interface IXYZ {
  89871. /**
  89872. * X
  89873. */
  89874. x: number;
  89875. /**
  89876. * Y
  89877. */
  89878. y: number;
  89879. /**
  89880. * Z
  89881. */
  89882. z: number;
  89883. }
  89884. }
  89885. declare module BABYLON {
  89886. /**
  89887. * Interface used to describe a physics joint
  89888. */
  89889. export interface PhysicsImpostorJoint {
  89890. /** Defines the main impostor to which the joint is linked */
  89891. mainImpostor: PhysicsImpostor;
  89892. /** Defines the impostor that is connected to the main impostor using this joint */
  89893. connectedImpostor: PhysicsImpostor;
  89894. /** Defines the joint itself */
  89895. joint: PhysicsJoint;
  89896. }
  89897. /** @hidden */
  89898. export interface IPhysicsEnginePlugin {
  89899. world: any;
  89900. name: string;
  89901. setGravity(gravity: Vector3): void;
  89902. setTimeStep(timeStep: number): void;
  89903. getTimeStep(): number;
  89904. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89905. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89906. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89907. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89908. removePhysicsBody(impostor: PhysicsImpostor): void;
  89909. generateJoint(joint: PhysicsImpostorJoint): void;
  89910. removeJoint(joint: PhysicsImpostorJoint): void;
  89911. isSupported(): boolean;
  89912. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89913. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89914. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89915. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89916. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89917. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89918. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89919. getBodyMass(impostor: PhysicsImpostor): number;
  89920. getBodyFriction(impostor: PhysicsImpostor): number;
  89921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89922. getBodyRestitution(impostor: PhysicsImpostor): number;
  89923. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89924. getBodyPressure?(impostor: PhysicsImpostor): number;
  89925. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89926. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89927. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89928. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89929. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89930. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89931. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89932. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89933. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89934. sleepBody(impostor: PhysicsImpostor): void;
  89935. wakeUpBody(impostor: PhysicsImpostor): void;
  89936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89937. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89938. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89939. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89940. getRadius(impostor: PhysicsImpostor): number;
  89941. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89942. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89943. dispose(): void;
  89944. }
  89945. /**
  89946. * Interface used to define a physics engine
  89947. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89948. */
  89949. export interface IPhysicsEngine {
  89950. /**
  89951. * Gets the gravity vector used by the simulation
  89952. */
  89953. gravity: Vector3;
  89954. /**
  89955. * Sets the gravity vector used by the simulation
  89956. * @param gravity defines the gravity vector to use
  89957. */
  89958. setGravity(gravity: Vector3): void;
  89959. /**
  89960. * Set the time step of the physics engine.
  89961. * Default is 1/60.
  89962. * To slow it down, enter 1/600 for example.
  89963. * To speed it up, 1/30
  89964. * @param newTimeStep the new timestep to apply to this world.
  89965. */
  89966. setTimeStep(newTimeStep: number): void;
  89967. /**
  89968. * Get the time step of the physics engine.
  89969. * @returns the current time step
  89970. */
  89971. getTimeStep(): number;
  89972. /**
  89973. * Release all resources
  89974. */
  89975. dispose(): void;
  89976. /**
  89977. * Gets the name of the current physics plugin
  89978. * @returns the name of the plugin
  89979. */
  89980. getPhysicsPluginName(): string;
  89981. /**
  89982. * Adding a new impostor for the impostor tracking.
  89983. * This will be done by the impostor itself.
  89984. * @param impostor the impostor to add
  89985. */
  89986. addImpostor(impostor: PhysicsImpostor): void;
  89987. /**
  89988. * Remove an impostor from the engine.
  89989. * This impostor and its mesh will not longer be updated by the physics engine.
  89990. * @param impostor the impostor to remove
  89991. */
  89992. removeImpostor(impostor: PhysicsImpostor): void;
  89993. /**
  89994. * Add a joint to the physics engine
  89995. * @param mainImpostor defines the main impostor to which the joint is added.
  89996. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89997. * @param joint defines the joint that will connect both impostors.
  89998. */
  89999. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90000. /**
  90001. * Removes a joint from the simulation
  90002. * @param mainImpostor defines the impostor used with the joint
  90003. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90004. * @param joint defines the joint to remove
  90005. */
  90006. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90007. /**
  90008. * Gets the current plugin used to run the simulation
  90009. * @returns current plugin
  90010. */
  90011. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90012. /**
  90013. * Gets the list of physic impostors
  90014. * @returns an array of PhysicsImpostor
  90015. */
  90016. getImpostors(): Array<PhysicsImpostor>;
  90017. /**
  90018. * Gets the impostor for a physics enabled object
  90019. * @param object defines the object impersonated by the impostor
  90020. * @returns the PhysicsImpostor or null if not found
  90021. */
  90022. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90023. /**
  90024. * Gets the impostor for a physics body object
  90025. * @param body defines physics body used by the impostor
  90026. * @returns the PhysicsImpostor or null if not found
  90027. */
  90028. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90029. /**
  90030. * Does a raycast in the physics world
  90031. * @param from when should the ray start?
  90032. * @param to when should the ray end?
  90033. * @returns PhysicsRaycastResult
  90034. */
  90035. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90036. /**
  90037. * Called by the scene. No need to call it.
  90038. * @param delta defines the timespam between frames
  90039. */
  90040. _step(delta: number): void;
  90041. }
  90042. }
  90043. declare module BABYLON {
  90044. /**
  90045. * The interface for the physics imposter parameters
  90046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90047. */
  90048. export interface PhysicsImpostorParameters {
  90049. /**
  90050. * The mass of the physics imposter
  90051. */
  90052. mass: number;
  90053. /**
  90054. * The friction of the physics imposter
  90055. */
  90056. friction?: number;
  90057. /**
  90058. * The coefficient of restitution of the physics imposter
  90059. */
  90060. restitution?: number;
  90061. /**
  90062. * The native options of the physics imposter
  90063. */
  90064. nativeOptions?: any;
  90065. /**
  90066. * Specifies if the parent should be ignored
  90067. */
  90068. ignoreParent?: boolean;
  90069. /**
  90070. * Specifies if bi-directional transformations should be disabled
  90071. */
  90072. disableBidirectionalTransformation?: boolean;
  90073. /**
  90074. * The pressure inside the physics imposter, soft object only
  90075. */
  90076. pressure?: number;
  90077. /**
  90078. * The stiffness the physics imposter, soft object only
  90079. */
  90080. stiffness?: number;
  90081. /**
  90082. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90083. */
  90084. velocityIterations?: number;
  90085. /**
  90086. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90087. */
  90088. positionIterations?: number;
  90089. /**
  90090. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90091. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90092. * Add to fix multiple points
  90093. */
  90094. fixedPoints?: number;
  90095. /**
  90096. * The collision margin around a soft object
  90097. */
  90098. margin?: number;
  90099. /**
  90100. * The collision margin around a soft object
  90101. */
  90102. damping?: number;
  90103. /**
  90104. * The path for a rope based on an extrusion
  90105. */
  90106. path?: any;
  90107. /**
  90108. * The shape of an extrusion used for a rope based on an extrusion
  90109. */
  90110. shape?: any;
  90111. }
  90112. /**
  90113. * Interface for a physics-enabled object
  90114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90115. */
  90116. export interface IPhysicsEnabledObject {
  90117. /**
  90118. * The position of the physics-enabled object
  90119. */
  90120. position: Vector3;
  90121. /**
  90122. * The rotation of the physics-enabled object
  90123. */
  90124. rotationQuaternion: Nullable<Quaternion>;
  90125. /**
  90126. * The scale of the physics-enabled object
  90127. */
  90128. scaling: Vector3;
  90129. /**
  90130. * The rotation of the physics-enabled object
  90131. */
  90132. rotation?: Vector3;
  90133. /**
  90134. * The parent of the physics-enabled object
  90135. */
  90136. parent?: any;
  90137. /**
  90138. * The bounding info of the physics-enabled object
  90139. * @returns The bounding info of the physics-enabled object
  90140. */
  90141. getBoundingInfo(): BoundingInfo;
  90142. /**
  90143. * Computes the world matrix
  90144. * @param force Specifies if the world matrix should be computed by force
  90145. * @returns A world matrix
  90146. */
  90147. computeWorldMatrix(force: boolean): Matrix;
  90148. /**
  90149. * Gets the world matrix
  90150. * @returns A world matrix
  90151. */
  90152. getWorldMatrix?(): Matrix;
  90153. /**
  90154. * Gets the child meshes
  90155. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90156. * @returns An array of abstract meshes
  90157. */
  90158. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90159. /**
  90160. * Gets the vertex data
  90161. * @param kind The type of vertex data
  90162. * @returns A nullable array of numbers, or a float32 array
  90163. */
  90164. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90165. /**
  90166. * Gets the indices from the mesh
  90167. * @returns A nullable array of index arrays
  90168. */
  90169. getIndices?(): Nullable<IndicesArray>;
  90170. /**
  90171. * Gets the scene from the mesh
  90172. * @returns the indices array or null
  90173. */
  90174. getScene?(): Scene;
  90175. /**
  90176. * Gets the absolute position from the mesh
  90177. * @returns the absolute position
  90178. */
  90179. getAbsolutePosition(): Vector3;
  90180. /**
  90181. * Gets the absolute pivot point from the mesh
  90182. * @returns the absolute pivot point
  90183. */
  90184. getAbsolutePivotPoint(): Vector3;
  90185. /**
  90186. * Rotates the mesh
  90187. * @param axis The axis of rotation
  90188. * @param amount The amount of rotation
  90189. * @param space The space of the rotation
  90190. * @returns The rotation transform node
  90191. */
  90192. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90193. /**
  90194. * Translates the mesh
  90195. * @param axis The axis of translation
  90196. * @param distance The distance of translation
  90197. * @param space The space of the translation
  90198. * @returns The transform node
  90199. */
  90200. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90201. /**
  90202. * Sets the absolute position of the mesh
  90203. * @param absolutePosition The absolute position of the mesh
  90204. * @returns The transform node
  90205. */
  90206. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90207. /**
  90208. * Gets the class name of the mesh
  90209. * @returns The class name
  90210. */
  90211. getClassName(): string;
  90212. }
  90213. /**
  90214. * Represents a physics imposter
  90215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90216. */
  90217. export class PhysicsImpostor {
  90218. /**
  90219. * The physics-enabled object used as the physics imposter
  90220. */
  90221. object: IPhysicsEnabledObject;
  90222. /**
  90223. * The type of the physics imposter
  90224. */
  90225. type: number;
  90226. private _options;
  90227. private _scene?;
  90228. /**
  90229. * The default object size of the imposter
  90230. */
  90231. static DEFAULT_OBJECT_SIZE: Vector3;
  90232. /**
  90233. * The identity quaternion of the imposter
  90234. */
  90235. static IDENTITY_QUATERNION: Quaternion;
  90236. /** @hidden */
  90237. _pluginData: any;
  90238. private _physicsEngine;
  90239. private _physicsBody;
  90240. private _bodyUpdateRequired;
  90241. private _onBeforePhysicsStepCallbacks;
  90242. private _onAfterPhysicsStepCallbacks;
  90243. /** @hidden */
  90244. _onPhysicsCollideCallbacks: Array<{
  90245. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90246. otherImpostors: Array<PhysicsImpostor>;
  90247. }>;
  90248. private _deltaPosition;
  90249. private _deltaRotation;
  90250. private _deltaRotationConjugated;
  90251. /** @hidden */
  90252. _isFromLine: boolean;
  90253. private _parent;
  90254. private _isDisposed;
  90255. private static _tmpVecs;
  90256. private static _tmpQuat;
  90257. /**
  90258. * Specifies if the physics imposter is disposed
  90259. */
  90260. readonly isDisposed: boolean;
  90261. /**
  90262. * Gets the mass of the physics imposter
  90263. */
  90264. mass: number;
  90265. /**
  90266. * Gets the coefficient of friction
  90267. */
  90268. /**
  90269. * Sets the coefficient of friction
  90270. */
  90271. friction: number;
  90272. /**
  90273. * Gets the coefficient of restitution
  90274. */
  90275. /**
  90276. * Sets the coefficient of restitution
  90277. */
  90278. restitution: number;
  90279. /**
  90280. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90281. */
  90282. /**
  90283. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90284. */
  90285. pressure: number;
  90286. /**
  90287. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90288. */
  90289. /**
  90290. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90291. */
  90292. stiffness: number;
  90293. /**
  90294. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90295. */
  90296. /**
  90297. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90298. */
  90299. velocityIterations: number;
  90300. /**
  90301. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90302. */
  90303. /**
  90304. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90305. */
  90306. positionIterations: number;
  90307. /**
  90308. * The unique id of the physics imposter
  90309. * set by the physics engine when adding this impostor to the array
  90310. */
  90311. uniqueId: number;
  90312. /**
  90313. * @hidden
  90314. */
  90315. soft: boolean;
  90316. /**
  90317. * @hidden
  90318. */
  90319. segments: number;
  90320. private _joints;
  90321. /**
  90322. * Initializes the physics imposter
  90323. * @param object The physics-enabled object used as the physics imposter
  90324. * @param type The type of the physics imposter
  90325. * @param _options The options for the physics imposter
  90326. * @param _scene The Babylon scene
  90327. */
  90328. constructor(
  90329. /**
  90330. * The physics-enabled object used as the physics imposter
  90331. */
  90332. object: IPhysicsEnabledObject,
  90333. /**
  90334. * The type of the physics imposter
  90335. */
  90336. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90337. /**
  90338. * This function will completly initialize this impostor.
  90339. * It will create a new body - but only if this mesh has no parent.
  90340. * If it has, this impostor will not be used other than to define the impostor
  90341. * of the child mesh.
  90342. * @hidden
  90343. */
  90344. _init(): void;
  90345. private _getPhysicsParent;
  90346. /**
  90347. * Should a new body be generated.
  90348. * @returns boolean specifying if body initialization is required
  90349. */
  90350. isBodyInitRequired(): boolean;
  90351. /**
  90352. * Sets the updated scaling
  90353. * @param updated Specifies if the scaling is updated
  90354. */
  90355. setScalingUpdated(): void;
  90356. /**
  90357. * Force a regeneration of this or the parent's impostor's body.
  90358. * Use under cautious - This will remove all joints already implemented.
  90359. */
  90360. forceUpdate(): void;
  90361. /**
  90362. * Gets the body that holds this impostor. Either its own, or its parent.
  90363. */
  90364. /**
  90365. * Set the physics body. Used mainly by the physics engine/plugin
  90366. */
  90367. physicsBody: any;
  90368. /**
  90369. * Get the parent of the physics imposter
  90370. * @returns Physics imposter or null
  90371. */
  90372. /**
  90373. * Sets the parent of the physics imposter
  90374. */
  90375. parent: Nullable<PhysicsImpostor>;
  90376. /**
  90377. * Resets the update flags
  90378. */
  90379. resetUpdateFlags(): void;
  90380. /**
  90381. * Gets the object extend size
  90382. * @returns the object extend size
  90383. */
  90384. getObjectExtendSize(): Vector3;
  90385. /**
  90386. * Gets the object center
  90387. * @returns The object center
  90388. */
  90389. getObjectCenter(): Vector3;
  90390. /**
  90391. * Get a specific parametes from the options parameter
  90392. * @param paramName The object parameter name
  90393. * @returns The object parameter
  90394. */
  90395. getParam(paramName: string): any;
  90396. /**
  90397. * Sets a specific parameter in the options given to the physics plugin
  90398. * @param paramName The parameter name
  90399. * @param value The value of the parameter
  90400. */
  90401. setParam(paramName: string, value: number): void;
  90402. /**
  90403. * Specifically change the body's mass option. Won't recreate the physics body object
  90404. * @param mass The mass of the physics imposter
  90405. */
  90406. setMass(mass: number): void;
  90407. /**
  90408. * Gets the linear velocity
  90409. * @returns linear velocity or null
  90410. */
  90411. getLinearVelocity(): Nullable<Vector3>;
  90412. /**
  90413. * Sets the linear velocity
  90414. * @param velocity linear velocity or null
  90415. */
  90416. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90417. /**
  90418. * Gets the angular velocity
  90419. * @returns angular velocity or null
  90420. */
  90421. getAngularVelocity(): Nullable<Vector3>;
  90422. /**
  90423. * Sets the angular velocity
  90424. * @param velocity The velocity or null
  90425. */
  90426. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90427. /**
  90428. * Execute a function with the physics plugin native code
  90429. * Provide a function the will have two variables - the world object and the physics body object
  90430. * @param func The function to execute with the physics plugin native code
  90431. */
  90432. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90433. /**
  90434. * Register a function that will be executed before the physics world is stepping forward
  90435. * @param func The function to execute before the physics world is stepped forward
  90436. */
  90437. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90438. /**
  90439. * Unregister a function that will be executed before the physics world is stepping forward
  90440. * @param func The function to execute before the physics world is stepped forward
  90441. */
  90442. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90443. /**
  90444. * Register a function that will be executed after the physics step
  90445. * @param func The function to execute after physics step
  90446. */
  90447. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90448. /**
  90449. * Unregisters a function that will be executed after the physics step
  90450. * @param func The function to execute after physics step
  90451. */
  90452. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90453. /**
  90454. * register a function that will be executed when this impostor collides against a different body
  90455. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90456. * @param func Callback that is executed on collision
  90457. */
  90458. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90459. /**
  90460. * Unregisters the physics imposter on contact
  90461. * @param collideAgainst The physics object to collide against
  90462. * @param func Callback to execute on collision
  90463. */
  90464. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90465. private _tmpQuat;
  90466. private _tmpQuat2;
  90467. /**
  90468. * Get the parent rotation
  90469. * @returns The parent rotation
  90470. */
  90471. getParentsRotation(): Quaternion;
  90472. /**
  90473. * this function is executed by the physics engine.
  90474. */
  90475. beforeStep: () => void;
  90476. /**
  90477. * this function is executed by the physics engine
  90478. */
  90479. afterStep: () => void;
  90480. /**
  90481. * Legacy collision detection event support
  90482. */
  90483. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90484. /**
  90485. * event and body object due to cannon's event-based architecture.
  90486. */
  90487. onCollide: (e: {
  90488. body: any;
  90489. }) => void;
  90490. /**
  90491. * Apply a force
  90492. * @param force The force to apply
  90493. * @param contactPoint The contact point for the force
  90494. * @returns The physics imposter
  90495. */
  90496. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90497. /**
  90498. * Apply an impulse
  90499. * @param force The impulse force
  90500. * @param contactPoint The contact point for the impulse force
  90501. * @returns The physics imposter
  90502. */
  90503. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90504. /**
  90505. * A help function to create a joint
  90506. * @param otherImpostor A physics imposter used to create a joint
  90507. * @param jointType The type of joint
  90508. * @param jointData The data for the joint
  90509. * @returns The physics imposter
  90510. */
  90511. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90512. /**
  90513. * Add a joint to this impostor with a different impostor
  90514. * @param otherImpostor A physics imposter used to add a joint
  90515. * @param joint The joint to add
  90516. * @returns The physics imposter
  90517. */
  90518. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90519. /**
  90520. * Add an anchor to a cloth impostor
  90521. * @param otherImpostor rigid impostor to anchor to
  90522. * @param width ratio across width from 0 to 1
  90523. * @param height ratio up height from 0 to 1
  90524. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90525. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90526. * @returns impostor the soft imposter
  90527. */
  90528. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90529. /**
  90530. * Add a hook to a rope impostor
  90531. * @param otherImpostor rigid impostor to anchor to
  90532. * @param length ratio across rope from 0 to 1
  90533. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90534. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90535. * @returns impostor the rope imposter
  90536. */
  90537. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90538. /**
  90539. * Will keep this body still, in a sleep mode.
  90540. * @returns the physics imposter
  90541. */
  90542. sleep(): PhysicsImpostor;
  90543. /**
  90544. * Wake the body up.
  90545. * @returns The physics imposter
  90546. */
  90547. wakeUp(): PhysicsImpostor;
  90548. /**
  90549. * Clones the physics imposter
  90550. * @param newObject The physics imposter clones to this physics-enabled object
  90551. * @returns A nullable physics imposter
  90552. */
  90553. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90554. /**
  90555. * Disposes the physics imposter
  90556. */
  90557. dispose(): void;
  90558. /**
  90559. * Sets the delta position
  90560. * @param position The delta position amount
  90561. */
  90562. setDeltaPosition(position: Vector3): void;
  90563. /**
  90564. * Sets the delta rotation
  90565. * @param rotation The delta rotation amount
  90566. */
  90567. setDeltaRotation(rotation: Quaternion): void;
  90568. /**
  90569. * Gets the box size of the physics imposter and stores the result in the input parameter
  90570. * @param result Stores the box size
  90571. * @returns The physics imposter
  90572. */
  90573. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90574. /**
  90575. * Gets the radius of the physics imposter
  90576. * @returns Radius of the physics imposter
  90577. */
  90578. getRadius(): number;
  90579. /**
  90580. * Sync a bone with this impostor
  90581. * @param bone The bone to sync to the impostor.
  90582. * @param boneMesh The mesh that the bone is influencing.
  90583. * @param jointPivot The pivot of the joint / bone in local space.
  90584. * @param distToJoint Optional distance from the impostor to the joint.
  90585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90586. */
  90587. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90588. /**
  90589. * Sync impostor to a bone
  90590. * @param bone The bone that the impostor will be synced to.
  90591. * @param boneMesh The mesh that the bone is influencing.
  90592. * @param jointPivot The pivot of the joint / bone in local space.
  90593. * @param distToJoint Optional distance from the impostor to the joint.
  90594. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90595. * @param boneAxis Optional vector3 axis the bone is aligned with
  90596. */
  90597. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90598. /**
  90599. * No-Imposter type
  90600. */
  90601. static NoImpostor: number;
  90602. /**
  90603. * Sphere-Imposter type
  90604. */
  90605. static SphereImpostor: number;
  90606. /**
  90607. * Box-Imposter type
  90608. */
  90609. static BoxImpostor: number;
  90610. /**
  90611. * Plane-Imposter type
  90612. */
  90613. static PlaneImpostor: number;
  90614. /**
  90615. * Mesh-imposter type
  90616. */
  90617. static MeshImpostor: number;
  90618. /**
  90619. * Capsule-Impostor type (Ammo.js plugin only)
  90620. */
  90621. static CapsuleImpostor: number;
  90622. /**
  90623. * Cylinder-Imposter type
  90624. */
  90625. static CylinderImpostor: number;
  90626. /**
  90627. * Particle-Imposter type
  90628. */
  90629. static ParticleImpostor: number;
  90630. /**
  90631. * Heightmap-Imposter type
  90632. */
  90633. static HeightmapImpostor: number;
  90634. /**
  90635. * ConvexHull-Impostor type (Ammo.js plugin only)
  90636. */
  90637. static ConvexHullImpostor: number;
  90638. /**
  90639. * Rope-Imposter type
  90640. */
  90641. static RopeImpostor: number;
  90642. /**
  90643. * Cloth-Imposter type
  90644. */
  90645. static ClothImpostor: number;
  90646. /**
  90647. * Softbody-Imposter type
  90648. */
  90649. static SoftbodyImpostor: number;
  90650. }
  90651. }
  90652. declare module BABYLON {
  90653. /**
  90654. * @hidden
  90655. **/
  90656. export class _CreationDataStorage {
  90657. closePath?: boolean;
  90658. closeArray?: boolean;
  90659. idx: number[];
  90660. dashSize: number;
  90661. gapSize: number;
  90662. path3D: Path3D;
  90663. pathArray: Vector3[][];
  90664. arc: number;
  90665. radius: number;
  90666. cap: number;
  90667. tessellation: number;
  90668. }
  90669. /**
  90670. * @hidden
  90671. **/
  90672. class _InstanceDataStorage {
  90673. visibleInstances: any;
  90674. batchCache: _InstancesBatch;
  90675. instancesBufferSize: number;
  90676. instancesBuffer: Nullable<Buffer>;
  90677. instancesData: Float32Array;
  90678. overridenInstanceCount: number;
  90679. isFrozen: boolean;
  90680. previousBatch: Nullable<_InstancesBatch>;
  90681. hardwareInstancedRendering: boolean;
  90682. sideOrientation: number;
  90683. }
  90684. /**
  90685. * @hidden
  90686. **/
  90687. export class _InstancesBatch {
  90688. mustReturn: boolean;
  90689. visibleInstances: Nullable<InstancedMesh[]>[];
  90690. renderSelf: boolean[];
  90691. hardwareInstancedRendering: boolean[];
  90692. }
  90693. /**
  90694. * Class used to represent renderable models
  90695. */
  90696. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90697. /**
  90698. * Mesh side orientation : usually the external or front surface
  90699. */
  90700. static readonly FRONTSIDE: number;
  90701. /**
  90702. * Mesh side orientation : usually the internal or back surface
  90703. */
  90704. static readonly BACKSIDE: number;
  90705. /**
  90706. * Mesh side orientation : both internal and external or front and back surfaces
  90707. */
  90708. static readonly DOUBLESIDE: number;
  90709. /**
  90710. * Mesh side orientation : by default, `FRONTSIDE`
  90711. */
  90712. static readonly DEFAULTSIDE: number;
  90713. /**
  90714. * Mesh cap setting : no cap
  90715. */
  90716. static readonly NO_CAP: number;
  90717. /**
  90718. * Mesh cap setting : one cap at the beginning of the mesh
  90719. */
  90720. static readonly CAP_START: number;
  90721. /**
  90722. * Mesh cap setting : one cap at the end of the mesh
  90723. */
  90724. static readonly CAP_END: number;
  90725. /**
  90726. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90727. */
  90728. static readonly CAP_ALL: number;
  90729. /**
  90730. * Mesh pattern setting : no flip or rotate
  90731. */
  90732. static readonly NO_FLIP: number;
  90733. /**
  90734. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90735. */
  90736. static readonly FLIP_TILE: number;
  90737. /**
  90738. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90739. */
  90740. static readonly ROTATE_TILE: number;
  90741. /**
  90742. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90743. */
  90744. static readonly FLIP_ROW: number;
  90745. /**
  90746. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90747. */
  90748. static readonly ROTATE_ROW: number;
  90749. /**
  90750. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90751. */
  90752. static readonly FLIP_N_ROTATE_TILE: number;
  90753. /**
  90754. * Mesh pattern setting : rotate pattern and rotate
  90755. */
  90756. static readonly FLIP_N_ROTATE_ROW: number;
  90757. /**
  90758. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90759. */
  90760. static readonly CENTER: number;
  90761. /**
  90762. * Mesh tile positioning : part tiles on left
  90763. */
  90764. static readonly LEFT: number;
  90765. /**
  90766. * Mesh tile positioning : part tiles on right
  90767. */
  90768. static readonly RIGHT: number;
  90769. /**
  90770. * Mesh tile positioning : part tiles on top
  90771. */
  90772. static readonly TOP: number;
  90773. /**
  90774. * Mesh tile positioning : part tiles on bottom
  90775. */
  90776. static readonly BOTTOM: number;
  90777. /**
  90778. * Gets the default side orientation.
  90779. * @param orientation the orientation to value to attempt to get
  90780. * @returns the default orientation
  90781. * @hidden
  90782. */
  90783. static _GetDefaultSideOrientation(orientation?: number): number;
  90784. private _internalMeshDataInfo;
  90785. /**
  90786. * An event triggered before rendering the mesh
  90787. */
  90788. readonly onBeforeRenderObservable: Observable<Mesh>;
  90789. /**
  90790. * An event triggered before binding the mesh
  90791. */
  90792. readonly onBeforeBindObservable: Observable<Mesh>;
  90793. /**
  90794. * An event triggered after rendering the mesh
  90795. */
  90796. readonly onAfterRenderObservable: Observable<Mesh>;
  90797. /**
  90798. * An event triggered before drawing the mesh
  90799. */
  90800. readonly onBeforeDrawObservable: Observable<Mesh>;
  90801. private _onBeforeDrawObserver;
  90802. /**
  90803. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90804. */
  90805. onBeforeDraw: () => void;
  90806. readonly hasInstances: boolean;
  90807. /**
  90808. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90809. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90810. */
  90811. delayLoadState: number;
  90812. /**
  90813. * Gets the list of instances created from this mesh
  90814. * it is not supposed to be modified manually.
  90815. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90816. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90817. */
  90818. instances: InstancedMesh[];
  90819. /**
  90820. * Gets the file containing delay loading data for this mesh
  90821. */
  90822. delayLoadingFile: string;
  90823. /** @hidden */
  90824. _binaryInfo: any;
  90825. /**
  90826. * User defined function used to change how LOD level selection is done
  90827. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90828. */
  90829. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90830. /**
  90831. * Gets or sets the morph target manager
  90832. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90833. */
  90834. morphTargetManager: Nullable<MorphTargetManager>;
  90835. /** @hidden */
  90836. _creationDataStorage: Nullable<_CreationDataStorage>;
  90837. /** @hidden */
  90838. _geometry: Nullable<Geometry>;
  90839. /** @hidden */
  90840. _delayInfo: Array<string>;
  90841. /** @hidden */
  90842. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90843. /** @hidden */
  90844. _instanceDataStorage: _InstanceDataStorage;
  90845. private _effectiveMaterial;
  90846. /** @hidden */
  90847. _shouldGenerateFlatShading: boolean;
  90848. /** @hidden */
  90849. _originalBuilderSideOrientation: number;
  90850. /**
  90851. * Use this property to change the original side orientation defined at construction time
  90852. */
  90853. overrideMaterialSideOrientation: Nullable<number>;
  90854. /**
  90855. * Gets the source mesh (the one used to clone this one from)
  90856. */
  90857. readonly source: Nullable<Mesh>;
  90858. /**
  90859. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90860. */
  90861. isUnIndexed: boolean;
  90862. /**
  90863. * @constructor
  90864. * @param name The value used by scene.getMeshByName() to do a lookup.
  90865. * @param scene The scene to add this mesh to.
  90866. * @param parent The parent of this mesh, if it has one
  90867. * @param source An optional Mesh from which geometry is shared, cloned.
  90868. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90869. * When false, achieved by calling a clone(), also passing False.
  90870. * This will make creation of children, recursive.
  90871. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90872. */
  90873. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90874. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90875. /**
  90876. * Gets the class name
  90877. * @returns the string "Mesh".
  90878. */
  90879. getClassName(): string;
  90880. /** @hidden */
  90881. readonly _isMesh: boolean;
  90882. /**
  90883. * Returns a description of this mesh
  90884. * @param fullDetails define if full details about this mesh must be used
  90885. * @returns a descriptive string representing this mesh
  90886. */
  90887. toString(fullDetails?: boolean): string;
  90888. /** @hidden */
  90889. _unBindEffect(): void;
  90890. /**
  90891. * Gets a boolean indicating if this mesh has LOD
  90892. */
  90893. readonly hasLODLevels: boolean;
  90894. /**
  90895. * Gets the list of MeshLODLevel associated with the current mesh
  90896. * @returns an array of MeshLODLevel
  90897. */
  90898. getLODLevels(): MeshLODLevel[];
  90899. private _sortLODLevels;
  90900. /**
  90901. * Add a mesh as LOD level triggered at the given distance.
  90902. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90903. * @param distance The distance from the center of the object to show this level
  90904. * @param mesh The mesh to be added as LOD level (can be null)
  90905. * @return This mesh (for chaining)
  90906. */
  90907. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90908. /**
  90909. * Returns the LOD level mesh at the passed distance or null if not found.
  90910. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90911. * @param distance The distance from the center of the object to show this level
  90912. * @returns a Mesh or `null`
  90913. */
  90914. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90915. /**
  90916. * Remove a mesh from the LOD array
  90917. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90918. * @param mesh defines the mesh to be removed
  90919. * @return This mesh (for chaining)
  90920. */
  90921. removeLODLevel(mesh: Mesh): Mesh;
  90922. /**
  90923. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90924. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90925. * @param camera defines the camera to use to compute distance
  90926. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90927. * @return This mesh (for chaining)
  90928. */
  90929. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90930. /**
  90931. * Gets the mesh internal Geometry object
  90932. */
  90933. readonly geometry: Nullable<Geometry>;
  90934. /**
  90935. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90936. * @returns the total number of vertices
  90937. */
  90938. getTotalVertices(): number;
  90939. /**
  90940. * Returns the content of an associated vertex buffer
  90941. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90942. * - VertexBuffer.PositionKind
  90943. * - VertexBuffer.UVKind
  90944. * - VertexBuffer.UV2Kind
  90945. * - VertexBuffer.UV3Kind
  90946. * - VertexBuffer.UV4Kind
  90947. * - VertexBuffer.UV5Kind
  90948. * - VertexBuffer.UV6Kind
  90949. * - VertexBuffer.ColorKind
  90950. * - VertexBuffer.MatricesIndicesKind
  90951. * - VertexBuffer.MatricesIndicesExtraKind
  90952. * - VertexBuffer.MatricesWeightsKind
  90953. * - VertexBuffer.MatricesWeightsExtraKind
  90954. * @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
  90955. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90956. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90957. */
  90958. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90959. /**
  90960. * Returns the mesh VertexBuffer object from the requested `kind`
  90961. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90962. * - VertexBuffer.PositionKind
  90963. * - VertexBuffer.NormalKind
  90964. * - VertexBuffer.UVKind
  90965. * - VertexBuffer.UV2Kind
  90966. * - VertexBuffer.UV3Kind
  90967. * - VertexBuffer.UV4Kind
  90968. * - VertexBuffer.UV5Kind
  90969. * - VertexBuffer.UV6Kind
  90970. * - VertexBuffer.ColorKind
  90971. * - VertexBuffer.MatricesIndicesKind
  90972. * - VertexBuffer.MatricesIndicesExtraKind
  90973. * - VertexBuffer.MatricesWeightsKind
  90974. * - VertexBuffer.MatricesWeightsExtraKind
  90975. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90976. */
  90977. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90978. /**
  90979. * Tests if a specific vertex buffer is associated with this mesh
  90980. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90981. * - VertexBuffer.PositionKind
  90982. * - VertexBuffer.NormalKind
  90983. * - VertexBuffer.UVKind
  90984. * - VertexBuffer.UV2Kind
  90985. * - VertexBuffer.UV3Kind
  90986. * - VertexBuffer.UV4Kind
  90987. * - VertexBuffer.UV5Kind
  90988. * - VertexBuffer.UV6Kind
  90989. * - VertexBuffer.ColorKind
  90990. * - VertexBuffer.MatricesIndicesKind
  90991. * - VertexBuffer.MatricesIndicesExtraKind
  90992. * - VertexBuffer.MatricesWeightsKind
  90993. * - VertexBuffer.MatricesWeightsExtraKind
  90994. * @returns a boolean
  90995. */
  90996. isVerticesDataPresent(kind: string): boolean;
  90997. /**
  90998. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90999. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91000. * - VertexBuffer.PositionKind
  91001. * - VertexBuffer.UVKind
  91002. * - VertexBuffer.UV2Kind
  91003. * - VertexBuffer.UV3Kind
  91004. * - VertexBuffer.UV4Kind
  91005. * - VertexBuffer.UV5Kind
  91006. * - VertexBuffer.UV6Kind
  91007. * - VertexBuffer.ColorKind
  91008. * - VertexBuffer.MatricesIndicesKind
  91009. * - VertexBuffer.MatricesIndicesExtraKind
  91010. * - VertexBuffer.MatricesWeightsKind
  91011. * - VertexBuffer.MatricesWeightsExtraKind
  91012. * @returns a boolean
  91013. */
  91014. isVertexBufferUpdatable(kind: string): boolean;
  91015. /**
  91016. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91017. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91018. * - VertexBuffer.PositionKind
  91019. * - VertexBuffer.NormalKind
  91020. * - VertexBuffer.UVKind
  91021. * - VertexBuffer.UV2Kind
  91022. * - VertexBuffer.UV3Kind
  91023. * - VertexBuffer.UV4Kind
  91024. * - VertexBuffer.UV5Kind
  91025. * - VertexBuffer.UV6Kind
  91026. * - VertexBuffer.ColorKind
  91027. * - VertexBuffer.MatricesIndicesKind
  91028. * - VertexBuffer.MatricesIndicesExtraKind
  91029. * - VertexBuffer.MatricesWeightsKind
  91030. * - VertexBuffer.MatricesWeightsExtraKind
  91031. * @returns an array of strings
  91032. */
  91033. getVerticesDataKinds(): string[];
  91034. /**
  91035. * Returns a positive integer : the total number of indices in this mesh geometry.
  91036. * @returns the numner of indices or zero if the mesh has no geometry.
  91037. */
  91038. getTotalIndices(): number;
  91039. /**
  91040. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91041. * @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.
  91042. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91043. * @returns the indices array or an empty array if the mesh has no geometry
  91044. */
  91045. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91046. readonly isBlocked: boolean;
  91047. /**
  91048. * Determine if the current mesh is ready to be rendered
  91049. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91050. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91051. * @returns true if all associated assets are ready (material, textures, shaders)
  91052. */
  91053. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91054. /**
  91055. * 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.
  91056. */
  91057. readonly areNormalsFrozen: boolean;
  91058. /**
  91059. * 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.
  91060. * @returns the current mesh
  91061. */
  91062. freezeNormals(): Mesh;
  91063. /**
  91064. * 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
  91065. * @returns the current mesh
  91066. */
  91067. unfreezeNormals(): Mesh;
  91068. /**
  91069. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91070. */
  91071. overridenInstanceCount: number;
  91072. /** @hidden */
  91073. _preActivate(): Mesh;
  91074. /** @hidden */
  91075. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91076. /** @hidden */
  91077. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91078. /**
  91079. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91080. * This means the mesh underlying bounding box and sphere are recomputed.
  91081. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91082. * @returns the current mesh
  91083. */
  91084. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91085. /** @hidden */
  91086. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91087. /**
  91088. * This function will subdivide the mesh into multiple submeshes
  91089. * @param count defines the expected number of submeshes
  91090. */
  91091. subdivide(count: number): void;
  91092. /**
  91093. * Copy a FloatArray into a specific associated vertex buffer
  91094. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91095. * - VertexBuffer.PositionKind
  91096. * - VertexBuffer.UVKind
  91097. * - VertexBuffer.UV2Kind
  91098. * - VertexBuffer.UV3Kind
  91099. * - VertexBuffer.UV4Kind
  91100. * - VertexBuffer.UV5Kind
  91101. * - VertexBuffer.UV6Kind
  91102. * - VertexBuffer.ColorKind
  91103. * - VertexBuffer.MatricesIndicesKind
  91104. * - VertexBuffer.MatricesIndicesExtraKind
  91105. * - VertexBuffer.MatricesWeightsKind
  91106. * - VertexBuffer.MatricesWeightsExtraKind
  91107. * @param data defines the data source
  91108. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91109. * @param stride defines the data stride size (can be null)
  91110. * @returns the current mesh
  91111. */
  91112. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91113. /**
  91114. * Flags an associated vertex buffer as updatable
  91115. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91116. * - VertexBuffer.PositionKind
  91117. * - VertexBuffer.UVKind
  91118. * - VertexBuffer.UV2Kind
  91119. * - VertexBuffer.UV3Kind
  91120. * - VertexBuffer.UV4Kind
  91121. * - VertexBuffer.UV5Kind
  91122. * - VertexBuffer.UV6Kind
  91123. * - VertexBuffer.ColorKind
  91124. * - VertexBuffer.MatricesIndicesKind
  91125. * - VertexBuffer.MatricesIndicesExtraKind
  91126. * - VertexBuffer.MatricesWeightsKind
  91127. * - VertexBuffer.MatricesWeightsExtraKind
  91128. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91129. */
  91130. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91131. /**
  91132. * Sets the mesh global Vertex Buffer
  91133. * @param buffer defines the buffer to use
  91134. * @returns the current mesh
  91135. */
  91136. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91137. /**
  91138. * Update a specific associated vertex buffer
  91139. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91140. * - VertexBuffer.PositionKind
  91141. * - VertexBuffer.UVKind
  91142. * - VertexBuffer.UV2Kind
  91143. * - VertexBuffer.UV3Kind
  91144. * - VertexBuffer.UV4Kind
  91145. * - VertexBuffer.UV5Kind
  91146. * - VertexBuffer.UV6Kind
  91147. * - VertexBuffer.ColorKind
  91148. * - VertexBuffer.MatricesIndicesKind
  91149. * - VertexBuffer.MatricesIndicesExtraKind
  91150. * - VertexBuffer.MatricesWeightsKind
  91151. * - VertexBuffer.MatricesWeightsExtraKind
  91152. * @param data defines the data source
  91153. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91154. * @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)
  91155. * @returns the current mesh
  91156. */
  91157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91158. /**
  91159. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91160. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91161. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91162. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91163. * @returns the current mesh
  91164. */
  91165. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91166. /**
  91167. * Creates a un-shared specific occurence of the geometry for the mesh.
  91168. * @returns the current mesh
  91169. */
  91170. makeGeometryUnique(): Mesh;
  91171. /**
  91172. * Set the index buffer of this mesh
  91173. * @param indices defines the source data
  91174. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91175. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91176. * @returns the current mesh
  91177. */
  91178. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91179. /**
  91180. * Update the current index buffer
  91181. * @param indices defines the source data
  91182. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91183. * @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)
  91184. * @returns the current mesh
  91185. */
  91186. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91187. /**
  91188. * Invert the geometry to move from a right handed system to a left handed one.
  91189. * @returns the current mesh
  91190. */
  91191. toLeftHanded(): Mesh;
  91192. /** @hidden */
  91193. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91194. /** @hidden */
  91195. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91196. /**
  91197. * Registers for this mesh a javascript function called just before the rendering process
  91198. * @param func defines the function to call before rendering this mesh
  91199. * @returns the current mesh
  91200. */
  91201. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91202. /**
  91203. * Disposes a previously registered javascript function called before the rendering
  91204. * @param func defines the function to remove
  91205. * @returns the current mesh
  91206. */
  91207. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91208. /**
  91209. * Registers for this mesh a javascript function called just after the rendering is complete
  91210. * @param func defines the function to call after rendering this mesh
  91211. * @returns the current mesh
  91212. */
  91213. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91214. /**
  91215. * Disposes a previously registered javascript function called after the rendering.
  91216. * @param func defines the function to remove
  91217. * @returns the current mesh
  91218. */
  91219. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91220. /** @hidden */
  91221. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91222. /** @hidden */
  91223. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91224. /** @hidden */
  91225. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91226. /** @hidden */
  91227. _rebuild(): void;
  91228. /** @hidden */
  91229. _freeze(): void;
  91230. /** @hidden */
  91231. _unFreeze(): void;
  91232. /**
  91233. * 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
  91234. * @param subMesh defines the subMesh to render
  91235. * @param enableAlphaMode defines if alpha mode can be changed
  91236. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91237. * @returns the current mesh
  91238. */
  91239. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91240. private _onBeforeDraw;
  91241. /**
  91242. * Renormalize the mesh and patch it up if there are no weights
  91243. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91244. * However in the case of zero weights then we set just a single influence to 1.
  91245. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91246. */
  91247. cleanMatrixWeights(): void;
  91248. private normalizeSkinFourWeights;
  91249. private normalizeSkinWeightsAndExtra;
  91250. /**
  91251. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91252. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91253. * the user know there was an issue with importing the mesh
  91254. * @returns a validation object with skinned, valid and report string
  91255. */
  91256. validateSkinning(): {
  91257. skinned: boolean;
  91258. valid: boolean;
  91259. report: string;
  91260. };
  91261. /** @hidden */
  91262. _checkDelayState(): Mesh;
  91263. private _queueLoad;
  91264. /**
  91265. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91266. * A mesh is in the frustum if its bounding box intersects the frustum
  91267. * @param frustumPlanes defines the frustum to test
  91268. * @returns true if the mesh is in the frustum planes
  91269. */
  91270. isInFrustum(frustumPlanes: Plane[]): boolean;
  91271. /**
  91272. * Sets the mesh material by the material or multiMaterial `id` property
  91273. * @param id is a string identifying the material or the multiMaterial
  91274. * @returns the current mesh
  91275. */
  91276. setMaterialByID(id: string): Mesh;
  91277. /**
  91278. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91279. * @returns an array of IAnimatable
  91280. */
  91281. getAnimatables(): IAnimatable[];
  91282. /**
  91283. * Modifies the mesh geometry according to the passed transformation matrix.
  91284. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91285. * The mesh normals are modified using the same transformation.
  91286. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91287. * @param transform defines the transform matrix to use
  91288. * @see http://doc.babylonjs.com/resources/baking_transformations
  91289. * @returns the current mesh
  91290. */
  91291. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91292. /**
  91293. * Modifies the mesh geometry according to its own current World Matrix.
  91294. * The mesh World Matrix is then reset.
  91295. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91296. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91297. * @see http://doc.babylonjs.com/resources/baking_transformations
  91298. * @returns the current mesh
  91299. */
  91300. bakeCurrentTransformIntoVertices(): Mesh;
  91301. /** @hidden */
  91302. readonly _positions: Nullable<Vector3[]>;
  91303. /** @hidden */
  91304. _resetPointsArrayCache(): Mesh;
  91305. /** @hidden */
  91306. _generatePointsArray(): boolean;
  91307. /**
  91308. * Returns a new Mesh object generated from the current mesh properties.
  91309. * This method must not get confused with createInstance()
  91310. * @param name is a string, the name given to the new mesh
  91311. * @param newParent can be any Node object (default `null`)
  91312. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91313. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91314. * @returns a new mesh
  91315. */
  91316. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91317. /**
  91318. * Releases resources associated with this mesh.
  91319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91321. */
  91322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91323. /**
  91324. * Modifies the mesh geometry according to a displacement map.
  91325. * 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.
  91326. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91327. * @param url is a string, the URL from the image file is to be downloaded.
  91328. * @param minHeight is the lower limit of the displacement.
  91329. * @param maxHeight is the upper limit of the displacement.
  91330. * @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.
  91331. * @param uvOffset is an optional vector2 used to offset UV.
  91332. * @param uvScale is an optional vector2 used to scale UV.
  91333. * @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.
  91334. * @returns the Mesh.
  91335. */
  91336. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91337. /**
  91338. * Modifies the mesh geometry according to a displacementMap buffer.
  91339. * 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.
  91340. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91341. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91342. * @param heightMapWidth is the width of the buffer image.
  91343. * @param heightMapHeight is the height of the buffer image.
  91344. * @param minHeight is the lower limit of the displacement.
  91345. * @param maxHeight is the upper limit of the displacement.
  91346. * @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.
  91347. * @param uvOffset is an optional vector2 used to offset UV.
  91348. * @param uvScale is an optional vector2 used to scale UV.
  91349. * @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.
  91350. * @returns the Mesh.
  91351. */
  91352. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91353. /**
  91354. * Modify the mesh to get a flat shading rendering.
  91355. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91356. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91357. * @returns current mesh
  91358. */
  91359. convertToFlatShadedMesh(): Mesh;
  91360. /**
  91361. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91362. * In other words, more vertices, no more indices and a single bigger VBO.
  91363. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91364. * @returns current mesh
  91365. */
  91366. convertToUnIndexedMesh(): Mesh;
  91367. /**
  91368. * Inverses facet orientations.
  91369. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91370. * @param flipNormals will also inverts the normals
  91371. * @returns current mesh
  91372. */
  91373. flipFaces(flipNormals?: boolean): Mesh;
  91374. /**
  91375. * Increase the number of facets and hence vertices in a mesh
  91376. * Vertex normals are interpolated from existing vertex normals
  91377. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91378. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91379. */
  91380. increaseVertices(numberPerEdge: number): void;
  91381. /**
  91382. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91383. * This will undo any application of covertToFlatShadedMesh
  91384. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91385. */
  91386. forceSharedVertices(): void;
  91387. /** @hidden */
  91388. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91389. /** @hidden */
  91390. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91391. /**
  91392. * Creates a new InstancedMesh object from the mesh model.
  91393. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91394. * @param name defines the name of the new instance
  91395. * @returns a new InstancedMesh
  91396. */
  91397. createInstance(name: string): InstancedMesh;
  91398. /**
  91399. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91400. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91401. * @returns the current mesh
  91402. */
  91403. synchronizeInstances(): Mesh;
  91404. /**
  91405. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91406. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91407. * This should be used together with the simplification to avoid disappearing triangles.
  91408. * @param successCallback an optional success callback to be called after the optimization finished.
  91409. * @returns the current mesh
  91410. */
  91411. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91412. /**
  91413. * Serialize current mesh
  91414. * @param serializationObject defines the object which will receive the serialization data
  91415. */
  91416. serialize(serializationObject: any): void;
  91417. /** @hidden */
  91418. _syncGeometryWithMorphTargetManager(): void;
  91419. /** @hidden */
  91420. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91421. /**
  91422. * Returns a new Mesh object parsed from the source provided.
  91423. * @param parsedMesh is the source
  91424. * @param scene defines the hosting scene
  91425. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91426. * @returns a new Mesh
  91427. */
  91428. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91429. /**
  91430. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91431. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91432. * @param name defines the name of the mesh to create
  91433. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91434. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91435. * @param closePath creates a seam between the first and the last points of each path of the path array
  91436. * @param offset is taken in account only if the `pathArray` is containing a single path
  91437. * @param scene defines the hosting scene
  91438. * @param updatable defines if the mesh must be flagged as updatable
  91439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91440. * @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)
  91441. * @returns a new Mesh
  91442. */
  91443. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91444. /**
  91445. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91446. * @param name defines the name of the mesh to create
  91447. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91448. * @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
  91449. * @param scene defines the hosting scene
  91450. * @param updatable defines if the mesh must be flagged as updatable
  91451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91452. * @returns a new Mesh
  91453. */
  91454. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91455. /**
  91456. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91457. * @param name defines the name of the mesh to create
  91458. * @param size sets the size (float) of each box side (default 1)
  91459. * @param scene defines the hosting scene
  91460. * @param updatable defines if the mesh must be flagged as updatable
  91461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91462. * @returns a new Mesh
  91463. */
  91464. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91465. /**
  91466. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91467. * @param name defines the name of the mesh to create
  91468. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91469. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91470. * @param scene defines the hosting scene
  91471. * @param updatable defines if the mesh must be flagged as updatable
  91472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91473. * @returns a new Mesh
  91474. */
  91475. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91476. /**
  91477. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91478. * @param name defines the name of the mesh to create
  91479. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91480. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91481. * @param scene defines the hosting scene
  91482. * @returns a new Mesh
  91483. */
  91484. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91485. /**
  91486. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91487. * @param name defines the name of the mesh to create
  91488. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91489. * @param diameterTop set the top cap diameter (floats, default 1)
  91490. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91491. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91492. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91493. * @param scene defines the hosting scene
  91494. * @param updatable defines if the mesh must be flagged as updatable
  91495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91496. * @returns a new Mesh
  91497. */
  91498. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91499. /**
  91500. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91501. * @param name defines the name of the mesh to create
  91502. * @param diameter sets the diameter size (float) of the torus (default 1)
  91503. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91504. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91505. * @param scene defines the hosting scene
  91506. * @param updatable defines if the mesh must be flagged as updatable
  91507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91508. * @returns a new Mesh
  91509. */
  91510. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91511. /**
  91512. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91513. * @param name defines the name of the mesh to create
  91514. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91515. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91516. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91517. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91518. * @param p the number of windings on X axis (positive integers, default 2)
  91519. * @param q the number of windings on Y axis (positive integers, default 3)
  91520. * @param scene defines the hosting scene
  91521. * @param updatable defines if the mesh must be flagged as updatable
  91522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91523. * @returns a new Mesh
  91524. */
  91525. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91526. /**
  91527. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91528. * @param name defines the name of the mesh to create
  91529. * @param points is an array successive Vector3
  91530. * @param scene defines the hosting scene
  91531. * @param updatable defines if the mesh must be flagged as updatable
  91532. * @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).
  91533. * @returns a new Mesh
  91534. */
  91535. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91536. /**
  91537. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91538. * @param name defines the name of the mesh to create
  91539. * @param points is an array successive Vector3
  91540. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91541. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91542. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91543. * @param scene defines the hosting scene
  91544. * @param updatable defines if the mesh must be flagged as updatable
  91545. * @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)
  91546. * @returns a new Mesh
  91547. */
  91548. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91549. /**
  91550. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91551. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91552. * 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.
  91553. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91554. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91555. * Remember you can only change the shape positions, not their number when updating a polygon.
  91556. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91557. * @param name defines the name of the mesh to create
  91558. * @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
  91559. * @param scene defines the hosting scene
  91560. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91561. * @param updatable defines if the mesh must be flagged as updatable
  91562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91563. * @param earcutInjection can be used to inject your own earcut reference
  91564. * @returns a new Mesh
  91565. */
  91566. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91567. /**
  91568. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91569. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91570. * @param name defines the name of the mesh to create
  91571. * @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
  91572. * @param depth defines the height of extrusion
  91573. * @param scene defines the hosting scene
  91574. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91575. * @param updatable defines if the mesh must be flagged as updatable
  91576. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91577. * @param earcutInjection can be used to inject your own earcut reference
  91578. * @returns a new Mesh
  91579. */
  91580. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91581. /**
  91582. * Creates an extruded shape mesh.
  91583. * 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
  91584. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91585. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91586. * @param name defines the name of the mesh to create
  91587. * @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
  91588. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91589. * @param scale is the value to scale the shape
  91590. * @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
  91591. * @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
  91592. * @param scene defines the hosting scene
  91593. * @param updatable defines if the mesh must be flagged as updatable
  91594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91595. * @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)
  91596. * @returns a new Mesh
  91597. */
  91598. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91599. /**
  91600. * Creates an custom extruded shape mesh.
  91601. * The custom extrusion is a parametric shape.
  91602. * It has no predefined shape. Its final shape will depend on the input parameters.
  91603. * Please consider using the same method from the MeshBuilder class instead
  91604. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91605. * @param name defines the name of the mesh to create
  91606. * @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
  91607. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91608. * @param scaleFunction is a custom Javascript function called on each path point
  91609. * @param rotationFunction is a custom Javascript function called on each path point
  91610. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91611. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91612. * @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
  91613. * @param scene defines the hosting scene
  91614. * @param updatable defines if the mesh must be flagged as updatable
  91615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91616. * @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)
  91617. * @returns a new Mesh
  91618. */
  91619. 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;
  91620. /**
  91621. * Creates lathe mesh.
  91622. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91623. * Please consider using the same method from the MeshBuilder class instead
  91624. * @param name defines the name of the mesh to create
  91625. * @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
  91626. * @param radius is the radius value of the lathe
  91627. * @param tessellation is the side number of the lathe.
  91628. * @param scene defines the hosting scene
  91629. * @param updatable defines if the mesh must be flagged as updatable
  91630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91631. * @returns a new Mesh
  91632. */
  91633. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91634. /**
  91635. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91636. * @param name defines the name of the mesh to create
  91637. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91638. * @param scene defines the hosting scene
  91639. * @param updatable defines if the mesh must be flagged as updatable
  91640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91641. * @returns a new Mesh
  91642. */
  91643. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91644. /**
  91645. * Creates a ground mesh.
  91646. * Please consider using the same method from the MeshBuilder class instead
  91647. * @param name defines the name of the mesh to create
  91648. * @param width set the width of the ground
  91649. * @param height set the height of the ground
  91650. * @param subdivisions sets the number of subdivisions per side
  91651. * @param scene defines the hosting scene
  91652. * @param updatable defines if the mesh must be flagged as updatable
  91653. * @returns a new Mesh
  91654. */
  91655. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91656. /**
  91657. * Creates a tiled ground mesh.
  91658. * Please consider using the same method from the MeshBuilder class instead
  91659. * @param name defines the name of the mesh to create
  91660. * @param xmin set the ground minimum X coordinate
  91661. * @param zmin set the ground minimum Y coordinate
  91662. * @param xmax set the ground maximum X coordinate
  91663. * @param zmax set the ground maximum Z coordinate
  91664. * @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
  91665. * @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
  91666. * @param scene defines the hosting scene
  91667. * @param updatable defines if the mesh must be flagged as updatable
  91668. * @returns a new Mesh
  91669. */
  91670. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91671. w: number;
  91672. h: number;
  91673. }, precision: {
  91674. w: number;
  91675. h: number;
  91676. }, scene: Scene, updatable?: boolean): Mesh;
  91677. /**
  91678. * Creates a ground mesh from a height map.
  91679. * Please consider using the same method from the MeshBuilder class instead
  91680. * @see http://doc.babylonjs.com/babylon101/height_map
  91681. * @param name defines the name of the mesh to create
  91682. * @param url sets the URL of the height map image resource
  91683. * @param width set the ground width size
  91684. * @param height set the ground height size
  91685. * @param subdivisions sets the number of subdivision per side
  91686. * @param minHeight is the minimum altitude on the ground
  91687. * @param maxHeight is the maximum altitude on the ground
  91688. * @param scene defines the hosting scene
  91689. * @param updatable defines if the mesh must be flagged as updatable
  91690. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91691. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91692. * @returns a new Mesh
  91693. */
  91694. 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;
  91695. /**
  91696. * Creates a tube mesh.
  91697. * The tube is a parametric shape.
  91698. * It has no predefined shape. Its final shape will depend on the input parameters.
  91699. * Please consider using the same method from the MeshBuilder class instead
  91700. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91701. * @param name defines the name of the mesh to create
  91702. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91703. * @param radius sets the tube radius size
  91704. * @param tessellation is the number of sides on the tubular surface
  91705. * @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
  91706. * @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
  91707. * @param scene defines the hosting scene
  91708. * @param updatable defines if the mesh must be flagged as updatable
  91709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91710. * @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)
  91711. * @returns a new Mesh
  91712. */
  91713. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91714. (i: number, distance: number): number;
  91715. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91716. /**
  91717. * Creates a polyhedron mesh.
  91718. * Please consider using the same method from the MeshBuilder class instead.
  91719. * * 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
  91720. * * The parameter `size` (positive float, default 1) sets the polygon size
  91721. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91722. * * 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`
  91723. * * 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
  91724. * * 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)`)
  91725. * * 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
  91726. * * 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
  91727. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91728. * * If you create a double-sided mesh, you can choose what parts of 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
  91729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91730. * @param name defines the name of the mesh to create
  91731. * @param options defines the options used to create the mesh
  91732. * @param scene defines the hosting scene
  91733. * @returns a new Mesh
  91734. */
  91735. static CreatePolyhedron(name: string, options: {
  91736. type?: number;
  91737. size?: number;
  91738. sizeX?: number;
  91739. sizeY?: number;
  91740. sizeZ?: number;
  91741. custom?: any;
  91742. faceUV?: Vector4[];
  91743. faceColors?: Color4[];
  91744. updatable?: boolean;
  91745. sideOrientation?: number;
  91746. }, scene: Scene): Mesh;
  91747. /**
  91748. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91749. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91750. * * 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`)
  91751. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91752. * * 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
  91753. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91754. * * If you create a double-sided mesh, you can choose what parts of 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
  91755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91756. * @param name defines the name of the mesh
  91757. * @param options defines the options used to create the mesh
  91758. * @param scene defines the hosting scene
  91759. * @returns a new Mesh
  91760. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91761. */
  91762. static CreateIcoSphere(name: string, options: {
  91763. radius?: number;
  91764. flat?: boolean;
  91765. subdivisions?: number;
  91766. sideOrientation?: number;
  91767. updatable?: boolean;
  91768. }, scene: Scene): Mesh;
  91769. /**
  91770. * Creates a decal mesh.
  91771. * Please consider using the same method from the MeshBuilder class instead.
  91772. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91773. * @param name defines the name of the mesh
  91774. * @param sourceMesh defines the mesh receiving the decal
  91775. * @param position sets the position of the decal in world coordinates
  91776. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91777. * @param size sets the decal scaling
  91778. * @param angle sets the angle to rotate the decal
  91779. * @returns a new Mesh
  91780. */
  91781. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91782. /**
  91783. * Prepare internal position array for software CPU skinning
  91784. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91785. */
  91786. setPositionsForCPUSkinning(): Float32Array;
  91787. /**
  91788. * Prepare internal normal array for software CPU skinning
  91789. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91790. */
  91791. setNormalsForCPUSkinning(): Float32Array;
  91792. /**
  91793. * Updates the vertex buffer by applying transformation from the bones
  91794. * @param skeleton defines the skeleton to apply to current mesh
  91795. * @returns the current mesh
  91796. */
  91797. applySkeleton(skeleton: Skeleton): Mesh;
  91798. /**
  91799. * 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
  91800. * @param meshes defines the list of meshes to scan
  91801. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91802. */
  91803. static MinMax(meshes: AbstractMesh[]): {
  91804. min: Vector3;
  91805. max: Vector3;
  91806. };
  91807. /**
  91808. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91809. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91810. * @returns a vector3
  91811. */
  91812. static Center(meshesOrMinMaxVector: {
  91813. min: Vector3;
  91814. max: Vector3;
  91815. } | AbstractMesh[]): Vector3;
  91816. /**
  91817. * Merge the array of meshes into a single mesh for performance reasons.
  91818. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91819. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91820. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91821. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91822. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91823. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91824. * @returns a new mesh
  91825. */
  91826. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91827. /** @hidden */
  91828. addInstance(instance: InstancedMesh): void;
  91829. /** @hidden */
  91830. removeInstance(instance: InstancedMesh): void;
  91831. }
  91832. }
  91833. declare module BABYLON {
  91834. /**
  91835. * This is the base class of all the camera used in the application.
  91836. * @see http://doc.babylonjs.com/features/cameras
  91837. */
  91838. export class Camera extends Node {
  91839. /** @hidden */
  91840. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91841. /**
  91842. * This is the default projection mode used by the cameras.
  91843. * It helps recreating a feeling of perspective and better appreciate depth.
  91844. * This is the best way to simulate real life cameras.
  91845. */
  91846. static readonly PERSPECTIVE_CAMERA: number;
  91847. /**
  91848. * This helps creating camera with an orthographic mode.
  91849. * 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.
  91850. */
  91851. static readonly ORTHOGRAPHIC_CAMERA: number;
  91852. /**
  91853. * This is the default FOV mode for perspective cameras.
  91854. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91855. */
  91856. static readonly FOVMODE_VERTICAL_FIXED: number;
  91857. /**
  91858. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91859. */
  91860. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91861. /**
  91862. * This specifies ther is no need for a camera rig.
  91863. * Basically only one eye is rendered corresponding to the camera.
  91864. */
  91865. static readonly RIG_MODE_NONE: number;
  91866. /**
  91867. * Simulates a camera Rig with one blue eye and one red eye.
  91868. * This can be use with 3d blue and red glasses.
  91869. */
  91870. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91871. /**
  91872. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91873. */
  91874. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91875. /**
  91876. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91877. */
  91878. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91879. /**
  91880. * Defines that both eyes of the camera will be rendered over under each other.
  91881. */
  91882. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91883. /**
  91884. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91885. */
  91886. static readonly RIG_MODE_VR: number;
  91887. /**
  91888. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91889. */
  91890. static readonly RIG_MODE_WEBVR: number;
  91891. /**
  91892. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91893. */
  91894. static readonly RIG_MODE_CUSTOM: number;
  91895. /**
  91896. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91897. */
  91898. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91899. /**
  91900. * Define the input manager associated with the camera.
  91901. */
  91902. inputs: CameraInputsManager<Camera>;
  91903. /** @hidden */
  91904. _position: Vector3;
  91905. /**
  91906. * Define the current local position of the camera in the scene
  91907. */
  91908. position: Vector3;
  91909. /**
  91910. * The vector the camera should consider as up.
  91911. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91912. */
  91913. upVector: Vector3;
  91914. /**
  91915. * Define the current limit on the left side for an orthographic camera
  91916. * In scene unit
  91917. */
  91918. orthoLeft: Nullable<number>;
  91919. /**
  91920. * Define the current limit on the right side for an orthographic camera
  91921. * In scene unit
  91922. */
  91923. orthoRight: Nullable<number>;
  91924. /**
  91925. * Define the current limit on the bottom side for an orthographic camera
  91926. * In scene unit
  91927. */
  91928. orthoBottom: Nullable<number>;
  91929. /**
  91930. * Define the current limit on the top side for an orthographic camera
  91931. * In scene unit
  91932. */
  91933. orthoTop: Nullable<number>;
  91934. /**
  91935. * Field Of View is set in Radians. (default is 0.8)
  91936. */
  91937. fov: number;
  91938. /**
  91939. * Define the minimum distance the camera can see from.
  91940. * This is important to note that the depth buffer are not infinite and the closer it starts
  91941. * the more your scene might encounter depth fighting issue.
  91942. */
  91943. minZ: number;
  91944. /**
  91945. * Define the maximum distance the camera can see to.
  91946. * This is important to note that the depth buffer are not infinite and the further it end
  91947. * the more your scene might encounter depth fighting issue.
  91948. */
  91949. maxZ: number;
  91950. /**
  91951. * Define the default inertia of the camera.
  91952. * This helps giving a smooth feeling to the camera movement.
  91953. */
  91954. inertia: number;
  91955. /**
  91956. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91957. */
  91958. mode: number;
  91959. /**
  91960. * Define wether the camera is intermediate.
  91961. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91962. */
  91963. isIntermediate: boolean;
  91964. /**
  91965. * Define the viewport of the camera.
  91966. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91967. */
  91968. viewport: Viewport;
  91969. /**
  91970. * Restricts the camera to viewing objects with the same layerMask.
  91971. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91972. */
  91973. layerMask: number;
  91974. /**
  91975. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91976. */
  91977. fovMode: number;
  91978. /**
  91979. * Rig mode of the camera.
  91980. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91981. * This is normally controlled byt the camera themselves as internal use.
  91982. */
  91983. cameraRigMode: number;
  91984. /**
  91985. * Defines the distance between both "eyes" in case of a RIG
  91986. */
  91987. interaxialDistance: number;
  91988. /**
  91989. * Defines if stereoscopic rendering is done side by side or over under.
  91990. */
  91991. isStereoscopicSideBySide: boolean;
  91992. /**
  91993. * 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
  91994. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91995. * else in the scene. (Eg. security camera)
  91996. *
  91997. * 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)
  91998. */
  91999. customRenderTargets: RenderTargetTexture[];
  92000. /**
  92001. * When set, the camera will render to this render target instead of the default canvas
  92002. *
  92003. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92004. */
  92005. outputRenderTarget: Nullable<RenderTargetTexture>;
  92006. /**
  92007. * Observable triggered when the camera view matrix has changed.
  92008. */
  92009. onViewMatrixChangedObservable: Observable<Camera>;
  92010. /**
  92011. * Observable triggered when the camera Projection matrix has changed.
  92012. */
  92013. onProjectionMatrixChangedObservable: Observable<Camera>;
  92014. /**
  92015. * Observable triggered when the inputs have been processed.
  92016. */
  92017. onAfterCheckInputsObservable: Observable<Camera>;
  92018. /**
  92019. * Observable triggered when reset has been called and applied to the camera.
  92020. */
  92021. onRestoreStateObservable: Observable<Camera>;
  92022. /** @hidden */
  92023. _cameraRigParams: any;
  92024. /** @hidden */
  92025. _rigCameras: Camera[];
  92026. /** @hidden */
  92027. _rigPostProcess: Nullable<PostProcess>;
  92028. protected _webvrViewMatrix: Matrix;
  92029. /** @hidden */
  92030. _skipRendering: boolean;
  92031. /** @hidden */
  92032. _projectionMatrix: Matrix;
  92033. /** @hidden */
  92034. _postProcesses: Nullable<PostProcess>[];
  92035. /** @hidden */
  92036. _activeMeshes: SmartArray<AbstractMesh>;
  92037. protected _globalPosition: Vector3;
  92038. /** @hidden */
  92039. _computedViewMatrix: Matrix;
  92040. private _doNotComputeProjectionMatrix;
  92041. private _transformMatrix;
  92042. private _frustumPlanes;
  92043. private _refreshFrustumPlanes;
  92044. private _storedFov;
  92045. private _stateStored;
  92046. /**
  92047. * Instantiates a new camera object.
  92048. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92049. * @see http://doc.babylonjs.com/features/cameras
  92050. * @param name Defines the name of the camera in the scene
  92051. * @param position Defines the position of the camera
  92052. * @param scene Defines the scene the camera belongs too
  92053. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92054. */
  92055. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92056. /**
  92057. * Store current camera state (fov, position, etc..)
  92058. * @returns the camera
  92059. */
  92060. storeState(): Camera;
  92061. /**
  92062. * Restores the camera state values if it has been stored. You must call storeState() first
  92063. */
  92064. protected _restoreStateValues(): boolean;
  92065. /**
  92066. * Restored camera state. You must call storeState() first.
  92067. * @returns true if restored and false otherwise
  92068. */
  92069. restoreState(): boolean;
  92070. /**
  92071. * Gets the class name of the camera.
  92072. * @returns the class name
  92073. */
  92074. getClassName(): string;
  92075. /** @hidden */
  92076. readonly _isCamera: boolean;
  92077. /**
  92078. * Gets a string representation of the camera useful for debug purpose.
  92079. * @param fullDetails Defines that a more verboe level of logging is required
  92080. * @returns the string representation
  92081. */
  92082. toString(fullDetails?: boolean): string;
  92083. /**
  92084. * Gets the current world space position of the camera.
  92085. */
  92086. readonly globalPosition: Vector3;
  92087. /**
  92088. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92089. * @returns the active meshe list
  92090. */
  92091. getActiveMeshes(): SmartArray<AbstractMesh>;
  92092. /**
  92093. * Check wether a mesh is part of the current active mesh list of the camera
  92094. * @param mesh Defines the mesh to check
  92095. * @returns true if active, false otherwise
  92096. */
  92097. isActiveMesh(mesh: Mesh): boolean;
  92098. /**
  92099. * Is this camera ready to be used/rendered
  92100. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92101. * @return true if the camera is ready
  92102. */
  92103. isReady(completeCheck?: boolean): boolean;
  92104. /** @hidden */
  92105. _initCache(): void;
  92106. /** @hidden */
  92107. _updateCache(ignoreParentClass?: boolean): void;
  92108. /** @hidden */
  92109. _isSynchronized(): boolean;
  92110. /** @hidden */
  92111. _isSynchronizedViewMatrix(): boolean;
  92112. /** @hidden */
  92113. _isSynchronizedProjectionMatrix(): boolean;
  92114. /**
  92115. * Attach the input controls to a specific dom element to get the input from.
  92116. * @param element Defines the element the controls should be listened from
  92117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92118. */
  92119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92120. /**
  92121. * Detach the current controls from the specified dom element.
  92122. * @param element Defines the element to stop listening the inputs from
  92123. */
  92124. detachControl(element: HTMLElement): void;
  92125. /**
  92126. * Update the camera state according to the different inputs gathered during the frame.
  92127. */
  92128. update(): void;
  92129. /** @hidden */
  92130. _checkInputs(): void;
  92131. /** @hidden */
  92132. readonly rigCameras: Camera[];
  92133. /**
  92134. * Gets the post process used by the rig cameras
  92135. */
  92136. readonly rigPostProcess: Nullable<PostProcess>;
  92137. /**
  92138. * Internal, gets the first post proces.
  92139. * @returns the first post process to be run on this camera.
  92140. */
  92141. _getFirstPostProcess(): Nullable<PostProcess>;
  92142. private _cascadePostProcessesToRigCams;
  92143. /**
  92144. * Attach a post process to the camera.
  92145. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92146. * @param postProcess The post process to attach to the camera
  92147. * @param insertAt The position of the post process in case several of them are in use in the scene
  92148. * @returns the position the post process has been inserted at
  92149. */
  92150. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92151. /**
  92152. * Detach a post process to the camera.
  92153. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92154. * @param postProcess The post process to detach from the camera
  92155. */
  92156. detachPostProcess(postProcess: PostProcess): void;
  92157. /**
  92158. * Gets the current world matrix of the camera
  92159. */
  92160. getWorldMatrix(): Matrix;
  92161. /** @hidden */
  92162. _getViewMatrix(): Matrix;
  92163. /**
  92164. * Gets the current view matrix of the camera.
  92165. * @param force forces the camera to recompute the matrix without looking at the cached state
  92166. * @returns the view matrix
  92167. */
  92168. getViewMatrix(force?: boolean): Matrix;
  92169. /**
  92170. * Freeze the projection matrix.
  92171. * It will prevent the cache check of the camera projection compute and can speed up perf
  92172. * if no parameter of the camera are meant to change
  92173. * @param projection Defines manually a projection if necessary
  92174. */
  92175. freezeProjectionMatrix(projection?: Matrix): void;
  92176. /**
  92177. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92178. */
  92179. unfreezeProjectionMatrix(): void;
  92180. /**
  92181. * Gets the current projection matrix of the camera.
  92182. * @param force forces the camera to recompute the matrix without looking at the cached state
  92183. * @returns the projection matrix
  92184. */
  92185. getProjectionMatrix(force?: boolean): Matrix;
  92186. /**
  92187. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92188. * @returns a Matrix
  92189. */
  92190. getTransformationMatrix(): Matrix;
  92191. private _updateFrustumPlanes;
  92192. /**
  92193. * Checks if a cullable object (mesh...) is in the camera frustum
  92194. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92195. * @param target The object to check
  92196. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92197. * @returns true if the object is in frustum otherwise false
  92198. */
  92199. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92200. /**
  92201. * Checks if a cullable object (mesh...) is in the camera frustum
  92202. * Unlike isInFrustum this cheks the full bounding box
  92203. * @param target The object to check
  92204. * @returns true if the object is in frustum otherwise false
  92205. */
  92206. isCompletelyInFrustum(target: ICullable): boolean;
  92207. /**
  92208. * Gets a ray in the forward direction from the camera.
  92209. * @param length Defines the length of the ray to create
  92210. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92211. * @param origin Defines the start point of the ray which defaults to the camera position
  92212. * @returns the forward ray
  92213. */
  92214. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92215. /**
  92216. * Releases resources associated with this node.
  92217. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92218. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92219. */
  92220. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92221. /** @hidden */
  92222. _isLeftCamera: boolean;
  92223. /**
  92224. * Gets the left camera of a rig setup in case of Rigged Camera
  92225. */
  92226. readonly isLeftCamera: boolean;
  92227. /** @hidden */
  92228. _isRightCamera: boolean;
  92229. /**
  92230. * Gets the right camera of a rig setup in case of Rigged Camera
  92231. */
  92232. readonly isRightCamera: boolean;
  92233. /**
  92234. * Gets the left camera of a rig setup in case of Rigged Camera
  92235. */
  92236. readonly leftCamera: Nullable<FreeCamera>;
  92237. /**
  92238. * Gets the right camera of a rig setup in case of Rigged Camera
  92239. */
  92240. readonly rightCamera: Nullable<FreeCamera>;
  92241. /**
  92242. * Gets the left camera target of a rig setup in case of Rigged Camera
  92243. * @returns the target position
  92244. */
  92245. getLeftTarget(): Nullable<Vector3>;
  92246. /**
  92247. * Gets the right camera target of a rig setup in case of Rigged Camera
  92248. * @returns the target position
  92249. */
  92250. getRightTarget(): Nullable<Vector3>;
  92251. /**
  92252. * @hidden
  92253. */
  92254. setCameraRigMode(mode: number, rigParams: any): void;
  92255. /** @hidden */
  92256. static _setStereoscopicRigMode(camera: Camera): void;
  92257. /** @hidden */
  92258. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92259. /** @hidden */
  92260. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92261. /** @hidden */
  92262. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92263. /** @hidden */
  92264. _getVRProjectionMatrix(): Matrix;
  92265. protected _updateCameraRotationMatrix(): void;
  92266. protected _updateWebVRCameraRotationMatrix(): void;
  92267. /**
  92268. * This function MUST be overwritten by the different WebVR cameras available.
  92269. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92270. * @hidden
  92271. */
  92272. _getWebVRProjectionMatrix(): Matrix;
  92273. /**
  92274. * This function MUST be overwritten by the different WebVR cameras available.
  92275. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92276. * @hidden
  92277. */
  92278. _getWebVRViewMatrix(): Matrix;
  92279. /** @hidden */
  92280. setCameraRigParameter(name: string, value: any): void;
  92281. /**
  92282. * needs to be overridden by children so sub has required properties to be copied
  92283. * @hidden
  92284. */
  92285. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92286. /**
  92287. * May need to be overridden by children
  92288. * @hidden
  92289. */
  92290. _updateRigCameras(): void;
  92291. /** @hidden */
  92292. _setupInputs(): void;
  92293. /**
  92294. * Serialiaze the camera setup to a json represention
  92295. * @returns the JSON representation
  92296. */
  92297. serialize(): any;
  92298. /**
  92299. * Clones the current camera.
  92300. * @param name The cloned camera name
  92301. * @returns the cloned camera
  92302. */
  92303. clone(name: string): Camera;
  92304. /**
  92305. * Gets the direction of the camera relative to a given local axis.
  92306. * @param localAxis Defines the reference axis to provide a relative direction.
  92307. * @return the direction
  92308. */
  92309. getDirection(localAxis: Vector3): Vector3;
  92310. /**
  92311. * Returns the current camera absolute rotation
  92312. */
  92313. readonly absoluteRotation: Quaternion;
  92314. /**
  92315. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92316. * @param localAxis Defines the reference axis to provide a relative direction.
  92317. * @param result Defines the vector to store the result in
  92318. */
  92319. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92320. /**
  92321. * Gets a camera constructor for a given camera type
  92322. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92323. * @param name The name of the camera the result will be able to instantiate
  92324. * @param scene The scene the result will construct the camera in
  92325. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92326. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92327. * @returns a factory method to construc the camera
  92328. */
  92329. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92330. /**
  92331. * Compute the world matrix of the camera.
  92332. * @returns the camera workd matrix
  92333. */
  92334. computeWorldMatrix(): Matrix;
  92335. /**
  92336. * Parse a JSON and creates the camera from the parsed information
  92337. * @param parsedCamera The JSON to parse
  92338. * @param scene The scene to instantiate the camera in
  92339. * @returns the newly constructed camera
  92340. */
  92341. static Parse(parsedCamera: any, scene: Scene): Camera;
  92342. }
  92343. }
  92344. declare module BABYLON {
  92345. /**
  92346. * Class containing static functions to help procedurally build meshes
  92347. */
  92348. export class DiscBuilder {
  92349. /**
  92350. * Creates a plane polygonal mesh. By default, this is a disc
  92351. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92352. * * 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
  92353. * * 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
  92354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92357. * @param name defines the name of the mesh
  92358. * @param options defines the options used to create the mesh
  92359. * @param scene defines the hosting scene
  92360. * @returns the plane polygonal mesh
  92361. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92362. */
  92363. static CreateDisc(name: string, options: {
  92364. radius?: number;
  92365. tessellation?: number;
  92366. arc?: number;
  92367. updatable?: boolean;
  92368. sideOrientation?: number;
  92369. frontUVs?: Vector4;
  92370. backUVs?: Vector4;
  92371. }, scene?: Nullable<Scene>): Mesh;
  92372. }
  92373. }
  92374. declare module BABYLON {
  92375. /**
  92376. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92377. *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.
  92378. * The SPS is also a particle system. It provides some methods to manage the particles.
  92379. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92380. *
  92381. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92382. */
  92383. export class SolidParticleSystem implements IDisposable {
  92384. /**
  92385. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92386. * Example : var p = SPS.particles[i];
  92387. */
  92388. particles: SolidParticle[];
  92389. /**
  92390. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92391. */
  92392. nbParticles: number;
  92393. /**
  92394. * If the particles must ever face the camera (default false). Useful for planar particles.
  92395. */
  92396. billboard: boolean;
  92397. /**
  92398. * Recompute normals when adding a shape
  92399. */
  92400. recomputeNormals: boolean;
  92401. /**
  92402. * This a counter ofr your own usage. It's not set by any SPS functions.
  92403. */
  92404. counter: number;
  92405. /**
  92406. * The SPS name. This name is also given to the underlying mesh.
  92407. */
  92408. name: string;
  92409. /**
  92410. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92411. */
  92412. mesh: Mesh;
  92413. /**
  92414. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92415. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92416. */
  92417. vars: any;
  92418. /**
  92419. * This array is populated when the SPS is set as 'pickable'.
  92420. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92421. * Each element of this array is an object `{idx: int, faceId: int}`.
  92422. * `idx` is the picked particle index in the `SPS.particles` array
  92423. * `faceId` is the picked face index counted within this particle.
  92424. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92425. */
  92426. pickedParticles: {
  92427. idx: number;
  92428. faceId: number;
  92429. }[];
  92430. /**
  92431. * This array is populated when `enableDepthSort` is set to true.
  92432. * Each element of this array is an instance of the class DepthSortedParticle.
  92433. */
  92434. depthSortedParticles: DepthSortedParticle[];
  92435. /**
  92436. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92437. * @hidden
  92438. */
  92439. _bSphereOnly: boolean;
  92440. /**
  92441. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92442. * @hidden
  92443. */
  92444. _bSphereRadiusFactor: number;
  92445. private _scene;
  92446. private _positions;
  92447. private _indices;
  92448. private _normals;
  92449. private _colors;
  92450. private _uvs;
  92451. private _indices32;
  92452. private _positions32;
  92453. private _normals32;
  92454. private _fixedNormal32;
  92455. private _colors32;
  92456. private _uvs32;
  92457. private _index;
  92458. private _updatable;
  92459. private _pickable;
  92460. private _isVisibilityBoxLocked;
  92461. private _alwaysVisible;
  92462. private _depthSort;
  92463. private _expandable;
  92464. private _shapeCounter;
  92465. private _copy;
  92466. private _color;
  92467. private _computeParticleColor;
  92468. private _computeParticleTexture;
  92469. private _computeParticleRotation;
  92470. private _computeParticleVertex;
  92471. private _computeBoundingBox;
  92472. private _depthSortParticles;
  92473. private _camera;
  92474. private _mustUnrotateFixedNormals;
  92475. private _particlesIntersect;
  92476. private _needs32Bits;
  92477. /**
  92478. * Creates a SPS (Solid Particle System) object.
  92479. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92480. * @param scene (Scene) is the scene in which the SPS is added.
  92481. * @param options defines the options of the sps e.g.
  92482. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92483. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92484. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92485. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92486. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92487. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92488. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92489. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92490. */
  92491. constructor(name: string, scene: Scene, options?: {
  92492. updatable?: boolean;
  92493. isPickable?: boolean;
  92494. enableDepthSort?: boolean;
  92495. particleIntersection?: boolean;
  92496. boundingSphereOnly?: boolean;
  92497. bSphereRadiusFactor?: number;
  92498. expandable?: boolean;
  92499. });
  92500. /**
  92501. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92502. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92503. * @returns the created mesh
  92504. */
  92505. buildMesh(): Mesh;
  92506. /**
  92507. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92508. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92509. * Thus the particles generated from `digest()` have their property `position` set yet.
  92510. * @param mesh ( Mesh ) is the mesh to be digested
  92511. * @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
  92512. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92513. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92514. * @returns the current SPS
  92515. */
  92516. digest(mesh: Mesh, options?: {
  92517. facetNb?: number;
  92518. number?: number;
  92519. delta?: number;
  92520. }): SolidParticleSystem;
  92521. private _unrotateFixedNormals;
  92522. private _resetCopy;
  92523. private _meshBuilder;
  92524. private _posToShape;
  92525. private _uvsToShapeUV;
  92526. private _addParticle;
  92527. /**
  92528. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92529. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92530. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92531. * @param nb (positive integer) the number of particles to be created from this model
  92532. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92533. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92534. * @returns the number of shapes in the system
  92535. */
  92536. addShape(mesh: Mesh, nb: number, options?: {
  92537. positionFunction?: any;
  92538. vertexFunction?: any;
  92539. }): number;
  92540. private _rebuildParticle;
  92541. /**
  92542. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92543. * @returns the SPS.
  92544. */
  92545. rebuildMesh(): SolidParticleSystem;
  92546. /**
  92547. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92548. * This method calls `updateParticle()` for each particle of the SPS.
  92549. * For an animated SPS, it is usually called within the render loop.
  92550. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92551. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92552. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92553. * @returns the SPS.
  92554. */
  92555. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92556. /**
  92557. * Disposes the SPS.
  92558. */
  92559. dispose(): void;
  92560. /**
  92561. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92562. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92563. * @returns the SPS.
  92564. */
  92565. refreshVisibleSize(): SolidParticleSystem;
  92566. /**
  92567. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92568. * @param size the size (float) of the visibility box
  92569. * note : this doesn't lock the SPS mesh bounding box.
  92570. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92571. */
  92572. setVisibilityBox(size: number): void;
  92573. /**
  92574. * Gets whether the SPS as always visible or not
  92575. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92576. */
  92577. /**
  92578. * Sets the SPS as always visible or not
  92579. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92580. */
  92581. isAlwaysVisible: boolean;
  92582. /**
  92583. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92584. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92585. */
  92586. /**
  92587. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92588. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92589. */
  92590. isVisibilityBoxLocked: boolean;
  92591. /**
  92592. * Tells to `setParticles()` to compute the particle rotations or not.
  92593. * Default value : true. The SPS is faster when it's set to false.
  92594. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92595. */
  92596. /**
  92597. * Gets if `setParticles()` computes the particle rotations or not.
  92598. * Default value : true. The SPS is faster when it's set to false.
  92599. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92600. */
  92601. computeParticleRotation: boolean;
  92602. /**
  92603. * Tells to `setParticles()` to compute the particle colors or not.
  92604. * Default value : true. The SPS is faster when it's set to false.
  92605. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92606. */
  92607. /**
  92608. * Gets if `setParticles()` computes the particle colors or not.
  92609. * Default value : true. The SPS is faster when it's set to false.
  92610. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92611. */
  92612. computeParticleColor: boolean;
  92613. /**
  92614. * Gets if `setParticles()` computes the particle textures or not.
  92615. * Default value : true. The SPS is faster when it's set to false.
  92616. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92617. */
  92618. computeParticleTexture: boolean;
  92619. /**
  92620. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92621. * Default value : false. The SPS is faster when it's set to false.
  92622. * Note : the particle custom vertex positions aren't stored values.
  92623. */
  92624. /**
  92625. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92626. * Default value : false. The SPS is faster when it's set to false.
  92627. * Note : the particle custom vertex positions aren't stored values.
  92628. */
  92629. computeParticleVertex: boolean;
  92630. /**
  92631. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92632. */
  92633. /**
  92634. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92635. */
  92636. computeBoundingBox: boolean;
  92637. /**
  92638. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92639. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92640. * Default : `true`
  92641. */
  92642. /**
  92643. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92644. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92645. * Default : `true`
  92646. */
  92647. depthSortParticles: boolean;
  92648. /**
  92649. * Gets if the SPS is created as expandable at construction time.
  92650. * Default : `false`
  92651. */
  92652. readonly expandable: boolean;
  92653. /**
  92654. * This function does nothing. It may be overwritten to set all the particle first values.
  92655. * The SPS doesn't call this function, you may have to call it by your own.
  92656. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92657. */
  92658. initParticles(): void;
  92659. /**
  92660. * This function does nothing. It may be overwritten to recycle a particle.
  92661. * The SPS doesn't call this function, you may have to call it by your own.
  92662. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92663. * @param particle The particle to recycle
  92664. * @returns the recycled particle
  92665. */
  92666. recycleParticle(particle: SolidParticle): SolidParticle;
  92667. /**
  92668. * Updates a particle : this function should be overwritten by the user.
  92669. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92670. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92671. * @example : just set a particle position or velocity and recycle conditions
  92672. * @param particle The particle to update
  92673. * @returns the updated particle
  92674. */
  92675. updateParticle(particle: SolidParticle): SolidParticle;
  92676. /**
  92677. * Updates a vertex of a particle : it can be overwritten by the user.
  92678. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92679. * @param particle the current particle
  92680. * @param vertex the current index of the current particle
  92681. * @param pt the index of the current vertex in the particle shape
  92682. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92683. * @example : just set a vertex particle position
  92684. * @returns the updated vertex
  92685. */
  92686. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92687. /**
  92688. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92689. * This does nothing and may be overwritten by the user.
  92690. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92691. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92692. * @param update the boolean update value actually passed to setParticles()
  92693. */
  92694. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92695. /**
  92696. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92697. * This will be passed three parameters.
  92698. * This does nothing and may be overwritten by the user.
  92699. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92700. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92701. * @param update the boolean update value actually passed to setParticles()
  92702. */
  92703. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92704. }
  92705. }
  92706. declare module BABYLON {
  92707. /**
  92708. * Represents one particle of a solid particle system.
  92709. */
  92710. export class SolidParticle {
  92711. /**
  92712. * particle global index
  92713. */
  92714. idx: number;
  92715. /**
  92716. * The color of the particle
  92717. */
  92718. color: Nullable<Color4>;
  92719. /**
  92720. * The world space position of the particle.
  92721. */
  92722. position: Vector3;
  92723. /**
  92724. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92725. */
  92726. rotation: Vector3;
  92727. /**
  92728. * The world space rotation quaternion of the particle.
  92729. */
  92730. rotationQuaternion: Nullable<Quaternion>;
  92731. /**
  92732. * The scaling of the particle.
  92733. */
  92734. scaling: Vector3;
  92735. /**
  92736. * The uvs of the particle.
  92737. */
  92738. uvs: Vector4;
  92739. /**
  92740. * The current speed of the particle.
  92741. */
  92742. velocity: Vector3;
  92743. /**
  92744. * The pivot point in the particle local space.
  92745. */
  92746. pivot: Vector3;
  92747. /**
  92748. * Must the particle be translated from its pivot point in its local space ?
  92749. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92750. * Default : false
  92751. */
  92752. translateFromPivot: boolean;
  92753. /**
  92754. * Is the particle active or not ?
  92755. */
  92756. alive: boolean;
  92757. /**
  92758. * Is the particle visible or not ?
  92759. */
  92760. isVisible: boolean;
  92761. /**
  92762. * Index of this particle in the global "positions" array (Internal use)
  92763. * @hidden
  92764. */
  92765. _pos: number;
  92766. /**
  92767. * @hidden Index of this particle in the global "indices" array (Internal use)
  92768. */
  92769. _ind: number;
  92770. /**
  92771. * @hidden ModelShape of this particle (Internal use)
  92772. */
  92773. _model: ModelShape;
  92774. /**
  92775. * ModelShape id of this particle
  92776. */
  92777. shapeId: number;
  92778. /**
  92779. * Index of the particle in its shape id
  92780. */
  92781. idxInShape: number;
  92782. /**
  92783. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92784. */
  92785. _modelBoundingInfo: BoundingInfo;
  92786. /**
  92787. * @hidden Particle BoundingInfo object (Internal use)
  92788. */
  92789. _boundingInfo: BoundingInfo;
  92790. /**
  92791. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92792. */
  92793. _sps: SolidParticleSystem;
  92794. /**
  92795. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92796. */
  92797. _stillInvisible: boolean;
  92798. /**
  92799. * @hidden Last computed particle rotation matrix
  92800. */
  92801. _rotationMatrix: number[];
  92802. /**
  92803. * Parent particle Id, if any.
  92804. * Default null.
  92805. */
  92806. parentId: Nullable<number>;
  92807. /**
  92808. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92809. * The possible values are :
  92810. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92811. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92812. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92813. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92814. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92815. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92816. * */
  92817. cullingStrategy: number;
  92818. /**
  92819. * @hidden Internal global position in the SPS.
  92820. */
  92821. _globalPosition: Vector3;
  92822. /**
  92823. * Creates a Solid Particle object.
  92824. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92825. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92826. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92827. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92828. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92829. * @param shapeId (integer) is the model shape identifier in the SPS.
  92830. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92831. * @param sps defines the sps it is associated to
  92832. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92833. */
  92834. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92835. /**
  92836. * Legacy support, changed scale to scaling
  92837. */
  92838. /**
  92839. * Legacy support, changed scale to scaling
  92840. */
  92841. scale: Vector3;
  92842. /**
  92843. * Legacy support, changed quaternion to rotationQuaternion
  92844. */
  92845. /**
  92846. * Legacy support, changed quaternion to rotationQuaternion
  92847. */
  92848. quaternion: Nullable<Quaternion>;
  92849. /**
  92850. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92851. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92852. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92853. * @returns true if it intersects
  92854. */
  92855. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92856. /**
  92857. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92858. * A particle is in the frustum if its bounding box intersects the frustum
  92859. * @param frustumPlanes defines the frustum to test
  92860. * @returns true if the particle is in the frustum planes
  92861. */
  92862. isInFrustum(frustumPlanes: Plane[]): boolean;
  92863. /**
  92864. * get the rotation matrix of the particle
  92865. * @hidden
  92866. */
  92867. getRotationMatrix(m: Matrix): void;
  92868. }
  92869. /**
  92870. * Represents the shape of the model used by one particle of a solid particle system.
  92871. * SPS internal tool, don't use it manually.
  92872. */
  92873. export class ModelShape {
  92874. /**
  92875. * The shape id
  92876. * @hidden
  92877. */
  92878. shapeID: number;
  92879. /**
  92880. * flat array of model positions (internal use)
  92881. * @hidden
  92882. */
  92883. _shape: Vector3[];
  92884. /**
  92885. * flat array of model UVs (internal use)
  92886. * @hidden
  92887. */
  92888. _shapeUV: number[];
  92889. /**
  92890. * length of the shape in the model indices array (internal use)
  92891. * @hidden
  92892. */
  92893. _indicesLength: number;
  92894. /**
  92895. * Custom position function (internal use)
  92896. * @hidden
  92897. */
  92898. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92899. /**
  92900. * Custom vertex function (internal use)
  92901. * @hidden
  92902. */
  92903. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92904. /**
  92905. * 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.
  92906. * SPS internal tool, don't use it manually.
  92907. * @hidden
  92908. */
  92909. 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>);
  92910. }
  92911. /**
  92912. * Represents a Depth Sorted Particle in the solid particle system.
  92913. */
  92914. export class DepthSortedParticle {
  92915. /**
  92916. * Index of the particle in the "indices" array
  92917. */
  92918. ind: number;
  92919. /**
  92920. * Length of the particle shape in the "indices" array
  92921. */
  92922. indicesLength: number;
  92923. /**
  92924. * Squared distance from the particle to the camera
  92925. */
  92926. sqDistance: number;
  92927. }
  92928. }
  92929. declare module BABYLON {
  92930. /**
  92931. * @hidden
  92932. */
  92933. export class _MeshCollisionData {
  92934. _checkCollisions: boolean;
  92935. _collisionMask: number;
  92936. _collisionGroup: number;
  92937. _collider: Nullable<Collider>;
  92938. _oldPositionForCollisions: Vector3;
  92939. _diffPositionForCollisions: Vector3;
  92940. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92941. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92942. }
  92943. }
  92944. declare module BABYLON {
  92945. /** @hidden */
  92946. class _FacetDataStorage {
  92947. facetPositions: Vector3[];
  92948. facetNormals: Vector3[];
  92949. facetPartitioning: number[][];
  92950. facetNb: number;
  92951. partitioningSubdivisions: number;
  92952. partitioningBBoxRatio: number;
  92953. facetDataEnabled: boolean;
  92954. facetParameters: any;
  92955. bbSize: Vector3;
  92956. subDiv: {
  92957. max: number;
  92958. X: number;
  92959. Y: number;
  92960. Z: number;
  92961. };
  92962. facetDepthSort: boolean;
  92963. facetDepthSortEnabled: boolean;
  92964. depthSortedIndices: IndicesArray;
  92965. depthSortedFacets: {
  92966. ind: number;
  92967. sqDistance: number;
  92968. }[];
  92969. facetDepthSortFunction: (f1: {
  92970. ind: number;
  92971. sqDistance: number;
  92972. }, f2: {
  92973. ind: number;
  92974. sqDistance: number;
  92975. }) => number;
  92976. facetDepthSortFrom: Vector3;
  92977. facetDepthSortOrigin: Vector3;
  92978. invertedMatrix: Matrix;
  92979. }
  92980. /**
  92981. * @hidden
  92982. **/
  92983. class _InternalAbstractMeshDataInfo {
  92984. _hasVertexAlpha: boolean;
  92985. _useVertexColors: boolean;
  92986. _numBoneInfluencers: number;
  92987. _applyFog: boolean;
  92988. _receiveShadows: boolean;
  92989. _facetData: _FacetDataStorage;
  92990. _visibility: number;
  92991. _skeleton: Nullable<Skeleton>;
  92992. _layerMask: number;
  92993. _computeBonesUsingShaders: boolean;
  92994. _isActive: boolean;
  92995. _onlyForInstances: boolean;
  92996. _isActiveIntermediate: boolean;
  92997. _onlyForInstancesIntermediate: boolean;
  92998. _actAsRegularMesh: boolean;
  92999. }
  93000. /**
  93001. * Class used to store all common mesh properties
  93002. */
  93003. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93004. /** No occlusion */
  93005. static OCCLUSION_TYPE_NONE: number;
  93006. /** Occlusion set to optimisitic */
  93007. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93008. /** Occlusion set to strict */
  93009. static OCCLUSION_TYPE_STRICT: number;
  93010. /** Use an accurante occlusion algorithm */
  93011. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93012. /** Use a conservative occlusion algorithm */
  93013. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93014. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93015. * Test order :
  93016. * Is the bounding sphere outside the frustum ?
  93017. * If not, are the bounding box vertices outside the frustum ?
  93018. * It not, then the cullable object is in the frustum.
  93019. */
  93020. static readonly CULLINGSTRATEGY_STANDARD: number;
  93021. /** Culling strategy : Bounding Sphere Only.
  93022. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93023. * It's also less accurate than the standard because some not visible objects can still be selected.
  93024. * Test : is the bounding sphere outside the frustum ?
  93025. * If not, then the cullable object is in the frustum.
  93026. */
  93027. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93028. /** Culling strategy : Optimistic Inclusion.
  93029. * This in an inclusion test first, then the standard exclusion test.
  93030. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93031. * 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.
  93032. * Anyway, it's as accurate as the standard strategy.
  93033. * Test :
  93034. * Is the cullable object bounding sphere center in the frustum ?
  93035. * If not, apply the default culling strategy.
  93036. */
  93037. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93038. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93039. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93040. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93041. * 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.
  93042. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93043. * Test :
  93044. * Is the cullable object bounding sphere center in the frustum ?
  93045. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93046. */
  93047. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93048. /**
  93049. * No billboard
  93050. */
  93051. static readonly BILLBOARDMODE_NONE: number;
  93052. /** Billboard on X axis */
  93053. static readonly BILLBOARDMODE_X: number;
  93054. /** Billboard on Y axis */
  93055. static readonly BILLBOARDMODE_Y: number;
  93056. /** Billboard on Z axis */
  93057. static readonly BILLBOARDMODE_Z: number;
  93058. /** Billboard on all axes */
  93059. static readonly BILLBOARDMODE_ALL: number;
  93060. /** Billboard on using position instead of orientation */
  93061. static readonly BILLBOARDMODE_USE_POSITION: number;
  93062. /** @hidden */
  93063. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93064. /**
  93065. * The culling strategy to use to check whether the mesh must be rendered or not.
  93066. * This value can be changed at any time and will be used on the next render mesh selection.
  93067. * The possible values are :
  93068. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93069. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93070. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93071. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93072. * Please read each static variable documentation to get details about the culling process.
  93073. * */
  93074. cullingStrategy: number;
  93075. /**
  93076. * Gets the number of facets in the mesh
  93077. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93078. */
  93079. readonly facetNb: number;
  93080. /**
  93081. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93083. */
  93084. partitioningSubdivisions: number;
  93085. /**
  93086. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93087. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93089. */
  93090. partitioningBBoxRatio: number;
  93091. /**
  93092. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93093. * Works only for updatable meshes.
  93094. * Doesn't work with multi-materials
  93095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93096. */
  93097. mustDepthSortFacets: boolean;
  93098. /**
  93099. * The location (Vector3) where the facet depth sort must be computed from.
  93100. * By default, the active camera position.
  93101. * Used only when facet depth sort is enabled
  93102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93103. */
  93104. facetDepthSortFrom: Vector3;
  93105. /**
  93106. * gets a boolean indicating if facetData is enabled
  93107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93108. */
  93109. readonly isFacetDataEnabled: boolean;
  93110. /** @hidden */
  93111. _updateNonUniformScalingState(value: boolean): boolean;
  93112. /**
  93113. * An event triggered when this mesh collides with another one
  93114. */
  93115. onCollideObservable: Observable<AbstractMesh>;
  93116. /** Set a function to call when this mesh collides with another one */
  93117. onCollide: () => void;
  93118. /**
  93119. * An event triggered when the collision's position changes
  93120. */
  93121. onCollisionPositionChangeObservable: Observable<Vector3>;
  93122. /** Set a function to call when the collision's position changes */
  93123. onCollisionPositionChange: () => void;
  93124. /**
  93125. * An event triggered when material is changed
  93126. */
  93127. onMaterialChangedObservable: Observable<AbstractMesh>;
  93128. /**
  93129. * Gets or sets the orientation for POV movement & rotation
  93130. */
  93131. definedFacingForward: boolean;
  93132. /** @hidden */
  93133. _occlusionQuery: Nullable<WebGLQuery>;
  93134. /** @hidden */
  93135. _renderingGroup: Nullable<RenderingGroup>;
  93136. /**
  93137. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93138. */
  93139. /**
  93140. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93141. */
  93142. visibility: number;
  93143. /** Gets or sets the alpha index used to sort transparent meshes
  93144. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93145. */
  93146. alphaIndex: number;
  93147. /**
  93148. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93149. */
  93150. isVisible: boolean;
  93151. /**
  93152. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93153. */
  93154. isPickable: boolean;
  93155. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93156. showSubMeshesBoundingBox: boolean;
  93157. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93159. */
  93160. isBlocker: boolean;
  93161. /**
  93162. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93163. */
  93164. enablePointerMoveEvents: boolean;
  93165. /**
  93166. * Specifies the rendering group id for this mesh (0 by default)
  93167. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93168. */
  93169. renderingGroupId: number;
  93170. private _material;
  93171. /** Gets or sets current material */
  93172. material: Nullable<Material>;
  93173. /**
  93174. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93175. * @see http://doc.babylonjs.com/babylon101/shadows
  93176. */
  93177. receiveShadows: boolean;
  93178. /** Defines color to use when rendering outline */
  93179. outlineColor: Color3;
  93180. /** Define width to use when rendering outline */
  93181. outlineWidth: number;
  93182. /** Defines color to use when rendering overlay */
  93183. overlayColor: Color3;
  93184. /** Defines alpha to use when rendering overlay */
  93185. overlayAlpha: number;
  93186. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93187. hasVertexAlpha: boolean;
  93188. /** 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) */
  93189. useVertexColors: boolean;
  93190. /**
  93191. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93192. */
  93193. computeBonesUsingShaders: boolean;
  93194. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93195. numBoneInfluencers: number;
  93196. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93197. applyFog: boolean;
  93198. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93199. useOctreeForRenderingSelection: boolean;
  93200. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93201. useOctreeForPicking: boolean;
  93202. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93203. useOctreeForCollisions: boolean;
  93204. /**
  93205. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93206. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93207. */
  93208. layerMask: number;
  93209. /**
  93210. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93211. */
  93212. alwaysSelectAsActiveMesh: boolean;
  93213. /**
  93214. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93215. */
  93216. doNotSyncBoundingInfo: boolean;
  93217. /**
  93218. * Gets or sets the current action manager
  93219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93220. */
  93221. actionManager: Nullable<AbstractActionManager>;
  93222. private _meshCollisionData;
  93223. /**
  93224. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93226. */
  93227. ellipsoid: Vector3;
  93228. /**
  93229. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93231. */
  93232. ellipsoidOffset: Vector3;
  93233. /**
  93234. * Gets or sets a collision mask used to mask collisions (default is -1).
  93235. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93236. */
  93237. collisionMask: number;
  93238. /**
  93239. * Gets or sets the current collision group mask (-1 by default).
  93240. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93241. */
  93242. collisionGroup: number;
  93243. /**
  93244. * Defines edge width used when edgesRenderer is enabled
  93245. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93246. */
  93247. edgesWidth: number;
  93248. /**
  93249. * Defines edge color used when edgesRenderer is enabled
  93250. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93251. */
  93252. edgesColor: Color4;
  93253. /** @hidden */
  93254. _edgesRenderer: Nullable<IEdgesRenderer>;
  93255. /** @hidden */
  93256. _masterMesh: Nullable<AbstractMesh>;
  93257. /** @hidden */
  93258. _boundingInfo: Nullable<BoundingInfo>;
  93259. /** @hidden */
  93260. _renderId: number;
  93261. /**
  93262. * Gets or sets the list of subMeshes
  93263. * @see http://doc.babylonjs.com/how_to/multi_materials
  93264. */
  93265. subMeshes: SubMesh[];
  93266. /** @hidden */
  93267. _intersectionsInProgress: AbstractMesh[];
  93268. /** @hidden */
  93269. _unIndexed: boolean;
  93270. /** @hidden */
  93271. _lightSources: Light[];
  93272. /** Gets the list of lights affecting that mesh */
  93273. readonly lightSources: Light[];
  93274. /** @hidden */
  93275. readonly _positions: Nullable<Vector3[]>;
  93276. /** @hidden */
  93277. _waitingData: {
  93278. lods: Nullable<any>;
  93279. actions: Nullable<any>;
  93280. freezeWorldMatrix: Nullable<boolean>;
  93281. };
  93282. /** @hidden */
  93283. _bonesTransformMatrices: Nullable<Float32Array>;
  93284. /** @hidden */
  93285. _transformMatrixTexture: Nullable<RawTexture>;
  93286. /**
  93287. * Gets or sets a skeleton to apply skining transformations
  93288. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93289. */
  93290. skeleton: Nullable<Skeleton>;
  93291. /**
  93292. * An event triggered when the mesh is rebuilt.
  93293. */
  93294. onRebuildObservable: Observable<AbstractMesh>;
  93295. /**
  93296. * Creates a new AbstractMesh
  93297. * @param name defines the name of the mesh
  93298. * @param scene defines the hosting scene
  93299. */
  93300. constructor(name: string, scene?: Nullable<Scene>);
  93301. /**
  93302. * Returns the string "AbstractMesh"
  93303. * @returns "AbstractMesh"
  93304. */
  93305. getClassName(): string;
  93306. /**
  93307. * Gets a string representation of the current mesh
  93308. * @param fullDetails defines a boolean indicating if full details must be included
  93309. * @returns a string representation of the current mesh
  93310. */
  93311. toString(fullDetails?: boolean): string;
  93312. /**
  93313. * @hidden
  93314. */
  93315. protected _getEffectiveParent(): Nullable<Node>;
  93316. /** @hidden */
  93317. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93318. /** @hidden */
  93319. _rebuild(): void;
  93320. /** @hidden */
  93321. _resyncLightSources(): void;
  93322. /** @hidden */
  93323. _resyncLighSource(light: Light): void;
  93324. /** @hidden */
  93325. _unBindEffect(): void;
  93326. /** @hidden */
  93327. _removeLightSource(light: Light, dispose: boolean): void;
  93328. private _markSubMeshesAsDirty;
  93329. /** @hidden */
  93330. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93331. /** @hidden */
  93332. _markSubMeshesAsAttributesDirty(): void;
  93333. /** @hidden */
  93334. _markSubMeshesAsMiscDirty(): void;
  93335. /**
  93336. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93337. */
  93338. scaling: Vector3;
  93339. /**
  93340. * Returns true if the mesh is blocked. Implemented by child classes
  93341. */
  93342. readonly isBlocked: boolean;
  93343. /**
  93344. * Returns the mesh itself by default. Implemented by child classes
  93345. * @param camera defines the camera to use to pick the right LOD level
  93346. * @returns the currentAbstractMesh
  93347. */
  93348. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93349. /**
  93350. * Returns 0 by default. Implemented by child classes
  93351. * @returns an integer
  93352. */
  93353. getTotalVertices(): number;
  93354. /**
  93355. * Returns a positive integer : the total number of indices in this mesh geometry.
  93356. * @returns the numner of indices or zero if the mesh has no geometry.
  93357. */
  93358. getTotalIndices(): number;
  93359. /**
  93360. * Returns null by default. Implemented by child classes
  93361. * @returns null
  93362. */
  93363. getIndices(): Nullable<IndicesArray>;
  93364. /**
  93365. * Returns the array of the requested vertex data kind. Implemented by child classes
  93366. * @param kind defines the vertex data kind to use
  93367. * @returns null
  93368. */
  93369. getVerticesData(kind: string): Nullable<FloatArray>;
  93370. /**
  93371. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93372. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93373. * Note that a new underlying VertexBuffer object is created each call.
  93374. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93375. * @param kind defines vertex data kind:
  93376. * * VertexBuffer.PositionKind
  93377. * * VertexBuffer.UVKind
  93378. * * VertexBuffer.UV2Kind
  93379. * * VertexBuffer.UV3Kind
  93380. * * VertexBuffer.UV4Kind
  93381. * * VertexBuffer.UV5Kind
  93382. * * VertexBuffer.UV6Kind
  93383. * * VertexBuffer.ColorKind
  93384. * * VertexBuffer.MatricesIndicesKind
  93385. * * VertexBuffer.MatricesIndicesExtraKind
  93386. * * VertexBuffer.MatricesWeightsKind
  93387. * * VertexBuffer.MatricesWeightsExtraKind
  93388. * @param data defines the data source
  93389. * @param updatable defines if the data must be flagged as updatable (or static)
  93390. * @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
  93391. * @returns the current mesh
  93392. */
  93393. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93394. /**
  93395. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93396. * If the mesh has no geometry, it is simply returned as it is.
  93397. * @param kind defines vertex data kind:
  93398. * * VertexBuffer.PositionKind
  93399. * * VertexBuffer.UVKind
  93400. * * VertexBuffer.UV2Kind
  93401. * * VertexBuffer.UV3Kind
  93402. * * VertexBuffer.UV4Kind
  93403. * * VertexBuffer.UV5Kind
  93404. * * VertexBuffer.UV6Kind
  93405. * * VertexBuffer.ColorKind
  93406. * * VertexBuffer.MatricesIndicesKind
  93407. * * VertexBuffer.MatricesIndicesExtraKind
  93408. * * VertexBuffer.MatricesWeightsKind
  93409. * * VertexBuffer.MatricesWeightsExtraKind
  93410. * @param data defines the data source
  93411. * @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
  93412. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93413. * @returns the current mesh
  93414. */
  93415. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93416. /**
  93417. * Sets the mesh indices,
  93418. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93419. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93420. * @param totalVertices Defines the total number of vertices
  93421. * @returns the current mesh
  93422. */
  93423. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93424. /**
  93425. * Gets a boolean indicating if specific vertex data is present
  93426. * @param kind defines the vertex data kind to use
  93427. * @returns true is data kind is present
  93428. */
  93429. isVerticesDataPresent(kind: string): boolean;
  93430. /**
  93431. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93432. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93433. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93434. * @returns a BoundingInfo
  93435. */
  93436. getBoundingInfo(): BoundingInfo;
  93437. /**
  93438. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93439. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93440. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93441. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93442. * @returns the current mesh
  93443. */
  93444. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93445. /**
  93446. * Overwrite the current bounding info
  93447. * @param boundingInfo defines the new bounding info
  93448. * @returns the current mesh
  93449. */
  93450. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93451. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93452. readonly useBones: boolean;
  93453. /** @hidden */
  93454. _preActivate(): void;
  93455. /** @hidden */
  93456. _preActivateForIntermediateRendering(renderId: number): void;
  93457. /** @hidden */
  93458. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93459. /** @hidden */
  93460. _postActivate(): void;
  93461. /** @hidden */
  93462. _freeze(): void;
  93463. /** @hidden */
  93464. _unFreeze(): void;
  93465. /**
  93466. * Gets the current world matrix
  93467. * @returns a Matrix
  93468. */
  93469. getWorldMatrix(): Matrix;
  93470. /** @hidden */
  93471. _getWorldMatrixDeterminant(): number;
  93472. /**
  93473. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93474. */
  93475. readonly isAnInstance: boolean;
  93476. /**
  93477. * Gets a boolean indicating if this mesh has instances
  93478. */
  93479. readonly hasInstances: boolean;
  93480. /**
  93481. * Perform relative position change from the point of view of behind the front of the mesh.
  93482. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93483. * Supports definition of mesh facing forward or backward
  93484. * @param amountRight defines the distance on the right axis
  93485. * @param amountUp defines the distance on the up axis
  93486. * @param amountForward defines the distance on the forward axis
  93487. * @returns the current mesh
  93488. */
  93489. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93490. /**
  93491. * Calculate relative position change from the point of view of behind the front of the mesh.
  93492. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93493. * Supports definition of mesh facing forward or backward
  93494. * @param amountRight defines the distance on the right axis
  93495. * @param amountUp defines the distance on the up axis
  93496. * @param amountForward defines the distance on the forward axis
  93497. * @returns the new displacement vector
  93498. */
  93499. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93500. /**
  93501. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93502. * Supports definition of mesh facing forward or backward
  93503. * @param flipBack defines the flip
  93504. * @param twirlClockwise defines the twirl
  93505. * @param tiltRight defines the tilt
  93506. * @returns the current mesh
  93507. */
  93508. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93509. /**
  93510. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93511. * Supports definition of mesh facing forward or backward.
  93512. * @param flipBack defines the flip
  93513. * @param twirlClockwise defines the twirl
  93514. * @param tiltRight defines the tilt
  93515. * @returns the new rotation vector
  93516. */
  93517. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93518. /**
  93519. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93520. * This means the mesh underlying bounding box and sphere are recomputed.
  93521. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93522. * @returns the current mesh
  93523. */
  93524. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93525. /** @hidden */
  93526. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93527. /** @hidden */
  93528. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93529. /** @hidden */
  93530. _updateBoundingInfo(): AbstractMesh;
  93531. /** @hidden */
  93532. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93533. /** @hidden */
  93534. protected _afterComputeWorldMatrix(): void;
  93535. /** @hidden */
  93536. readonly _effectiveMesh: AbstractMesh;
  93537. /**
  93538. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93539. * A mesh is in the frustum if its bounding box intersects the frustum
  93540. * @param frustumPlanes defines the frustum to test
  93541. * @returns true if the mesh is in the frustum planes
  93542. */
  93543. isInFrustum(frustumPlanes: Plane[]): boolean;
  93544. /**
  93545. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93546. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93547. * @param frustumPlanes defines the frustum to test
  93548. * @returns true if the mesh is completely in the frustum planes
  93549. */
  93550. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93551. /**
  93552. * True if the mesh intersects another mesh or a SolidParticle object
  93553. * @param mesh defines a target mesh or SolidParticle to test
  93554. * @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)
  93555. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93556. * @returns true if there is an intersection
  93557. */
  93558. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93559. /**
  93560. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93561. * @param point defines the point to test
  93562. * @returns true if there is an intersection
  93563. */
  93564. intersectsPoint(point: Vector3): boolean;
  93565. /**
  93566. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93568. */
  93569. checkCollisions: boolean;
  93570. /**
  93571. * Gets Collider object used to compute collisions (not physics)
  93572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93573. */
  93574. readonly collider: Nullable<Collider>;
  93575. /**
  93576. * Move the mesh using collision engine
  93577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93578. * @param displacement defines the requested displacement vector
  93579. * @returns the current mesh
  93580. */
  93581. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93582. private _onCollisionPositionChange;
  93583. /** @hidden */
  93584. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93585. /** @hidden */
  93586. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93587. /** @hidden */
  93588. _checkCollision(collider: Collider): AbstractMesh;
  93589. /** @hidden */
  93590. _generatePointsArray(): boolean;
  93591. /**
  93592. * Checks if the passed Ray intersects with the mesh
  93593. * @param ray defines the ray to use
  93594. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93596. * @returns the picking info
  93597. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93598. */
  93599. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93600. /**
  93601. * Clones the current mesh
  93602. * @param name defines the mesh name
  93603. * @param newParent defines the new mesh parent
  93604. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93605. * @returns the new mesh
  93606. */
  93607. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93608. /**
  93609. * Disposes all the submeshes of the current meshnp
  93610. * @returns the current mesh
  93611. */
  93612. releaseSubMeshes(): AbstractMesh;
  93613. /**
  93614. * Releases resources associated with this abstract mesh.
  93615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93617. */
  93618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93619. /**
  93620. * Adds the passed mesh as a child to the current mesh
  93621. * @param mesh defines the child mesh
  93622. * @returns the current mesh
  93623. */
  93624. addChild(mesh: AbstractMesh): AbstractMesh;
  93625. /**
  93626. * Removes the passed mesh from the current mesh children list
  93627. * @param mesh defines the child mesh
  93628. * @returns the current mesh
  93629. */
  93630. removeChild(mesh: AbstractMesh): AbstractMesh;
  93631. /** @hidden */
  93632. private _initFacetData;
  93633. /**
  93634. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93635. * This method can be called within the render loop.
  93636. * 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
  93637. * @returns the current mesh
  93638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93639. */
  93640. updateFacetData(): AbstractMesh;
  93641. /**
  93642. * Returns the facetLocalNormals array.
  93643. * The normals are expressed in the mesh local spac
  93644. * @returns an array of Vector3
  93645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93646. */
  93647. getFacetLocalNormals(): Vector3[];
  93648. /**
  93649. * Returns the facetLocalPositions array.
  93650. * The facet positions are expressed in the mesh local space
  93651. * @returns an array of Vector3
  93652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93653. */
  93654. getFacetLocalPositions(): Vector3[];
  93655. /**
  93656. * Returns the facetLocalPartioning array
  93657. * @returns an array of array of numbers
  93658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93659. */
  93660. getFacetLocalPartitioning(): number[][];
  93661. /**
  93662. * Returns the i-th facet position in the world system.
  93663. * This method allocates a new Vector3 per call
  93664. * @param i defines the facet index
  93665. * @returns a new Vector3
  93666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93667. */
  93668. getFacetPosition(i: number): Vector3;
  93669. /**
  93670. * Sets the reference Vector3 with the i-th facet position in the world system
  93671. * @param i defines the facet index
  93672. * @param ref defines the target vector
  93673. * @returns the current mesh
  93674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93675. */
  93676. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93677. /**
  93678. * Returns the i-th facet normal in the world system.
  93679. * This method allocates a new Vector3 per call
  93680. * @param i defines the facet index
  93681. * @returns a new Vector3
  93682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93683. */
  93684. getFacetNormal(i: number): Vector3;
  93685. /**
  93686. * Sets the reference Vector3 with the i-th facet normal in the world system
  93687. * @param i defines the facet index
  93688. * @param ref defines the target vector
  93689. * @returns the current mesh
  93690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93691. */
  93692. getFacetNormalToRef(i: number, ref: Vector3): this;
  93693. /**
  93694. * 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)
  93695. * @param x defines x coordinate
  93696. * @param y defines y coordinate
  93697. * @param z defines z coordinate
  93698. * @returns the array of facet indexes
  93699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93700. */
  93701. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93702. /**
  93703. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93704. * @param projected sets as the (x,y,z) world projection on the facet
  93705. * @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
  93706. * @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
  93707. * @param x defines x coordinate
  93708. * @param y defines y coordinate
  93709. * @param z defines z coordinate
  93710. * @returns the face index if found (or null instead)
  93711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93712. */
  93713. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93714. /**
  93715. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93716. * @param projected sets as the (x,y,z) local projection on the facet
  93717. * @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
  93718. * @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
  93719. * @param x defines x coordinate
  93720. * @param y defines y coordinate
  93721. * @param z defines z coordinate
  93722. * @returns the face index if found (or null instead)
  93723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93724. */
  93725. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93726. /**
  93727. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93728. * @returns the parameters
  93729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93730. */
  93731. getFacetDataParameters(): any;
  93732. /**
  93733. * Disables the feature FacetData and frees the related memory
  93734. * @returns the current mesh
  93735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93736. */
  93737. disableFacetData(): AbstractMesh;
  93738. /**
  93739. * Updates the AbstractMesh indices array
  93740. * @param indices defines the data source
  93741. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93742. * @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)
  93743. * @returns the current mesh
  93744. */
  93745. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93746. /**
  93747. * Creates new normals data for the mesh
  93748. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93749. * @returns the current mesh
  93750. */
  93751. createNormals(updatable: boolean): AbstractMesh;
  93752. /**
  93753. * Align the mesh with a normal
  93754. * @param normal defines the normal to use
  93755. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93756. * @returns the current mesh
  93757. */
  93758. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93759. /** @hidden */
  93760. _checkOcclusionQuery(): boolean;
  93761. /**
  93762. * Disables the mesh edge rendering mode
  93763. * @returns the currentAbstractMesh
  93764. */
  93765. disableEdgesRendering(): AbstractMesh;
  93766. /**
  93767. * Enables the edge rendering mode on the mesh.
  93768. * This mode makes the mesh edges visible
  93769. * @param epsilon defines the maximal distance between two angles to detect a face
  93770. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93771. * @returns the currentAbstractMesh
  93772. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93773. */
  93774. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93775. }
  93776. }
  93777. declare module BABYLON {
  93778. /**
  93779. * Interface used to define ActionEvent
  93780. */
  93781. export interface IActionEvent {
  93782. /** The mesh or sprite that triggered the action */
  93783. source: any;
  93784. /** The X mouse cursor position at the time of the event */
  93785. pointerX: number;
  93786. /** The Y mouse cursor position at the time of the event */
  93787. pointerY: number;
  93788. /** The mesh that is currently pointed at (can be null) */
  93789. meshUnderPointer: Nullable<AbstractMesh>;
  93790. /** the original (browser) event that triggered the ActionEvent */
  93791. sourceEvent?: any;
  93792. /** additional data for the event */
  93793. additionalData?: any;
  93794. }
  93795. /**
  93796. * ActionEvent is the event being sent when an action is triggered.
  93797. */
  93798. export class ActionEvent implements IActionEvent {
  93799. /** The mesh or sprite that triggered the action */
  93800. source: any;
  93801. /** The X mouse cursor position at the time of the event */
  93802. pointerX: number;
  93803. /** The Y mouse cursor position at the time of the event */
  93804. pointerY: number;
  93805. /** The mesh that is currently pointed at (can be null) */
  93806. meshUnderPointer: Nullable<AbstractMesh>;
  93807. /** the original (browser) event that triggered the ActionEvent */
  93808. sourceEvent?: any;
  93809. /** additional data for the event */
  93810. additionalData?: any;
  93811. /**
  93812. * Creates a new ActionEvent
  93813. * @param source The mesh or sprite that triggered the action
  93814. * @param pointerX The X mouse cursor position at the time of the event
  93815. * @param pointerY The Y mouse cursor position at the time of the event
  93816. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93817. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93818. * @param additionalData additional data for the event
  93819. */
  93820. constructor(
  93821. /** The mesh or sprite that triggered the action */
  93822. source: any,
  93823. /** The X mouse cursor position at the time of the event */
  93824. pointerX: number,
  93825. /** The Y mouse cursor position at the time of the event */
  93826. pointerY: number,
  93827. /** The mesh that is currently pointed at (can be null) */
  93828. meshUnderPointer: Nullable<AbstractMesh>,
  93829. /** the original (browser) event that triggered the ActionEvent */
  93830. sourceEvent?: any,
  93831. /** additional data for the event */
  93832. additionalData?: any);
  93833. /**
  93834. * Helper function to auto-create an ActionEvent from a source mesh.
  93835. * @param source The source mesh that triggered the event
  93836. * @param evt The original (browser) event
  93837. * @param additionalData additional data for the event
  93838. * @returns the new ActionEvent
  93839. */
  93840. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93841. /**
  93842. * Helper function to auto-create an ActionEvent from a source sprite
  93843. * @param source The source sprite that triggered the event
  93844. * @param scene Scene associated with the sprite
  93845. * @param evt The original (browser) event
  93846. * @param additionalData additional data for the event
  93847. * @returns the new ActionEvent
  93848. */
  93849. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93850. /**
  93851. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93852. * @param scene the scene where the event occurred
  93853. * @param evt The original (browser) event
  93854. * @returns the new ActionEvent
  93855. */
  93856. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93857. /**
  93858. * Helper function to auto-create an ActionEvent from a primitive
  93859. * @param prim defines the target primitive
  93860. * @param pointerPos defines the pointer position
  93861. * @param evt The original (browser) event
  93862. * @param additionalData additional data for the event
  93863. * @returns the new ActionEvent
  93864. */
  93865. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93866. }
  93867. }
  93868. declare module BABYLON {
  93869. /**
  93870. * Abstract class used to decouple action Manager from scene and meshes.
  93871. * Do not instantiate.
  93872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93873. */
  93874. export abstract class AbstractActionManager implements IDisposable {
  93875. /** Gets the list of active triggers */
  93876. static Triggers: {
  93877. [key: string]: number;
  93878. };
  93879. /** Gets the cursor to use when hovering items */
  93880. hoverCursor: string;
  93881. /** Gets the list of actions */
  93882. actions: IAction[];
  93883. /**
  93884. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93885. */
  93886. isRecursive: boolean;
  93887. /**
  93888. * Releases all associated resources
  93889. */
  93890. abstract dispose(): void;
  93891. /**
  93892. * Does this action manager has pointer triggers
  93893. */
  93894. abstract readonly hasPointerTriggers: boolean;
  93895. /**
  93896. * Does this action manager has pick triggers
  93897. */
  93898. abstract readonly hasPickTriggers: boolean;
  93899. /**
  93900. * Process a specific trigger
  93901. * @param trigger defines the trigger to process
  93902. * @param evt defines the event details to be processed
  93903. */
  93904. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93905. /**
  93906. * Does this action manager handles actions of any of the given triggers
  93907. * @param triggers defines the triggers to be tested
  93908. * @return a boolean indicating whether one (or more) of the triggers is handled
  93909. */
  93910. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93911. /**
  93912. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93913. * speed.
  93914. * @param triggerA defines the trigger to be tested
  93915. * @param triggerB defines the trigger to be tested
  93916. * @return a boolean indicating whether one (or more) of the triggers is handled
  93917. */
  93918. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93919. /**
  93920. * Does this action manager handles actions of a given trigger
  93921. * @param trigger defines the trigger to be tested
  93922. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93923. * @return whether the trigger is handled
  93924. */
  93925. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93926. /**
  93927. * Serialize this manager to a JSON object
  93928. * @param name defines the property name to store this manager
  93929. * @returns a JSON representation of this manager
  93930. */
  93931. abstract serialize(name: string): any;
  93932. /**
  93933. * Registers an action to this action manager
  93934. * @param action defines the action to be registered
  93935. * @return the action amended (prepared) after registration
  93936. */
  93937. abstract registerAction(action: IAction): Nullable<IAction>;
  93938. /**
  93939. * Unregisters an action to this action manager
  93940. * @param action defines the action to be unregistered
  93941. * @return a boolean indicating whether the action has been unregistered
  93942. */
  93943. abstract unregisterAction(action: IAction): Boolean;
  93944. /**
  93945. * Does exist one action manager with at least one trigger
  93946. **/
  93947. static readonly HasTriggers: boolean;
  93948. /**
  93949. * Does exist one action manager with at least one pick trigger
  93950. **/
  93951. static readonly HasPickTriggers: boolean;
  93952. /**
  93953. * Does exist one action manager that handles actions of a given trigger
  93954. * @param trigger defines the trigger to be tested
  93955. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93956. **/
  93957. static HasSpecificTrigger(trigger: number): boolean;
  93958. }
  93959. }
  93960. declare module BABYLON {
  93961. /**
  93962. * Defines how a node can be built from a string name.
  93963. */
  93964. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93965. /**
  93966. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93967. */
  93968. export class Node implements IBehaviorAware<Node> {
  93969. /** @hidden */
  93970. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93971. private static _NodeConstructors;
  93972. /**
  93973. * Add a new node constructor
  93974. * @param type defines the type name of the node to construct
  93975. * @param constructorFunc defines the constructor function
  93976. */
  93977. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93978. /**
  93979. * Returns a node constructor based on type name
  93980. * @param type defines the type name
  93981. * @param name defines the new node name
  93982. * @param scene defines the hosting scene
  93983. * @param options defines optional options to transmit to constructors
  93984. * @returns the new constructor or null
  93985. */
  93986. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93987. /**
  93988. * Gets or sets the name of the node
  93989. */
  93990. name: string;
  93991. /**
  93992. * Gets or sets the id of the node
  93993. */
  93994. id: string;
  93995. /**
  93996. * Gets or sets the unique id of the node
  93997. */
  93998. uniqueId: number;
  93999. /**
  94000. * Gets or sets a string used to store user defined state for the node
  94001. */
  94002. state: string;
  94003. /**
  94004. * Gets or sets an object used to store user defined information for the node
  94005. */
  94006. metadata: any;
  94007. /**
  94008. * For internal use only. Please do not use.
  94009. */
  94010. reservedDataStore: any;
  94011. /**
  94012. * List of inspectable custom properties (used by the Inspector)
  94013. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94014. */
  94015. inspectableCustomProperties: IInspectable[];
  94016. private _doNotSerialize;
  94017. /**
  94018. * Gets or sets a boolean used to define if the node must be serialized
  94019. */
  94020. doNotSerialize: boolean;
  94021. /** @hidden */
  94022. _isDisposed: boolean;
  94023. /**
  94024. * Gets a list of Animations associated with the node
  94025. */
  94026. animations: Animation[];
  94027. protected _ranges: {
  94028. [name: string]: Nullable<AnimationRange>;
  94029. };
  94030. /**
  94031. * Callback raised when the node is ready to be used
  94032. */
  94033. onReady: Nullable<(node: Node) => void>;
  94034. private _isEnabled;
  94035. private _isParentEnabled;
  94036. private _isReady;
  94037. /** @hidden */
  94038. _currentRenderId: number;
  94039. private _parentUpdateId;
  94040. /** @hidden */
  94041. _childUpdateId: number;
  94042. /** @hidden */
  94043. _waitingParentId: Nullable<string>;
  94044. /** @hidden */
  94045. _scene: Scene;
  94046. /** @hidden */
  94047. _cache: any;
  94048. private _parentNode;
  94049. private _children;
  94050. /** @hidden */
  94051. _worldMatrix: Matrix;
  94052. /** @hidden */
  94053. _worldMatrixDeterminant: number;
  94054. /** @hidden */
  94055. _worldMatrixDeterminantIsDirty: boolean;
  94056. /** @hidden */
  94057. private _sceneRootNodesIndex;
  94058. /**
  94059. * Gets a boolean indicating if the node has been disposed
  94060. * @returns true if the node was disposed
  94061. */
  94062. isDisposed(): boolean;
  94063. /**
  94064. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94065. * @see https://doc.babylonjs.com/how_to/parenting
  94066. */
  94067. parent: Nullable<Node>;
  94068. private addToSceneRootNodes;
  94069. private removeFromSceneRootNodes;
  94070. private _animationPropertiesOverride;
  94071. /**
  94072. * Gets or sets the animation properties override
  94073. */
  94074. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94075. /**
  94076. * Gets a string idenfifying the name of the class
  94077. * @returns "Node" string
  94078. */
  94079. getClassName(): string;
  94080. /** @hidden */
  94081. readonly _isNode: boolean;
  94082. /**
  94083. * An event triggered when the mesh is disposed
  94084. */
  94085. onDisposeObservable: Observable<Node>;
  94086. private _onDisposeObserver;
  94087. /**
  94088. * Sets a callback that will be raised when the node will be disposed
  94089. */
  94090. onDispose: () => void;
  94091. /**
  94092. * Creates a new Node
  94093. * @param name the name and id to be given to this node
  94094. * @param scene the scene this node will be added to
  94095. * @param addToRootNodes the node will be added to scene.rootNodes
  94096. */
  94097. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94098. /**
  94099. * Gets the scene of the node
  94100. * @returns a scene
  94101. */
  94102. getScene(): Scene;
  94103. /**
  94104. * Gets the engine of the node
  94105. * @returns a Engine
  94106. */
  94107. getEngine(): Engine;
  94108. private _behaviors;
  94109. /**
  94110. * Attach a behavior to the node
  94111. * @see http://doc.babylonjs.com/features/behaviour
  94112. * @param behavior defines the behavior to attach
  94113. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94114. * @returns the current Node
  94115. */
  94116. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94117. /**
  94118. * Remove an attached behavior
  94119. * @see http://doc.babylonjs.com/features/behaviour
  94120. * @param behavior defines the behavior to attach
  94121. * @returns the current Node
  94122. */
  94123. removeBehavior(behavior: Behavior<Node>): Node;
  94124. /**
  94125. * Gets the list of attached behaviors
  94126. * @see http://doc.babylonjs.com/features/behaviour
  94127. */
  94128. readonly behaviors: Behavior<Node>[];
  94129. /**
  94130. * Gets an attached behavior by name
  94131. * @param name defines the name of the behavior to look for
  94132. * @see http://doc.babylonjs.com/features/behaviour
  94133. * @returns null if behavior was not found else the requested behavior
  94134. */
  94135. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94136. /**
  94137. * Returns the latest update of the World matrix
  94138. * @returns a Matrix
  94139. */
  94140. getWorldMatrix(): Matrix;
  94141. /** @hidden */
  94142. _getWorldMatrixDeterminant(): number;
  94143. /**
  94144. * Returns directly the latest state of the mesh World matrix.
  94145. * A Matrix is returned.
  94146. */
  94147. readonly worldMatrixFromCache: Matrix;
  94148. /** @hidden */
  94149. _initCache(): void;
  94150. /** @hidden */
  94151. updateCache(force?: boolean): void;
  94152. /** @hidden */
  94153. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94154. /** @hidden */
  94155. _updateCache(ignoreParentClass?: boolean): void;
  94156. /** @hidden */
  94157. _isSynchronized(): boolean;
  94158. /** @hidden */
  94159. _markSyncedWithParent(): void;
  94160. /** @hidden */
  94161. isSynchronizedWithParent(): boolean;
  94162. /** @hidden */
  94163. isSynchronized(): boolean;
  94164. /**
  94165. * Is this node ready to be used/rendered
  94166. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94167. * @return true if the node is ready
  94168. */
  94169. isReady(completeCheck?: boolean): boolean;
  94170. /**
  94171. * Is this node enabled?
  94172. * 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
  94173. * @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
  94174. * @return whether this node (and its parent) is enabled
  94175. */
  94176. isEnabled(checkAncestors?: boolean): boolean;
  94177. /** @hidden */
  94178. protected _syncParentEnabledState(): void;
  94179. /**
  94180. * Set the enabled state of this node
  94181. * @param value defines the new enabled state
  94182. */
  94183. setEnabled(value: boolean): void;
  94184. /**
  94185. * Is this node a descendant of the given node?
  94186. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94187. * @param ancestor defines the parent node to inspect
  94188. * @returns a boolean indicating if this node is a descendant of the given node
  94189. */
  94190. isDescendantOf(ancestor: Node): boolean;
  94191. /** @hidden */
  94192. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94193. /**
  94194. * Will return all nodes that have this node as ascendant
  94195. * @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
  94196. * @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
  94197. * @return all children nodes of all types
  94198. */
  94199. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94200. /**
  94201. * Get all child-meshes of this node
  94202. * @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)
  94203. * @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
  94204. * @returns an array of AbstractMesh
  94205. */
  94206. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94207. /**
  94208. * Get all direct children of this node
  94209. * @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
  94210. * @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)
  94211. * @returns an array of Node
  94212. */
  94213. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94214. /** @hidden */
  94215. _setReady(state: boolean): void;
  94216. /**
  94217. * Get an animation by name
  94218. * @param name defines the name of the animation to look for
  94219. * @returns null if not found else the requested animation
  94220. */
  94221. getAnimationByName(name: string): Nullable<Animation>;
  94222. /**
  94223. * Creates an animation range for this node
  94224. * @param name defines the name of the range
  94225. * @param from defines the starting key
  94226. * @param to defines the end key
  94227. */
  94228. createAnimationRange(name: string, from: number, to: number): void;
  94229. /**
  94230. * Delete a specific animation range
  94231. * @param name defines the name of the range to delete
  94232. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94233. */
  94234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94235. /**
  94236. * Get an animation range by name
  94237. * @param name defines the name of the animation range to look for
  94238. * @returns null if not found else the requested animation range
  94239. */
  94240. getAnimationRange(name: string): Nullable<AnimationRange>;
  94241. /**
  94242. * Gets the list of all animation ranges defined on this node
  94243. * @returns an array
  94244. */
  94245. getAnimationRanges(): Nullable<AnimationRange>[];
  94246. /**
  94247. * Will start the animation sequence
  94248. * @param name defines the range frames for animation sequence
  94249. * @param loop defines if the animation should loop (false by default)
  94250. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94251. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94252. * @returns the object created for this animation. If range does not exist, it will return null
  94253. */
  94254. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94255. /**
  94256. * Serialize animation ranges into a JSON compatible object
  94257. * @returns serialization object
  94258. */
  94259. serializeAnimationRanges(): any;
  94260. /**
  94261. * Computes the world matrix of the node
  94262. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94263. * @returns the world matrix
  94264. */
  94265. computeWorldMatrix(force?: boolean): Matrix;
  94266. /**
  94267. * Releases resources associated with this node.
  94268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94270. */
  94271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94272. /**
  94273. * Parse animation range data from a serialization object and store them into a given node
  94274. * @param node defines where to store the animation ranges
  94275. * @param parsedNode defines the serialization object to read data from
  94276. * @param scene defines the hosting scene
  94277. */
  94278. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94279. /**
  94280. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94281. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94282. * @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
  94283. * @returns the new bounding vectors
  94284. */
  94285. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94286. min: Vector3;
  94287. max: Vector3;
  94288. };
  94289. }
  94290. }
  94291. declare module BABYLON {
  94292. /**
  94293. * @hidden
  94294. */
  94295. export class _IAnimationState {
  94296. key: number;
  94297. repeatCount: number;
  94298. workValue?: any;
  94299. loopMode?: number;
  94300. offsetValue?: any;
  94301. highLimitValue?: any;
  94302. }
  94303. /**
  94304. * Class used to store any kind of animation
  94305. */
  94306. export class Animation {
  94307. /**Name of the animation */
  94308. name: string;
  94309. /**Property to animate */
  94310. targetProperty: string;
  94311. /**The frames per second of the animation */
  94312. framePerSecond: number;
  94313. /**The data type of the animation */
  94314. dataType: number;
  94315. /**The loop mode of the animation */
  94316. loopMode?: number | undefined;
  94317. /**Specifies if blending should be enabled */
  94318. enableBlending?: boolean | undefined;
  94319. /**
  94320. * Use matrix interpolation instead of using direct key value when animating matrices
  94321. */
  94322. static AllowMatricesInterpolation: boolean;
  94323. /**
  94324. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94325. */
  94326. static AllowMatrixDecomposeForInterpolation: boolean;
  94327. /**
  94328. * Stores the key frames of the animation
  94329. */
  94330. private _keys;
  94331. /**
  94332. * Stores the easing function of the animation
  94333. */
  94334. private _easingFunction;
  94335. /**
  94336. * @hidden Internal use only
  94337. */
  94338. _runtimeAnimations: RuntimeAnimation[];
  94339. /**
  94340. * The set of event that will be linked to this animation
  94341. */
  94342. private _events;
  94343. /**
  94344. * Stores an array of target property paths
  94345. */
  94346. targetPropertyPath: string[];
  94347. /**
  94348. * Stores the blending speed of the animation
  94349. */
  94350. blendingSpeed: number;
  94351. /**
  94352. * Stores the animation ranges for the animation
  94353. */
  94354. private _ranges;
  94355. /**
  94356. * @hidden Internal use
  94357. */
  94358. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94359. /**
  94360. * Sets up an animation
  94361. * @param property The property to animate
  94362. * @param animationType The animation type to apply
  94363. * @param framePerSecond The frames per second of the animation
  94364. * @param easingFunction The easing function used in the animation
  94365. * @returns The created animation
  94366. */
  94367. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94368. /**
  94369. * Create and start an animation on a node
  94370. * @param name defines the name of the global animation that will be run on all nodes
  94371. * @param node defines the root node where the animation will take place
  94372. * @param targetProperty defines property to animate
  94373. * @param framePerSecond defines the number of frame per second yo use
  94374. * @param totalFrame defines the number of frames in total
  94375. * @param from defines the initial value
  94376. * @param to defines the final value
  94377. * @param loopMode defines which loop mode you want to use (off by default)
  94378. * @param easingFunction defines the easing function to use (linear by default)
  94379. * @param onAnimationEnd defines the callback to call when animation end
  94380. * @returns the animatable created for this animation
  94381. */
  94382. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94383. /**
  94384. * Create and start an animation on a node and its descendants
  94385. * @param name defines the name of the global animation that will be run on all nodes
  94386. * @param node defines the root node where the animation will take place
  94387. * @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
  94388. * @param targetProperty defines property to animate
  94389. * @param framePerSecond defines the number of frame per second to use
  94390. * @param totalFrame defines the number of frames in total
  94391. * @param from defines the initial value
  94392. * @param to defines the final value
  94393. * @param loopMode defines which loop mode you want to use (off by default)
  94394. * @param easingFunction defines the easing function to use (linear by default)
  94395. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94396. * @returns the list of animatables created for all nodes
  94397. * @example https://www.babylonjs-playground.com/#MH0VLI
  94398. */
  94399. 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[]>;
  94400. /**
  94401. * Creates a new animation, merges it with the existing animations and starts it
  94402. * @param name Name of the animation
  94403. * @param node Node which contains the scene that begins the animations
  94404. * @param targetProperty Specifies which property to animate
  94405. * @param framePerSecond The frames per second of the animation
  94406. * @param totalFrame The total number of frames
  94407. * @param from The frame at the beginning of the animation
  94408. * @param to The frame at the end of the animation
  94409. * @param loopMode Specifies the loop mode of the animation
  94410. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94411. * @param onAnimationEnd Callback to run once the animation is complete
  94412. * @returns Nullable animation
  94413. */
  94414. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94415. /**
  94416. * Transition property of an host to the target Value
  94417. * @param property The property to transition
  94418. * @param targetValue The target Value of the property
  94419. * @param host The object where the property to animate belongs
  94420. * @param scene Scene used to run the animation
  94421. * @param frameRate Framerate (in frame/s) to use
  94422. * @param transition The transition type we want to use
  94423. * @param duration The duration of the animation, in milliseconds
  94424. * @param onAnimationEnd Callback trigger at the end of the animation
  94425. * @returns Nullable animation
  94426. */
  94427. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94428. /**
  94429. * Return the array of runtime animations currently using this animation
  94430. */
  94431. readonly runtimeAnimations: RuntimeAnimation[];
  94432. /**
  94433. * Specifies if any of the runtime animations are currently running
  94434. */
  94435. readonly hasRunningRuntimeAnimations: boolean;
  94436. /**
  94437. * Initializes the animation
  94438. * @param name Name of the animation
  94439. * @param targetProperty Property to animate
  94440. * @param framePerSecond The frames per second of the animation
  94441. * @param dataType The data type of the animation
  94442. * @param loopMode The loop mode of the animation
  94443. * @param enableBlending Specifies if blending should be enabled
  94444. */
  94445. constructor(
  94446. /**Name of the animation */
  94447. name: string,
  94448. /**Property to animate */
  94449. targetProperty: string,
  94450. /**The frames per second of the animation */
  94451. framePerSecond: number,
  94452. /**The data type of the animation */
  94453. dataType: number,
  94454. /**The loop mode of the animation */
  94455. loopMode?: number | undefined,
  94456. /**Specifies if blending should be enabled */
  94457. enableBlending?: boolean | undefined);
  94458. /**
  94459. * Converts the animation to a string
  94460. * @param fullDetails support for multiple levels of logging within scene loading
  94461. * @returns String form of the animation
  94462. */
  94463. toString(fullDetails?: boolean): string;
  94464. /**
  94465. * Add an event to this animation
  94466. * @param event Event to add
  94467. */
  94468. addEvent(event: AnimationEvent): void;
  94469. /**
  94470. * Remove all events found at the given frame
  94471. * @param frame The frame to remove events from
  94472. */
  94473. removeEvents(frame: number): void;
  94474. /**
  94475. * Retrieves all the events from the animation
  94476. * @returns Events from the animation
  94477. */
  94478. getEvents(): AnimationEvent[];
  94479. /**
  94480. * Creates an animation range
  94481. * @param name Name of the animation range
  94482. * @param from Starting frame of the animation range
  94483. * @param to Ending frame of the animation
  94484. */
  94485. createRange(name: string, from: number, to: number): void;
  94486. /**
  94487. * Deletes an animation range by name
  94488. * @param name Name of the animation range to delete
  94489. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94490. */
  94491. deleteRange(name: string, deleteFrames?: boolean): void;
  94492. /**
  94493. * Gets the animation range by name, or null if not defined
  94494. * @param name Name of the animation range
  94495. * @returns Nullable animation range
  94496. */
  94497. getRange(name: string): Nullable<AnimationRange>;
  94498. /**
  94499. * Gets the key frames from the animation
  94500. * @returns The key frames of the animation
  94501. */
  94502. getKeys(): Array<IAnimationKey>;
  94503. /**
  94504. * Gets the highest frame rate of the animation
  94505. * @returns Highest frame rate of the animation
  94506. */
  94507. getHighestFrame(): number;
  94508. /**
  94509. * Gets the easing function of the animation
  94510. * @returns Easing function of the animation
  94511. */
  94512. getEasingFunction(): IEasingFunction;
  94513. /**
  94514. * Sets the easing function of the animation
  94515. * @param easingFunction A custom mathematical formula for animation
  94516. */
  94517. setEasingFunction(easingFunction: EasingFunction): void;
  94518. /**
  94519. * Interpolates a scalar linearly
  94520. * @param startValue Start value of the animation curve
  94521. * @param endValue End value of the animation curve
  94522. * @param gradient Scalar amount to interpolate
  94523. * @returns Interpolated scalar value
  94524. */
  94525. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94526. /**
  94527. * Interpolates a scalar cubically
  94528. * @param startValue Start value of the animation curve
  94529. * @param outTangent End tangent of the animation
  94530. * @param endValue End value of the animation curve
  94531. * @param inTangent Start tangent of the animation curve
  94532. * @param gradient Scalar amount to interpolate
  94533. * @returns Interpolated scalar value
  94534. */
  94535. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94536. /**
  94537. * Interpolates a quaternion using a spherical linear interpolation
  94538. * @param startValue Start value of the animation curve
  94539. * @param endValue End value of the animation curve
  94540. * @param gradient Scalar amount to interpolate
  94541. * @returns Interpolated quaternion value
  94542. */
  94543. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94544. /**
  94545. * Interpolates a quaternion cubically
  94546. * @param startValue Start value of the animation curve
  94547. * @param outTangent End tangent of the animation curve
  94548. * @param endValue End value of the animation curve
  94549. * @param inTangent Start tangent of the animation curve
  94550. * @param gradient Scalar amount to interpolate
  94551. * @returns Interpolated quaternion value
  94552. */
  94553. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94554. /**
  94555. * Interpolates a Vector3 linearl
  94556. * @param startValue Start value of the animation curve
  94557. * @param endValue End value of the animation curve
  94558. * @param gradient Scalar amount to interpolate
  94559. * @returns Interpolated scalar value
  94560. */
  94561. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94562. /**
  94563. * Interpolates a Vector3 cubically
  94564. * @param startValue Start value of the animation curve
  94565. * @param outTangent End tangent of the animation
  94566. * @param endValue End value of the animation curve
  94567. * @param inTangent Start tangent of the animation curve
  94568. * @param gradient Scalar amount to interpolate
  94569. * @returns InterpolatedVector3 value
  94570. */
  94571. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94572. /**
  94573. * Interpolates a Vector2 linearly
  94574. * @param startValue Start value of the animation curve
  94575. * @param endValue End value of the animation curve
  94576. * @param gradient Scalar amount to interpolate
  94577. * @returns Interpolated Vector2 value
  94578. */
  94579. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94580. /**
  94581. * Interpolates a Vector2 cubically
  94582. * @param startValue Start value of the animation curve
  94583. * @param outTangent End tangent of the animation
  94584. * @param endValue End value of the animation curve
  94585. * @param inTangent Start tangent of the animation curve
  94586. * @param gradient Scalar amount to interpolate
  94587. * @returns Interpolated Vector2 value
  94588. */
  94589. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94590. /**
  94591. * Interpolates a size linearly
  94592. * @param startValue Start value of the animation curve
  94593. * @param endValue End value of the animation curve
  94594. * @param gradient Scalar amount to interpolate
  94595. * @returns Interpolated Size value
  94596. */
  94597. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94598. /**
  94599. * Interpolates a Color3 linearly
  94600. * @param startValue Start value of the animation curve
  94601. * @param endValue End value of the animation curve
  94602. * @param gradient Scalar amount to interpolate
  94603. * @returns Interpolated Color3 value
  94604. */
  94605. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94606. /**
  94607. * @hidden Internal use only
  94608. */
  94609. _getKeyValue(value: any): any;
  94610. /**
  94611. * @hidden Internal use only
  94612. */
  94613. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94614. /**
  94615. * Defines the function to use to interpolate matrices
  94616. * @param startValue defines the start matrix
  94617. * @param endValue defines the end matrix
  94618. * @param gradient defines the gradient between both matrices
  94619. * @param result defines an optional target matrix where to store the interpolation
  94620. * @returns the interpolated matrix
  94621. */
  94622. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94623. /**
  94624. * Makes a copy of the animation
  94625. * @returns Cloned animation
  94626. */
  94627. clone(): Animation;
  94628. /**
  94629. * Sets the key frames of the animation
  94630. * @param values The animation key frames to set
  94631. */
  94632. setKeys(values: Array<IAnimationKey>): void;
  94633. /**
  94634. * Serializes the animation to an object
  94635. * @returns Serialized object
  94636. */
  94637. serialize(): any;
  94638. /**
  94639. * Float animation type
  94640. */
  94641. private static _ANIMATIONTYPE_FLOAT;
  94642. /**
  94643. * Vector3 animation type
  94644. */
  94645. private static _ANIMATIONTYPE_VECTOR3;
  94646. /**
  94647. * Quaternion animation type
  94648. */
  94649. private static _ANIMATIONTYPE_QUATERNION;
  94650. /**
  94651. * Matrix animation type
  94652. */
  94653. private static _ANIMATIONTYPE_MATRIX;
  94654. /**
  94655. * Color3 animation type
  94656. */
  94657. private static _ANIMATIONTYPE_COLOR3;
  94658. /**
  94659. * Vector2 animation type
  94660. */
  94661. private static _ANIMATIONTYPE_VECTOR2;
  94662. /**
  94663. * Size animation type
  94664. */
  94665. private static _ANIMATIONTYPE_SIZE;
  94666. /**
  94667. * Relative Loop Mode
  94668. */
  94669. private static _ANIMATIONLOOPMODE_RELATIVE;
  94670. /**
  94671. * Cycle Loop Mode
  94672. */
  94673. private static _ANIMATIONLOOPMODE_CYCLE;
  94674. /**
  94675. * Constant Loop Mode
  94676. */
  94677. private static _ANIMATIONLOOPMODE_CONSTANT;
  94678. /**
  94679. * Get the float animation type
  94680. */
  94681. static readonly ANIMATIONTYPE_FLOAT: number;
  94682. /**
  94683. * Get the Vector3 animation type
  94684. */
  94685. static readonly ANIMATIONTYPE_VECTOR3: number;
  94686. /**
  94687. * Get the Vector2 animation type
  94688. */
  94689. static readonly ANIMATIONTYPE_VECTOR2: number;
  94690. /**
  94691. * Get the Size animation type
  94692. */
  94693. static readonly ANIMATIONTYPE_SIZE: number;
  94694. /**
  94695. * Get the Quaternion animation type
  94696. */
  94697. static readonly ANIMATIONTYPE_QUATERNION: number;
  94698. /**
  94699. * Get the Matrix animation type
  94700. */
  94701. static readonly ANIMATIONTYPE_MATRIX: number;
  94702. /**
  94703. * Get the Color3 animation type
  94704. */
  94705. static readonly ANIMATIONTYPE_COLOR3: number;
  94706. /**
  94707. * Get the Relative Loop Mode
  94708. */
  94709. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94710. /**
  94711. * Get the Cycle Loop Mode
  94712. */
  94713. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94714. /**
  94715. * Get the Constant Loop Mode
  94716. */
  94717. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94718. /** @hidden */
  94719. static _UniversalLerp(left: any, right: any, amount: number): any;
  94720. /**
  94721. * Parses an animation object and creates an animation
  94722. * @param parsedAnimation Parsed animation object
  94723. * @returns Animation object
  94724. */
  94725. static Parse(parsedAnimation: any): Animation;
  94726. /**
  94727. * Appends the serialized animations from the source animations
  94728. * @param source Source containing the animations
  94729. * @param destination Target to store the animations
  94730. */
  94731. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94732. }
  94733. }
  94734. declare module BABYLON {
  94735. /**
  94736. * Interface containing an array of animations
  94737. */
  94738. export interface IAnimatable {
  94739. /**
  94740. * Array of animations
  94741. */
  94742. animations: Nullable<Array<Animation>>;
  94743. }
  94744. }
  94745. declare module BABYLON {
  94746. /**
  94747. * This represents all the required information to add a fresnel effect on a material:
  94748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94749. */
  94750. export class FresnelParameters {
  94751. private _isEnabled;
  94752. /**
  94753. * Define if the fresnel effect is enable or not.
  94754. */
  94755. isEnabled: boolean;
  94756. /**
  94757. * Define the color used on edges (grazing angle)
  94758. */
  94759. leftColor: Color3;
  94760. /**
  94761. * Define the color used on center
  94762. */
  94763. rightColor: Color3;
  94764. /**
  94765. * Define bias applied to computed fresnel term
  94766. */
  94767. bias: number;
  94768. /**
  94769. * Defined the power exponent applied to fresnel term
  94770. */
  94771. power: number;
  94772. /**
  94773. * Clones the current fresnel and its valuues
  94774. * @returns a clone fresnel configuration
  94775. */
  94776. clone(): FresnelParameters;
  94777. /**
  94778. * Serializes the current fresnel parameters to a JSON representation.
  94779. * @return the JSON serialization
  94780. */
  94781. serialize(): any;
  94782. /**
  94783. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94784. * @param parsedFresnelParameters Define the JSON representation
  94785. * @returns the parsed parameters
  94786. */
  94787. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94788. }
  94789. }
  94790. declare module BABYLON {
  94791. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94792. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94793. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94794. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94795. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94796. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94797. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94798. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94799. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94800. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94801. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94802. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94803. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94804. /**
  94805. * Decorator used to define property that can be serialized as reference to a camera
  94806. * @param sourceName defines the name of the property to decorate
  94807. */
  94808. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94809. /**
  94810. * Class used to help serialization objects
  94811. */
  94812. export class SerializationHelper {
  94813. /** @hidden */
  94814. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94815. /** @hidden */
  94816. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94817. /** @hidden */
  94818. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94819. /** @hidden */
  94820. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94821. /**
  94822. * Appends the serialized animations from the source animations
  94823. * @param source Source containing the animations
  94824. * @param destination Target to store the animations
  94825. */
  94826. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94827. /**
  94828. * Static function used to serialized a specific entity
  94829. * @param entity defines the entity to serialize
  94830. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94831. * @returns a JSON compatible object representing the serialization of the entity
  94832. */
  94833. static Serialize<T>(entity: T, serializationObject?: any): any;
  94834. /**
  94835. * Creates a new entity from a serialization data object
  94836. * @param creationFunction defines a function used to instanciated the new entity
  94837. * @param source defines the source serialization data
  94838. * @param scene defines the hosting scene
  94839. * @param rootUrl defines the root url for resources
  94840. * @returns a new entity
  94841. */
  94842. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94843. /**
  94844. * Clones an object
  94845. * @param creationFunction defines the function used to instanciate the new object
  94846. * @param source defines the source object
  94847. * @returns the cloned object
  94848. */
  94849. static Clone<T>(creationFunction: () => T, source: T): T;
  94850. /**
  94851. * Instanciates a new object based on a source one (some data will be shared between both object)
  94852. * @param creationFunction defines the function used to instanciate the new object
  94853. * @param source defines the source object
  94854. * @returns the new object
  94855. */
  94856. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94857. }
  94858. }
  94859. declare module BABYLON {
  94860. /**
  94861. * Class used to manipulate GUIDs
  94862. */
  94863. export class GUID {
  94864. /**
  94865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94866. * Be aware Math.random() could cause collisions, but:
  94867. * "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"
  94868. * @returns a pseudo random id
  94869. */
  94870. static RandomId(): string;
  94871. }
  94872. }
  94873. declare module BABYLON {
  94874. /**
  94875. * Base class of all the textures in babylon.
  94876. * It groups all the common properties the materials, post process, lights... might need
  94877. * in order to make a correct use of the texture.
  94878. */
  94879. export class BaseTexture implements IAnimatable {
  94880. /**
  94881. * Default anisotropic filtering level for the application.
  94882. * It is set to 4 as a good tradeoff between perf and quality.
  94883. */
  94884. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94885. /**
  94886. * Gets or sets the unique id of the texture
  94887. */
  94888. uniqueId: number;
  94889. /**
  94890. * Define the name of the texture.
  94891. */
  94892. name: string;
  94893. /**
  94894. * Gets or sets an object used to store user defined information.
  94895. */
  94896. metadata: any;
  94897. /**
  94898. * For internal use only. Please do not use.
  94899. */
  94900. reservedDataStore: any;
  94901. private _hasAlpha;
  94902. /**
  94903. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94904. */
  94905. hasAlpha: boolean;
  94906. /**
  94907. * Defines if the alpha value should be determined via the rgb values.
  94908. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94909. */
  94910. getAlphaFromRGB: boolean;
  94911. /**
  94912. * Intensity or strength of the texture.
  94913. * It is commonly used by materials to fine tune the intensity of the texture
  94914. */
  94915. level: number;
  94916. /**
  94917. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94918. * This is part of the texture as textures usually maps to one uv set.
  94919. */
  94920. coordinatesIndex: number;
  94921. private _coordinatesMode;
  94922. /**
  94923. * How a texture is mapped.
  94924. *
  94925. * | Value | Type | Description |
  94926. * | ----- | ----------------------------------- | ----------- |
  94927. * | 0 | EXPLICIT_MODE | |
  94928. * | 1 | SPHERICAL_MODE | |
  94929. * | 2 | PLANAR_MODE | |
  94930. * | 3 | CUBIC_MODE | |
  94931. * | 4 | PROJECTION_MODE | |
  94932. * | 5 | SKYBOX_MODE | |
  94933. * | 6 | INVCUBIC_MODE | |
  94934. * | 7 | EQUIRECTANGULAR_MODE | |
  94935. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94936. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94937. */
  94938. coordinatesMode: number;
  94939. /**
  94940. * | Value | Type | Description |
  94941. * | ----- | ------------------ | ----------- |
  94942. * | 0 | CLAMP_ADDRESSMODE | |
  94943. * | 1 | WRAP_ADDRESSMODE | |
  94944. * | 2 | MIRROR_ADDRESSMODE | |
  94945. */
  94946. wrapU: number;
  94947. /**
  94948. * | Value | Type | Description |
  94949. * | ----- | ------------------ | ----------- |
  94950. * | 0 | CLAMP_ADDRESSMODE | |
  94951. * | 1 | WRAP_ADDRESSMODE | |
  94952. * | 2 | MIRROR_ADDRESSMODE | |
  94953. */
  94954. wrapV: number;
  94955. /**
  94956. * | Value | Type | Description |
  94957. * | ----- | ------------------ | ----------- |
  94958. * | 0 | CLAMP_ADDRESSMODE | |
  94959. * | 1 | WRAP_ADDRESSMODE | |
  94960. * | 2 | MIRROR_ADDRESSMODE | |
  94961. */
  94962. wrapR: number;
  94963. /**
  94964. * With compliant hardware and browser (supporting anisotropic filtering)
  94965. * this defines the level of anisotropic filtering in the texture.
  94966. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94967. */
  94968. anisotropicFilteringLevel: number;
  94969. /**
  94970. * Define if the texture is a cube texture or if false a 2d texture.
  94971. */
  94972. isCube: boolean;
  94973. /**
  94974. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94975. */
  94976. is3D: boolean;
  94977. /**
  94978. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94979. * HDR texture are usually stored in linear space.
  94980. * This only impacts the PBR and Background materials
  94981. */
  94982. gammaSpace: boolean;
  94983. /**
  94984. * Gets or sets whether or not the texture contains RGBD data.
  94985. */
  94986. isRGBD: boolean;
  94987. /**
  94988. * Is Z inverted in the texture (useful in a cube texture).
  94989. */
  94990. invertZ: boolean;
  94991. /**
  94992. * Are mip maps generated for this texture or not.
  94993. */
  94994. readonly noMipmap: boolean;
  94995. /**
  94996. * @hidden
  94997. */
  94998. lodLevelInAlpha: boolean;
  94999. /**
  95000. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95001. */
  95002. lodGenerationOffset: number;
  95003. /**
  95004. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95005. */
  95006. lodGenerationScale: number;
  95007. /**
  95008. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95009. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95010. * average roughness values.
  95011. */
  95012. linearSpecularLOD: boolean;
  95013. /**
  95014. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95015. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95016. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95017. */
  95018. irradianceTexture: Nullable<BaseTexture>;
  95019. /**
  95020. * Define if the texture is a render target.
  95021. */
  95022. isRenderTarget: boolean;
  95023. /**
  95024. * Define the unique id of the texture in the scene.
  95025. */
  95026. readonly uid: string;
  95027. /**
  95028. * Return a string representation of the texture.
  95029. * @returns the texture as a string
  95030. */
  95031. toString(): string;
  95032. /**
  95033. * Get the class name of the texture.
  95034. * @returns "BaseTexture"
  95035. */
  95036. getClassName(): string;
  95037. /**
  95038. * Define the list of animation attached to the texture.
  95039. */
  95040. animations: Animation[];
  95041. /**
  95042. * An event triggered when the texture is disposed.
  95043. */
  95044. onDisposeObservable: Observable<BaseTexture>;
  95045. private _onDisposeObserver;
  95046. /**
  95047. * Callback triggered when the texture has been disposed.
  95048. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95049. */
  95050. onDispose: () => void;
  95051. /**
  95052. * Define the current state of the loading sequence when in delayed load mode.
  95053. */
  95054. delayLoadState: number;
  95055. private _scene;
  95056. /** @hidden */
  95057. _texture: Nullable<InternalTexture>;
  95058. private _uid;
  95059. /**
  95060. * Define if the texture is preventinga material to render or not.
  95061. * If not and the texture is not ready, the engine will use a default black texture instead.
  95062. */
  95063. readonly isBlocking: boolean;
  95064. /**
  95065. * Instantiates a new BaseTexture.
  95066. * Base class of all the textures in babylon.
  95067. * It groups all the common properties the materials, post process, lights... might need
  95068. * in order to make a correct use of the texture.
  95069. * @param scene Define the scene the texture blongs to
  95070. */
  95071. constructor(scene: Nullable<Scene>);
  95072. /**
  95073. * Get the scene the texture belongs to.
  95074. * @returns the scene or null if undefined
  95075. */
  95076. getScene(): Nullable<Scene>;
  95077. /**
  95078. * Get the texture transform matrix used to offset tile the texture for istance.
  95079. * @returns the transformation matrix
  95080. */
  95081. getTextureMatrix(): Matrix;
  95082. /**
  95083. * Get the texture reflection matrix used to rotate/transform the reflection.
  95084. * @returns the reflection matrix
  95085. */
  95086. getReflectionTextureMatrix(): Matrix;
  95087. /**
  95088. * Get the underlying lower level texture from Babylon.
  95089. * @returns the insternal texture
  95090. */
  95091. getInternalTexture(): Nullable<InternalTexture>;
  95092. /**
  95093. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95094. * @returns true if ready or not blocking
  95095. */
  95096. isReadyOrNotBlocking(): boolean;
  95097. /**
  95098. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95099. * @returns true if fully ready
  95100. */
  95101. isReady(): boolean;
  95102. private _cachedSize;
  95103. /**
  95104. * Get the size of the texture.
  95105. * @returns the texture size.
  95106. */
  95107. getSize(): ISize;
  95108. /**
  95109. * Get the base size of the texture.
  95110. * It can be different from the size if the texture has been resized for POT for instance
  95111. * @returns the base size
  95112. */
  95113. getBaseSize(): ISize;
  95114. /**
  95115. * Update the sampling mode of the texture.
  95116. * Default is Trilinear mode.
  95117. *
  95118. * | Value | Type | Description |
  95119. * | ----- | ------------------ | ----------- |
  95120. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95121. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95122. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95123. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95124. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95125. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95126. * | 7 | NEAREST_LINEAR | |
  95127. * | 8 | NEAREST_NEAREST | |
  95128. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95129. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95130. * | 11 | LINEAR_LINEAR | |
  95131. * | 12 | LINEAR_NEAREST | |
  95132. *
  95133. * > _mag_: magnification filter (close to the viewer)
  95134. * > _min_: minification filter (far from the viewer)
  95135. * > _mip_: filter used between mip map levels
  95136. *@param samplingMode Define the new sampling mode of the texture
  95137. */
  95138. updateSamplingMode(samplingMode: number): void;
  95139. /**
  95140. * Scales the texture if is `canRescale()`
  95141. * @param ratio the resize factor we want to use to rescale
  95142. */
  95143. scale(ratio: number): void;
  95144. /**
  95145. * Get if the texture can rescale.
  95146. */
  95147. readonly canRescale: boolean;
  95148. /** @hidden */
  95149. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95150. /** @hidden */
  95151. _rebuild(): void;
  95152. /**
  95153. * Triggers the load sequence in delayed load mode.
  95154. */
  95155. delayLoad(): void;
  95156. /**
  95157. * Clones the texture.
  95158. * @returns the cloned texture
  95159. */
  95160. clone(): Nullable<BaseTexture>;
  95161. /**
  95162. * Get the texture underlying type (INT, FLOAT...)
  95163. */
  95164. readonly textureType: number;
  95165. /**
  95166. * Get the texture underlying format (RGB, RGBA...)
  95167. */
  95168. readonly textureFormat: number;
  95169. /**
  95170. * Indicates that textures need to be re-calculated for all materials
  95171. */
  95172. protected _markAllSubMeshesAsTexturesDirty(): void;
  95173. /**
  95174. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95175. * This will returns an RGBA array buffer containing either in values (0-255) or
  95176. * float values (0-1) depending of the underlying buffer type.
  95177. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95178. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95179. * @param buffer defines a user defined buffer to fill with data (can be null)
  95180. * @returns The Array buffer containing the pixels data.
  95181. */
  95182. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95183. /**
  95184. * Release and destroy the underlying lower level texture aka internalTexture.
  95185. */
  95186. releaseInternalTexture(): void;
  95187. /** @hidden */
  95188. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95189. /** @hidden */
  95190. readonly _lodTextureMid: Nullable<BaseTexture>;
  95191. /** @hidden */
  95192. readonly _lodTextureLow: Nullable<BaseTexture>;
  95193. /**
  95194. * Dispose the texture and release its associated resources.
  95195. */
  95196. dispose(): void;
  95197. /**
  95198. * Serialize the texture into a JSON representation that can be parsed later on.
  95199. * @returns the JSON representation of the texture
  95200. */
  95201. serialize(): any;
  95202. /**
  95203. * Helper function to be called back once a list of texture contains only ready textures.
  95204. * @param textures Define the list of textures to wait for
  95205. * @param callback Define the callback triggered once the entire list will be ready
  95206. */
  95207. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95208. }
  95209. }
  95210. declare module BABYLON {
  95211. /**
  95212. * Options to be used when creating an effect.
  95213. */
  95214. export interface IEffectCreationOptions {
  95215. /**
  95216. * Atrributes that will be used in the shader.
  95217. */
  95218. attributes: string[];
  95219. /**
  95220. * Uniform varible names that will be set in the shader.
  95221. */
  95222. uniformsNames: string[];
  95223. /**
  95224. * Uniform buffer varible names that will be set in the shader.
  95225. */
  95226. uniformBuffersNames: string[];
  95227. /**
  95228. * Sampler texture variable names that will be set in the shader.
  95229. */
  95230. samplers: string[];
  95231. /**
  95232. * Define statements that will be set in the shader.
  95233. */
  95234. defines: any;
  95235. /**
  95236. * Possible fallbacks for this effect to improve performance when needed.
  95237. */
  95238. fallbacks: Nullable<IEffectFallbacks>;
  95239. /**
  95240. * Callback that will be called when the shader is compiled.
  95241. */
  95242. onCompiled: Nullable<(effect: Effect) => void>;
  95243. /**
  95244. * Callback that will be called if an error occurs during shader compilation.
  95245. */
  95246. onError: Nullable<(effect: Effect, errors: string) => void>;
  95247. /**
  95248. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95249. */
  95250. indexParameters?: any;
  95251. /**
  95252. * Max number of lights that can be used in the shader.
  95253. */
  95254. maxSimultaneousLights?: number;
  95255. /**
  95256. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95257. */
  95258. transformFeedbackVaryings?: Nullable<string[]>;
  95259. }
  95260. /**
  95261. * Effect containing vertex and fragment shader that can be executed on an object.
  95262. */
  95263. export class Effect implements IDisposable {
  95264. /**
  95265. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95266. */
  95267. static ShadersRepository: string;
  95268. /**
  95269. * Name of the effect.
  95270. */
  95271. name: any;
  95272. /**
  95273. * String container all the define statements that should be set on the shader.
  95274. */
  95275. defines: string;
  95276. /**
  95277. * Callback that will be called when the shader is compiled.
  95278. */
  95279. onCompiled: Nullable<(effect: Effect) => void>;
  95280. /**
  95281. * Callback that will be called if an error occurs during shader compilation.
  95282. */
  95283. onError: Nullable<(effect: Effect, errors: string) => void>;
  95284. /**
  95285. * Callback that will be called when effect is bound.
  95286. */
  95287. onBind: Nullable<(effect: Effect) => void>;
  95288. /**
  95289. * Unique ID of the effect.
  95290. */
  95291. uniqueId: number;
  95292. /**
  95293. * Observable that will be called when the shader is compiled.
  95294. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95295. */
  95296. onCompileObservable: Observable<Effect>;
  95297. /**
  95298. * Observable that will be called if an error occurs during shader compilation.
  95299. */
  95300. onErrorObservable: Observable<Effect>;
  95301. /** @hidden */
  95302. _onBindObservable: Nullable<Observable<Effect>>;
  95303. /**
  95304. * Observable that will be called when effect is bound.
  95305. */
  95306. readonly onBindObservable: Observable<Effect>;
  95307. /** @hidden */
  95308. _bonesComputationForcedToCPU: boolean;
  95309. private static _uniqueIdSeed;
  95310. private _engine;
  95311. private _uniformBuffersNames;
  95312. private _uniformsNames;
  95313. private _samplerList;
  95314. private _samplers;
  95315. private _isReady;
  95316. private _compilationError;
  95317. private _allFallbacksProcessed;
  95318. private _attributesNames;
  95319. private _attributes;
  95320. private _uniforms;
  95321. /**
  95322. * Key for the effect.
  95323. * @hidden
  95324. */
  95325. _key: string;
  95326. private _indexParameters;
  95327. private _fallbacks;
  95328. private _vertexSourceCode;
  95329. private _fragmentSourceCode;
  95330. private _vertexSourceCodeOverride;
  95331. private _fragmentSourceCodeOverride;
  95332. private _transformFeedbackVaryings;
  95333. /**
  95334. * Compiled shader to webGL program.
  95335. * @hidden
  95336. */
  95337. _pipelineContext: Nullable<IPipelineContext>;
  95338. private _valueCache;
  95339. private static _baseCache;
  95340. /**
  95341. * Instantiates an effect.
  95342. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95343. * @param baseName Name of the effect.
  95344. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95345. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95346. * @param samplers List of sampler variables that will be passed to the shader.
  95347. * @param engine Engine to be used to render the effect
  95348. * @param defines Define statements to be added to the shader.
  95349. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95350. * @param onCompiled Callback that will be called when the shader is compiled.
  95351. * @param onError Callback that will be called if an error occurs during shader compilation.
  95352. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95353. */
  95354. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  95355. private _useFinalCode;
  95356. /**
  95357. * Unique key for this effect
  95358. */
  95359. readonly key: string;
  95360. /**
  95361. * If the effect has been compiled and prepared.
  95362. * @returns if the effect is compiled and prepared.
  95363. */
  95364. isReady(): boolean;
  95365. private _isReadyInternal;
  95366. /**
  95367. * The engine the effect was initialized with.
  95368. * @returns the engine.
  95369. */
  95370. getEngine(): Engine;
  95371. /**
  95372. * The pipeline context for this effect
  95373. * @returns the associated pipeline context
  95374. */
  95375. getPipelineContext(): Nullable<IPipelineContext>;
  95376. /**
  95377. * The set of names of attribute variables for the shader.
  95378. * @returns An array of attribute names.
  95379. */
  95380. getAttributesNames(): string[];
  95381. /**
  95382. * Returns the attribute at the given index.
  95383. * @param index The index of the attribute.
  95384. * @returns The location of the attribute.
  95385. */
  95386. getAttributeLocation(index: number): number;
  95387. /**
  95388. * Returns the attribute based on the name of the variable.
  95389. * @param name of the attribute to look up.
  95390. * @returns the attribute location.
  95391. */
  95392. getAttributeLocationByName(name: string): number;
  95393. /**
  95394. * The number of attributes.
  95395. * @returns the numnber of attributes.
  95396. */
  95397. getAttributesCount(): number;
  95398. /**
  95399. * Gets the index of a uniform variable.
  95400. * @param uniformName of the uniform to look up.
  95401. * @returns the index.
  95402. */
  95403. getUniformIndex(uniformName: string): number;
  95404. /**
  95405. * Returns the attribute based on the name of the variable.
  95406. * @param uniformName of the uniform to look up.
  95407. * @returns the location of the uniform.
  95408. */
  95409. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95410. /**
  95411. * Returns an array of sampler variable names
  95412. * @returns The array of sampler variable neames.
  95413. */
  95414. getSamplers(): string[];
  95415. /**
  95416. * The error from the last compilation.
  95417. * @returns the error string.
  95418. */
  95419. getCompilationError(): string;
  95420. /**
  95421. * Gets a boolean indicating that all fallbacks were used during compilation
  95422. * @returns true if all fallbacks were used
  95423. */
  95424. allFallbacksProcessed(): boolean;
  95425. /**
  95426. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95427. * @param func The callback to be used.
  95428. */
  95429. executeWhenCompiled(func: (effect: Effect) => void): void;
  95430. private _checkIsReady;
  95431. private _loadShader;
  95432. /**
  95433. * Recompiles the webGL program
  95434. * @param vertexSourceCode The source code for the vertex shader.
  95435. * @param fragmentSourceCode The source code for the fragment shader.
  95436. * @param onCompiled Callback called when completed.
  95437. * @param onError Callback called on error.
  95438. * @hidden
  95439. */
  95440. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95441. /**
  95442. * Prepares the effect
  95443. * @hidden
  95444. */
  95445. _prepareEffect(): void;
  95446. private _processCompilationErrors;
  95447. /**
  95448. * Checks if the effect is supported. (Must be called after compilation)
  95449. */
  95450. readonly isSupported: boolean;
  95451. /**
  95452. * Binds a texture to the engine to be used as output of the shader.
  95453. * @param channel Name of the output variable.
  95454. * @param texture Texture to bind.
  95455. * @hidden
  95456. */
  95457. _bindTexture(channel: string, texture: InternalTexture): void;
  95458. /**
  95459. * Sets a texture on the engine to be used in the shader.
  95460. * @param channel Name of the sampler variable.
  95461. * @param texture Texture to set.
  95462. */
  95463. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95464. /**
  95465. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95466. * @param channel Name of the sampler variable.
  95467. * @param texture Texture to set.
  95468. */
  95469. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95470. /**
  95471. * Sets an array of textures on the engine to be used in the shader.
  95472. * @param channel Name of the variable.
  95473. * @param textures Textures to set.
  95474. */
  95475. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95476. /**
  95477. * 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)
  95478. * @param channel Name of the sampler variable.
  95479. * @param postProcess Post process to get the input texture from.
  95480. */
  95481. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95482. /**
  95483. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95484. * 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)
  95485. * @param channel Name of the sampler variable.
  95486. * @param postProcess Post process to get the output texture from.
  95487. */
  95488. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95489. /** @hidden */
  95490. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95491. /** @hidden */
  95492. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95493. /** @hidden */
  95494. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95495. /** @hidden */
  95496. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95497. /**
  95498. * Binds a buffer to a uniform.
  95499. * @param buffer Buffer to bind.
  95500. * @param name Name of the uniform variable to bind to.
  95501. */
  95502. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95503. /**
  95504. * Binds block to a uniform.
  95505. * @param blockName Name of the block to bind.
  95506. * @param index Index to bind.
  95507. */
  95508. bindUniformBlock(blockName: string, index: number): void;
  95509. /**
  95510. * Sets an interger value on a uniform variable.
  95511. * @param uniformName Name of the variable.
  95512. * @param value Value to be set.
  95513. * @returns this effect.
  95514. */
  95515. setInt(uniformName: string, value: number): Effect;
  95516. /**
  95517. * Sets an int array on a uniform variable.
  95518. * @param uniformName Name of the variable.
  95519. * @param array array to be set.
  95520. * @returns this effect.
  95521. */
  95522. setIntArray(uniformName: string, array: Int32Array): Effect;
  95523. /**
  95524. * 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)
  95525. * @param uniformName Name of the variable.
  95526. * @param array array to be set.
  95527. * @returns this effect.
  95528. */
  95529. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95530. /**
  95531. * 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)
  95532. * @param uniformName Name of the variable.
  95533. * @param array array to be set.
  95534. * @returns this effect.
  95535. */
  95536. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95537. /**
  95538. * 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)
  95539. * @param uniformName Name of the variable.
  95540. * @param array array to be set.
  95541. * @returns this effect.
  95542. */
  95543. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95544. /**
  95545. * Sets an float array on a uniform variable.
  95546. * @param uniformName Name of the variable.
  95547. * @param array array to be set.
  95548. * @returns this effect.
  95549. */
  95550. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95551. /**
  95552. * 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)
  95553. * @param uniformName Name of the variable.
  95554. * @param array array to be set.
  95555. * @returns this effect.
  95556. */
  95557. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95558. /**
  95559. * 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)
  95560. * @param uniformName Name of the variable.
  95561. * @param array array to be set.
  95562. * @returns this effect.
  95563. */
  95564. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95565. /**
  95566. * 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)
  95567. * @param uniformName Name of the variable.
  95568. * @param array array to be set.
  95569. * @returns this effect.
  95570. */
  95571. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95572. /**
  95573. * Sets an array on a uniform variable.
  95574. * @param uniformName Name of the variable.
  95575. * @param array array to be set.
  95576. * @returns this effect.
  95577. */
  95578. setArray(uniformName: string, array: number[]): Effect;
  95579. /**
  95580. * 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)
  95581. * @param uniformName Name of the variable.
  95582. * @param array array to be set.
  95583. * @returns this effect.
  95584. */
  95585. setArray2(uniformName: string, array: number[]): Effect;
  95586. /**
  95587. * 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)
  95588. * @param uniformName Name of the variable.
  95589. * @param array array to be set.
  95590. * @returns this effect.
  95591. */
  95592. setArray3(uniformName: string, array: number[]): Effect;
  95593. /**
  95594. * 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)
  95595. * @param uniformName Name of the variable.
  95596. * @param array array to be set.
  95597. * @returns this effect.
  95598. */
  95599. setArray4(uniformName: string, array: number[]): Effect;
  95600. /**
  95601. * Sets matrices on a uniform variable.
  95602. * @param uniformName Name of the variable.
  95603. * @param matrices matrices to be set.
  95604. * @returns this effect.
  95605. */
  95606. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95607. /**
  95608. * Sets matrix on a uniform variable.
  95609. * @param uniformName Name of the variable.
  95610. * @param matrix matrix to be set.
  95611. * @returns this effect.
  95612. */
  95613. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95614. /**
  95615. * 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)
  95616. * @param uniformName Name of the variable.
  95617. * @param matrix matrix to be set.
  95618. * @returns this effect.
  95619. */
  95620. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95621. /**
  95622. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95623. * @param uniformName Name of the variable.
  95624. * @param matrix matrix to be set.
  95625. * @returns this effect.
  95626. */
  95627. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95628. /**
  95629. * Sets a float on a uniform variable.
  95630. * @param uniformName Name of the variable.
  95631. * @param value value to be set.
  95632. * @returns this effect.
  95633. */
  95634. setFloat(uniformName: string, value: number): Effect;
  95635. /**
  95636. * Sets a boolean on a uniform variable.
  95637. * @param uniformName Name of the variable.
  95638. * @param bool value to be set.
  95639. * @returns this effect.
  95640. */
  95641. setBool(uniformName: string, bool: boolean): Effect;
  95642. /**
  95643. * Sets a Vector2 on a uniform variable.
  95644. * @param uniformName Name of the variable.
  95645. * @param vector2 vector2 to be set.
  95646. * @returns this effect.
  95647. */
  95648. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95649. /**
  95650. * Sets a float2 on a uniform variable.
  95651. * @param uniformName Name of the variable.
  95652. * @param x First float in float2.
  95653. * @param y Second float in float2.
  95654. * @returns this effect.
  95655. */
  95656. setFloat2(uniformName: string, x: number, y: number): Effect;
  95657. /**
  95658. * Sets a Vector3 on a uniform variable.
  95659. * @param uniformName Name of the variable.
  95660. * @param vector3 Value to be set.
  95661. * @returns this effect.
  95662. */
  95663. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95664. /**
  95665. * Sets a float3 on a uniform variable.
  95666. * @param uniformName Name of the variable.
  95667. * @param x First float in float3.
  95668. * @param y Second float in float3.
  95669. * @param z Third float in float3.
  95670. * @returns this effect.
  95671. */
  95672. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95673. /**
  95674. * Sets a Vector4 on a uniform variable.
  95675. * @param uniformName Name of the variable.
  95676. * @param vector4 Value to be set.
  95677. * @returns this effect.
  95678. */
  95679. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95680. /**
  95681. * Sets a float4 on a uniform variable.
  95682. * @param uniformName Name of the variable.
  95683. * @param x First float in float4.
  95684. * @param y Second float in float4.
  95685. * @param z Third float in float4.
  95686. * @param w Fourth float in float4.
  95687. * @returns this effect.
  95688. */
  95689. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95690. /**
  95691. * Sets a Color3 on a uniform variable.
  95692. * @param uniformName Name of the variable.
  95693. * @param color3 Value to be set.
  95694. * @returns this effect.
  95695. */
  95696. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95697. /**
  95698. * Sets a Color4 on a uniform variable.
  95699. * @param uniformName Name of the variable.
  95700. * @param color3 Value to be set.
  95701. * @param alpha Alpha value to be set.
  95702. * @returns this effect.
  95703. */
  95704. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95705. /**
  95706. * Sets a Color4 on a uniform variable
  95707. * @param uniformName defines the name of the variable
  95708. * @param color4 defines the value to be set
  95709. * @returns this effect.
  95710. */
  95711. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95712. /** Release all associated resources */
  95713. dispose(): void;
  95714. /**
  95715. * This function will add a new shader to the shader store
  95716. * @param name the name of the shader
  95717. * @param pixelShader optional pixel shader content
  95718. * @param vertexShader optional vertex shader content
  95719. */
  95720. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95721. /**
  95722. * Store of each shader (The can be looked up using effect.key)
  95723. */
  95724. static ShadersStore: {
  95725. [key: string]: string;
  95726. };
  95727. /**
  95728. * Store of each included file for a shader (The can be looked up using effect.key)
  95729. */
  95730. static IncludesShadersStore: {
  95731. [key: string]: string;
  95732. };
  95733. /**
  95734. * Resets the cache of effects.
  95735. */
  95736. static ResetCache(): void;
  95737. }
  95738. }
  95739. declare module BABYLON {
  95740. /**
  95741. * Class used to describe the capabilities of the engine relatively to the current browser
  95742. */
  95743. export class EngineCapabilities {
  95744. /** Maximum textures units per fragment shader */
  95745. maxTexturesImageUnits: number;
  95746. /** Maximum texture units per vertex shader */
  95747. maxVertexTextureImageUnits: number;
  95748. /** Maximum textures units in the entire pipeline */
  95749. maxCombinedTexturesImageUnits: number;
  95750. /** Maximum texture size */
  95751. maxTextureSize: number;
  95752. /** Maximum cube texture size */
  95753. maxCubemapTextureSize: number;
  95754. /** Maximum render texture size */
  95755. maxRenderTextureSize: number;
  95756. /** Maximum number of vertex attributes */
  95757. maxVertexAttribs: number;
  95758. /** Maximum number of varyings */
  95759. maxVaryingVectors: number;
  95760. /** Maximum number of uniforms per vertex shader */
  95761. maxVertexUniformVectors: number;
  95762. /** Maximum number of uniforms per fragment shader */
  95763. maxFragmentUniformVectors: number;
  95764. /** Defines if standard derivates (dx/dy) are supported */
  95765. standardDerivatives: boolean;
  95766. /** Defines if s3tc texture compression is supported */
  95767. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95768. /** Defines if pvrtc texture compression is supported */
  95769. pvrtc: any;
  95770. /** Defines if etc1 texture compression is supported */
  95771. etc1: any;
  95772. /** Defines if etc2 texture compression is supported */
  95773. etc2: any;
  95774. /** Defines if astc texture compression is supported */
  95775. astc: any;
  95776. /** Defines if float textures are supported */
  95777. textureFloat: boolean;
  95778. /** Defines if vertex array objects are supported */
  95779. vertexArrayObject: boolean;
  95780. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95781. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95782. /** Gets the maximum level of anisotropy supported */
  95783. maxAnisotropy: number;
  95784. /** Defines if instancing is supported */
  95785. instancedArrays: boolean;
  95786. /** Defines if 32 bits indices are supported */
  95787. uintIndices: boolean;
  95788. /** Defines if high precision shaders are supported */
  95789. highPrecisionShaderSupported: boolean;
  95790. /** Defines if depth reading in the fragment shader is supported */
  95791. fragmentDepthSupported: boolean;
  95792. /** Defines if float texture linear filtering is supported*/
  95793. textureFloatLinearFiltering: boolean;
  95794. /** Defines if rendering to float textures is supported */
  95795. textureFloatRender: boolean;
  95796. /** Defines if half float textures are supported*/
  95797. textureHalfFloat: boolean;
  95798. /** Defines if half float texture linear filtering is supported*/
  95799. textureHalfFloatLinearFiltering: boolean;
  95800. /** Defines if rendering to half float textures is supported */
  95801. textureHalfFloatRender: boolean;
  95802. /** Defines if textureLOD shader command is supported */
  95803. textureLOD: boolean;
  95804. /** Defines if draw buffers extension is supported */
  95805. drawBuffersExtension: boolean;
  95806. /** Defines if depth textures are supported */
  95807. depthTextureExtension: boolean;
  95808. /** Defines if float color buffer are supported */
  95809. colorBufferFloat: boolean;
  95810. /** Gets disjoint timer query extension (null if not supported) */
  95811. timerQuery: EXT_disjoint_timer_query;
  95812. /** Defines if timestamp can be used with timer query */
  95813. canUseTimestampForTimerQuery: boolean;
  95814. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95815. multiview: any;
  95816. /** Function used to let the system compiles shaders in background */
  95817. parallelShaderCompile: {
  95818. COMPLETION_STATUS_KHR: number;
  95819. };
  95820. /** Max number of texture samples for MSAA */
  95821. maxMSAASamples: number;
  95822. /** Defines if the blend min max extension is supported */
  95823. blendMinMax: boolean;
  95824. }
  95825. }
  95826. declare module BABYLON {
  95827. /**
  95828. * @hidden
  95829. **/
  95830. export class DepthCullingState {
  95831. private _isDepthTestDirty;
  95832. private _isDepthMaskDirty;
  95833. private _isDepthFuncDirty;
  95834. private _isCullFaceDirty;
  95835. private _isCullDirty;
  95836. private _isZOffsetDirty;
  95837. private _isFrontFaceDirty;
  95838. private _depthTest;
  95839. private _depthMask;
  95840. private _depthFunc;
  95841. private _cull;
  95842. private _cullFace;
  95843. private _zOffset;
  95844. private _frontFace;
  95845. /**
  95846. * Initializes the state.
  95847. */
  95848. constructor();
  95849. readonly isDirty: boolean;
  95850. zOffset: number;
  95851. cullFace: Nullable<number>;
  95852. cull: Nullable<boolean>;
  95853. depthFunc: Nullable<number>;
  95854. depthMask: boolean;
  95855. depthTest: boolean;
  95856. frontFace: Nullable<number>;
  95857. reset(): void;
  95858. apply(gl: WebGLRenderingContext): void;
  95859. }
  95860. }
  95861. declare module BABYLON {
  95862. /**
  95863. * @hidden
  95864. **/
  95865. export class StencilState {
  95866. /** 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 */
  95867. static readonly ALWAYS: number;
  95868. /** Passed to stencilOperation to specify that stencil value must be kept */
  95869. static readonly KEEP: number;
  95870. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95871. static readonly REPLACE: number;
  95872. private _isStencilTestDirty;
  95873. private _isStencilMaskDirty;
  95874. private _isStencilFuncDirty;
  95875. private _isStencilOpDirty;
  95876. private _stencilTest;
  95877. private _stencilMask;
  95878. private _stencilFunc;
  95879. private _stencilFuncRef;
  95880. private _stencilFuncMask;
  95881. private _stencilOpStencilFail;
  95882. private _stencilOpDepthFail;
  95883. private _stencilOpStencilDepthPass;
  95884. readonly isDirty: boolean;
  95885. stencilFunc: number;
  95886. stencilFuncRef: number;
  95887. stencilFuncMask: number;
  95888. stencilOpStencilFail: number;
  95889. stencilOpDepthFail: number;
  95890. stencilOpStencilDepthPass: number;
  95891. stencilMask: number;
  95892. stencilTest: boolean;
  95893. constructor();
  95894. reset(): void;
  95895. apply(gl: WebGLRenderingContext): void;
  95896. }
  95897. }
  95898. declare module BABYLON {
  95899. /**
  95900. * @hidden
  95901. **/
  95902. export class AlphaState {
  95903. private _isAlphaBlendDirty;
  95904. private _isBlendFunctionParametersDirty;
  95905. private _isBlendEquationParametersDirty;
  95906. private _isBlendConstantsDirty;
  95907. private _alphaBlend;
  95908. private _blendFunctionParameters;
  95909. private _blendEquationParameters;
  95910. private _blendConstants;
  95911. /**
  95912. * Initializes the state.
  95913. */
  95914. constructor();
  95915. readonly isDirty: boolean;
  95916. alphaBlend: boolean;
  95917. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95918. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95919. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95920. reset(): void;
  95921. apply(gl: WebGLRenderingContext): void;
  95922. }
  95923. }
  95924. declare module BABYLON {
  95925. /** @hidden */
  95926. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95927. attributeProcessor(attribute: string): string;
  95928. varyingProcessor(varying: string, isFragment: boolean): string;
  95929. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95930. }
  95931. }
  95932. declare module BABYLON {
  95933. /**
  95934. * Interface for attribute information associated with buffer instanciation
  95935. */
  95936. export class InstancingAttributeInfo {
  95937. /**
  95938. * Index/offset of the attribute in the vertex shader
  95939. */
  95940. index: number;
  95941. /**
  95942. * size of the attribute, 1, 2, 3 or 4
  95943. */
  95944. attributeSize: number;
  95945. /**
  95946. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95947. * default is FLOAT
  95948. */
  95949. attribyteType: number;
  95950. /**
  95951. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95952. */
  95953. normalized: boolean;
  95954. /**
  95955. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95956. */
  95957. offset: number;
  95958. /**
  95959. * Name of the GLSL attribute, for debugging purpose only
  95960. */
  95961. attributeName: string;
  95962. }
  95963. }
  95964. declare module BABYLON {
  95965. interface ThinEngine {
  95966. /**
  95967. * Update a video texture
  95968. * @param texture defines the texture to update
  95969. * @param video defines the video element to use
  95970. * @param invertY defines if data must be stored with Y axis inverted
  95971. */
  95972. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95973. }
  95974. }
  95975. declare module BABYLON {
  95976. /**
  95977. * Settings for finer control over video usage
  95978. */
  95979. export interface VideoTextureSettings {
  95980. /**
  95981. * Applies `autoplay` to video, if specified
  95982. */
  95983. autoPlay?: boolean;
  95984. /**
  95985. * Applies `loop` to video, if specified
  95986. */
  95987. loop?: boolean;
  95988. /**
  95989. * Automatically updates internal texture from video at every frame in the render loop
  95990. */
  95991. autoUpdateTexture: boolean;
  95992. /**
  95993. * Image src displayed during the video loading or until the user interacts with the video.
  95994. */
  95995. poster?: string;
  95996. }
  95997. /**
  95998. * If you want to display a video in your scene, this is the special texture for that.
  95999. * This special texture works similar to other textures, with the exception of a few parameters.
  96000. * @see https://doc.babylonjs.com/how_to/video_texture
  96001. */
  96002. export class VideoTexture extends Texture {
  96003. /**
  96004. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96005. */
  96006. readonly autoUpdateTexture: boolean;
  96007. /**
  96008. * The video instance used by the texture internally
  96009. */
  96010. readonly video: HTMLVideoElement;
  96011. private _onUserActionRequestedObservable;
  96012. /**
  96013. * Event triggerd when a dom action is required by the user to play the video.
  96014. * This happens due to recent changes in browser policies preventing video to auto start.
  96015. */
  96016. readonly onUserActionRequestedObservable: Observable<Texture>;
  96017. private _generateMipMaps;
  96018. private _engine;
  96019. private _stillImageCaptured;
  96020. private _displayingPosterTexture;
  96021. private _settings;
  96022. private _createInternalTextureOnEvent;
  96023. private _frameId;
  96024. /**
  96025. * Creates a video texture.
  96026. * If you want to display a video in your scene, this is the special texture for that.
  96027. * This special texture works similar to other textures, with the exception of a few parameters.
  96028. * @see https://doc.babylonjs.com/how_to/video_texture
  96029. * @param name optional name, will detect from video source, if not defined
  96030. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96031. * @param scene is obviously the current scene.
  96032. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96033. * @param invertY is false by default but can be used to invert video on Y axis
  96034. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96035. * @param settings allows finer control over video usage
  96036. */
  96037. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96038. private _getName;
  96039. private _getVideo;
  96040. private _createInternalTexture;
  96041. private reset;
  96042. /**
  96043. * @hidden Internal method to initiate `update`.
  96044. */
  96045. _rebuild(): void;
  96046. /**
  96047. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96048. */
  96049. update(): void;
  96050. /**
  96051. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96052. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96053. */
  96054. updateTexture(isVisible: boolean): void;
  96055. protected _updateInternalTexture: () => void;
  96056. /**
  96057. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96058. * @param url New url.
  96059. */
  96060. updateURL(url: string): void;
  96061. /**
  96062. * Dispose the texture and release its associated resources.
  96063. */
  96064. dispose(): void;
  96065. /**
  96066. * Creates a video texture straight from a stream.
  96067. * @param scene Define the scene the texture should be created in
  96068. * @param stream Define the stream the texture should be created from
  96069. * @returns The created video texture as a promise
  96070. */
  96071. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96072. /**
  96073. * Creates a video texture straight from your WebCam video feed.
  96074. * @param scene Define the scene the texture should be created in
  96075. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96076. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96077. * @returns The created video texture as a promise
  96078. */
  96079. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96080. minWidth: number;
  96081. maxWidth: number;
  96082. minHeight: number;
  96083. maxHeight: number;
  96084. deviceId: string;
  96085. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96086. /**
  96087. * Creates a video texture straight from your WebCam video feed.
  96088. * @param scene Define the scene the texture should be created in
  96089. * @param onReady Define a callback to triggered once the texture will be ready
  96090. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96091. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96092. */
  96093. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96094. minWidth: number;
  96095. maxWidth: number;
  96096. minHeight: number;
  96097. maxHeight: number;
  96098. deviceId: string;
  96099. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96100. }
  96101. }
  96102. declare module BABYLON {
  96103. /**
  96104. * Defines the interface used by objects working like Scene
  96105. * @hidden
  96106. */
  96107. interface ISceneLike {
  96108. _addPendingData(data: any): void;
  96109. _removePendingData(data: any): void;
  96110. offlineProvider: IOfflineProvider;
  96111. }
  96112. /** Interface defining initialization parameters for Engine class */
  96113. export interface EngineOptions extends WebGLContextAttributes {
  96114. /**
  96115. * Defines if the engine should no exceed a specified device ratio
  96116. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96117. */
  96118. limitDeviceRatio?: number;
  96119. /**
  96120. * Defines if webvr should be enabled automatically
  96121. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96122. */
  96123. autoEnableWebVR?: boolean;
  96124. /**
  96125. * Defines if webgl2 should be turned off even if supported
  96126. * @see http://doc.babylonjs.com/features/webgl2
  96127. */
  96128. disableWebGL2Support?: boolean;
  96129. /**
  96130. * Defines if webaudio should be initialized as well
  96131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96132. */
  96133. audioEngine?: boolean;
  96134. /**
  96135. * Defines if animations should run using a deterministic lock step
  96136. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96137. */
  96138. deterministicLockstep?: boolean;
  96139. /** Defines the maximum steps to use with deterministic lock step mode */
  96140. lockstepMaxSteps?: number;
  96141. /**
  96142. * Defines that engine should ignore context lost events
  96143. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96144. */
  96145. doNotHandleContextLost?: boolean;
  96146. /**
  96147. * Defines that engine should ignore modifying touch action attribute and style
  96148. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96149. */
  96150. doNotHandleTouchAction?: boolean;
  96151. /**
  96152. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96153. */
  96154. useHighPrecisionFloats?: boolean;
  96155. }
  96156. /**
  96157. * The base engine class (root of all engines)
  96158. */
  96159. export class ThinEngine {
  96160. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96161. static ExceptionList: ({
  96162. key: string;
  96163. capture: string;
  96164. captureConstraint: number;
  96165. targets: string[];
  96166. } | {
  96167. key: string;
  96168. capture: null;
  96169. captureConstraint: null;
  96170. targets: string[];
  96171. })[];
  96172. /** @hidden */
  96173. static _TextureLoaders: IInternalTextureLoader[];
  96174. /**
  96175. * Returns the current npm package of the sdk
  96176. */
  96177. static readonly NpmPackage: string;
  96178. /**
  96179. * Returns the current version of the framework
  96180. */
  96181. static readonly Version: string;
  96182. /**
  96183. * Returns a string describing the current engine
  96184. */
  96185. readonly description: string;
  96186. /**
  96187. * Gets or sets the epsilon value used by collision engine
  96188. */
  96189. static CollisionsEpsilon: number;
  96190. /**
  96191. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96192. */
  96193. static ShadersRepository: string;
  96194. /** @hidden */
  96195. _shaderProcessor: IShaderProcessor;
  96196. /**
  96197. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96198. */
  96199. forcePOTTextures: boolean;
  96200. /**
  96201. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96202. */
  96203. isFullscreen: boolean;
  96204. /**
  96205. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96206. */
  96207. cullBackFaces: boolean;
  96208. /**
  96209. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96210. */
  96211. renderEvenInBackground: boolean;
  96212. /**
  96213. * Gets or sets a boolean indicating that cache can be kept between frames
  96214. */
  96215. preventCacheWipeBetweenFrames: boolean;
  96216. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96217. validateShaderPrograms: boolean;
  96218. /**
  96219. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96220. */
  96221. disableUniformBuffers: boolean;
  96222. /** @hidden */
  96223. _uniformBuffers: UniformBuffer[];
  96224. /**
  96225. * Gets a boolean indicating that the engine supports uniform buffers
  96226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96227. */
  96228. readonly supportsUniformBuffers: boolean;
  96229. /** @hidden */
  96230. _gl: WebGLRenderingContext;
  96231. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96232. protected _windowIsBackground: boolean;
  96233. protected _webGLVersion: number;
  96234. protected _highPrecisionShadersAllowed: boolean;
  96235. /** @hidden */
  96236. readonly _shouldUseHighPrecisionShader: boolean;
  96237. /**
  96238. * Gets a boolean indicating that only power of 2 textures are supported
  96239. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96240. */
  96241. readonly needPOTTextures: boolean;
  96242. /** @hidden */
  96243. _badOS: boolean;
  96244. /** @hidden */
  96245. _badDesktopOS: boolean;
  96246. private _hardwareScalingLevel;
  96247. /** @hidden */
  96248. _caps: EngineCapabilities;
  96249. private _isStencilEnable;
  96250. protected _colorWrite: boolean;
  96251. private _glVersion;
  96252. private _glRenderer;
  96253. private _glVendor;
  96254. /** @hidden */
  96255. _videoTextureSupported: boolean;
  96256. protected _renderingQueueLaunched: boolean;
  96257. protected _activeRenderLoops: (() => void)[];
  96258. /**
  96259. * Observable signaled when a context lost event is raised
  96260. */
  96261. onContextLostObservable: Observable<ThinEngine>;
  96262. /**
  96263. * Observable signaled when a context restored event is raised
  96264. */
  96265. onContextRestoredObservable: Observable<ThinEngine>;
  96266. private _onContextLost;
  96267. private _onContextRestored;
  96268. protected _contextWasLost: boolean;
  96269. /** @hidden */
  96270. _doNotHandleContextLost: boolean;
  96271. /**
  96272. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96274. */
  96275. doNotHandleContextLost: boolean;
  96276. /**
  96277. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96278. */
  96279. disableVertexArrayObjects: boolean;
  96280. /** @hidden */
  96281. protected _depthCullingState: DepthCullingState;
  96282. /** @hidden */
  96283. protected _stencilState: StencilState;
  96284. /** @hidden */
  96285. protected _alphaState: AlphaState;
  96286. /** @hidden */
  96287. _internalTexturesCache: InternalTexture[];
  96288. /** @hidden */
  96289. protected _activeChannel: number;
  96290. private _currentTextureChannel;
  96291. /** @hidden */
  96292. protected _boundTexturesCache: {
  96293. [key: string]: Nullable<InternalTexture>;
  96294. };
  96295. /** @hidden */
  96296. protected _currentEffect: Nullable<Effect>;
  96297. /** @hidden */
  96298. protected _currentProgram: Nullable<WebGLProgram>;
  96299. private _compiledEffects;
  96300. private _vertexAttribArraysEnabled;
  96301. /** @hidden */
  96302. protected _cachedViewport: Nullable<IViewportLike>;
  96303. private _cachedVertexArrayObject;
  96304. /** @hidden */
  96305. protected _cachedVertexBuffers: any;
  96306. /** @hidden */
  96307. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96308. /** @hidden */
  96309. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96310. /** @hidden */
  96311. _currentRenderTarget: Nullable<InternalTexture>;
  96312. private _uintIndicesCurrentlySet;
  96313. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96314. /** @hidden */
  96315. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96316. private _currentBufferPointers;
  96317. private _currentInstanceLocations;
  96318. private _currentInstanceBuffers;
  96319. private _textureUnits;
  96320. /** @hidden */
  96321. _workingCanvas: Nullable<HTMLCanvasElement>;
  96322. /** @hidden */
  96323. _workingContext: Nullable<CanvasRenderingContext2D>;
  96324. /** @hidden */
  96325. _bindedRenderFunction: any;
  96326. private _vaoRecordInProgress;
  96327. private _mustWipeVertexAttributes;
  96328. private _emptyTexture;
  96329. private _emptyCubeTexture;
  96330. private _emptyTexture3D;
  96331. /** @hidden */
  96332. _frameHandler: number;
  96333. private _nextFreeTextureSlots;
  96334. private _maxSimultaneousTextures;
  96335. private _activeRequests;
  96336. protected _texturesSupported: string[];
  96337. /** @hidden */
  96338. _textureFormatInUse: Nullable<string>;
  96339. protected readonly _supportsHardwareTextureRescaling: boolean;
  96340. /**
  96341. * Gets the list of texture formats supported
  96342. */
  96343. readonly texturesSupported: Array<string>;
  96344. /**
  96345. * Gets the list of texture formats in use
  96346. */
  96347. readonly textureFormatInUse: Nullable<string>;
  96348. /**
  96349. * Gets the current viewport
  96350. */
  96351. readonly currentViewport: Nullable<IViewportLike>;
  96352. /**
  96353. * Gets the default empty texture
  96354. */
  96355. readonly emptyTexture: InternalTexture;
  96356. /**
  96357. * Gets the default empty 3D texture
  96358. */
  96359. readonly emptyTexture3D: InternalTexture;
  96360. /**
  96361. * Gets the default empty cube texture
  96362. */
  96363. readonly emptyCubeTexture: InternalTexture;
  96364. /**
  96365. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96366. */
  96367. readonly premultipliedAlpha: boolean;
  96368. /**
  96369. * Observable event triggered before each texture is initialized
  96370. */
  96371. onBeforeTextureInitObservable: Observable<Texture>;
  96372. /**
  96373. * Creates a new engine
  96374. * @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
  96375. * @param antialias defines enable antialiasing (default: false)
  96376. * @param options defines further options to be sent to the getContext() function
  96377. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96378. */
  96379. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96380. private _rebuildInternalTextures;
  96381. private _rebuildEffects;
  96382. /**
  96383. * Gets a boolean indicating if all created effects are ready
  96384. * @returns true if all effects are ready
  96385. */
  96386. areAllEffectsReady(): boolean;
  96387. protected _rebuildBuffers(): void;
  96388. private _initGLContext;
  96389. /**
  96390. * Gets version of the current webGL context
  96391. */
  96392. readonly webGLVersion: number;
  96393. /**
  96394. * Gets a string idenfifying the name of the class
  96395. * @returns "Engine" string
  96396. */
  96397. getClassName(): string;
  96398. /**
  96399. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96400. */
  96401. readonly isStencilEnable: boolean;
  96402. /** @hidden */
  96403. _prepareWorkingCanvas(): void;
  96404. /**
  96405. * Reset the texture cache to empty state
  96406. */
  96407. resetTextureCache(): void;
  96408. /**
  96409. * Gets an object containing information about the current webGL context
  96410. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96411. */
  96412. getGlInfo(): {
  96413. vendor: string;
  96414. renderer: string;
  96415. version: string;
  96416. };
  96417. /**
  96418. * Defines the hardware scaling level.
  96419. * By default the hardware scaling level is computed from the window device ratio.
  96420. * 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.
  96421. * @param level defines the level to use
  96422. */
  96423. setHardwareScalingLevel(level: number): void;
  96424. /**
  96425. * Gets the current hardware scaling level.
  96426. * By default the hardware scaling level is computed from the window device ratio.
  96427. * 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.
  96428. * @returns a number indicating the current hardware scaling level
  96429. */
  96430. getHardwareScalingLevel(): number;
  96431. /**
  96432. * Gets the list of loaded textures
  96433. * @returns an array containing all loaded textures
  96434. */
  96435. getLoadedTexturesCache(): InternalTexture[];
  96436. /**
  96437. * Gets the object containing all engine capabilities
  96438. * @returns the EngineCapabilities object
  96439. */
  96440. getCaps(): EngineCapabilities;
  96441. /**
  96442. * stop executing a render loop function and remove it from the execution array
  96443. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96444. */
  96445. stopRenderLoop(renderFunction?: () => void): void;
  96446. /** @hidden */
  96447. _renderLoop(): void;
  96448. /**
  96449. * Gets the HTML canvas attached with the current webGL context
  96450. * @returns a HTML canvas
  96451. */
  96452. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96453. /**
  96454. * Gets host window
  96455. * @returns the host window object
  96456. */
  96457. getHostWindow(): Window;
  96458. /**
  96459. * Gets the current render width
  96460. * @param useScreen defines if screen size must be used (or the current render target if any)
  96461. * @returns a number defining the current render width
  96462. */
  96463. getRenderWidth(useScreen?: boolean): number;
  96464. /**
  96465. * Gets the current render height
  96466. * @param useScreen defines if screen size must be used (or the current render target if any)
  96467. * @returns a number defining the current render height
  96468. */
  96469. getRenderHeight(useScreen?: boolean): number;
  96470. /**
  96471. * Can be used to override the current requestAnimationFrame requester.
  96472. * @hidden
  96473. */
  96474. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96475. /**
  96476. * Register and execute a render loop. The engine can have more than one render function
  96477. * @param renderFunction defines the function to continuously execute
  96478. */
  96479. runRenderLoop(renderFunction: () => void): void;
  96480. /**
  96481. * Clear the current render buffer or the current render target (if any is set up)
  96482. * @param color defines the color to use
  96483. * @param backBuffer defines if the back buffer must be cleared
  96484. * @param depth defines if the depth buffer must be cleared
  96485. * @param stencil defines if the stencil buffer must be cleared
  96486. */
  96487. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96488. private _viewportCached;
  96489. /** @hidden */
  96490. _viewport(x: number, y: number, width: number, height: number): void;
  96491. /**
  96492. * Set the WebGL's viewport
  96493. * @param viewport defines the viewport element to be used
  96494. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96495. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96496. */
  96497. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96498. /**
  96499. * Begin a new frame
  96500. */
  96501. beginFrame(): void;
  96502. /**
  96503. * Enf the current frame
  96504. */
  96505. endFrame(): void;
  96506. /**
  96507. * Resize the view according to the canvas' size
  96508. */
  96509. resize(): void;
  96510. /**
  96511. * Force a specific size of the canvas
  96512. * @param width defines the new canvas' width
  96513. * @param height defines the new canvas' height
  96514. */
  96515. setSize(width: number, height: number): void;
  96516. /**
  96517. * Binds the frame buffer to the specified texture.
  96518. * @param texture The texture to render to or null for the default canvas
  96519. * @param faceIndex The face of the texture to render to in case of cube texture
  96520. * @param requiredWidth The width of the target to render to
  96521. * @param requiredHeight The height of the target to render to
  96522. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96523. * @param depthStencilTexture The depth stencil texture to use to render
  96524. * @param lodLevel defines le lod level to bind to the frame buffer
  96525. */
  96526. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96527. /** @hidden */
  96528. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96529. /**
  96530. * Unbind the current render target texture from the webGL context
  96531. * @param texture defines the render target texture to unbind
  96532. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96533. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96534. */
  96535. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96536. /**
  96537. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96538. */
  96539. flushFramebuffer(): void;
  96540. /**
  96541. * Unbind the current render target and bind the default framebuffer
  96542. */
  96543. restoreDefaultFramebuffer(): void;
  96544. private _resetVertexBufferBinding;
  96545. /**
  96546. * Creates a vertex buffer
  96547. * @param data the data for the vertex buffer
  96548. * @returns the new WebGL static buffer
  96549. */
  96550. createVertexBuffer(data: DataArray): DataBuffer;
  96551. private _createVertexBuffer;
  96552. /**
  96553. * Creates a dynamic vertex buffer
  96554. * @param data the data for the dynamic vertex buffer
  96555. * @returns the new WebGL dynamic buffer
  96556. */
  96557. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96558. /**
  96559. * Updates a dynamic vertex buffer.
  96560. * @param vertexBuffer the vertex buffer to update
  96561. * @param data the data used to update the vertex buffer
  96562. * @param byteOffset the byte offset of the data
  96563. * @param byteLength the byte length of the data
  96564. */
  96565. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96566. protected _resetIndexBufferBinding(): void;
  96567. /**
  96568. * Creates a new index buffer
  96569. * @param indices defines the content of the index buffer
  96570. * @param updatable defines if the index buffer must be updatable
  96571. * @returns a new webGL buffer
  96572. */
  96573. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96574. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96575. /**
  96576. * Bind a webGL buffer to the webGL context
  96577. * @param buffer defines the buffer to bind
  96578. */
  96579. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96580. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96581. private bindBuffer;
  96582. /**
  96583. * update the bound buffer with the given data
  96584. * @param data defines the data to update
  96585. */
  96586. updateArrayBuffer(data: Float32Array): void;
  96587. private _vertexAttribPointer;
  96588. private _bindIndexBufferWithCache;
  96589. private _bindVertexBuffersAttributes;
  96590. /**
  96591. * Records a vertex array object
  96592. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96593. * @param vertexBuffers defines the list of vertex buffers to store
  96594. * @param indexBuffer defines the index buffer to store
  96595. * @param effect defines the effect to store
  96596. * @returns the new vertex array object
  96597. */
  96598. recordVertexArrayObject(vertexBuffers: {
  96599. [key: string]: VertexBuffer;
  96600. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96601. /**
  96602. * Bind a specific vertex array object
  96603. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96604. * @param vertexArrayObject defines the vertex array object to bind
  96605. * @param indexBuffer defines the index buffer to bind
  96606. */
  96607. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96608. /**
  96609. * Bind webGl buffers directly to the webGL context
  96610. * @param vertexBuffer defines the vertex buffer to bind
  96611. * @param indexBuffer defines the index buffer to bind
  96612. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96613. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96614. * @param effect defines the effect associated with the vertex buffer
  96615. */
  96616. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96617. private _unbindVertexArrayObject;
  96618. /**
  96619. * Bind a list of vertex buffers to the webGL context
  96620. * @param vertexBuffers defines the list of vertex buffers to bind
  96621. * @param indexBuffer defines the index buffer to bind
  96622. * @param effect defines the effect associated with the vertex buffers
  96623. */
  96624. bindBuffers(vertexBuffers: {
  96625. [key: string]: Nullable<VertexBuffer>;
  96626. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96627. /**
  96628. * Unbind all instance attributes
  96629. */
  96630. unbindInstanceAttributes(): void;
  96631. /**
  96632. * Release and free the memory of a vertex array object
  96633. * @param vao defines the vertex array object to delete
  96634. */
  96635. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96636. /** @hidden */
  96637. _releaseBuffer(buffer: DataBuffer): boolean;
  96638. protected _deleteBuffer(buffer: DataBuffer): void;
  96639. /**
  96640. * Creates a webGL buffer to use with instanciation
  96641. * @param capacity defines the size of the buffer
  96642. * @returns the webGL buffer
  96643. */
  96644. createInstancesBuffer(capacity: number): DataBuffer;
  96645. /**
  96646. * Delete a webGL buffer used with instanciation
  96647. * @param buffer defines the webGL buffer to delete
  96648. */
  96649. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96650. /**
  96651. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96652. * @param instancesBuffer defines the webGL buffer to update and bind
  96653. * @param data defines the data to store in the buffer
  96654. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96655. */
  96656. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96657. /**
  96658. * Apply all cached states (depth, culling, stencil and alpha)
  96659. */
  96660. applyStates(): void;
  96661. /**
  96662. * Send a draw order
  96663. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96664. * @param indexStart defines the starting index
  96665. * @param indexCount defines the number of index to draw
  96666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96667. */
  96668. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96669. /**
  96670. * Draw a list of points
  96671. * @param verticesStart defines the index of first vertex to draw
  96672. * @param verticesCount defines the count of vertices to draw
  96673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96674. */
  96675. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96676. /**
  96677. * Draw a list of unindexed primitives
  96678. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96679. * @param verticesStart defines the index of first vertex to draw
  96680. * @param verticesCount defines the count of vertices to draw
  96681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96682. */
  96683. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96684. /**
  96685. * Draw a list of indexed primitives
  96686. * @param fillMode defines the primitive to use
  96687. * @param indexStart defines the starting index
  96688. * @param indexCount defines the number of index to draw
  96689. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96690. */
  96691. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96692. /**
  96693. * Draw a list of unindexed primitives
  96694. * @param fillMode defines the primitive to use
  96695. * @param verticesStart defines the index of first vertex to draw
  96696. * @param verticesCount defines the count of vertices to draw
  96697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96698. */
  96699. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96700. private _drawMode;
  96701. /** @hidden */
  96702. protected _reportDrawCall(): void;
  96703. /** @hidden */
  96704. _releaseEffect(effect: Effect): void;
  96705. /** @hidden */
  96706. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96707. /**
  96708. * Create a new effect (used to store vertex/fragment shaders)
  96709. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96710. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96711. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96712. * @param samplers defines an array of string used to represent textures
  96713. * @param defines defines the string containing the defines to use to compile the shaders
  96714. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96715. * @param onCompiled defines a function to call when the effect creation is successful
  96716. * @param onError defines a function to call when the effect creation has failed
  96717. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96718. * @returns the new Effect
  96719. */
  96720. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96721. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96722. private _compileShader;
  96723. private _compileRawShader;
  96724. /**
  96725. * Directly creates a webGL program
  96726. * @param pipelineContext defines the pipeline context to attach to
  96727. * @param vertexCode defines the vertex shader code to use
  96728. * @param fragmentCode defines the fragment shader code to use
  96729. * @param context defines the webGL context to use (if not set, the current one will be used)
  96730. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96731. * @returns the new webGL program
  96732. */
  96733. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96734. /**
  96735. * Creates a webGL program
  96736. * @param pipelineContext defines the pipeline context to attach to
  96737. * @param vertexCode defines the vertex shader code to use
  96738. * @param fragmentCode defines the fragment shader code to use
  96739. * @param defines defines the string containing the defines to use to compile the shaders
  96740. * @param context defines the webGL context to use (if not set, the current one will be used)
  96741. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96742. * @returns the new webGL program
  96743. */
  96744. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96745. /**
  96746. * Creates a new pipeline context
  96747. * @returns the new pipeline
  96748. */
  96749. createPipelineContext(): IPipelineContext;
  96750. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96751. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96752. /** @hidden */
  96753. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96754. /** @hidden */
  96755. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96756. /** @hidden */
  96757. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96758. /**
  96759. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96760. * @param pipelineContext defines the pipeline context to use
  96761. * @param uniformsNames defines the list of uniform names
  96762. * @returns an array of webGL uniform locations
  96763. */
  96764. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96765. /**
  96766. * Gets the lsit of active attributes for a given webGL program
  96767. * @param pipelineContext defines the pipeline context to use
  96768. * @param attributesNames defines the list of attribute names to get
  96769. * @returns an array of indices indicating the offset of each attribute
  96770. */
  96771. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96772. /**
  96773. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96774. * @param effect defines the effect to activate
  96775. */
  96776. enableEffect(effect: Nullable<Effect>): void;
  96777. /**
  96778. * Set the value of an uniform to an array of int32
  96779. * @param uniform defines the webGL uniform location where to store the value
  96780. * @param array defines the array of int32 to store
  96781. */
  96782. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96783. /**
  96784. * Set the value of an uniform to an array of int32 (stored as vec2)
  96785. * @param uniform defines the webGL uniform location where to store the value
  96786. * @param array defines the array of int32 to store
  96787. */
  96788. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96789. /**
  96790. * Set the value of an uniform to an array of int32 (stored as vec3)
  96791. * @param uniform defines the webGL uniform location where to store the value
  96792. * @param array defines the array of int32 to store
  96793. */
  96794. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96795. /**
  96796. * Set the value of an uniform to an array of int32 (stored as vec4)
  96797. * @param uniform defines the webGL uniform location where to store the value
  96798. * @param array defines the array of int32 to store
  96799. */
  96800. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96801. /**
  96802. * Set the value of an uniform to an array of float32
  96803. * @param uniform defines the webGL uniform location where to store the value
  96804. * @param array defines the array of float32 to store
  96805. */
  96806. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96807. /**
  96808. * Set the value of an uniform to an array of float32 (stored as vec2)
  96809. * @param uniform defines the webGL uniform location where to store the value
  96810. * @param array defines the array of float32 to store
  96811. */
  96812. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96813. /**
  96814. * Set the value of an uniform to an array of float32 (stored as vec3)
  96815. * @param uniform defines the webGL uniform location where to store the value
  96816. * @param array defines the array of float32 to store
  96817. */
  96818. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96819. /**
  96820. * Set the value of an uniform to an array of float32 (stored as vec4)
  96821. * @param uniform defines the webGL uniform location where to store the value
  96822. * @param array defines the array of float32 to store
  96823. */
  96824. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96825. /**
  96826. * Set the value of an uniform to an array of number
  96827. * @param uniform defines the webGL uniform location where to store the value
  96828. * @param array defines the array of number to store
  96829. */
  96830. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96831. /**
  96832. * Set the value of an uniform to an array of number (stored as vec2)
  96833. * @param uniform defines the webGL uniform location where to store the value
  96834. * @param array defines the array of number to store
  96835. */
  96836. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96837. /**
  96838. * Set the value of an uniform to an array of number (stored as vec3)
  96839. * @param uniform defines the webGL uniform location where to store the value
  96840. * @param array defines the array of number to store
  96841. */
  96842. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96843. /**
  96844. * Set the value of an uniform to an array of number (stored as vec4)
  96845. * @param uniform defines the webGL uniform location where to store the value
  96846. * @param array defines the array of number to store
  96847. */
  96848. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96849. /**
  96850. * Set the value of an uniform to an array of float32 (stored as matrices)
  96851. * @param uniform defines the webGL uniform location where to store the value
  96852. * @param matrices defines the array of float32 to store
  96853. */
  96854. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96855. /**
  96856. * Set the value of an uniform to a matrix (3x3)
  96857. * @param uniform defines the webGL uniform location where to store the value
  96858. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96859. */
  96860. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96861. /**
  96862. * Set the value of an uniform to a matrix (2x2)
  96863. * @param uniform defines the webGL uniform location where to store the value
  96864. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96865. */
  96866. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96867. /**
  96868. * Set the value of an uniform to a number (int)
  96869. * @param uniform defines the webGL uniform location where to store the value
  96870. * @param value defines the int number to store
  96871. */
  96872. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96873. /**
  96874. * Set the value of an uniform to a number (float)
  96875. * @param uniform defines the webGL uniform location where to store the value
  96876. * @param value defines the float number to store
  96877. */
  96878. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96879. /**
  96880. * Set the value of an uniform to a vec2
  96881. * @param uniform defines the webGL uniform location where to store the value
  96882. * @param x defines the 1st component of the value
  96883. * @param y defines the 2nd component of the value
  96884. */
  96885. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96886. /**
  96887. * Set the value of an uniform to a vec3
  96888. * @param uniform defines the webGL uniform location where to store the value
  96889. * @param x defines the 1st component of the value
  96890. * @param y defines the 2nd component of the value
  96891. * @param z defines the 3rd component of the value
  96892. */
  96893. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96894. /**
  96895. * Set the value of an uniform to a boolean
  96896. * @param uniform defines the webGL uniform location where to store the value
  96897. * @param bool defines the boolean to store
  96898. */
  96899. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96900. /**
  96901. * Set the value of an uniform to a vec4
  96902. * @param uniform defines the webGL uniform location where to store the value
  96903. * @param x defines the 1st component of the value
  96904. * @param y defines the 2nd component of the value
  96905. * @param z defines the 3rd component of the value
  96906. * @param w defines the 4th component of the value
  96907. */
  96908. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96909. /**
  96910. * Sets a Color4 on a uniform variable
  96911. * @param uniform defines the uniform location
  96912. * @param color4 defines the value to be set
  96913. */
  96914. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96915. /**
  96916. * Gets the depth culling state manager
  96917. */
  96918. readonly depthCullingState: DepthCullingState;
  96919. /**
  96920. * Gets the alpha state manager
  96921. */
  96922. readonly alphaState: AlphaState;
  96923. /**
  96924. * Gets the stencil state manager
  96925. */
  96926. readonly stencilState: StencilState;
  96927. /**
  96928. * Clears the list of texture accessible through engine.
  96929. * This can help preventing texture load conflict due to name collision.
  96930. */
  96931. clearInternalTexturesCache(): void;
  96932. /**
  96933. * Force the entire cache to be cleared
  96934. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96935. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96936. */
  96937. wipeCaches(bruteForce?: boolean): void;
  96938. /** @hidden */
  96939. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96940. min: number;
  96941. mag: number;
  96942. };
  96943. /** @hidden */
  96944. _createTexture(): WebGLTexture;
  96945. /**
  96946. * Usually called from Texture.ts.
  96947. * Passed information to create a WebGLTexture
  96948. * @param urlArg defines a value which contains one of the following:
  96949. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96950. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96951. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96952. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96953. * @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)
  96954. * @param scene needed for loading to the correct scene
  96955. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96956. * @param onLoad optional callback to be called upon successful completion
  96957. * @param onError optional callback to be called upon failure
  96958. * @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
  96959. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96960. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96961. * @param forcedExtension defines the extension to use to pick the right loader
  96962. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96963. * @param mimeType defines an optional mime type
  96964. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96965. */
  96966. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  96967. /**
  96968. * @hidden
  96969. */
  96970. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96971. /**
  96972. * Creates a raw texture
  96973. * @param data defines the data to store in the texture
  96974. * @param width defines the width of the texture
  96975. * @param height defines the height of the texture
  96976. * @param format defines the format of the data
  96977. * @param generateMipMaps defines if the engine should generate the mip levels
  96978. * @param invertY defines if data must be stored with Y axis inverted
  96979. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96980. * @param compression defines the compression used (null by default)
  96981. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96982. * @returns the raw texture inside an InternalTexture
  96983. */
  96984. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96985. /**
  96986. * Creates a new raw cube texture
  96987. * @param data defines the array of data to use to create each face
  96988. * @param size defines the size of the textures
  96989. * @param format defines the format of the data
  96990. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96991. * @param generateMipMaps defines if the engine should generate the mip levels
  96992. * @param invertY defines if data must be stored with Y axis inverted
  96993. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96994. * @param compression defines the compression used (null by default)
  96995. * @returns the cube texture as an InternalTexture
  96996. */
  96997. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96998. /**
  96999. * Creates a new raw 3D texture
  97000. * @param data defines the data used to create the texture
  97001. * @param width defines the width of the texture
  97002. * @param height defines the height of the texture
  97003. * @param depth defines the depth of the texture
  97004. * @param format defines the format of the texture
  97005. * @param generateMipMaps defines if the engine must generate mip levels
  97006. * @param invertY defines if data must be stored with Y axis inverted
  97007. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97008. * @param compression defines the compressed used (can be null)
  97009. * @param textureType defines the compressed used (can be null)
  97010. * @returns a new raw 3D texture (stored in an InternalTexture)
  97011. */
  97012. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97013. private _unpackFlipYCached;
  97014. /**
  97015. * In case you are sharing the context with other applications, it might
  97016. * be interested to not cache the unpack flip y state to ensure a consistent
  97017. * value would be set.
  97018. */
  97019. enableUnpackFlipYCached: boolean;
  97020. /** @hidden */
  97021. _unpackFlipY(value: boolean): void;
  97022. /** @hidden */
  97023. _getUnpackAlignement(): number;
  97024. /**
  97025. * Update the sampling mode of a given texture
  97026. * @param samplingMode defines the required sampling mode
  97027. * @param texture defines the texture to update
  97028. */
  97029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97030. /**
  97031. * Updates a depth texture Comparison Mode and Function.
  97032. * If the comparison Function is equal to 0, the mode will be set to none.
  97033. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97034. * @param texture The texture to set the comparison function for
  97035. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97036. */
  97037. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97038. /** @hidden */
  97039. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97040. width: number;
  97041. height: number;
  97042. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97043. /**
  97044. * Creates a depth stencil texture.
  97045. * This is only available in WebGL 2 or with the depth texture extension available.
  97046. * @param size The size of face edge in the texture.
  97047. * @param options The options defining the texture.
  97048. * @returns The texture
  97049. */
  97050. createDepthStencilTexture(size: number | {
  97051. width: number;
  97052. height: number;
  97053. }, options: DepthTextureCreationOptions): InternalTexture;
  97054. /**
  97055. * Creates a depth stencil texture.
  97056. * This is only available in WebGL 2 or with the depth texture extension available.
  97057. * @param size The size of face edge in the texture.
  97058. * @param options The options defining the texture.
  97059. * @returns The texture
  97060. */
  97061. private _createDepthStencilTexture;
  97062. /** @hidden */
  97063. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97064. /** @hidden */
  97065. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97066. /** @hidden */
  97067. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97068. /** @hidden */
  97069. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97070. /**
  97071. * @hidden
  97072. */
  97073. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97074. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97075. private _prepareWebGLTexture;
  97076. /** @hidden */
  97077. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97078. /** @hidden */
  97079. _releaseFramebufferObjects(texture: InternalTexture): void;
  97080. /** @hidden */
  97081. _releaseTexture(texture: InternalTexture): void;
  97082. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97083. protected _setProgram(program: WebGLProgram): void;
  97084. protected _boundUniforms: {
  97085. [key: number]: WebGLUniformLocation;
  97086. };
  97087. /**
  97088. * Binds an effect to the webGL context
  97089. * @param effect defines the effect to bind
  97090. */
  97091. bindSamplers(effect: Effect): void;
  97092. private _activateCurrentTexture;
  97093. /** @hidden */
  97094. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97095. /** @hidden */
  97096. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97097. /**
  97098. * Unbind all textures from the webGL context
  97099. */
  97100. unbindAllTextures(): void;
  97101. /**
  97102. * Sets a texture to the according uniform.
  97103. * @param channel The texture channel
  97104. * @param uniform The uniform to set
  97105. * @param texture The texture to apply
  97106. */
  97107. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97108. private _bindSamplerUniformToChannel;
  97109. private _getTextureWrapMode;
  97110. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97111. /**
  97112. * Sets an array of texture to the webGL context
  97113. * @param channel defines the channel where the texture array must be set
  97114. * @param uniform defines the associated uniform location
  97115. * @param textures defines the array of textures to bind
  97116. */
  97117. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97118. /** @hidden */
  97119. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97120. private _setTextureParameterFloat;
  97121. private _setTextureParameterInteger;
  97122. /**
  97123. * Unbind all vertex attributes from the webGL context
  97124. */
  97125. unbindAllAttributes(): void;
  97126. /**
  97127. * 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
  97128. */
  97129. releaseEffects(): void;
  97130. /**
  97131. * Dispose and release all associated resources
  97132. */
  97133. dispose(): void;
  97134. /**
  97135. * Attach a new callback raised when context lost event is fired
  97136. * @param callback defines the callback to call
  97137. */
  97138. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97139. /**
  97140. * Attach a new callback raised when context restored event is fired
  97141. * @param callback defines the callback to call
  97142. */
  97143. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97144. /**
  97145. * Get the current error code of the webGL context
  97146. * @returns the error code
  97147. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97148. */
  97149. getError(): number;
  97150. private _canRenderToFloatFramebuffer;
  97151. private _canRenderToHalfFloatFramebuffer;
  97152. private _canRenderToFramebuffer;
  97153. /** @hidden */
  97154. _getWebGLTextureType(type: number): number;
  97155. /** @hidden */
  97156. _getInternalFormat(format: number): number;
  97157. /** @hidden */
  97158. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97159. /** @hidden */
  97160. _getRGBAMultiSampleBufferFormat(type: number): number;
  97161. /** @hidden */
  97162. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  97163. /**
  97164. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97165. * @returns true if the engine can be created
  97166. * @ignorenaming
  97167. */
  97168. static isSupported(): boolean;
  97169. /**
  97170. * Find the next highest power of two.
  97171. * @param x Number to start search from.
  97172. * @return Next highest power of two.
  97173. */
  97174. static CeilingPOT(x: number): number;
  97175. /**
  97176. * Find the next lowest power of two.
  97177. * @param x Number to start search from.
  97178. * @return Next lowest power of two.
  97179. */
  97180. static FloorPOT(x: number): number;
  97181. /**
  97182. * Find the nearest power of two.
  97183. * @param x Number to start search from.
  97184. * @return Next nearest power of two.
  97185. */
  97186. static NearestPOT(x: number): number;
  97187. /**
  97188. * Get the closest exponent of two
  97189. * @param value defines the value to approximate
  97190. * @param max defines the maximum value to return
  97191. * @param mode defines how to define the closest value
  97192. * @returns closest exponent of two of the given value
  97193. */
  97194. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97195. /**
  97196. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97197. * @param func - the function to be called
  97198. * @param requester - the object that will request the next frame. Falls back to window.
  97199. * @returns frame number
  97200. */
  97201. static QueueNewFrame(func: () => void, requester?: any): number;
  97202. }
  97203. }
  97204. declare module BABYLON {
  97205. /**
  97206. * Class representing spherical harmonics coefficients to the 3rd degree
  97207. */
  97208. export class SphericalHarmonics {
  97209. /**
  97210. * Defines whether or not the harmonics have been prescaled for rendering.
  97211. */
  97212. preScaled: boolean;
  97213. /**
  97214. * The l0,0 coefficients of the spherical harmonics
  97215. */
  97216. l00: Vector3;
  97217. /**
  97218. * The l1,-1 coefficients of the spherical harmonics
  97219. */
  97220. l1_1: Vector3;
  97221. /**
  97222. * The l1,0 coefficients of the spherical harmonics
  97223. */
  97224. l10: Vector3;
  97225. /**
  97226. * The l1,1 coefficients of the spherical harmonics
  97227. */
  97228. l11: Vector3;
  97229. /**
  97230. * The l2,-2 coefficients of the spherical harmonics
  97231. */
  97232. l2_2: Vector3;
  97233. /**
  97234. * The l2,-1 coefficients of the spherical harmonics
  97235. */
  97236. l2_1: Vector3;
  97237. /**
  97238. * The l2,0 coefficients of the spherical harmonics
  97239. */
  97240. l20: Vector3;
  97241. /**
  97242. * The l2,1 coefficients of the spherical harmonics
  97243. */
  97244. l21: Vector3;
  97245. /**
  97246. * The l2,2 coefficients of the spherical harmonics
  97247. */
  97248. l22: Vector3;
  97249. /**
  97250. * Adds a light to the spherical harmonics
  97251. * @param direction the direction of the light
  97252. * @param color the color of the light
  97253. * @param deltaSolidAngle the delta solid angle of the light
  97254. */
  97255. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97256. /**
  97257. * Scales the spherical harmonics by the given amount
  97258. * @param scale the amount to scale
  97259. */
  97260. scaleInPlace(scale: number): void;
  97261. /**
  97262. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97263. *
  97264. * ```
  97265. * E_lm = A_l * L_lm
  97266. * ```
  97267. *
  97268. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97269. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97270. * the scaling factors are given in equation 9.
  97271. */
  97272. convertIncidentRadianceToIrradiance(): void;
  97273. /**
  97274. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97275. *
  97276. * ```
  97277. * L = (1/pi) * E * rho
  97278. * ```
  97279. *
  97280. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97281. */
  97282. convertIrradianceToLambertianRadiance(): void;
  97283. /**
  97284. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97285. * required operations at run time.
  97286. *
  97287. * This is simply done by scaling back the SH with Ylm constants parameter.
  97288. * The trigonometric part being applied by the shader at run time.
  97289. */
  97290. preScaleForRendering(): void;
  97291. /**
  97292. * Constructs a spherical harmonics from an array.
  97293. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97294. * @returns the spherical harmonics
  97295. */
  97296. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97297. /**
  97298. * Gets the spherical harmonics from polynomial
  97299. * @param polynomial the spherical polynomial
  97300. * @returns the spherical harmonics
  97301. */
  97302. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97303. }
  97304. /**
  97305. * Class representing spherical polynomial coefficients to the 3rd degree
  97306. */
  97307. export class SphericalPolynomial {
  97308. private _harmonics;
  97309. /**
  97310. * The spherical harmonics used to create the polynomials.
  97311. */
  97312. readonly preScaledHarmonics: SphericalHarmonics;
  97313. /**
  97314. * The x coefficients of the spherical polynomial
  97315. */
  97316. x: Vector3;
  97317. /**
  97318. * The y coefficients of the spherical polynomial
  97319. */
  97320. y: Vector3;
  97321. /**
  97322. * The z coefficients of the spherical polynomial
  97323. */
  97324. z: Vector3;
  97325. /**
  97326. * The xx coefficients of the spherical polynomial
  97327. */
  97328. xx: Vector3;
  97329. /**
  97330. * The yy coefficients of the spherical polynomial
  97331. */
  97332. yy: Vector3;
  97333. /**
  97334. * The zz coefficients of the spherical polynomial
  97335. */
  97336. zz: Vector3;
  97337. /**
  97338. * The xy coefficients of the spherical polynomial
  97339. */
  97340. xy: Vector3;
  97341. /**
  97342. * The yz coefficients of the spherical polynomial
  97343. */
  97344. yz: Vector3;
  97345. /**
  97346. * The zx coefficients of the spherical polynomial
  97347. */
  97348. zx: Vector3;
  97349. /**
  97350. * Adds an ambient color to the spherical polynomial
  97351. * @param color the color to add
  97352. */
  97353. addAmbient(color: Color3): void;
  97354. /**
  97355. * Scales the spherical polynomial by the given amount
  97356. * @param scale the amount to scale
  97357. */
  97358. scaleInPlace(scale: number): void;
  97359. /**
  97360. * Gets the spherical polynomial from harmonics
  97361. * @param harmonics the spherical harmonics
  97362. * @returns the spherical polynomial
  97363. */
  97364. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97365. /**
  97366. * Constructs a spherical polynomial from an array.
  97367. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97368. * @returns the spherical polynomial
  97369. */
  97370. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97371. }
  97372. }
  97373. declare module BABYLON {
  97374. /**
  97375. * Defines the source of the internal texture
  97376. */
  97377. export enum InternalTextureSource {
  97378. /**
  97379. * The source of the texture data is unknown
  97380. */
  97381. Unknown = 0,
  97382. /**
  97383. * Texture data comes from an URL
  97384. */
  97385. Url = 1,
  97386. /**
  97387. * Texture data is only used for temporary storage
  97388. */
  97389. Temp = 2,
  97390. /**
  97391. * Texture data comes from raw data (ArrayBuffer)
  97392. */
  97393. Raw = 3,
  97394. /**
  97395. * Texture content is dynamic (video or dynamic texture)
  97396. */
  97397. Dynamic = 4,
  97398. /**
  97399. * Texture content is generated by rendering to it
  97400. */
  97401. RenderTarget = 5,
  97402. /**
  97403. * Texture content is part of a multi render target process
  97404. */
  97405. MultiRenderTarget = 6,
  97406. /**
  97407. * Texture data comes from a cube data file
  97408. */
  97409. Cube = 7,
  97410. /**
  97411. * Texture data comes from a raw cube data
  97412. */
  97413. CubeRaw = 8,
  97414. /**
  97415. * Texture data come from a prefiltered cube data file
  97416. */
  97417. CubePrefiltered = 9,
  97418. /**
  97419. * Texture content is raw 3D data
  97420. */
  97421. Raw3D = 10,
  97422. /**
  97423. * Texture content is a depth texture
  97424. */
  97425. Depth = 11,
  97426. /**
  97427. * Texture data comes from a raw cube data encoded with RGBD
  97428. */
  97429. CubeRawRGBD = 12
  97430. }
  97431. /**
  97432. * Class used to store data associated with WebGL texture data for the engine
  97433. * This class should not be used directly
  97434. */
  97435. export class InternalTexture {
  97436. /** @hidden */
  97437. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97438. /**
  97439. * Defines if the texture is ready
  97440. */
  97441. isReady: boolean;
  97442. /**
  97443. * Defines if the texture is a cube texture
  97444. */
  97445. isCube: boolean;
  97446. /**
  97447. * Defines if the texture contains 3D data
  97448. */
  97449. is3D: boolean;
  97450. /**
  97451. * Defines if the texture contains multiview data
  97452. */
  97453. isMultiview: boolean;
  97454. /**
  97455. * Gets the URL used to load this texture
  97456. */
  97457. url: string;
  97458. /**
  97459. * Gets the sampling mode of the texture
  97460. */
  97461. samplingMode: number;
  97462. /**
  97463. * Gets a boolean indicating if the texture needs mipmaps generation
  97464. */
  97465. generateMipMaps: boolean;
  97466. /**
  97467. * Gets the number of samples used by the texture (WebGL2+ only)
  97468. */
  97469. samples: number;
  97470. /**
  97471. * Gets the type of the texture (int, float...)
  97472. */
  97473. type: number;
  97474. /**
  97475. * Gets the format of the texture (RGB, RGBA...)
  97476. */
  97477. format: number;
  97478. /**
  97479. * Observable called when the texture is loaded
  97480. */
  97481. onLoadedObservable: Observable<InternalTexture>;
  97482. /**
  97483. * Gets the width of the texture
  97484. */
  97485. width: number;
  97486. /**
  97487. * Gets the height of the texture
  97488. */
  97489. height: number;
  97490. /**
  97491. * Gets the depth of the texture
  97492. */
  97493. depth: number;
  97494. /**
  97495. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97496. */
  97497. baseWidth: number;
  97498. /**
  97499. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97500. */
  97501. baseHeight: number;
  97502. /**
  97503. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97504. */
  97505. baseDepth: number;
  97506. /**
  97507. * Gets a boolean indicating if the texture is inverted on Y axis
  97508. */
  97509. invertY: boolean;
  97510. /** @hidden */
  97511. _invertVScale: boolean;
  97512. /** @hidden */
  97513. _associatedChannel: number;
  97514. /** @hidden */
  97515. _source: InternalTextureSource;
  97516. /** @hidden */
  97517. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97518. /** @hidden */
  97519. _bufferView: Nullable<ArrayBufferView>;
  97520. /** @hidden */
  97521. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97522. /** @hidden */
  97523. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97524. /** @hidden */
  97525. _size: number;
  97526. /** @hidden */
  97527. _extension: string;
  97528. /** @hidden */
  97529. _files: Nullable<string[]>;
  97530. /** @hidden */
  97531. _workingCanvas: Nullable<HTMLCanvasElement>;
  97532. /** @hidden */
  97533. _workingContext: Nullable<CanvasRenderingContext2D>;
  97534. /** @hidden */
  97535. _framebuffer: Nullable<WebGLFramebuffer>;
  97536. /** @hidden */
  97537. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97538. /** @hidden */
  97539. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97540. /** @hidden */
  97541. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97542. /** @hidden */
  97543. _attachments: Nullable<number[]>;
  97544. /** @hidden */
  97545. _cachedCoordinatesMode: Nullable<number>;
  97546. /** @hidden */
  97547. _cachedWrapU: Nullable<number>;
  97548. /** @hidden */
  97549. _cachedWrapV: Nullable<number>;
  97550. /** @hidden */
  97551. _cachedWrapR: Nullable<number>;
  97552. /** @hidden */
  97553. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97554. /** @hidden */
  97555. _isDisabled: boolean;
  97556. /** @hidden */
  97557. _compression: Nullable<string>;
  97558. /** @hidden */
  97559. _generateStencilBuffer: boolean;
  97560. /** @hidden */
  97561. _generateDepthBuffer: boolean;
  97562. /** @hidden */
  97563. _comparisonFunction: number;
  97564. /** @hidden */
  97565. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97566. /** @hidden */
  97567. _lodGenerationScale: number;
  97568. /** @hidden */
  97569. _lodGenerationOffset: number;
  97570. /** @hidden */
  97571. _colorTextureArray: Nullable<WebGLTexture>;
  97572. /** @hidden */
  97573. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97574. /** @hidden */
  97575. _lodTextureHigh: Nullable<BaseTexture>;
  97576. /** @hidden */
  97577. _lodTextureMid: Nullable<BaseTexture>;
  97578. /** @hidden */
  97579. _lodTextureLow: Nullable<BaseTexture>;
  97580. /** @hidden */
  97581. _isRGBD: boolean;
  97582. /** @hidden */
  97583. _linearSpecularLOD: boolean;
  97584. /** @hidden */
  97585. _irradianceTexture: Nullable<BaseTexture>;
  97586. /** @hidden */
  97587. _webGLTexture: Nullable<WebGLTexture>;
  97588. /** @hidden */
  97589. _references: number;
  97590. private _engine;
  97591. /**
  97592. * Gets the Engine the texture belongs to.
  97593. * @returns The babylon engine
  97594. */
  97595. getEngine(): ThinEngine;
  97596. /**
  97597. * Gets the data source type of the texture
  97598. */
  97599. readonly source: InternalTextureSource;
  97600. /**
  97601. * Creates a new InternalTexture
  97602. * @param engine defines the engine to use
  97603. * @param source defines the type of data that will be used
  97604. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97605. */
  97606. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97607. /**
  97608. * Increments the number of references (ie. the number of Texture that point to it)
  97609. */
  97610. incrementReferences(): void;
  97611. /**
  97612. * Change the size of the texture (not the size of the content)
  97613. * @param width defines the new width
  97614. * @param height defines the new height
  97615. * @param depth defines the new depth (1 by default)
  97616. */
  97617. updateSize(width: int, height: int, depth?: int): void;
  97618. /** @hidden */
  97619. _rebuild(): void;
  97620. /** @hidden */
  97621. _swapAndDie(target: InternalTexture): void;
  97622. /**
  97623. * Dispose the current allocated resources
  97624. */
  97625. dispose(): void;
  97626. }
  97627. }
  97628. declare module BABYLON {
  97629. /**
  97630. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97632. */
  97633. export class Analyser {
  97634. /**
  97635. * Gets or sets the smoothing
  97636. * @ignorenaming
  97637. */
  97638. SMOOTHING: number;
  97639. /**
  97640. * Gets or sets the FFT table size
  97641. * @ignorenaming
  97642. */
  97643. FFT_SIZE: number;
  97644. /**
  97645. * Gets or sets the bar graph amplitude
  97646. * @ignorenaming
  97647. */
  97648. BARGRAPHAMPLITUDE: number;
  97649. /**
  97650. * Gets or sets the position of the debug canvas
  97651. * @ignorenaming
  97652. */
  97653. DEBUGCANVASPOS: {
  97654. x: number;
  97655. y: number;
  97656. };
  97657. /**
  97658. * Gets or sets the debug canvas size
  97659. * @ignorenaming
  97660. */
  97661. DEBUGCANVASSIZE: {
  97662. width: number;
  97663. height: number;
  97664. };
  97665. private _byteFreqs;
  97666. private _byteTime;
  97667. private _floatFreqs;
  97668. private _webAudioAnalyser;
  97669. private _debugCanvas;
  97670. private _debugCanvasContext;
  97671. private _scene;
  97672. private _registerFunc;
  97673. private _audioEngine;
  97674. /**
  97675. * Creates a new analyser
  97676. * @param scene defines hosting scene
  97677. */
  97678. constructor(scene: Scene);
  97679. /**
  97680. * Get the number of data values you will have to play with for the visualization
  97681. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97682. * @returns a number
  97683. */
  97684. getFrequencyBinCount(): number;
  97685. /**
  97686. * Gets the current frequency data as a byte array
  97687. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97688. * @returns a Uint8Array
  97689. */
  97690. getByteFrequencyData(): Uint8Array;
  97691. /**
  97692. * Gets the current waveform as a byte array
  97693. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97694. * @returns a Uint8Array
  97695. */
  97696. getByteTimeDomainData(): Uint8Array;
  97697. /**
  97698. * Gets the current frequency data as a float array
  97699. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97700. * @returns a Float32Array
  97701. */
  97702. getFloatFrequencyData(): Float32Array;
  97703. /**
  97704. * Renders the debug canvas
  97705. */
  97706. drawDebugCanvas(): void;
  97707. /**
  97708. * Stops rendering the debug canvas and removes it
  97709. */
  97710. stopDebugCanvas(): void;
  97711. /**
  97712. * Connects two audio nodes
  97713. * @param inputAudioNode defines first node to connect
  97714. * @param outputAudioNode defines second node to connect
  97715. */
  97716. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97717. /**
  97718. * Releases all associated resources
  97719. */
  97720. dispose(): void;
  97721. }
  97722. }
  97723. declare module BABYLON {
  97724. /**
  97725. * This represents an audio engine and it is responsible
  97726. * to play, synchronize and analyse sounds throughout the application.
  97727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97728. */
  97729. export interface IAudioEngine extends IDisposable {
  97730. /**
  97731. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97732. */
  97733. readonly canUseWebAudio: boolean;
  97734. /**
  97735. * Gets the current AudioContext if available.
  97736. */
  97737. readonly audioContext: Nullable<AudioContext>;
  97738. /**
  97739. * The master gain node defines the global audio volume of your audio engine.
  97740. */
  97741. readonly masterGain: GainNode;
  97742. /**
  97743. * Gets whether or not mp3 are supported by your browser.
  97744. */
  97745. readonly isMP3supported: boolean;
  97746. /**
  97747. * Gets whether or not ogg are supported by your browser.
  97748. */
  97749. readonly isOGGsupported: boolean;
  97750. /**
  97751. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97752. * @ignoreNaming
  97753. */
  97754. WarnedWebAudioUnsupported: boolean;
  97755. /**
  97756. * Defines if the audio engine relies on a custom unlocked button.
  97757. * In this case, the embedded button will not be displayed.
  97758. */
  97759. useCustomUnlockedButton: boolean;
  97760. /**
  97761. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97762. */
  97763. readonly unlocked: boolean;
  97764. /**
  97765. * Event raised when audio has been unlocked on the browser.
  97766. */
  97767. onAudioUnlockedObservable: Observable<AudioEngine>;
  97768. /**
  97769. * Event raised when audio has been locked on the browser.
  97770. */
  97771. onAudioLockedObservable: Observable<AudioEngine>;
  97772. /**
  97773. * Flags the audio engine in Locked state.
  97774. * This happens due to new browser policies preventing audio to autoplay.
  97775. */
  97776. lock(): void;
  97777. /**
  97778. * Unlocks the audio engine once a user action has been done on the dom.
  97779. * This is helpful to resume play once browser policies have been satisfied.
  97780. */
  97781. unlock(): void;
  97782. }
  97783. /**
  97784. * This represents the default audio engine used in babylon.
  97785. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97787. */
  97788. export class AudioEngine implements IAudioEngine {
  97789. private _audioContext;
  97790. private _audioContextInitialized;
  97791. private _muteButton;
  97792. private _hostElement;
  97793. /**
  97794. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97795. */
  97796. canUseWebAudio: boolean;
  97797. /**
  97798. * The master gain node defines the global audio volume of your audio engine.
  97799. */
  97800. masterGain: GainNode;
  97801. /**
  97802. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97803. * @ignoreNaming
  97804. */
  97805. WarnedWebAudioUnsupported: boolean;
  97806. /**
  97807. * Gets whether or not mp3 are supported by your browser.
  97808. */
  97809. isMP3supported: boolean;
  97810. /**
  97811. * Gets whether or not ogg are supported by your browser.
  97812. */
  97813. isOGGsupported: boolean;
  97814. /**
  97815. * Gets whether audio has been unlocked on the device.
  97816. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97817. * a user interaction has happened.
  97818. */
  97819. unlocked: boolean;
  97820. /**
  97821. * Defines if the audio engine relies on a custom unlocked button.
  97822. * In this case, the embedded button will not be displayed.
  97823. */
  97824. useCustomUnlockedButton: boolean;
  97825. /**
  97826. * Event raised when audio has been unlocked on the browser.
  97827. */
  97828. onAudioUnlockedObservable: Observable<AudioEngine>;
  97829. /**
  97830. * Event raised when audio has been locked on the browser.
  97831. */
  97832. onAudioLockedObservable: Observable<AudioEngine>;
  97833. /**
  97834. * Gets the current AudioContext if available.
  97835. */
  97836. readonly audioContext: Nullable<AudioContext>;
  97837. private _connectedAnalyser;
  97838. /**
  97839. * Instantiates a new audio engine.
  97840. *
  97841. * There should be only one per page as some browsers restrict the number
  97842. * of audio contexts you can create.
  97843. * @param hostElement defines the host element where to display the mute icon if necessary
  97844. */
  97845. constructor(hostElement?: Nullable<HTMLElement>);
  97846. /**
  97847. * Flags the audio engine in Locked state.
  97848. * This happens due to new browser policies preventing audio to autoplay.
  97849. */
  97850. lock(): void;
  97851. /**
  97852. * Unlocks the audio engine once a user action has been done on the dom.
  97853. * This is helpful to resume play once browser policies have been satisfied.
  97854. */
  97855. unlock(): void;
  97856. private _resumeAudioContext;
  97857. private _initializeAudioContext;
  97858. private _tryToRun;
  97859. private _triggerRunningState;
  97860. private _triggerSuspendedState;
  97861. private _displayMuteButton;
  97862. private _moveButtonToTopLeft;
  97863. private _onResize;
  97864. private _hideMuteButton;
  97865. /**
  97866. * Destroy and release the resources associated with the audio ccontext.
  97867. */
  97868. dispose(): void;
  97869. /**
  97870. * Gets the global volume sets on the master gain.
  97871. * @returns the global volume if set or -1 otherwise
  97872. */
  97873. getGlobalVolume(): number;
  97874. /**
  97875. * Sets the global volume of your experience (sets on the master gain).
  97876. * @param newVolume Defines the new global volume of the application
  97877. */
  97878. setGlobalVolume(newVolume: number): void;
  97879. /**
  97880. * Connect the audio engine to an audio analyser allowing some amazing
  97881. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97883. * @param analyser The analyser to connect to the engine
  97884. */
  97885. connectToAnalyser(analyser: Analyser): void;
  97886. }
  97887. }
  97888. declare module BABYLON {
  97889. /**
  97890. * Interface used to present a loading screen while loading a scene
  97891. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97892. */
  97893. export interface ILoadingScreen {
  97894. /**
  97895. * Function called to display the loading screen
  97896. */
  97897. displayLoadingUI: () => void;
  97898. /**
  97899. * Function called to hide the loading screen
  97900. */
  97901. hideLoadingUI: () => void;
  97902. /**
  97903. * Gets or sets the color to use for the background
  97904. */
  97905. loadingUIBackgroundColor: string;
  97906. /**
  97907. * Gets or sets the text to display while loading
  97908. */
  97909. loadingUIText: string;
  97910. }
  97911. /**
  97912. * Class used for the default loading screen
  97913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97914. */
  97915. export class DefaultLoadingScreen implements ILoadingScreen {
  97916. private _renderingCanvas;
  97917. private _loadingText;
  97918. private _loadingDivBackgroundColor;
  97919. private _loadingDiv;
  97920. private _loadingTextDiv;
  97921. /** Gets or sets the logo url to use for the default loading screen */
  97922. static DefaultLogoUrl: string;
  97923. /** Gets or sets the spinner url to use for the default loading screen */
  97924. static DefaultSpinnerUrl: string;
  97925. /**
  97926. * Creates a new default loading screen
  97927. * @param _renderingCanvas defines the canvas used to render the scene
  97928. * @param _loadingText defines the default text to display
  97929. * @param _loadingDivBackgroundColor defines the default background color
  97930. */
  97931. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97932. /**
  97933. * Function called to display the loading screen
  97934. */
  97935. displayLoadingUI(): void;
  97936. /**
  97937. * Function called to hide the loading screen
  97938. */
  97939. hideLoadingUI(): void;
  97940. /**
  97941. * Gets or sets the text to display while loading
  97942. */
  97943. loadingUIText: string;
  97944. /**
  97945. * Gets or sets the color to use for the background
  97946. */
  97947. loadingUIBackgroundColor: string;
  97948. private _resizeLoadingUI;
  97949. }
  97950. }
  97951. declare module BABYLON {
  97952. /**
  97953. * Interface for any object that can request an animation frame
  97954. */
  97955. export interface ICustomAnimationFrameRequester {
  97956. /**
  97957. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97958. */
  97959. renderFunction?: Function;
  97960. /**
  97961. * Called to request the next frame to render to
  97962. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97963. */
  97964. requestAnimationFrame: Function;
  97965. /**
  97966. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97967. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97968. */
  97969. requestID?: number;
  97970. }
  97971. }
  97972. declare module BABYLON {
  97973. /**
  97974. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97975. */
  97976. export class PerformanceMonitor {
  97977. private _enabled;
  97978. private _rollingFrameTime;
  97979. private _lastFrameTimeMs;
  97980. /**
  97981. * constructor
  97982. * @param frameSampleSize The number of samples required to saturate the sliding window
  97983. */
  97984. constructor(frameSampleSize?: number);
  97985. /**
  97986. * Samples current frame
  97987. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97988. */
  97989. sampleFrame(timeMs?: number): void;
  97990. /**
  97991. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97992. */
  97993. readonly averageFrameTime: number;
  97994. /**
  97995. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97996. */
  97997. readonly averageFrameTimeVariance: number;
  97998. /**
  97999. * Returns the frame time of the most recent frame
  98000. */
  98001. readonly instantaneousFrameTime: number;
  98002. /**
  98003. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98004. */
  98005. readonly averageFPS: number;
  98006. /**
  98007. * Returns the average framerate in frames per second using the most recent frame time
  98008. */
  98009. readonly instantaneousFPS: number;
  98010. /**
  98011. * Returns true if enough samples have been taken to completely fill the sliding window
  98012. */
  98013. readonly isSaturated: boolean;
  98014. /**
  98015. * Enables contributions to the sliding window sample set
  98016. */
  98017. enable(): void;
  98018. /**
  98019. * Disables contributions to the sliding window sample set
  98020. * Samples will not be interpolated over the disabled period
  98021. */
  98022. disable(): void;
  98023. /**
  98024. * Returns true if sampling is enabled
  98025. */
  98026. readonly isEnabled: boolean;
  98027. /**
  98028. * Resets performance monitor
  98029. */
  98030. reset(): void;
  98031. }
  98032. /**
  98033. * RollingAverage
  98034. *
  98035. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98036. */
  98037. export class RollingAverage {
  98038. /**
  98039. * Current average
  98040. */
  98041. average: number;
  98042. /**
  98043. * Current variance
  98044. */
  98045. variance: number;
  98046. protected _samples: Array<number>;
  98047. protected _sampleCount: number;
  98048. protected _pos: number;
  98049. protected _m2: number;
  98050. /**
  98051. * constructor
  98052. * @param length The number of samples required to saturate the sliding window
  98053. */
  98054. constructor(length: number);
  98055. /**
  98056. * Adds a sample to the sample set
  98057. * @param v The sample value
  98058. */
  98059. add(v: number): void;
  98060. /**
  98061. * Returns previously added values or null if outside of history or outside the sliding window domain
  98062. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98063. * @return Value previously recorded with add() or null if outside of range
  98064. */
  98065. history(i: number): number;
  98066. /**
  98067. * Returns true if enough samples have been taken to completely fill the sliding window
  98068. * @return true if sample-set saturated
  98069. */
  98070. isSaturated(): boolean;
  98071. /**
  98072. * Resets the rolling average (equivalent to 0 samples taken so far)
  98073. */
  98074. reset(): void;
  98075. /**
  98076. * Wraps a value around the sample range boundaries
  98077. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98078. * @return Wrapped position in sample range
  98079. */
  98080. protected _wrapPosition(i: number): number;
  98081. }
  98082. }
  98083. declare module BABYLON {
  98084. /**
  98085. * This class is used to track a performance counter which is number based.
  98086. * The user has access to many properties which give statistics of different nature.
  98087. *
  98088. * The implementer can track two kinds of Performance Counter: time and count.
  98089. * 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.
  98090. * 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.
  98091. */
  98092. export class PerfCounter {
  98093. /**
  98094. * Gets or sets a global boolean to turn on and off all the counters
  98095. */
  98096. static Enabled: boolean;
  98097. /**
  98098. * Returns the smallest value ever
  98099. */
  98100. readonly min: number;
  98101. /**
  98102. * Returns the biggest value ever
  98103. */
  98104. readonly max: number;
  98105. /**
  98106. * Returns the average value since the performance counter is running
  98107. */
  98108. readonly average: number;
  98109. /**
  98110. * Returns the average value of the last second the counter was monitored
  98111. */
  98112. readonly lastSecAverage: number;
  98113. /**
  98114. * Returns the current value
  98115. */
  98116. readonly current: number;
  98117. /**
  98118. * Gets the accumulated total
  98119. */
  98120. readonly total: number;
  98121. /**
  98122. * Gets the total value count
  98123. */
  98124. readonly count: number;
  98125. /**
  98126. * Creates a new counter
  98127. */
  98128. constructor();
  98129. /**
  98130. * Call this method to start monitoring a new frame.
  98131. * 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.
  98132. */
  98133. fetchNewFrame(): void;
  98134. /**
  98135. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98136. * @param newCount the count value to add to the monitored count
  98137. * @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.
  98138. */
  98139. addCount(newCount: number, fetchResult: boolean): void;
  98140. /**
  98141. * Start monitoring this performance counter
  98142. */
  98143. beginMonitoring(): void;
  98144. /**
  98145. * Compute the time lapsed since the previous beginMonitoring() call.
  98146. * @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
  98147. */
  98148. endMonitoring(newFrame?: boolean): void;
  98149. private _fetchResult;
  98150. private _startMonitoringTime;
  98151. private _min;
  98152. private _max;
  98153. private _average;
  98154. private _current;
  98155. private _totalValueCount;
  98156. private _totalAccumulated;
  98157. private _lastSecAverage;
  98158. private _lastSecAccumulated;
  98159. private _lastSecTime;
  98160. private _lastSecValueCount;
  98161. }
  98162. }
  98163. declare module BABYLON {
  98164. /**
  98165. * Defines the interface used by display changed events
  98166. */
  98167. export interface IDisplayChangedEventArgs {
  98168. /** Gets the vrDisplay object (if any) */
  98169. vrDisplay: Nullable<any>;
  98170. /** Gets a boolean indicating if webVR is supported */
  98171. vrSupported: boolean;
  98172. }
  98173. /**
  98174. * Defines the interface used by objects containing a viewport (like a camera)
  98175. */
  98176. interface IViewportOwnerLike {
  98177. /**
  98178. * Gets or sets the viewport
  98179. */
  98180. viewport: IViewportLike;
  98181. }
  98182. /**
  98183. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98184. */
  98185. export class Engine extends ThinEngine {
  98186. /** Defines that alpha blending is disabled */
  98187. static readonly ALPHA_DISABLE: number;
  98188. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98189. static readonly ALPHA_ADD: number;
  98190. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98191. static readonly ALPHA_COMBINE: number;
  98192. /** Defines that alpha blending to DEST - SRC * DEST */
  98193. static readonly ALPHA_SUBTRACT: number;
  98194. /** Defines that alpha blending to SRC * DEST */
  98195. static readonly ALPHA_MULTIPLY: number;
  98196. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98197. static readonly ALPHA_MAXIMIZED: number;
  98198. /** Defines that alpha blending to SRC + DEST */
  98199. static readonly ALPHA_ONEONE: number;
  98200. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98201. static readonly ALPHA_PREMULTIPLIED: number;
  98202. /**
  98203. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98204. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98205. */
  98206. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98207. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98208. static readonly ALPHA_INTERPOLATE: number;
  98209. /**
  98210. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98211. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98212. */
  98213. static readonly ALPHA_SCREENMODE: number;
  98214. /** Defines that the ressource is not delayed*/
  98215. static readonly DELAYLOADSTATE_NONE: number;
  98216. /** Defines that the ressource was successfully delay loaded */
  98217. static readonly DELAYLOADSTATE_LOADED: number;
  98218. /** Defines that the ressource is currently delay loading */
  98219. static readonly DELAYLOADSTATE_LOADING: number;
  98220. /** Defines that the ressource is delayed and has not started loading */
  98221. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98222. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98223. static readonly NEVER: number;
  98224. /** 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 */
  98225. static readonly ALWAYS: number;
  98226. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98227. static readonly LESS: number;
  98228. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98229. static readonly EQUAL: number;
  98230. /** 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 */
  98231. static readonly LEQUAL: number;
  98232. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98233. static readonly GREATER: number;
  98234. /** 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 */
  98235. static readonly GEQUAL: number;
  98236. /** 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 */
  98237. static readonly NOTEQUAL: number;
  98238. /** Passed to stencilOperation to specify that stencil value must be kept */
  98239. static readonly KEEP: number;
  98240. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98241. static readonly REPLACE: number;
  98242. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98243. static readonly INCR: number;
  98244. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98245. static readonly DECR: number;
  98246. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98247. static readonly INVERT: number;
  98248. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98249. static readonly INCR_WRAP: number;
  98250. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98251. static readonly DECR_WRAP: number;
  98252. /** Texture is not repeating outside of 0..1 UVs */
  98253. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98254. /** Texture is repeating outside of 0..1 UVs */
  98255. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98256. /** Texture is repeating and mirrored */
  98257. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98258. /** ALPHA */
  98259. static readonly TEXTUREFORMAT_ALPHA: number;
  98260. /** LUMINANCE */
  98261. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98262. /** LUMINANCE_ALPHA */
  98263. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98264. /** RGB */
  98265. static readonly TEXTUREFORMAT_RGB: number;
  98266. /** RGBA */
  98267. static readonly TEXTUREFORMAT_RGBA: number;
  98268. /** RED */
  98269. static readonly TEXTUREFORMAT_RED: number;
  98270. /** RED (2nd reference) */
  98271. static readonly TEXTUREFORMAT_R: number;
  98272. /** RG */
  98273. static readonly TEXTUREFORMAT_RG: number;
  98274. /** RED_INTEGER */
  98275. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98276. /** RED_INTEGER (2nd reference) */
  98277. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98278. /** RG_INTEGER */
  98279. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98280. /** RGB_INTEGER */
  98281. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98282. /** RGBA_INTEGER */
  98283. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98284. /** UNSIGNED_BYTE */
  98285. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98286. /** UNSIGNED_BYTE (2nd reference) */
  98287. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98288. /** FLOAT */
  98289. static readonly TEXTURETYPE_FLOAT: number;
  98290. /** HALF_FLOAT */
  98291. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98292. /** BYTE */
  98293. static readonly TEXTURETYPE_BYTE: number;
  98294. /** SHORT */
  98295. static readonly TEXTURETYPE_SHORT: number;
  98296. /** UNSIGNED_SHORT */
  98297. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98298. /** INT */
  98299. static readonly TEXTURETYPE_INT: number;
  98300. /** UNSIGNED_INT */
  98301. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98302. /** UNSIGNED_SHORT_4_4_4_4 */
  98303. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98304. /** UNSIGNED_SHORT_5_5_5_1 */
  98305. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98306. /** UNSIGNED_SHORT_5_6_5 */
  98307. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98308. /** UNSIGNED_INT_2_10_10_10_REV */
  98309. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98310. /** UNSIGNED_INT_24_8 */
  98311. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98312. /** UNSIGNED_INT_10F_11F_11F_REV */
  98313. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98314. /** UNSIGNED_INT_5_9_9_9_REV */
  98315. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98316. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98317. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98318. /** nearest is mag = nearest and min = nearest and mip = linear */
  98319. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98320. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98321. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98322. /** Trilinear is mag = linear and min = linear and mip = linear */
  98323. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98324. /** nearest is mag = nearest and min = nearest and mip = linear */
  98325. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98326. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98327. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98328. /** Trilinear is mag = linear and min = linear and mip = linear */
  98329. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98330. /** mag = nearest and min = nearest and mip = nearest */
  98331. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98332. /** mag = nearest and min = linear and mip = nearest */
  98333. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98334. /** mag = nearest and min = linear and mip = linear */
  98335. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98336. /** mag = nearest and min = linear and mip = none */
  98337. static readonly TEXTURE_NEAREST_LINEAR: number;
  98338. /** mag = nearest and min = nearest and mip = none */
  98339. static readonly TEXTURE_NEAREST_NEAREST: number;
  98340. /** mag = linear and min = nearest and mip = nearest */
  98341. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98342. /** mag = linear and min = nearest and mip = linear */
  98343. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98344. /** mag = linear and min = linear and mip = none */
  98345. static readonly TEXTURE_LINEAR_LINEAR: number;
  98346. /** mag = linear and min = nearest and mip = none */
  98347. static readonly TEXTURE_LINEAR_NEAREST: number;
  98348. /** Explicit coordinates mode */
  98349. static readonly TEXTURE_EXPLICIT_MODE: number;
  98350. /** Spherical coordinates mode */
  98351. static readonly TEXTURE_SPHERICAL_MODE: number;
  98352. /** Planar coordinates mode */
  98353. static readonly TEXTURE_PLANAR_MODE: number;
  98354. /** Cubic coordinates mode */
  98355. static readonly TEXTURE_CUBIC_MODE: number;
  98356. /** Projection coordinates mode */
  98357. static readonly TEXTURE_PROJECTION_MODE: number;
  98358. /** Skybox coordinates mode */
  98359. static readonly TEXTURE_SKYBOX_MODE: number;
  98360. /** Inverse Cubic coordinates mode */
  98361. static readonly TEXTURE_INVCUBIC_MODE: number;
  98362. /** Equirectangular coordinates mode */
  98363. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98364. /** Equirectangular Fixed coordinates mode */
  98365. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98366. /** Equirectangular Fixed Mirrored coordinates mode */
  98367. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98368. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98369. static readonly SCALEMODE_FLOOR: number;
  98370. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98371. static readonly SCALEMODE_NEAREST: number;
  98372. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98373. static readonly SCALEMODE_CEILING: number;
  98374. /**
  98375. * Returns the current npm package of the sdk
  98376. */
  98377. static readonly NpmPackage: string;
  98378. /**
  98379. * Returns the current version of the framework
  98380. */
  98381. static readonly Version: string;
  98382. /** Gets the list of created engines */
  98383. static readonly Instances: Engine[];
  98384. /**
  98385. * Gets the latest created engine
  98386. */
  98387. static readonly LastCreatedEngine: Nullable<Engine>;
  98388. /**
  98389. * Gets the latest created scene
  98390. */
  98391. static readonly LastCreatedScene: Nullable<Scene>;
  98392. /**
  98393. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98394. * @param flag defines which part of the materials must be marked as dirty
  98395. * @param predicate defines a predicate used to filter which materials should be affected
  98396. */
  98397. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98398. /**
  98399. * Method called to create the default loading screen.
  98400. * This can be overriden in your own app.
  98401. * @param canvas The rendering canvas element
  98402. * @returns The loading screen
  98403. */
  98404. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98405. /**
  98406. * Method called to create the default rescale post process on each engine.
  98407. */
  98408. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98409. /**
  98410. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98411. **/
  98412. enableOfflineSupport: boolean;
  98413. /**
  98414. * 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)
  98415. **/
  98416. disableManifestCheck: boolean;
  98417. /**
  98418. * Gets the list of created scenes
  98419. */
  98420. scenes: Scene[];
  98421. /**
  98422. * Event raised when a new scene is created
  98423. */
  98424. onNewSceneAddedObservable: Observable<Scene>;
  98425. /**
  98426. * Gets the list of created postprocesses
  98427. */
  98428. postProcesses: PostProcess[];
  98429. /**
  98430. * Gets a boolean indicating if the pointer is currently locked
  98431. */
  98432. isPointerLock: boolean;
  98433. /**
  98434. * Observable event triggered each time the rendering canvas is resized
  98435. */
  98436. onResizeObservable: Observable<Engine>;
  98437. /**
  98438. * Observable event triggered each time the canvas loses focus
  98439. */
  98440. onCanvasBlurObservable: Observable<Engine>;
  98441. /**
  98442. * Observable event triggered each time the canvas gains focus
  98443. */
  98444. onCanvasFocusObservable: Observable<Engine>;
  98445. /**
  98446. * Observable event triggered each time the canvas receives pointerout event
  98447. */
  98448. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98449. /**
  98450. * Observable raised when the engine begins a new frame
  98451. */
  98452. onBeginFrameObservable: Observable<Engine>;
  98453. /**
  98454. * If set, will be used to request the next animation frame for the render loop
  98455. */
  98456. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98457. /**
  98458. * Observable raised when the engine ends the current frame
  98459. */
  98460. onEndFrameObservable: Observable<Engine>;
  98461. /**
  98462. * Observable raised when the engine is about to compile a shader
  98463. */
  98464. onBeforeShaderCompilationObservable: Observable<Engine>;
  98465. /**
  98466. * Observable raised when the engine has jsut compiled a shader
  98467. */
  98468. onAfterShaderCompilationObservable: Observable<Engine>;
  98469. /**
  98470. * Gets the audio engine
  98471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98472. * @ignorenaming
  98473. */
  98474. static audioEngine: IAudioEngine;
  98475. /**
  98476. * Default AudioEngine factory responsible of creating the Audio Engine.
  98477. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98478. */
  98479. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98480. /**
  98481. * Default offline support factory responsible of creating a tool used to store data locally.
  98482. * By default, this will create a Database object if the workload has been embedded.
  98483. */
  98484. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98485. private _loadingScreen;
  98486. private _pointerLockRequested;
  98487. private _dummyFramebuffer;
  98488. private _rescalePostProcess;
  98489. /** @hidden */
  98490. protected _alphaMode: number;
  98491. /** @hidden */
  98492. protected _alphaEquation: number;
  98493. private _deterministicLockstep;
  98494. private _lockstepMaxSteps;
  98495. protected readonly _supportsHardwareTextureRescaling: boolean;
  98496. private _fps;
  98497. private _deltaTime;
  98498. /** @hidden */
  98499. _drawCalls: PerfCounter;
  98500. /**
  98501. * Turn this value on if you want to pause FPS computation when in background
  98502. */
  98503. disablePerformanceMonitorInBackground: boolean;
  98504. private _performanceMonitor;
  98505. /**
  98506. * Gets the performance monitor attached to this engine
  98507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98508. */
  98509. readonly performanceMonitor: PerformanceMonitor;
  98510. private _onFocus;
  98511. private _onBlur;
  98512. private _onCanvasPointerOut;
  98513. private _onCanvasBlur;
  98514. private _onCanvasFocus;
  98515. private _onFullscreenChange;
  98516. private _onPointerLockChange;
  98517. /**
  98518. * Creates a new engine
  98519. * @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
  98520. * @param antialias defines enable antialiasing (default: false)
  98521. * @param options defines further options to be sent to the getContext() function
  98522. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98523. */
  98524. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98525. /**
  98526. * Gets current aspect ratio
  98527. * @param viewportOwner defines the camera to use to get the aspect ratio
  98528. * @param useScreen defines if screen size must be used (or the current render target if any)
  98529. * @returns a number defining the aspect ratio
  98530. */
  98531. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98532. /**
  98533. * Gets current screen aspect ratio
  98534. * @returns a number defining the aspect ratio
  98535. */
  98536. getScreenAspectRatio(): number;
  98537. /**
  98538. * Gets host document
  98539. * @returns the host document object
  98540. */
  98541. getHostDocument(): Document;
  98542. /**
  98543. * Gets the client rect of the HTML canvas attached with the current webGL context
  98544. * @returns a client rectanglee
  98545. */
  98546. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98547. /**
  98548. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98550. * @returns true if engine is in deterministic lock step mode
  98551. */
  98552. isDeterministicLockStep(): boolean;
  98553. /**
  98554. * Gets the max steps when engine is running in deterministic lock step
  98555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98556. * @returns the max steps
  98557. */
  98558. getLockstepMaxSteps(): number;
  98559. /**
  98560. * Force the mipmap generation for the given render target texture
  98561. * @param texture defines the render target texture to use
  98562. */
  98563. generateMipMapsForCubemap(texture: InternalTexture): void;
  98564. /** States */
  98565. /**
  98566. * Set various states to the webGL context
  98567. * @param culling defines backface culling state
  98568. * @param zOffset defines the value to apply to zOffset (0 by default)
  98569. * @param force defines if states must be applied even if cache is up to date
  98570. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98571. */
  98572. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98573. /**
  98574. * Set the z offset to apply to current rendering
  98575. * @param value defines the offset to apply
  98576. */
  98577. setZOffset(value: number): void;
  98578. /**
  98579. * Gets the current value of the zOffset
  98580. * @returns the current zOffset state
  98581. */
  98582. getZOffset(): number;
  98583. /**
  98584. * Enable or disable depth buffering
  98585. * @param enable defines the state to set
  98586. */
  98587. setDepthBuffer(enable: boolean): void;
  98588. /**
  98589. * Gets a boolean indicating if depth writing is enabled
  98590. * @returns the current depth writing state
  98591. */
  98592. getDepthWrite(): boolean;
  98593. /**
  98594. * Enable or disable depth writing
  98595. * @param enable defines the state to set
  98596. */
  98597. setDepthWrite(enable: boolean): void;
  98598. /**
  98599. * Enable or disable color writing
  98600. * @param enable defines the state to set
  98601. */
  98602. setColorWrite(enable: boolean): void;
  98603. /**
  98604. * Gets a boolean indicating if color writing is enabled
  98605. * @returns the current color writing state
  98606. */
  98607. getColorWrite(): boolean;
  98608. /**
  98609. * Sets alpha constants used by some alpha blending modes
  98610. * @param r defines the red component
  98611. * @param g defines the green component
  98612. * @param b defines the blue component
  98613. * @param a defines the alpha component
  98614. */
  98615. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98616. /**
  98617. * Sets the current alpha mode
  98618. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98619. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98620. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98621. */
  98622. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98623. /**
  98624. * Gets the current alpha mode
  98625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98626. * @returns the current alpha mode
  98627. */
  98628. getAlphaMode(): number;
  98629. /**
  98630. * Sets the current alpha equation
  98631. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98632. */
  98633. setAlphaEquation(equation: number): void;
  98634. /**
  98635. * Gets the current alpha equation.
  98636. * @returns the current alpha equation
  98637. */
  98638. getAlphaEquation(): number;
  98639. /**
  98640. * Gets a boolean indicating if stencil buffer is enabled
  98641. * @returns the current stencil buffer state
  98642. */
  98643. getStencilBuffer(): boolean;
  98644. /**
  98645. * Enable or disable the stencil buffer
  98646. * @param enable defines if the stencil buffer must be enabled or disabled
  98647. */
  98648. setStencilBuffer(enable: boolean): void;
  98649. /**
  98650. * Gets the current stencil mask
  98651. * @returns a number defining the new stencil mask to use
  98652. */
  98653. getStencilMask(): number;
  98654. /**
  98655. * Sets the current stencil mask
  98656. * @param mask defines the new stencil mask to use
  98657. */
  98658. setStencilMask(mask: number): void;
  98659. /**
  98660. * Gets the current stencil function
  98661. * @returns a number defining the stencil function to use
  98662. */
  98663. getStencilFunction(): number;
  98664. /**
  98665. * Gets the current stencil reference value
  98666. * @returns a number defining the stencil reference value to use
  98667. */
  98668. getStencilFunctionReference(): number;
  98669. /**
  98670. * Gets the current stencil mask
  98671. * @returns a number defining the stencil mask to use
  98672. */
  98673. getStencilFunctionMask(): number;
  98674. /**
  98675. * Sets the current stencil function
  98676. * @param stencilFunc defines the new stencil function to use
  98677. */
  98678. setStencilFunction(stencilFunc: number): void;
  98679. /**
  98680. * Sets the current stencil reference
  98681. * @param reference defines the new stencil reference to use
  98682. */
  98683. setStencilFunctionReference(reference: number): void;
  98684. /**
  98685. * Sets the current stencil mask
  98686. * @param mask defines the new stencil mask to use
  98687. */
  98688. setStencilFunctionMask(mask: number): void;
  98689. /**
  98690. * Gets the current stencil operation when stencil fails
  98691. * @returns a number defining stencil operation to use when stencil fails
  98692. */
  98693. getStencilOperationFail(): number;
  98694. /**
  98695. * Gets the current stencil operation when depth fails
  98696. * @returns a number defining stencil operation to use when depth fails
  98697. */
  98698. getStencilOperationDepthFail(): number;
  98699. /**
  98700. * Gets the current stencil operation when stencil passes
  98701. * @returns a number defining stencil operation to use when stencil passes
  98702. */
  98703. getStencilOperationPass(): number;
  98704. /**
  98705. * Sets the stencil operation to use when stencil fails
  98706. * @param operation defines the stencil operation to use when stencil fails
  98707. */
  98708. setStencilOperationFail(operation: number): void;
  98709. /**
  98710. * Sets the stencil operation to use when depth fails
  98711. * @param operation defines the stencil operation to use when depth fails
  98712. */
  98713. setStencilOperationDepthFail(operation: number): void;
  98714. /**
  98715. * Sets the stencil operation to use when stencil passes
  98716. * @param operation defines the stencil operation to use when stencil passes
  98717. */
  98718. setStencilOperationPass(operation: number): void;
  98719. /**
  98720. * Sets a boolean indicating if the dithering state is enabled or disabled
  98721. * @param value defines the dithering state
  98722. */
  98723. setDitheringState(value: boolean): void;
  98724. /**
  98725. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98726. * @param value defines the rasterizer state
  98727. */
  98728. setRasterizerState(value: boolean): void;
  98729. /**
  98730. * Gets the current depth function
  98731. * @returns a number defining the depth function
  98732. */
  98733. getDepthFunction(): Nullable<number>;
  98734. /**
  98735. * Sets the current depth function
  98736. * @param depthFunc defines the function to use
  98737. */
  98738. setDepthFunction(depthFunc: number): void;
  98739. /**
  98740. * Sets the current depth function to GREATER
  98741. */
  98742. setDepthFunctionToGreater(): void;
  98743. /**
  98744. * Sets the current depth function to GEQUAL
  98745. */
  98746. setDepthFunctionToGreaterOrEqual(): void;
  98747. /**
  98748. * Sets the current depth function to LESS
  98749. */
  98750. setDepthFunctionToLess(): void;
  98751. /**
  98752. * Sets the current depth function to LEQUAL
  98753. */
  98754. setDepthFunctionToLessOrEqual(): void;
  98755. private _cachedStencilBuffer;
  98756. private _cachedStencilFunction;
  98757. private _cachedStencilMask;
  98758. private _cachedStencilOperationPass;
  98759. private _cachedStencilOperationFail;
  98760. private _cachedStencilOperationDepthFail;
  98761. private _cachedStencilReference;
  98762. /**
  98763. * Caches the the state of the stencil buffer
  98764. */
  98765. cacheStencilState(): void;
  98766. /**
  98767. * Restores the state of the stencil buffer
  98768. */
  98769. restoreStencilState(): void;
  98770. /**
  98771. * Directly set the WebGL Viewport
  98772. * @param x defines the x coordinate of the viewport (in screen space)
  98773. * @param y defines the y coordinate of the viewport (in screen space)
  98774. * @param width defines the width of the viewport (in screen space)
  98775. * @param height defines the height of the viewport (in screen space)
  98776. * @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
  98777. */
  98778. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98779. /**
  98780. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98781. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98782. * @param y defines the y-coordinate of the corner of the clear rectangle
  98783. * @param width defines the width of the clear rectangle
  98784. * @param height defines the height of the clear rectangle
  98785. * @param clearColor defines the clear color
  98786. */
  98787. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98788. /**
  98789. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98790. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98791. * @param y defines the y-coordinate of the corner of the clear rectangle
  98792. * @param width defines the width of the clear rectangle
  98793. * @param height defines the height of the clear rectangle
  98794. */
  98795. enableScissor(x: number, y: number, width: number, height: number): void;
  98796. /**
  98797. * Disable previously set scissor test rectangle
  98798. */
  98799. disableScissor(): void;
  98800. protected _reportDrawCall(): void;
  98801. /**
  98802. * Initializes a webVR display and starts listening to display change events
  98803. * The onVRDisplayChangedObservable will be notified upon these changes
  98804. * @returns The onVRDisplayChangedObservable
  98805. */
  98806. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98807. /** @hidden */
  98808. _prepareVRComponent(): void;
  98809. /** @hidden */
  98810. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98811. /** @hidden */
  98812. _submitVRFrame(): void;
  98813. /**
  98814. * Call this function to leave webVR mode
  98815. * Will do nothing if webVR is not supported or if there is no webVR device
  98816. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98817. */
  98818. disableVR(): void;
  98819. /**
  98820. * Gets a boolean indicating that the system is in VR mode and is presenting
  98821. * @returns true if VR mode is engaged
  98822. */
  98823. isVRPresenting(): boolean;
  98824. /** @hidden */
  98825. _requestVRFrame(): void;
  98826. /** @hidden */
  98827. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98828. /**
  98829. * Gets the source code of the vertex shader associated with a specific webGL program
  98830. * @param program defines the program to use
  98831. * @returns a string containing the source code of the vertex shader associated with the program
  98832. */
  98833. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98834. /**
  98835. * Gets the source code of the fragment shader associated with a specific webGL program
  98836. * @param program defines the program to use
  98837. * @returns a string containing the source code of the fragment shader associated with the program
  98838. */
  98839. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98840. /**
  98841. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98842. * @param x defines the x coordinate of the rectangle where pixels must be read
  98843. * @param y defines the y coordinate of the rectangle where pixels must be read
  98844. * @param width defines the width of the rectangle where pixels must be read
  98845. * @param height defines the height of the rectangle where pixels must be read
  98846. * @returns a Uint8Array containing RGBA colors
  98847. */
  98848. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98849. /**
  98850. * Sets a depth stencil texture from a render target to the according uniform.
  98851. * @param channel The texture channel
  98852. * @param uniform The uniform to set
  98853. * @param texture The render target texture containing the depth stencil texture to apply
  98854. */
  98855. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98856. /**
  98857. * Sets a texture to the webGL context from a postprocess
  98858. * @param channel defines the channel to use
  98859. * @param postProcess defines the source postprocess
  98860. */
  98861. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98862. /**
  98863. * Binds the output of the passed in post process to the texture channel specified
  98864. * @param channel The channel the texture should be bound to
  98865. * @param postProcess The post process which's output should be bound
  98866. */
  98867. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98868. /** @hidden */
  98869. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98870. protected _rebuildBuffers(): void;
  98871. _renderLoop(): void;
  98872. /**
  98873. * Toggle full screen mode
  98874. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98875. */
  98876. switchFullscreen(requestPointerLock: boolean): void;
  98877. /**
  98878. * Enters full screen mode
  98879. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98880. */
  98881. enterFullscreen(requestPointerLock: boolean): void;
  98882. /**
  98883. * Exits full screen mode
  98884. */
  98885. exitFullscreen(): void;
  98886. /**
  98887. * Enters Pointerlock mode
  98888. */
  98889. enterPointerlock(): void;
  98890. /**
  98891. * Exits Pointerlock mode
  98892. */
  98893. exitPointerlock(): void;
  98894. /**
  98895. * Begin a new frame
  98896. */
  98897. beginFrame(): void;
  98898. /**
  98899. * Enf the current frame
  98900. */
  98901. endFrame(): void;
  98902. resize(): void;
  98903. /**
  98904. * Set the compressed texture format to use, based on the formats you have, and the formats
  98905. * supported by the hardware / browser.
  98906. *
  98907. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98908. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98909. * to API arguments needed to compressed textures. This puts the burden on the container
  98910. * generator to house the arcane code for determining these for current & future formats.
  98911. *
  98912. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98913. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98914. *
  98915. * Note: The result of this call is not taken into account when a texture is base64.
  98916. *
  98917. * @param formatsAvailable defines the list of those format families you have created
  98918. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98919. *
  98920. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98921. * @returns The extension selected.
  98922. */
  98923. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98924. /**
  98925. * Force a specific size of the canvas
  98926. * @param width defines the new canvas' width
  98927. * @param height defines the new canvas' height
  98928. */
  98929. setSize(width: number, height: number): void;
  98930. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98931. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98932. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98933. _releaseTexture(texture: InternalTexture): void;
  98934. /**
  98935. * @hidden
  98936. * Rescales a texture
  98937. * @param source input texutre
  98938. * @param destination destination texture
  98939. * @param scene scene to use to render the resize
  98940. * @param internalFormat format to use when resizing
  98941. * @param onComplete callback to be called when resize has completed
  98942. */
  98943. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98944. /**
  98945. * Gets the current framerate
  98946. * @returns a number representing the framerate
  98947. */
  98948. getFps(): number;
  98949. /**
  98950. * Gets the time spent between current and previous frame
  98951. * @returns a number representing the delta time in ms
  98952. */
  98953. getDeltaTime(): number;
  98954. private _measureFps;
  98955. /**
  98956. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98957. * @param renderTarget The render target to set the frame buffer for
  98958. */
  98959. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98960. /**
  98961. * Update a dynamic index buffer
  98962. * @param indexBuffer defines the target index buffer
  98963. * @param indices defines the data to update
  98964. * @param offset defines the offset in the target index buffer where update should start
  98965. */
  98966. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98967. /**
  98968. * Updates the sample count of a render target texture
  98969. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98970. * @param texture defines the texture to update
  98971. * @param samples defines the sample count to set
  98972. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98973. */
  98974. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98975. /** @hidden */
  98976. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98977. dispose(): void;
  98978. private _disableTouchAction;
  98979. /**
  98980. * Display the loading screen
  98981. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98982. */
  98983. displayLoadingUI(): void;
  98984. /**
  98985. * Hide the loading screen
  98986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98987. */
  98988. hideLoadingUI(): void;
  98989. /**
  98990. * Gets the current loading screen object
  98991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98992. */
  98993. /**
  98994. * Sets the current loading screen object
  98995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98996. */
  98997. loadingScreen: ILoadingScreen;
  98998. /**
  98999. * Sets the current loading screen text
  99000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99001. */
  99002. loadingUIText: string;
  99003. /**
  99004. * Sets the current loading screen background color
  99005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99006. */
  99007. loadingUIBackgroundColor: string;
  99008. /** Pointerlock and fullscreen */
  99009. /**
  99010. * Ask the browser to promote the current element to pointerlock mode
  99011. * @param element defines the DOM element to promote
  99012. */
  99013. static _RequestPointerlock(element: HTMLElement): void;
  99014. /**
  99015. * Asks the browser to exit pointerlock mode
  99016. */
  99017. static _ExitPointerlock(): void;
  99018. /**
  99019. * Ask the browser to promote the current element to fullscreen rendering mode
  99020. * @param element defines the DOM element to promote
  99021. */
  99022. static _RequestFullscreen(element: HTMLElement): void;
  99023. /**
  99024. * Asks the browser to exit fullscreen mode
  99025. */
  99026. static _ExitFullscreen(): void;
  99027. }
  99028. }
  99029. declare module BABYLON {
  99030. /**
  99031. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99032. * during the life time of the application.
  99033. */
  99034. export class EngineStore {
  99035. /** Gets the list of created engines */
  99036. static Instances: Engine[];
  99037. /** @hidden */
  99038. static _LastCreatedScene: Nullable<Scene>;
  99039. /**
  99040. * Gets the latest created engine
  99041. */
  99042. static readonly LastCreatedEngine: Nullable<Engine>;
  99043. /**
  99044. * Gets the latest created scene
  99045. */
  99046. static readonly LastCreatedScene: Nullable<Scene>;
  99047. /**
  99048. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99049. * @ignorenaming
  99050. */
  99051. static UseFallbackTexture: boolean;
  99052. /**
  99053. * Texture content used if a texture cannot loaded
  99054. * @ignorenaming
  99055. */
  99056. static FallbackTexture: string;
  99057. }
  99058. }
  99059. declare module BABYLON {
  99060. /**
  99061. * Helper class that provides a small promise polyfill
  99062. */
  99063. export class PromisePolyfill {
  99064. /**
  99065. * Static function used to check if the polyfill is required
  99066. * If this is the case then the function will inject the polyfill to window.Promise
  99067. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99068. */
  99069. static Apply(force?: boolean): void;
  99070. }
  99071. }
  99072. declare module BABYLON {
  99073. /**
  99074. * Interface for screenshot methods with describe argument called `size` as object with options
  99075. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99076. */
  99077. export interface IScreenshotSize {
  99078. /**
  99079. * number in pixels for canvas height
  99080. */
  99081. height?: number;
  99082. /**
  99083. * multiplier allowing render at a higher or lower resolution
  99084. * If value is defined then height and width will be ignored and taken from camera
  99085. */
  99086. precision?: number;
  99087. /**
  99088. * number in pixels for canvas width
  99089. */
  99090. width?: number;
  99091. }
  99092. }
  99093. declare module BABYLON {
  99094. interface IColor4Like {
  99095. r: float;
  99096. g: float;
  99097. b: float;
  99098. a: float;
  99099. }
  99100. /**
  99101. * Class containing a set of static utilities functions
  99102. */
  99103. export class Tools {
  99104. /**
  99105. * Gets or sets the base URL to use to load assets
  99106. */
  99107. static BaseUrl: string;
  99108. /**
  99109. * Enable/Disable Custom HTTP Request Headers globally.
  99110. * default = false
  99111. * @see CustomRequestHeaders
  99112. */
  99113. static UseCustomRequestHeaders: boolean;
  99114. /**
  99115. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99116. * i.e. when loading files, where the server/service expects an Authorization header
  99117. */
  99118. static CustomRequestHeaders: {
  99119. [key: string]: string;
  99120. };
  99121. /**
  99122. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99123. */
  99124. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99125. /**
  99126. * Default behaviour for cors in the application.
  99127. * It can be a string if the expected behavior is identical in the entire app.
  99128. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99129. */
  99130. static CorsBehavior: string | ((url: string | string[]) => string);
  99131. /**
  99132. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99133. * @ignorenaming
  99134. */
  99135. static UseFallbackTexture: boolean;
  99136. /**
  99137. * Use this object to register external classes like custom textures or material
  99138. * to allow the laoders to instantiate them
  99139. */
  99140. static RegisteredExternalClasses: {
  99141. [key: string]: Object;
  99142. };
  99143. /**
  99144. * Texture content used if a texture cannot loaded
  99145. * @ignorenaming
  99146. */
  99147. static fallbackTexture: string;
  99148. /**
  99149. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99150. * @param u defines the coordinate on X axis
  99151. * @param v defines the coordinate on Y axis
  99152. * @param width defines the width of the source data
  99153. * @param height defines the height of the source data
  99154. * @param pixels defines the source byte array
  99155. * @param color defines the output color
  99156. */
  99157. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99158. /**
  99159. * Interpolates between a and b via alpha
  99160. * @param a The lower value (returned when alpha = 0)
  99161. * @param b The upper value (returned when alpha = 1)
  99162. * @param alpha The interpolation-factor
  99163. * @return The mixed value
  99164. */
  99165. static Mix(a: number, b: number, alpha: number): number;
  99166. /**
  99167. * Tries to instantiate a new object from a given class name
  99168. * @param className defines the class name to instantiate
  99169. * @returns the new object or null if the system was not able to do the instantiation
  99170. */
  99171. static Instantiate(className: string): any;
  99172. /**
  99173. * Provides a slice function that will work even on IE
  99174. * @param data defines the array to slice
  99175. * @param start defines the start of the data (optional)
  99176. * @param end defines the end of the data (optional)
  99177. * @returns the new sliced array
  99178. */
  99179. static Slice<T>(data: T, start?: number, end?: number): T;
  99180. /**
  99181. * Polyfill for setImmediate
  99182. * @param action defines the action to execute after the current execution block
  99183. */
  99184. static SetImmediate(action: () => void): void;
  99185. /**
  99186. * Function indicating if a number is an exponent of 2
  99187. * @param value defines the value to test
  99188. * @returns true if the value is an exponent of 2
  99189. */
  99190. static IsExponentOfTwo(value: number): boolean;
  99191. private static _tmpFloatArray;
  99192. /**
  99193. * Returns the nearest 32-bit single precision float representation of a Number
  99194. * @param value A Number. If the parameter is of a different type, it will get converted
  99195. * to a number or to NaN if it cannot be converted
  99196. * @returns number
  99197. */
  99198. static FloatRound(value: number): number;
  99199. /**
  99200. * Extracts the filename from a path
  99201. * @param path defines the path to use
  99202. * @returns the filename
  99203. */
  99204. static GetFilename(path: string): string;
  99205. /**
  99206. * Extracts the "folder" part of a path (everything before the filename).
  99207. * @param uri The URI to extract the info from
  99208. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99209. * @returns The "folder" part of the path
  99210. */
  99211. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99212. /**
  99213. * Extracts text content from a DOM element hierarchy
  99214. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99215. */
  99216. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99217. /**
  99218. * Convert an angle in radians to degrees
  99219. * @param angle defines the angle to convert
  99220. * @returns the angle in degrees
  99221. */
  99222. static ToDegrees(angle: number): number;
  99223. /**
  99224. * Convert an angle in degrees to radians
  99225. * @param angle defines the angle to convert
  99226. * @returns the angle in radians
  99227. */
  99228. static ToRadians(angle: number): number;
  99229. /**
  99230. * Encode a buffer to a base64 string
  99231. * @param buffer defines the buffer to encode
  99232. * @returns the encoded string
  99233. */
  99234. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  99235. /**
  99236. * Returns an array if obj is not an array
  99237. * @param obj defines the object to evaluate as an array
  99238. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99239. * @returns either obj directly if obj is an array or a new array containing obj
  99240. */
  99241. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99242. /**
  99243. * Gets the pointer prefix to use
  99244. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99245. */
  99246. static GetPointerPrefix(): string;
  99247. /**
  99248. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99249. * @param url define the url we are trying
  99250. * @param element define the dom element where to configure the cors policy
  99251. */
  99252. static SetCorsBehavior(url: string | string[], element: {
  99253. crossOrigin: string | null;
  99254. }): void;
  99255. /**
  99256. * Removes unwanted characters from an url
  99257. * @param url defines the url to clean
  99258. * @returns the cleaned url
  99259. */
  99260. static CleanUrl(url: string): string;
  99261. /**
  99262. * Gets or sets a function used to pre-process url before using them to load assets
  99263. */
  99264. static PreprocessUrl: (url: string) => string;
  99265. /**
  99266. * Loads an image as an HTMLImageElement.
  99267. * @param input url string, ArrayBuffer, or Blob to load
  99268. * @param onLoad callback called when the image successfully loads
  99269. * @param onError callback called when the image fails to load
  99270. * @param offlineProvider offline provider for caching
  99271. * @param mimeType optional mime type
  99272. * @returns the HTMLImageElement of the loaded image
  99273. */
  99274. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  99275. /**
  99276. * Loads a file
  99277. * @param url url string, ArrayBuffer, or Blob to load
  99278. * @param onSuccess callback called when the file successfully loads
  99279. * @param onProgress callback called while file is loading (if the server supports this mode)
  99280. * @param offlineProvider defines the offline provider for caching
  99281. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99282. * @param onError callback called when the file fails to load
  99283. * @returns a file request object
  99284. */
  99285. 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;
  99286. /**
  99287. * Loads a file from a url
  99288. * @param url the file url to load
  99289. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99290. */
  99291. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99292. /**
  99293. * Load a script (identified by an url). When the url returns, the
  99294. * content of this file is added into a new script element, attached to the DOM (body element)
  99295. * @param scriptUrl defines the url of the script to laod
  99296. * @param onSuccess defines the callback called when the script is loaded
  99297. * @param onError defines the callback to call if an error occurs
  99298. * @param scriptId defines the id of the script element
  99299. */
  99300. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99301. /**
  99302. * Load an asynchronous script (identified by an url). When the url returns, the
  99303. * content of this file is added into a new script element, attached to the DOM (body element)
  99304. * @param scriptUrl defines the url of the script to laod
  99305. * @param scriptId defines the id of the script element
  99306. * @returns a promise request object
  99307. */
  99308. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99309. /**
  99310. * Loads a file from a blob
  99311. * @param fileToLoad defines the blob to use
  99312. * @param callback defines the callback to call when data is loaded
  99313. * @param progressCallback defines the callback to call during loading process
  99314. * @returns a file request object
  99315. */
  99316. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99317. /**
  99318. * Loads a file
  99319. * @param fileToLoad defines the file to load
  99320. * @param callback defines the callback to call when data is loaded
  99321. * @param progressCallBack defines the callback to call during loading process
  99322. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99323. * @returns a file request object
  99324. */
  99325. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  99326. /**
  99327. * Creates a data url from a given string content
  99328. * @param content defines the content to convert
  99329. * @returns the new data url link
  99330. */
  99331. static FileAsURL(content: string): string;
  99332. /**
  99333. * Format the given number to a specific decimal format
  99334. * @param value defines the number to format
  99335. * @param decimals defines the number of decimals to use
  99336. * @returns the formatted string
  99337. */
  99338. static Format(value: number, decimals?: number): string;
  99339. /**
  99340. * Tries to copy an object by duplicating every property
  99341. * @param source defines the source object
  99342. * @param destination defines the target object
  99343. * @param doNotCopyList defines a list of properties to avoid
  99344. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99345. */
  99346. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99347. /**
  99348. * Gets a boolean indicating if the given object has no own property
  99349. * @param obj defines the object to test
  99350. * @returns true if object has no own property
  99351. */
  99352. static IsEmpty(obj: any): boolean;
  99353. /**
  99354. * Function used to register events at window level
  99355. * @param windowElement defines the Window object to use
  99356. * @param events defines the events to register
  99357. */
  99358. static RegisterTopRootEvents(windowElement: Window, events: {
  99359. name: string;
  99360. handler: Nullable<(e: FocusEvent) => any>;
  99361. }[]): void;
  99362. /**
  99363. * Function used to unregister events from window level
  99364. * @param windowElement defines the Window object to use
  99365. * @param events defines the events to unregister
  99366. */
  99367. static UnregisterTopRootEvents(windowElement: Window, events: {
  99368. name: string;
  99369. handler: Nullable<(e: FocusEvent) => any>;
  99370. }[]): void;
  99371. /**
  99372. * @ignore
  99373. */
  99374. static _ScreenshotCanvas: HTMLCanvasElement;
  99375. /**
  99376. * Dumps the current bound framebuffer
  99377. * @param width defines the rendering width
  99378. * @param height defines the rendering height
  99379. * @param engine defines the hosting engine
  99380. * @param successCallback defines the callback triggered once the data are available
  99381. * @param mimeType defines the mime type of the result
  99382. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99383. */
  99384. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99385. /**
  99386. * Converts the canvas data to blob.
  99387. * This acts as a polyfill for browsers not supporting the to blob function.
  99388. * @param canvas Defines the canvas to extract the data from
  99389. * @param successCallback Defines the callback triggered once the data are available
  99390. * @param mimeType Defines the mime type of the result
  99391. */
  99392. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99393. /**
  99394. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99395. * @param successCallback defines the callback triggered once the data are available
  99396. * @param mimeType defines the mime type of the result
  99397. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99398. */
  99399. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99400. /**
  99401. * Downloads a blob in the browser
  99402. * @param blob defines the blob to download
  99403. * @param fileName defines the name of the downloaded file
  99404. */
  99405. static Download(blob: Blob, fileName: string): void;
  99406. /**
  99407. * Captures a screenshot of the current rendering
  99408. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99409. * @param engine defines the rendering engine
  99410. * @param camera defines the source camera
  99411. * @param size This parameter can be set to a single number or to an object with the
  99412. * following (optional) properties: precision, width, height. If a single number is passed,
  99413. * it will be used for both width and height. If an object is passed, the screenshot size
  99414. * will be derived from the parameters. The precision property is a multiplier allowing
  99415. * rendering at a higher or lower resolution
  99416. * @param successCallback defines the callback receives a single parameter which contains the
  99417. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99418. * src parameter of an <img> to display it
  99419. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99420. * Check your browser for supported MIME types
  99421. */
  99422. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99423. /**
  99424. * Captures a screenshot of the current rendering
  99425. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99426. * @param engine defines the rendering engine
  99427. * @param camera defines the source camera
  99428. * @param size This parameter can be set to a single number or to an object with the
  99429. * following (optional) properties: precision, width, height. If a single number is passed,
  99430. * it will be used for both width and height. If an object is passed, the screenshot size
  99431. * will be derived from the parameters. The precision property is a multiplier allowing
  99432. * rendering at a higher or lower resolution
  99433. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99434. * Check your browser for supported MIME types
  99435. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99436. * to the src parameter of an <img> to display it
  99437. */
  99438. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99439. /**
  99440. * Generates an image screenshot from the specified camera.
  99441. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99442. * @param engine The engine to use for rendering
  99443. * @param camera The camera to use for rendering
  99444. * @param size This parameter can be set to a single number or to an object with the
  99445. * following (optional) properties: precision, width, height. If a single number is passed,
  99446. * it will be used for both width and height. If an object is passed, the screenshot size
  99447. * will be derived from the parameters. The precision property is a multiplier allowing
  99448. * rendering at a higher or lower resolution
  99449. * @param successCallback The callback receives a single parameter which contains the
  99450. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99451. * src parameter of an <img> to display it
  99452. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99453. * Check your browser for supported MIME types
  99454. * @param samples Texture samples (default: 1)
  99455. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99456. * @param fileName A name for for the downloaded file.
  99457. */
  99458. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99459. /**
  99460. * Generates an image screenshot from the specified camera.
  99461. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99462. * @param engine The engine to use for rendering
  99463. * @param camera The camera to use for rendering
  99464. * @param size This parameter can be set to a single number or to an object with the
  99465. * following (optional) properties: precision, width, height. If a single number is passed,
  99466. * it will be used for both width and height. If an object is passed, the screenshot size
  99467. * will be derived from the parameters. The precision property is a multiplier allowing
  99468. * rendering at a higher or lower resolution
  99469. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99470. * Check your browser for supported MIME types
  99471. * @param samples Texture samples (default: 1)
  99472. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99473. * @param fileName A name for for the downloaded file.
  99474. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99475. * to the src parameter of an <img> to display it
  99476. */
  99477. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99478. /**
  99479. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99480. * Be aware Math.random() could cause collisions, but:
  99481. * "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"
  99482. * @returns a pseudo random id
  99483. */
  99484. static RandomId(): string;
  99485. /**
  99486. * Test if the given uri is a base64 string
  99487. * @param uri The uri to test
  99488. * @return True if the uri is a base64 string or false otherwise
  99489. */
  99490. static IsBase64(uri: string): boolean;
  99491. /**
  99492. * Decode the given base64 uri.
  99493. * @param uri The uri to decode
  99494. * @return The decoded base64 data.
  99495. */
  99496. static DecodeBase64(uri: string): ArrayBuffer;
  99497. /**
  99498. * Gets the absolute url.
  99499. * @param url the input url
  99500. * @return the absolute url
  99501. */
  99502. static GetAbsoluteUrl(url: string): string;
  99503. /**
  99504. * No log
  99505. */
  99506. static readonly NoneLogLevel: number;
  99507. /**
  99508. * Only message logs
  99509. */
  99510. static readonly MessageLogLevel: number;
  99511. /**
  99512. * Only warning logs
  99513. */
  99514. static readonly WarningLogLevel: number;
  99515. /**
  99516. * Only error logs
  99517. */
  99518. static readonly ErrorLogLevel: number;
  99519. /**
  99520. * All logs
  99521. */
  99522. static readonly AllLogLevel: number;
  99523. /**
  99524. * Gets a value indicating the number of loading errors
  99525. * @ignorenaming
  99526. */
  99527. static readonly errorsCount: number;
  99528. /**
  99529. * Callback called when a new log is added
  99530. */
  99531. static OnNewCacheEntry: (entry: string) => void;
  99532. /**
  99533. * Log a message to the console
  99534. * @param message defines the message to log
  99535. */
  99536. static Log(message: string): void;
  99537. /**
  99538. * Write a warning message to the console
  99539. * @param message defines the message to log
  99540. */
  99541. static Warn(message: string): void;
  99542. /**
  99543. * Write an error message to the console
  99544. * @param message defines the message to log
  99545. */
  99546. static Error(message: string): void;
  99547. /**
  99548. * Gets current log cache (list of logs)
  99549. */
  99550. static readonly LogCache: string;
  99551. /**
  99552. * Clears the log cache
  99553. */
  99554. static ClearLogCache(): void;
  99555. /**
  99556. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99557. */
  99558. static LogLevels: number;
  99559. /**
  99560. * Checks if the window object exists
  99561. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99562. */
  99563. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99564. /**
  99565. * No performance log
  99566. */
  99567. static readonly PerformanceNoneLogLevel: number;
  99568. /**
  99569. * Use user marks to log performance
  99570. */
  99571. static readonly PerformanceUserMarkLogLevel: number;
  99572. /**
  99573. * Log performance to the console
  99574. */
  99575. static readonly PerformanceConsoleLogLevel: number;
  99576. private static _performance;
  99577. /**
  99578. * Sets the current performance log level
  99579. */
  99580. static PerformanceLogLevel: number;
  99581. private static _StartPerformanceCounterDisabled;
  99582. private static _EndPerformanceCounterDisabled;
  99583. private static _StartUserMark;
  99584. private static _EndUserMark;
  99585. private static _StartPerformanceConsole;
  99586. private static _EndPerformanceConsole;
  99587. /**
  99588. * Starts a performance counter
  99589. */
  99590. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99591. /**
  99592. * Ends a specific performance coutner
  99593. */
  99594. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99595. /**
  99596. * Gets either window.performance.now() if supported or Date.now() else
  99597. */
  99598. static readonly Now: number;
  99599. /**
  99600. * This method will return the name of the class used to create the instance of the given object.
  99601. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99602. * @param object the object to get the class name from
  99603. * @param isType defines if the object is actually a type
  99604. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99605. */
  99606. static GetClassName(object: any, isType?: boolean): string;
  99607. /**
  99608. * Gets the first element of an array satisfying a given predicate
  99609. * @param array defines the array to browse
  99610. * @param predicate defines the predicate to use
  99611. * @returns null if not found or the element
  99612. */
  99613. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99614. /**
  99615. * This method will return the name of the full name of the class, including its owning module (if any).
  99616. * 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).
  99617. * @param object the object to get the class name from
  99618. * @param isType defines if the object is actually a type
  99619. * @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.
  99620. * @ignorenaming
  99621. */
  99622. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99623. /**
  99624. * Returns a promise that resolves after the given amount of time.
  99625. * @param delay Number of milliseconds to delay
  99626. * @returns Promise that resolves after the given amount of time
  99627. */
  99628. static DelayAsync(delay: number): Promise<void>;
  99629. }
  99630. /**
  99631. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99632. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99633. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99634. * @param name The name of the class, case should be preserved
  99635. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99636. */
  99637. export function className(name: string, module?: string): (target: Object) => void;
  99638. /**
  99639. * An implementation of a loop for asynchronous functions.
  99640. */
  99641. export class AsyncLoop {
  99642. /**
  99643. * Defines the number of iterations for the loop
  99644. */
  99645. iterations: number;
  99646. /**
  99647. * Defines the current index of the loop.
  99648. */
  99649. index: number;
  99650. private _done;
  99651. private _fn;
  99652. private _successCallback;
  99653. /**
  99654. * Constructor.
  99655. * @param iterations the number of iterations.
  99656. * @param func the function to run each iteration
  99657. * @param successCallback the callback that will be called upon succesful execution
  99658. * @param offset starting offset.
  99659. */
  99660. constructor(
  99661. /**
  99662. * Defines the number of iterations for the loop
  99663. */
  99664. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99665. /**
  99666. * Execute the next iteration. Must be called after the last iteration was finished.
  99667. */
  99668. executeNext(): void;
  99669. /**
  99670. * Break the loop and run the success callback.
  99671. */
  99672. breakLoop(): void;
  99673. /**
  99674. * Create and run an async loop.
  99675. * @param iterations the number of iterations.
  99676. * @param fn the function to run each iteration
  99677. * @param successCallback the callback that will be called upon succesful execution
  99678. * @param offset starting offset.
  99679. * @returns the created async loop object
  99680. */
  99681. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99682. /**
  99683. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99684. * @param iterations total number of iterations
  99685. * @param syncedIterations number of synchronous iterations in each async iteration.
  99686. * @param fn the function to call each iteration.
  99687. * @param callback a success call back that will be called when iterating stops.
  99688. * @param breakFunction a break condition (optional)
  99689. * @param timeout timeout settings for the setTimeout function. default - 0.
  99690. * @returns the created async loop object
  99691. */
  99692. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99693. }
  99694. }
  99695. declare module BABYLON {
  99696. /**
  99697. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99698. * The underlying implementation relies on an associative array to ensure the best performances.
  99699. * The value can be anything including 'null' but except 'undefined'
  99700. */
  99701. export class StringDictionary<T> {
  99702. /**
  99703. * This will clear this dictionary and copy the content from the 'source' one.
  99704. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99705. * @param source the dictionary to take the content from and copy to this dictionary
  99706. */
  99707. copyFrom(source: StringDictionary<T>): void;
  99708. /**
  99709. * Get a value based from its key
  99710. * @param key the given key to get the matching value from
  99711. * @return the value if found, otherwise undefined is returned
  99712. */
  99713. get(key: string): T | undefined;
  99714. /**
  99715. * Get a value from its key or add it if it doesn't exist.
  99716. * This method will ensure you that a given key/data will be present in the dictionary.
  99717. * @param key the given key to get the matching value from
  99718. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99719. * The factory will only be invoked if there's no data for the given key.
  99720. * @return the value corresponding to the key.
  99721. */
  99722. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99723. /**
  99724. * Get a value from its key if present in the dictionary otherwise add it
  99725. * @param key the key to get the value from
  99726. * @param val if there's no such key/value pair in the dictionary add it with this value
  99727. * @return the value corresponding to the key
  99728. */
  99729. getOrAdd(key: string, val: T): T;
  99730. /**
  99731. * Check if there's a given key in the dictionary
  99732. * @param key the key to check for
  99733. * @return true if the key is present, false otherwise
  99734. */
  99735. contains(key: string): boolean;
  99736. /**
  99737. * Add a new key and its corresponding value
  99738. * @param key the key to add
  99739. * @param value the value corresponding to the key
  99740. * @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
  99741. */
  99742. add(key: string, value: T): boolean;
  99743. /**
  99744. * Update a specific value associated to a key
  99745. * @param key defines the key to use
  99746. * @param value defines the value to store
  99747. * @returns true if the value was updated (or false if the key was not found)
  99748. */
  99749. set(key: string, value: T): boolean;
  99750. /**
  99751. * Get the element of the given key and remove it from the dictionary
  99752. * @param key defines the key to search
  99753. * @returns the value associated with the key or null if not found
  99754. */
  99755. getAndRemove(key: string): Nullable<T>;
  99756. /**
  99757. * Remove a key/value from the dictionary.
  99758. * @param key the key to remove
  99759. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99760. */
  99761. remove(key: string): boolean;
  99762. /**
  99763. * Clear the whole content of the dictionary
  99764. */
  99765. clear(): void;
  99766. /**
  99767. * Gets the current count
  99768. */
  99769. readonly count: number;
  99770. /**
  99771. * Execute a callback on each key/val of the dictionary.
  99772. * Note that you can remove any element in this dictionary in the callback implementation
  99773. * @param callback the callback to execute on a given key/value pair
  99774. */
  99775. forEach(callback: (key: string, val: T) => void): void;
  99776. /**
  99777. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99778. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99779. * Note that you can remove any element in this dictionary in the callback implementation
  99780. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99781. * @returns the first item
  99782. */
  99783. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99784. private _count;
  99785. private _data;
  99786. }
  99787. }
  99788. declare module BABYLON {
  99789. /** @hidden */
  99790. export interface ICollisionCoordinator {
  99791. createCollider(): Collider;
  99792. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99793. init(scene: Scene): void;
  99794. }
  99795. /** @hidden */
  99796. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99797. private _scene;
  99798. private _scaledPosition;
  99799. private _scaledVelocity;
  99800. private _finalPosition;
  99801. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99802. createCollider(): Collider;
  99803. init(scene: Scene): void;
  99804. private _collideWithWorld;
  99805. }
  99806. }
  99807. declare module BABYLON {
  99808. /**
  99809. * Class used to manage all inputs for the scene.
  99810. */
  99811. export class InputManager {
  99812. /** The distance in pixel that you have to move to prevent some events */
  99813. static DragMovementThreshold: number;
  99814. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99815. static LongPressDelay: number;
  99816. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99817. static DoubleClickDelay: number;
  99818. /** If you need to check double click without raising a single click at first click, enable this flag */
  99819. static ExclusiveDoubleClickMode: boolean;
  99820. private _wheelEventName;
  99821. private _onPointerMove;
  99822. private _onPointerDown;
  99823. private _onPointerUp;
  99824. private _initClickEvent;
  99825. private _initActionManager;
  99826. private _delayedSimpleClick;
  99827. private _delayedSimpleClickTimeout;
  99828. private _previousDelayedSimpleClickTimeout;
  99829. private _meshPickProceed;
  99830. private _previousButtonPressed;
  99831. private _currentPickResult;
  99832. private _previousPickResult;
  99833. private _totalPointersPressed;
  99834. private _doubleClickOccured;
  99835. private _pointerOverMesh;
  99836. private _pickedDownMesh;
  99837. private _pickedUpMesh;
  99838. private _pointerX;
  99839. private _pointerY;
  99840. private _unTranslatedPointerX;
  99841. private _unTranslatedPointerY;
  99842. private _startingPointerPosition;
  99843. private _previousStartingPointerPosition;
  99844. private _startingPointerTime;
  99845. private _previousStartingPointerTime;
  99846. private _pointerCaptures;
  99847. private _onKeyDown;
  99848. private _onKeyUp;
  99849. private _onCanvasFocusObserver;
  99850. private _onCanvasBlurObserver;
  99851. private _scene;
  99852. /**
  99853. * Creates a new InputManager
  99854. * @param scene defines the hosting scene
  99855. */
  99856. constructor(scene: Scene);
  99857. /**
  99858. * Gets the mesh that is currently under the pointer
  99859. */
  99860. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99861. /**
  99862. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99863. */
  99864. readonly unTranslatedPointer: Vector2;
  99865. /**
  99866. * Gets or sets the current on-screen X position of the pointer
  99867. */
  99868. pointerX: number;
  99869. /**
  99870. * Gets or sets the current on-screen Y position of the pointer
  99871. */
  99872. pointerY: number;
  99873. private _updatePointerPosition;
  99874. private _processPointerMove;
  99875. private _setRayOnPointerInfo;
  99876. private _checkPrePointerObservable;
  99877. /**
  99878. * Use this method to simulate a pointer move on a mesh
  99879. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99880. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99881. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99882. */
  99883. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99884. /**
  99885. * Use this method to simulate a pointer down on a mesh
  99886. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99887. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99888. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99889. */
  99890. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99891. private _processPointerDown;
  99892. /** @hidden */
  99893. _isPointerSwiping(): boolean;
  99894. /**
  99895. * Use this method to simulate a pointer up on a mesh
  99896. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99897. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99898. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99899. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99900. */
  99901. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99902. private _processPointerUp;
  99903. /**
  99904. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99905. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99906. * @returns true if the pointer was captured
  99907. */
  99908. isPointerCaptured(pointerId?: number): boolean;
  99909. /**
  99910. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99911. * @param attachUp defines if you want to attach events to pointerup
  99912. * @param attachDown defines if you want to attach events to pointerdown
  99913. * @param attachMove defines if you want to attach events to pointermove
  99914. */
  99915. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99916. /**
  99917. * Detaches all event handlers
  99918. */
  99919. detachControl(): void;
  99920. /**
  99921. * Force the value of meshUnderPointer
  99922. * @param mesh defines the mesh to use
  99923. */
  99924. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99925. /**
  99926. * Gets the mesh under the pointer
  99927. * @returns a Mesh or null if no mesh is under the pointer
  99928. */
  99929. getPointerOverMesh(): Nullable<AbstractMesh>;
  99930. }
  99931. }
  99932. declare module BABYLON {
  99933. /**
  99934. * Helper class used to generate session unique ID
  99935. */
  99936. export class UniqueIdGenerator {
  99937. private static _UniqueIdCounter;
  99938. /**
  99939. * Gets an unique (relatively to the current scene) Id
  99940. */
  99941. static readonly UniqueId: number;
  99942. }
  99943. }
  99944. declare module BABYLON {
  99945. /**
  99946. * This class defines the direct association between an animation and a target
  99947. */
  99948. export class TargetedAnimation {
  99949. /**
  99950. * Animation to perform
  99951. */
  99952. animation: Animation;
  99953. /**
  99954. * Target to animate
  99955. */
  99956. target: any;
  99957. /**
  99958. * Serialize the object
  99959. * @returns the JSON object representing the current entity
  99960. */
  99961. serialize(): any;
  99962. }
  99963. /**
  99964. * Use this class to create coordinated animations on multiple targets
  99965. */
  99966. export class AnimationGroup implements IDisposable {
  99967. /** The name of the animation group */
  99968. name: string;
  99969. private _scene;
  99970. private _targetedAnimations;
  99971. private _animatables;
  99972. private _from;
  99973. private _to;
  99974. private _isStarted;
  99975. private _isPaused;
  99976. private _speedRatio;
  99977. private _loopAnimation;
  99978. /**
  99979. * Gets or sets the unique id of the node
  99980. */
  99981. uniqueId: number;
  99982. /**
  99983. * This observable will notify when one animation have ended
  99984. */
  99985. onAnimationEndObservable: Observable<TargetedAnimation>;
  99986. /**
  99987. * Observer raised when one animation loops
  99988. */
  99989. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99990. /**
  99991. * This observable will notify when all animations have ended.
  99992. */
  99993. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99994. /**
  99995. * This observable will notify when all animations have paused.
  99996. */
  99997. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99998. /**
  99999. * This observable will notify when all animations are playing.
  100000. */
  100001. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100002. /**
  100003. * Gets the first frame
  100004. */
  100005. readonly from: number;
  100006. /**
  100007. * Gets the last frame
  100008. */
  100009. readonly to: number;
  100010. /**
  100011. * Define if the animations are started
  100012. */
  100013. readonly isStarted: boolean;
  100014. /**
  100015. * Gets a value indicating that the current group is playing
  100016. */
  100017. readonly isPlaying: boolean;
  100018. /**
  100019. * Gets or sets the speed ratio to use for all animations
  100020. */
  100021. /**
  100022. * Gets or sets the speed ratio to use for all animations
  100023. */
  100024. speedRatio: number;
  100025. /**
  100026. * Gets or sets if all animations should loop or not
  100027. */
  100028. loopAnimation: boolean;
  100029. /**
  100030. * Gets the targeted animations for this animation group
  100031. */
  100032. readonly targetedAnimations: Array<TargetedAnimation>;
  100033. /**
  100034. * returning the list of animatables controlled by this animation group.
  100035. */
  100036. readonly animatables: Array<Animatable>;
  100037. /**
  100038. * Instantiates a new Animation Group.
  100039. * This helps managing several animations at once.
  100040. * @see http://doc.babylonjs.com/how_to/group
  100041. * @param name Defines the name of the group
  100042. * @param scene Defines the scene the group belongs to
  100043. */
  100044. constructor(
  100045. /** The name of the animation group */
  100046. name: string, scene?: Nullable<Scene>);
  100047. /**
  100048. * Add an animation (with its target) in the group
  100049. * @param animation defines the animation we want to add
  100050. * @param target defines the target of the animation
  100051. * @returns the TargetedAnimation object
  100052. */
  100053. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100054. /**
  100055. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100056. * It can add constant keys at begin or end
  100057. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100058. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100059. * @returns the animation group
  100060. */
  100061. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100062. /**
  100063. * Start all animations on given targets
  100064. * @param loop defines if animations must loop
  100065. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100066. * @param from defines the from key (optional)
  100067. * @param to defines the to key (optional)
  100068. * @returns the current animation group
  100069. */
  100070. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100071. /**
  100072. * Pause all animations
  100073. * @returns the animation group
  100074. */
  100075. pause(): AnimationGroup;
  100076. /**
  100077. * Play all animations to initial state
  100078. * This function will start() the animations if they were not started or will restart() them if they were paused
  100079. * @param loop defines if animations must loop
  100080. * @returns the animation group
  100081. */
  100082. play(loop?: boolean): AnimationGroup;
  100083. /**
  100084. * Reset all animations to initial state
  100085. * @returns the animation group
  100086. */
  100087. reset(): AnimationGroup;
  100088. /**
  100089. * Restart animations from key 0
  100090. * @returns the animation group
  100091. */
  100092. restart(): AnimationGroup;
  100093. /**
  100094. * Stop all animations
  100095. * @returns the animation group
  100096. */
  100097. stop(): AnimationGroup;
  100098. /**
  100099. * Set animation weight for all animatables
  100100. * @param weight defines the weight to use
  100101. * @return the animationGroup
  100102. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100103. */
  100104. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100105. /**
  100106. * Synchronize and normalize all animatables with a source animatable
  100107. * @param root defines the root animatable to synchronize with
  100108. * @return the animationGroup
  100109. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100110. */
  100111. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100112. /**
  100113. * Goes to a specific frame in this animation group
  100114. * @param frame the frame number to go to
  100115. * @return the animationGroup
  100116. */
  100117. goToFrame(frame: number): AnimationGroup;
  100118. /**
  100119. * Dispose all associated resources
  100120. */
  100121. dispose(): void;
  100122. private _checkAnimationGroupEnded;
  100123. /**
  100124. * Clone the current animation group and returns a copy
  100125. * @param newName defines the name of the new group
  100126. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100127. * @returns the new aniamtion group
  100128. */
  100129. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100130. /**
  100131. * Serializes the animationGroup to an object
  100132. * @returns Serialized object
  100133. */
  100134. serialize(): any;
  100135. /**
  100136. * Returns a new AnimationGroup object parsed from the source provided.
  100137. * @param parsedAnimationGroup defines the source
  100138. * @param scene defines the scene that will receive the animationGroup
  100139. * @returns a new AnimationGroup
  100140. */
  100141. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100142. /**
  100143. * Returns the string "AnimationGroup"
  100144. * @returns "AnimationGroup"
  100145. */
  100146. getClassName(): string;
  100147. /**
  100148. * Creates a detailled string about the object
  100149. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100150. * @returns a string representing the object
  100151. */
  100152. toString(fullDetails?: boolean): string;
  100153. }
  100154. }
  100155. declare module BABYLON {
  100156. /**
  100157. * Define an interface for all classes that will hold resources
  100158. */
  100159. export interface IDisposable {
  100160. /**
  100161. * Releases all held resources
  100162. */
  100163. dispose(): void;
  100164. }
  100165. /** Interface defining initialization parameters for Scene class */
  100166. export interface SceneOptions {
  100167. /**
  100168. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100169. * It will improve performance when the number of geometries becomes important.
  100170. */
  100171. useGeometryUniqueIdsMap?: boolean;
  100172. /**
  100173. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100174. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100175. */
  100176. useMaterialMeshMap?: boolean;
  100177. /**
  100178. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100179. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100180. */
  100181. useClonedMeshhMap?: boolean;
  100182. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100183. virtual?: boolean;
  100184. }
  100185. /**
  100186. * Represents a scene to be rendered by the engine.
  100187. * @see http://doc.babylonjs.com/features/scene
  100188. */
  100189. export class Scene extends AbstractScene implements IAnimatable {
  100190. /** The fog is deactivated */
  100191. static readonly FOGMODE_NONE: number;
  100192. /** The fog density is following an exponential function */
  100193. static readonly FOGMODE_EXP: number;
  100194. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100195. static readonly FOGMODE_EXP2: number;
  100196. /** The fog density is following a linear function. */
  100197. static readonly FOGMODE_LINEAR: number;
  100198. /**
  100199. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100200. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100201. */
  100202. static MinDeltaTime: number;
  100203. /**
  100204. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100206. */
  100207. static MaxDeltaTime: number;
  100208. /**
  100209. * Factory used to create the default material.
  100210. * @param name The name of the material to create
  100211. * @param scene The scene to create the material for
  100212. * @returns The default material
  100213. */
  100214. static DefaultMaterialFactory(scene: Scene): Material;
  100215. /**
  100216. * Factory used to create the a collision coordinator.
  100217. * @returns The collision coordinator
  100218. */
  100219. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100220. /** @hidden */
  100221. _inputManager: InputManager;
  100222. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100223. cameraToUseForPointers: Nullable<Camera>;
  100224. /** @hidden */
  100225. readonly _isScene: boolean;
  100226. /**
  100227. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100228. */
  100229. autoClear: boolean;
  100230. /**
  100231. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100232. */
  100233. autoClearDepthAndStencil: boolean;
  100234. /**
  100235. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100236. */
  100237. clearColor: Color4;
  100238. /**
  100239. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100240. */
  100241. ambientColor: Color3;
  100242. /**
  100243. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100244. * It should only be one of the following (if not the default embedded one):
  100245. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100246. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100247. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100248. * The material properties need to be setup according to the type of texture in use.
  100249. */
  100250. environmentBRDFTexture: BaseTexture;
  100251. /** @hidden */
  100252. protected _environmentTexture: Nullable<BaseTexture>;
  100253. /**
  100254. * Texture used in all pbr material as the reflection texture.
  100255. * As in the majority of the scene they are the same (exception for multi room and so on),
  100256. * this is easier to reference from here than from all the materials.
  100257. */
  100258. /**
  100259. * Texture used in all pbr material as the reflection texture.
  100260. * As in the majority of the scene they are the same (exception for multi room and so on),
  100261. * this is easier to set here than in all the materials.
  100262. */
  100263. environmentTexture: Nullable<BaseTexture>;
  100264. /** @hidden */
  100265. protected _environmentIntensity: number;
  100266. /**
  100267. * Intensity of the environment in all pbr material.
  100268. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100269. * As in the majority of the scene they are the same (exception for multi room and so on),
  100270. * this is easier to reference from here than from all the materials.
  100271. */
  100272. /**
  100273. * Intensity of the environment in all pbr material.
  100274. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100275. * As in the majority of the scene they are the same (exception for multi room and so on),
  100276. * this is easier to set here than in all the materials.
  100277. */
  100278. environmentIntensity: number;
  100279. /** @hidden */
  100280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100281. /**
  100282. * Default image processing configuration used either in the rendering
  100283. * Forward main pass or through the imageProcessingPostProcess if present.
  100284. * As in the majority of the scene they are the same (exception for multi camera),
  100285. * this is easier to reference from here than from all the materials and post process.
  100286. *
  100287. * No setter as we it is a shared configuration, you can set the values instead.
  100288. */
  100289. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100290. private _forceWireframe;
  100291. /**
  100292. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100293. */
  100294. forceWireframe: boolean;
  100295. private _forcePointsCloud;
  100296. /**
  100297. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100298. */
  100299. forcePointsCloud: boolean;
  100300. /**
  100301. * Gets or sets the active clipplane 1
  100302. */
  100303. clipPlane: Nullable<Plane>;
  100304. /**
  100305. * Gets or sets the active clipplane 2
  100306. */
  100307. clipPlane2: Nullable<Plane>;
  100308. /**
  100309. * Gets or sets the active clipplane 3
  100310. */
  100311. clipPlane3: Nullable<Plane>;
  100312. /**
  100313. * Gets or sets the active clipplane 4
  100314. */
  100315. clipPlane4: Nullable<Plane>;
  100316. /**
  100317. * Gets or sets a boolean indicating if animations are enabled
  100318. */
  100319. animationsEnabled: boolean;
  100320. private _animationPropertiesOverride;
  100321. /**
  100322. * Gets or sets the animation properties override
  100323. */
  100324. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100325. /**
  100326. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100327. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100328. */
  100329. useConstantAnimationDeltaTime: boolean;
  100330. /**
  100331. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100332. * Please note that it requires to run a ray cast through the scene on every frame
  100333. */
  100334. constantlyUpdateMeshUnderPointer: boolean;
  100335. /**
  100336. * Defines the HTML cursor to use when hovering over interactive elements
  100337. */
  100338. hoverCursor: string;
  100339. /**
  100340. * Defines the HTML default cursor to use (empty by default)
  100341. */
  100342. defaultCursor: string;
  100343. /**
  100344. * This is used to call preventDefault() on pointer down
  100345. * in order to block unwanted artifacts like system double clicks
  100346. */
  100347. preventDefaultOnPointerDown: boolean;
  100348. /**
  100349. * This is used to call preventDefault() on pointer up
  100350. * in order to block unwanted artifacts like system double clicks
  100351. */
  100352. preventDefaultOnPointerUp: boolean;
  100353. /**
  100354. * Gets or sets user defined metadata
  100355. */
  100356. metadata: any;
  100357. /**
  100358. * For internal use only. Please do not use.
  100359. */
  100360. reservedDataStore: any;
  100361. /**
  100362. * Gets the name of the plugin used to load this scene (null by default)
  100363. */
  100364. loadingPluginName: string;
  100365. /**
  100366. * Use this array to add regular expressions used to disable offline support for specific urls
  100367. */
  100368. disableOfflineSupportExceptionRules: RegExp[];
  100369. /**
  100370. * An event triggered when the scene is disposed.
  100371. */
  100372. onDisposeObservable: Observable<Scene>;
  100373. private _onDisposeObserver;
  100374. /** Sets a function to be executed when this scene is disposed. */
  100375. onDispose: () => void;
  100376. /**
  100377. * An event triggered before rendering the scene (right after animations and physics)
  100378. */
  100379. onBeforeRenderObservable: Observable<Scene>;
  100380. private _onBeforeRenderObserver;
  100381. /** Sets a function to be executed before rendering this scene */
  100382. beforeRender: Nullable<() => void>;
  100383. /**
  100384. * An event triggered after rendering the scene
  100385. */
  100386. onAfterRenderObservable: Observable<Scene>;
  100387. /**
  100388. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100389. */
  100390. onAfterRenderCameraObservable: Observable<Camera>;
  100391. private _onAfterRenderObserver;
  100392. /** Sets a function to be executed after rendering this scene */
  100393. afterRender: Nullable<() => void>;
  100394. /**
  100395. * An event triggered before animating the scene
  100396. */
  100397. onBeforeAnimationsObservable: Observable<Scene>;
  100398. /**
  100399. * An event triggered after animations processing
  100400. */
  100401. onAfterAnimationsObservable: Observable<Scene>;
  100402. /**
  100403. * An event triggered before draw calls are ready to be sent
  100404. */
  100405. onBeforeDrawPhaseObservable: Observable<Scene>;
  100406. /**
  100407. * An event triggered after draw calls have been sent
  100408. */
  100409. onAfterDrawPhaseObservable: Observable<Scene>;
  100410. /**
  100411. * An event triggered when the scene is ready
  100412. */
  100413. onReadyObservable: Observable<Scene>;
  100414. /**
  100415. * An event triggered before rendering a camera
  100416. */
  100417. onBeforeCameraRenderObservable: Observable<Camera>;
  100418. private _onBeforeCameraRenderObserver;
  100419. /** Sets a function to be executed before rendering a camera*/
  100420. beforeCameraRender: () => void;
  100421. /**
  100422. * An event triggered after rendering a camera
  100423. */
  100424. onAfterCameraRenderObservable: Observable<Camera>;
  100425. private _onAfterCameraRenderObserver;
  100426. /** Sets a function to be executed after rendering a camera*/
  100427. afterCameraRender: () => void;
  100428. /**
  100429. * An event triggered when active meshes evaluation is about to start
  100430. */
  100431. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100432. /**
  100433. * An event triggered when active meshes evaluation is done
  100434. */
  100435. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100436. /**
  100437. * An event triggered when particles rendering is about to start
  100438. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100439. */
  100440. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100441. /**
  100442. * An event triggered when particles rendering is done
  100443. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100444. */
  100445. onAfterParticlesRenderingObservable: Observable<Scene>;
  100446. /**
  100447. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100448. */
  100449. onDataLoadedObservable: Observable<Scene>;
  100450. /**
  100451. * An event triggered when a camera is created
  100452. */
  100453. onNewCameraAddedObservable: Observable<Camera>;
  100454. /**
  100455. * An event triggered when a camera is removed
  100456. */
  100457. onCameraRemovedObservable: Observable<Camera>;
  100458. /**
  100459. * An event triggered when a light is created
  100460. */
  100461. onNewLightAddedObservable: Observable<Light>;
  100462. /**
  100463. * An event triggered when a light is removed
  100464. */
  100465. onLightRemovedObservable: Observable<Light>;
  100466. /**
  100467. * An event triggered when a geometry is created
  100468. */
  100469. onNewGeometryAddedObservable: Observable<Geometry>;
  100470. /**
  100471. * An event triggered when a geometry is removed
  100472. */
  100473. onGeometryRemovedObservable: Observable<Geometry>;
  100474. /**
  100475. * An event triggered when a transform node is created
  100476. */
  100477. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100478. /**
  100479. * An event triggered when a transform node is removed
  100480. */
  100481. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100482. /**
  100483. * An event triggered when a mesh is created
  100484. */
  100485. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100486. /**
  100487. * An event triggered when a mesh is removed
  100488. */
  100489. onMeshRemovedObservable: Observable<AbstractMesh>;
  100490. /**
  100491. * An event triggered when a skeleton is created
  100492. */
  100493. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100494. /**
  100495. * An event triggered when a skeleton is removed
  100496. */
  100497. onSkeletonRemovedObservable: Observable<Skeleton>;
  100498. /**
  100499. * An event triggered when a material is created
  100500. */
  100501. onNewMaterialAddedObservable: Observable<Material>;
  100502. /**
  100503. * An event triggered when a material is removed
  100504. */
  100505. onMaterialRemovedObservable: Observable<Material>;
  100506. /**
  100507. * An event triggered when a texture is created
  100508. */
  100509. onNewTextureAddedObservable: Observable<BaseTexture>;
  100510. /**
  100511. * An event triggered when a texture is removed
  100512. */
  100513. onTextureRemovedObservable: Observable<BaseTexture>;
  100514. /**
  100515. * An event triggered when render targets are about to be rendered
  100516. * Can happen multiple times per frame.
  100517. */
  100518. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100519. /**
  100520. * An event triggered when render targets were rendered.
  100521. * Can happen multiple times per frame.
  100522. */
  100523. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100524. /**
  100525. * An event triggered before calculating deterministic simulation step
  100526. */
  100527. onBeforeStepObservable: Observable<Scene>;
  100528. /**
  100529. * An event triggered after calculating deterministic simulation step
  100530. */
  100531. onAfterStepObservable: Observable<Scene>;
  100532. /**
  100533. * An event triggered when the activeCamera property is updated
  100534. */
  100535. onActiveCameraChanged: Observable<Scene>;
  100536. /**
  100537. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100538. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100539. * 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)
  100540. */
  100541. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100542. /**
  100543. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100544. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100545. * 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)
  100546. */
  100547. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100548. /**
  100549. * This Observable will when a mesh has been imported into the scene.
  100550. */
  100551. onMeshImportedObservable: Observable<AbstractMesh>;
  100552. /**
  100553. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100554. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100555. */
  100556. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100557. /** @hidden */
  100558. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100559. /**
  100560. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100561. */
  100562. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100563. /**
  100564. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100565. */
  100566. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100567. /**
  100568. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100569. */
  100570. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100571. /** Callback called when a pointer move is detected */
  100572. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100573. /** Callback called when a pointer down is detected */
  100574. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100575. /** Callback called when a pointer up is detected */
  100576. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100577. /** Callback called when a pointer pick is detected */
  100578. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100579. /**
  100580. * 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).
  100581. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100582. */
  100583. onPrePointerObservable: Observable<PointerInfoPre>;
  100584. /**
  100585. * Observable event triggered each time an input event is received from the rendering canvas
  100586. */
  100587. onPointerObservable: Observable<PointerInfo>;
  100588. /**
  100589. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100590. */
  100591. readonly unTranslatedPointer: Vector2;
  100592. /**
  100593. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100594. */
  100595. static DragMovementThreshold: number;
  100596. /**
  100597. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100598. */
  100599. static LongPressDelay: number;
  100600. /**
  100601. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100602. */
  100603. static DoubleClickDelay: number;
  100604. /** If you need to check double click without raising a single click at first click, enable this flag */
  100605. static ExclusiveDoubleClickMode: boolean;
  100606. /** @hidden */
  100607. _mirroredCameraPosition: Nullable<Vector3>;
  100608. /**
  100609. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100610. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100611. */
  100612. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100613. /**
  100614. * Observable event triggered each time an keyboard event is received from the hosting window
  100615. */
  100616. onKeyboardObservable: Observable<KeyboardInfo>;
  100617. private _useRightHandedSystem;
  100618. /**
  100619. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100620. */
  100621. useRightHandedSystem: boolean;
  100622. private _timeAccumulator;
  100623. private _currentStepId;
  100624. private _currentInternalStep;
  100625. /**
  100626. * Sets the step Id used by deterministic lock step
  100627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100628. * @param newStepId defines the step Id
  100629. */
  100630. setStepId(newStepId: number): void;
  100631. /**
  100632. * Gets the step Id used by deterministic lock step
  100633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100634. * @returns the step Id
  100635. */
  100636. getStepId(): number;
  100637. /**
  100638. * Gets the internal step used by deterministic lock step
  100639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100640. * @returns the internal step
  100641. */
  100642. getInternalStep(): number;
  100643. private _fogEnabled;
  100644. /**
  100645. * Gets or sets a boolean indicating if fog is enabled on this scene
  100646. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100647. * (Default is true)
  100648. */
  100649. fogEnabled: boolean;
  100650. private _fogMode;
  100651. /**
  100652. * Gets or sets the fog mode to use
  100653. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100654. * | mode | value |
  100655. * | --- | --- |
  100656. * | FOGMODE_NONE | 0 |
  100657. * | FOGMODE_EXP | 1 |
  100658. * | FOGMODE_EXP2 | 2 |
  100659. * | FOGMODE_LINEAR | 3 |
  100660. */
  100661. fogMode: number;
  100662. /**
  100663. * Gets or sets the fog color to use
  100664. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100665. * (Default is Color3(0.2, 0.2, 0.3))
  100666. */
  100667. fogColor: Color3;
  100668. /**
  100669. * Gets or sets the fog density to use
  100670. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100671. * (Default is 0.1)
  100672. */
  100673. fogDensity: number;
  100674. /**
  100675. * Gets or sets the fog start distance to use
  100676. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100677. * (Default is 0)
  100678. */
  100679. fogStart: number;
  100680. /**
  100681. * Gets or sets the fog end distance to use
  100682. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100683. * (Default is 1000)
  100684. */
  100685. fogEnd: number;
  100686. private _shadowsEnabled;
  100687. /**
  100688. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100689. */
  100690. shadowsEnabled: boolean;
  100691. private _lightsEnabled;
  100692. /**
  100693. * Gets or sets a boolean indicating if lights are enabled on this scene
  100694. */
  100695. lightsEnabled: boolean;
  100696. /** All of the active cameras added to this scene. */
  100697. activeCameras: Camera[];
  100698. /** @hidden */
  100699. _activeCamera: Nullable<Camera>;
  100700. /** Gets or sets the current active camera */
  100701. activeCamera: Nullable<Camera>;
  100702. private _defaultMaterial;
  100703. /** The default material used on meshes when no material is affected */
  100704. /** The default material used on meshes when no material is affected */
  100705. defaultMaterial: Material;
  100706. private _texturesEnabled;
  100707. /**
  100708. * Gets or sets a boolean indicating if textures are enabled on this scene
  100709. */
  100710. texturesEnabled: boolean;
  100711. /**
  100712. * Gets or sets a boolean indicating if particles are enabled on this scene
  100713. */
  100714. particlesEnabled: boolean;
  100715. /**
  100716. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100717. */
  100718. spritesEnabled: boolean;
  100719. private _skeletonsEnabled;
  100720. /**
  100721. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100722. */
  100723. skeletonsEnabled: boolean;
  100724. /**
  100725. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100726. */
  100727. lensFlaresEnabled: boolean;
  100728. /**
  100729. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100731. */
  100732. collisionsEnabled: boolean;
  100733. private _collisionCoordinator;
  100734. /** @hidden */
  100735. readonly collisionCoordinator: ICollisionCoordinator;
  100736. /**
  100737. * Defines the gravity applied to this scene (used only for collisions)
  100738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100739. */
  100740. gravity: Vector3;
  100741. /**
  100742. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100743. */
  100744. postProcessesEnabled: boolean;
  100745. /**
  100746. * The list of postprocesses added to the scene
  100747. */
  100748. postProcesses: PostProcess[];
  100749. /**
  100750. * Gets the current postprocess manager
  100751. */
  100752. postProcessManager: PostProcessManager;
  100753. /**
  100754. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100755. */
  100756. renderTargetsEnabled: boolean;
  100757. /**
  100758. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100759. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100760. */
  100761. dumpNextRenderTargets: boolean;
  100762. /**
  100763. * The list of user defined render targets added to the scene
  100764. */
  100765. customRenderTargets: RenderTargetTexture[];
  100766. /**
  100767. * Defines if texture loading must be delayed
  100768. * If true, textures will only be loaded when they need to be rendered
  100769. */
  100770. useDelayedTextureLoading: boolean;
  100771. /**
  100772. * Gets the list of meshes imported to the scene through SceneLoader
  100773. */
  100774. importedMeshesFiles: String[];
  100775. /**
  100776. * Gets or sets a boolean indicating if probes are enabled on this scene
  100777. */
  100778. probesEnabled: boolean;
  100779. /**
  100780. * Gets or sets the current offline provider to use to store scene data
  100781. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100782. */
  100783. offlineProvider: IOfflineProvider;
  100784. /**
  100785. * Gets or sets the action manager associated with the scene
  100786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100787. */
  100788. actionManager: AbstractActionManager;
  100789. private _meshesForIntersections;
  100790. /**
  100791. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100792. */
  100793. proceduralTexturesEnabled: boolean;
  100794. private _engine;
  100795. private _totalVertices;
  100796. /** @hidden */
  100797. _activeIndices: PerfCounter;
  100798. /** @hidden */
  100799. _activeParticles: PerfCounter;
  100800. /** @hidden */
  100801. _activeBones: PerfCounter;
  100802. private _animationRatio;
  100803. /** @hidden */
  100804. _animationTimeLast: number;
  100805. /** @hidden */
  100806. _animationTime: number;
  100807. /**
  100808. * Gets or sets a general scale for animation speed
  100809. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100810. */
  100811. animationTimeScale: number;
  100812. /** @hidden */
  100813. _cachedMaterial: Nullable<Material>;
  100814. /** @hidden */
  100815. _cachedEffect: Nullable<Effect>;
  100816. /** @hidden */
  100817. _cachedVisibility: Nullable<number>;
  100818. private _renderId;
  100819. private _frameId;
  100820. private _executeWhenReadyTimeoutId;
  100821. private _intermediateRendering;
  100822. private _viewUpdateFlag;
  100823. private _projectionUpdateFlag;
  100824. /** @hidden */
  100825. _toBeDisposed: Nullable<IDisposable>[];
  100826. private _activeRequests;
  100827. /** @hidden */
  100828. _pendingData: any[];
  100829. private _isDisposed;
  100830. /**
  100831. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100832. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100833. */
  100834. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100835. private _activeMeshes;
  100836. private _processedMaterials;
  100837. private _renderTargets;
  100838. /** @hidden */
  100839. _activeParticleSystems: SmartArray<IParticleSystem>;
  100840. private _activeSkeletons;
  100841. private _softwareSkinnedMeshes;
  100842. private _renderingManager;
  100843. /** @hidden */
  100844. _activeAnimatables: Animatable[];
  100845. private _transformMatrix;
  100846. private _sceneUbo;
  100847. /** @hidden */
  100848. _viewMatrix: Matrix;
  100849. private _projectionMatrix;
  100850. /** @hidden */
  100851. _forcedViewPosition: Nullable<Vector3>;
  100852. /** @hidden */
  100853. _frustumPlanes: Plane[];
  100854. /**
  100855. * Gets the list of frustum planes (built from the active camera)
  100856. */
  100857. readonly frustumPlanes: Plane[];
  100858. /**
  100859. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100860. * This is useful if there are more lights that the maximum simulteanous authorized
  100861. */
  100862. requireLightSorting: boolean;
  100863. /** @hidden */
  100864. readonly useMaterialMeshMap: boolean;
  100865. /** @hidden */
  100866. readonly useClonedMeshhMap: boolean;
  100867. private _externalData;
  100868. private _uid;
  100869. /**
  100870. * @hidden
  100871. * Backing store of defined scene components.
  100872. */
  100873. _components: ISceneComponent[];
  100874. /**
  100875. * @hidden
  100876. * Backing store of defined scene components.
  100877. */
  100878. _serializableComponents: ISceneSerializableComponent[];
  100879. /**
  100880. * List of components to register on the next registration step.
  100881. */
  100882. private _transientComponents;
  100883. /**
  100884. * Registers the transient components if needed.
  100885. */
  100886. private _registerTransientComponents;
  100887. /**
  100888. * @hidden
  100889. * Add a component to the scene.
  100890. * Note that the ccomponent could be registered on th next frame if this is called after
  100891. * the register component stage.
  100892. * @param component Defines the component to add to the scene
  100893. */
  100894. _addComponent(component: ISceneComponent): void;
  100895. /**
  100896. * @hidden
  100897. * Gets a component from the scene.
  100898. * @param name defines the name of the component to retrieve
  100899. * @returns the component or null if not present
  100900. */
  100901. _getComponent(name: string): Nullable<ISceneComponent>;
  100902. /**
  100903. * @hidden
  100904. * Defines the actions happening before camera updates.
  100905. */
  100906. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100907. /**
  100908. * @hidden
  100909. * Defines the actions happening before clear the canvas.
  100910. */
  100911. _beforeClearStage: Stage<SimpleStageAction>;
  100912. /**
  100913. * @hidden
  100914. * Defines the actions when collecting render targets for the frame.
  100915. */
  100916. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100917. /**
  100918. * @hidden
  100919. * Defines the actions happening for one camera in the frame.
  100920. */
  100921. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100922. /**
  100923. * @hidden
  100924. * Defines the actions happening during the per mesh ready checks.
  100925. */
  100926. _isReadyForMeshStage: Stage<MeshStageAction>;
  100927. /**
  100928. * @hidden
  100929. * Defines the actions happening before evaluate active mesh checks.
  100930. */
  100931. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100932. /**
  100933. * @hidden
  100934. * Defines the actions happening during the evaluate sub mesh checks.
  100935. */
  100936. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100937. /**
  100938. * @hidden
  100939. * Defines the actions happening during the active mesh stage.
  100940. */
  100941. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100942. /**
  100943. * @hidden
  100944. * Defines the actions happening during the per camera render target step.
  100945. */
  100946. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100947. /**
  100948. * @hidden
  100949. * Defines the actions happening just before the active camera is drawing.
  100950. */
  100951. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100952. /**
  100953. * @hidden
  100954. * Defines the actions happening just before a render target is drawing.
  100955. */
  100956. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100957. /**
  100958. * @hidden
  100959. * Defines the actions happening just before a rendering group is drawing.
  100960. */
  100961. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100962. /**
  100963. * @hidden
  100964. * Defines the actions happening just before a mesh is drawing.
  100965. */
  100966. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100967. /**
  100968. * @hidden
  100969. * Defines the actions happening just after a mesh has been drawn.
  100970. */
  100971. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100972. /**
  100973. * @hidden
  100974. * Defines the actions happening just after a rendering group has been drawn.
  100975. */
  100976. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100977. /**
  100978. * @hidden
  100979. * Defines the actions happening just after the active camera has been drawn.
  100980. */
  100981. _afterCameraDrawStage: Stage<CameraStageAction>;
  100982. /**
  100983. * @hidden
  100984. * Defines the actions happening just after a render target has been drawn.
  100985. */
  100986. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100987. /**
  100988. * @hidden
  100989. * Defines the actions happening just after rendering all cameras and computing intersections.
  100990. */
  100991. _afterRenderStage: Stage<SimpleStageAction>;
  100992. /**
  100993. * @hidden
  100994. * Defines the actions happening when a pointer move event happens.
  100995. */
  100996. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100997. /**
  100998. * @hidden
  100999. * Defines the actions happening when a pointer down event happens.
  101000. */
  101001. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101002. /**
  101003. * @hidden
  101004. * Defines the actions happening when a pointer up event happens.
  101005. */
  101006. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101007. /**
  101008. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101009. */
  101010. private geometriesByUniqueId;
  101011. /**
  101012. * Creates a new Scene
  101013. * @param engine defines the engine to use to render this scene
  101014. * @param options defines the scene options
  101015. */
  101016. constructor(engine: Engine, options?: SceneOptions);
  101017. /**
  101018. * Gets a string idenfifying the name of the class
  101019. * @returns "Scene" string
  101020. */
  101021. getClassName(): string;
  101022. private _defaultMeshCandidates;
  101023. /**
  101024. * @hidden
  101025. */
  101026. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101027. private _defaultSubMeshCandidates;
  101028. /**
  101029. * @hidden
  101030. */
  101031. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101032. /**
  101033. * Sets the default candidate providers for the scene.
  101034. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101035. * and getCollidingSubMeshCandidates to their default function
  101036. */
  101037. setDefaultCandidateProviders(): void;
  101038. /**
  101039. * Gets the mesh that is currently under the pointer
  101040. */
  101041. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101042. /**
  101043. * Gets or sets the current on-screen X position of the pointer
  101044. */
  101045. pointerX: number;
  101046. /**
  101047. * Gets or sets the current on-screen Y position of the pointer
  101048. */
  101049. pointerY: number;
  101050. /**
  101051. * Gets the cached material (ie. the latest rendered one)
  101052. * @returns the cached material
  101053. */
  101054. getCachedMaterial(): Nullable<Material>;
  101055. /**
  101056. * Gets the cached effect (ie. the latest rendered one)
  101057. * @returns the cached effect
  101058. */
  101059. getCachedEffect(): Nullable<Effect>;
  101060. /**
  101061. * Gets the cached visibility state (ie. the latest rendered one)
  101062. * @returns the cached visibility state
  101063. */
  101064. getCachedVisibility(): Nullable<number>;
  101065. /**
  101066. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101067. * @param material defines the current material
  101068. * @param effect defines the current effect
  101069. * @param visibility defines the current visibility state
  101070. * @returns true if one parameter is not cached
  101071. */
  101072. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101073. /**
  101074. * Gets the engine associated with the scene
  101075. * @returns an Engine
  101076. */
  101077. getEngine(): Engine;
  101078. /**
  101079. * Gets the total number of vertices rendered per frame
  101080. * @returns the total number of vertices rendered per frame
  101081. */
  101082. getTotalVertices(): number;
  101083. /**
  101084. * Gets the performance counter for total vertices
  101085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101086. */
  101087. readonly totalVerticesPerfCounter: PerfCounter;
  101088. /**
  101089. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101090. * @returns the total number of active indices rendered per frame
  101091. */
  101092. getActiveIndices(): number;
  101093. /**
  101094. * Gets the performance counter for active indices
  101095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101096. */
  101097. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101098. /**
  101099. * Gets the total number of active particles rendered per frame
  101100. * @returns the total number of active particles rendered per frame
  101101. */
  101102. getActiveParticles(): number;
  101103. /**
  101104. * Gets the performance counter for active particles
  101105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101106. */
  101107. readonly activeParticlesPerfCounter: PerfCounter;
  101108. /**
  101109. * Gets the total number of active bones rendered per frame
  101110. * @returns the total number of active bones rendered per frame
  101111. */
  101112. getActiveBones(): number;
  101113. /**
  101114. * Gets the performance counter for active bones
  101115. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101116. */
  101117. readonly activeBonesPerfCounter: PerfCounter;
  101118. /**
  101119. * Gets the array of active meshes
  101120. * @returns an array of AbstractMesh
  101121. */
  101122. getActiveMeshes(): SmartArray<AbstractMesh>;
  101123. /**
  101124. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101125. * @returns a number
  101126. */
  101127. getAnimationRatio(): number;
  101128. /**
  101129. * Gets an unique Id for the current render phase
  101130. * @returns a number
  101131. */
  101132. getRenderId(): number;
  101133. /**
  101134. * Gets an unique Id for the current frame
  101135. * @returns a number
  101136. */
  101137. getFrameId(): number;
  101138. /** Call this function if you want to manually increment the render Id*/
  101139. incrementRenderId(): void;
  101140. private _createUbo;
  101141. /**
  101142. * Use this method to simulate a pointer move on a mesh
  101143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101146. * @returns the current scene
  101147. */
  101148. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101149. /**
  101150. * Use this method to simulate a pointer down on a mesh
  101151. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101152. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101153. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101154. * @returns the current scene
  101155. */
  101156. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101157. /**
  101158. * Use this method to simulate a pointer up on a mesh
  101159. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101160. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101161. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101162. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101163. * @returns the current scene
  101164. */
  101165. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101166. /**
  101167. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101168. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101169. * @returns true if the pointer was captured
  101170. */
  101171. isPointerCaptured(pointerId?: number): boolean;
  101172. /**
  101173. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101174. * @param attachUp defines if you want to attach events to pointerup
  101175. * @param attachDown defines if you want to attach events to pointerdown
  101176. * @param attachMove defines if you want to attach events to pointermove
  101177. */
  101178. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101179. /** Detaches all event handlers*/
  101180. detachControl(): void;
  101181. /**
  101182. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101183. * Delay loaded resources are not taking in account
  101184. * @return true if all required resources are ready
  101185. */
  101186. isReady(): boolean;
  101187. /** Resets all cached information relative to material (including effect and visibility) */
  101188. resetCachedMaterial(): void;
  101189. /**
  101190. * Registers a function to be called before every frame render
  101191. * @param func defines the function to register
  101192. */
  101193. registerBeforeRender(func: () => void): void;
  101194. /**
  101195. * Unregisters a function called before every frame render
  101196. * @param func defines the function to unregister
  101197. */
  101198. unregisterBeforeRender(func: () => void): void;
  101199. /**
  101200. * Registers a function to be called after every frame render
  101201. * @param func defines the function to register
  101202. */
  101203. registerAfterRender(func: () => void): void;
  101204. /**
  101205. * Unregisters a function called after every frame render
  101206. * @param func defines the function to unregister
  101207. */
  101208. unregisterAfterRender(func: () => void): void;
  101209. private _executeOnceBeforeRender;
  101210. /**
  101211. * The provided function will run before render once and will be disposed afterwards.
  101212. * A timeout delay can be provided so that the function will be executed in N ms.
  101213. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101214. * @param func The function to be executed.
  101215. * @param timeout optional delay in ms
  101216. */
  101217. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101218. /** @hidden */
  101219. _addPendingData(data: any): void;
  101220. /** @hidden */
  101221. _removePendingData(data: any): void;
  101222. /**
  101223. * Returns the number of items waiting to be loaded
  101224. * @returns the number of items waiting to be loaded
  101225. */
  101226. getWaitingItemsCount(): number;
  101227. /**
  101228. * Returns a boolean indicating if the scene is still loading data
  101229. */
  101230. readonly isLoading: boolean;
  101231. /**
  101232. * Registers a function to be executed when the scene is ready
  101233. * @param {Function} func - the function to be executed
  101234. */
  101235. executeWhenReady(func: () => void): void;
  101236. /**
  101237. * Returns a promise that resolves when the scene is ready
  101238. * @returns A promise that resolves when the scene is ready
  101239. */
  101240. whenReadyAsync(): Promise<void>;
  101241. /** @hidden */
  101242. _checkIsReady(): void;
  101243. /**
  101244. * Gets all animatable attached to the scene
  101245. */
  101246. readonly animatables: Animatable[];
  101247. /**
  101248. * Resets the last animation time frame.
  101249. * Useful to override when animations start running when loading a scene for the first time.
  101250. */
  101251. resetLastAnimationTimeFrame(): void;
  101252. /**
  101253. * Gets the current view matrix
  101254. * @returns a Matrix
  101255. */
  101256. getViewMatrix(): Matrix;
  101257. /**
  101258. * Gets the current projection matrix
  101259. * @returns a Matrix
  101260. */
  101261. getProjectionMatrix(): Matrix;
  101262. /**
  101263. * Gets the current transform matrix
  101264. * @returns a Matrix made of View * Projection
  101265. */
  101266. getTransformMatrix(): Matrix;
  101267. /**
  101268. * Sets the current transform matrix
  101269. * @param viewL defines the View matrix to use
  101270. * @param projectionL defines the Projection matrix to use
  101271. * @param viewR defines the right View matrix to use (if provided)
  101272. * @param projectionR defines the right Projection matrix to use (if provided)
  101273. */
  101274. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101275. /**
  101276. * Gets the uniform buffer used to store scene data
  101277. * @returns a UniformBuffer
  101278. */
  101279. getSceneUniformBuffer(): UniformBuffer;
  101280. /**
  101281. * Gets an unique (relatively to the current scene) Id
  101282. * @returns an unique number for the scene
  101283. */
  101284. getUniqueId(): number;
  101285. /**
  101286. * Add a mesh to the list of scene's meshes
  101287. * @param newMesh defines the mesh to add
  101288. * @param recursive if all child meshes should also be added to the scene
  101289. */
  101290. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101291. /**
  101292. * Remove a mesh for the list of scene's meshes
  101293. * @param toRemove defines the mesh to remove
  101294. * @param recursive if all child meshes should also be removed from the scene
  101295. * @returns the index where the mesh was in the mesh list
  101296. */
  101297. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101298. /**
  101299. * Add a transform node to the list of scene's transform nodes
  101300. * @param newTransformNode defines the transform node to add
  101301. */
  101302. addTransformNode(newTransformNode: TransformNode): void;
  101303. /**
  101304. * Remove a transform node for the list of scene's transform nodes
  101305. * @param toRemove defines the transform node to remove
  101306. * @returns the index where the transform node was in the transform node list
  101307. */
  101308. removeTransformNode(toRemove: TransformNode): number;
  101309. /**
  101310. * Remove a skeleton for the list of scene's skeletons
  101311. * @param toRemove defines the skeleton to remove
  101312. * @returns the index where the skeleton was in the skeleton list
  101313. */
  101314. removeSkeleton(toRemove: Skeleton): number;
  101315. /**
  101316. * Remove a morph target for the list of scene's morph targets
  101317. * @param toRemove defines the morph target to remove
  101318. * @returns the index where the morph target was in the morph target list
  101319. */
  101320. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101321. /**
  101322. * Remove a light for the list of scene's lights
  101323. * @param toRemove defines the light to remove
  101324. * @returns the index where the light was in the light list
  101325. */
  101326. removeLight(toRemove: Light): number;
  101327. /**
  101328. * Remove a camera for the list of scene's cameras
  101329. * @param toRemove defines the camera to remove
  101330. * @returns the index where the camera was in the camera list
  101331. */
  101332. removeCamera(toRemove: Camera): number;
  101333. /**
  101334. * Remove a particle system for the list of scene's particle systems
  101335. * @param toRemove defines the particle system to remove
  101336. * @returns the index where the particle system was in the particle system list
  101337. */
  101338. removeParticleSystem(toRemove: IParticleSystem): number;
  101339. /**
  101340. * Remove a animation for the list of scene's animations
  101341. * @param toRemove defines the animation to remove
  101342. * @returns the index where the animation was in the animation list
  101343. */
  101344. removeAnimation(toRemove: Animation): number;
  101345. /**
  101346. * Will stop the animation of the given target
  101347. * @param target - the target
  101348. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101349. * @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)
  101350. */
  101351. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101352. /**
  101353. * Removes the given animation group from this scene.
  101354. * @param toRemove The animation group to remove
  101355. * @returns The index of the removed animation group
  101356. */
  101357. removeAnimationGroup(toRemove: AnimationGroup): number;
  101358. /**
  101359. * Removes the given multi-material from this scene.
  101360. * @param toRemove The multi-material to remove
  101361. * @returns The index of the removed multi-material
  101362. */
  101363. removeMultiMaterial(toRemove: MultiMaterial): number;
  101364. /**
  101365. * Removes the given material from this scene.
  101366. * @param toRemove The material to remove
  101367. * @returns The index of the removed material
  101368. */
  101369. removeMaterial(toRemove: Material): number;
  101370. /**
  101371. * Removes the given action manager from this scene.
  101372. * @param toRemove The action manager to remove
  101373. * @returns The index of the removed action manager
  101374. */
  101375. removeActionManager(toRemove: AbstractActionManager): number;
  101376. /**
  101377. * Removes the given texture from this scene.
  101378. * @param toRemove The texture to remove
  101379. * @returns The index of the removed texture
  101380. */
  101381. removeTexture(toRemove: BaseTexture): number;
  101382. /**
  101383. * Adds the given light to this scene
  101384. * @param newLight The light to add
  101385. */
  101386. addLight(newLight: Light): void;
  101387. /**
  101388. * Sorts the list list based on light priorities
  101389. */
  101390. sortLightsByPriority(): void;
  101391. /**
  101392. * Adds the given camera to this scene
  101393. * @param newCamera The camera to add
  101394. */
  101395. addCamera(newCamera: Camera): void;
  101396. /**
  101397. * Adds the given skeleton to this scene
  101398. * @param newSkeleton The skeleton to add
  101399. */
  101400. addSkeleton(newSkeleton: Skeleton): void;
  101401. /**
  101402. * Adds the given particle system to this scene
  101403. * @param newParticleSystem The particle system to add
  101404. */
  101405. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101406. /**
  101407. * Adds the given animation to this scene
  101408. * @param newAnimation The animation to add
  101409. */
  101410. addAnimation(newAnimation: Animation): void;
  101411. /**
  101412. * Adds the given animation group to this scene.
  101413. * @param newAnimationGroup The animation group to add
  101414. */
  101415. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101416. /**
  101417. * Adds the given multi-material to this scene
  101418. * @param newMultiMaterial The multi-material to add
  101419. */
  101420. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101421. /**
  101422. * Adds the given material to this scene
  101423. * @param newMaterial The material to add
  101424. */
  101425. addMaterial(newMaterial: Material): void;
  101426. /**
  101427. * Adds the given morph target to this scene
  101428. * @param newMorphTargetManager The morph target to add
  101429. */
  101430. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101431. /**
  101432. * Adds the given geometry to this scene
  101433. * @param newGeometry The geometry to add
  101434. */
  101435. addGeometry(newGeometry: Geometry): void;
  101436. /**
  101437. * Adds the given action manager to this scene
  101438. * @param newActionManager The action manager to add
  101439. */
  101440. addActionManager(newActionManager: AbstractActionManager): void;
  101441. /**
  101442. * Adds the given texture to this scene.
  101443. * @param newTexture The texture to add
  101444. */
  101445. addTexture(newTexture: BaseTexture): void;
  101446. /**
  101447. * Switch active camera
  101448. * @param newCamera defines the new active camera
  101449. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101450. */
  101451. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101452. /**
  101453. * sets the active camera of the scene using its ID
  101454. * @param id defines the camera's ID
  101455. * @return the new active camera or null if none found.
  101456. */
  101457. setActiveCameraByID(id: string): Nullable<Camera>;
  101458. /**
  101459. * sets the active camera of the scene using its name
  101460. * @param name defines the camera's name
  101461. * @returns the new active camera or null if none found.
  101462. */
  101463. setActiveCameraByName(name: string): Nullable<Camera>;
  101464. /**
  101465. * get an animation group using its name
  101466. * @param name defines the material's name
  101467. * @return the animation group or null if none found.
  101468. */
  101469. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101470. /**
  101471. * Get a material using its unique id
  101472. * @param uniqueId defines the material's unique id
  101473. * @return the material or null if none found.
  101474. */
  101475. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101476. /**
  101477. * get a material using its id
  101478. * @param id defines the material's ID
  101479. * @return the material or null if none found.
  101480. */
  101481. getMaterialByID(id: string): Nullable<Material>;
  101482. /**
  101483. * Gets a the last added material using a given id
  101484. * @param id defines the material's ID
  101485. * @return the last material with the given id or null if none found.
  101486. */
  101487. getLastMaterialByID(id: string): Nullable<Material>;
  101488. /**
  101489. * Gets a material using its name
  101490. * @param name defines the material's name
  101491. * @return the material or null if none found.
  101492. */
  101493. getMaterialByName(name: string): Nullable<Material>;
  101494. /**
  101495. * Get a texture using its unique id
  101496. * @param uniqueId defines the texture's unique id
  101497. * @return the texture or null if none found.
  101498. */
  101499. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101500. /**
  101501. * Gets a camera using its id
  101502. * @param id defines the id to look for
  101503. * @returns the camera or null if not found
  101504. */
  101505. getCameraByID(id: string): Nullable<Camera>;
  101506. /**
  101507. * Gets a camera using its unique id
  101508. * @param uniqueId defines the unique id to look for
  101509. * @returns the camera or null if not found
  101510. */
  101511. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101512. /**
  101513. * Gets a camera using its name
  101514. * @param name defines the camera's name
  101515. * @return the camera or null if none found.
  101516. */
  101517. getCameraByName(name: string): Nullable<Camera>;
  101518. /**
  101519. * Gets a bone using its id
  101520. * @param id defines the bone's id
  101521. * @return the bone or null if not found
  101522. */
  101523. getBoneByID(id: string): Nullable<Bone>;
  101524. /**
  101525. * Gets a bone using its id
  101526. * @param name defines the bone's name
  101527. * @return the bone or null if not found
  101528. */
  101529. getBoneByName(name: string): Nullable<Bone>;
  101530. /**
  101531. * Gets a light node using its name
  101532. * @param name defines the the light's name
  101533. * @return the light or null if none found.
  101534. */
  101535. getLightByName(name: string): Nullable<Light>;
  101536. /**
  101537. * Gets a light node using its id
  101538. * @param id defines the light's id
  101539. * @return the light or null if none found.
  101540. */
  101541. getLightByID(id: string): Nullable<Light>;
  101542. /**
  101543. * Gets a light node using its scene-generated unique ID
  101544. * @param uniqueId defines the light's unique id
  101545. * @return the light or null if none found.
  101546. */
  101547. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101548. /**
  101549. * Gets a particle system by id
  101550. * @param id defines the particle system id
  101551. * @return the corresponding system or null if none found
  101552. */
  101553. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101554. /**
  101555. * Gets a geometry using its ID
  101556. * @param id defines the geometry's id
  101557. * @return the geometry or null if none found.
  101558. */
  101559. getGeometryByID(id: string): Nullable<Geometry>;
  101560. private _getGeometryByUniqueID;
  101561. /**
  101562. * Add a new geometry to this scene
  101563. * @param geometry defines the geometry to be added to the scene.
  101564. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101565. * @return a boolean defining if the geometry was added or not
  101566. */
  101567. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101568. /**
  101569. * Removes an existing geometry
  101570. * @param geometry defines the geometry to be removed from the scene
  101571. * @return a boolean defining if the geometry was removed or not
  101572. */
  101573. removeGeometry(geometry: Geometry): boolean;
  101574. /**
  101575. * Gets the list of geometries attached to the scene
  101576. * @returns an array of Geometry
  101577. */
  101578. getGeometries(): Geometry[];
  101579. /**
  101580. * Gets the first added mesh found of a given ID
  101581. * @param id defines the id to search for
  101582. * @return the mesh found or null if not found at all
  101583. */
  101584. getMeshByID(id: string): Nullable<AbstractMesh>;
  101585. /**
  101586. * Gets a list of meshes using their id
  101587. * @param id defines the id to search for
  101588. * @returns a list of meshes
  101589. */
  101590. getMeshesByID(id: string): Array<AbstractMesh>;
  101591. /**
  101592. * Gets the first added transform node found of a given ID
  101593. * @param id defines the id to search for
  101594. * @return the found transform node or null if not found at all.
  101595. */
  101596. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101597. /**
  101598. * Gets a transform node with its auto-generated unique id
  101599. * @param uniqueId efines the unique id to search for
  101600. * @return the found transform node or null if not found at all.
  101601. */
  101602. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101603. /**
  101604. * Gets a list of transform nodes using their id
  101605. * @param id defines the id to search for
  101606. * @returns a list of transform nodes
  101607. */
  101608. getTransformNodesByID(id: string): Array<TransformNode>;
  101609. /**
  101610. * Gets a mesh with its auto-generated unique id
  101611. * @param uniqueId defines the unique id to search for
  101612. * @return the found mesh or null if not found at all.
  101613. */
  101614. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101615. /**
  101616. * Gets a the last added mesh using a given id
  101617. * @param id defines the id to search for
  101618. * @return the found mesh or null if not found at all.
  101619. */
  101620. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101621. /**
  101622. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101623. * @param id defines the id to search for
  101624. * @return the found node or null if not found at all
  101625. */
  101626. getLastEntryByID(id: string): Nullable<Node>;
  101627. /**
  101628. * Gets a node (Mesh, Camera, Light) using a given id
  101629. * @param id defines the id to search for
  101630. * @return the found node or null if not found at all
  101631. */
  101632. getNodeByID(id: string): Nullable<Node>;
  101633. /**
  101634. * Gets a node (Mesh, Camera, Light) using a given name
  101635. * @param name defines the name to search for
  101636. * @return the found node or null if not found at all.
  101637. */
  101638. getNodeByName(name: string): Nullable<Node>;
  101639. /**
  101640. * Gets a mesh using a given name
  101641. * @param name defines the name to search for
  101642. * @return the found mesh or null if not found at all.
  101643. */
  101644. getMeshByName(name: string): Nullable<AbstractMesh>;
  101645. /**
  101646. * Gets a transform node using a given name
  101647. * @param name defines the name to search for
  101648. * @return the found transform node or null if not found at all.
  101649. */
  101650. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101651. /**
  101652. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101653. * @param id defines the id to search for
  101654. * @return the found skeleton or null if not found at all.
  101655. */
  101656. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101657. /**
  101658. * Gets a skeleton using a given auto generated unique id
  101659. * @param uniqueId defines the unique id to search for
  101660. * @return the found skeleton or null if not found at all.
  101661. */
  101662. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101663. /**
  101664. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101665. * @param id defines the id to search for
  101666. * @return the found skeleton or null if not found at all.
  101667. */
  101668. getSkeletonById(id: string): Nullable<Skeleton>;
  101669. /**
  101670. * Gets a skeleton using a given name
  101671. * @param name defines the name to search for
  101672. * @return the found skeleton or null if not found at all.
  101673. */
  101674. getSkeletonByName(name: string): Nullable<Skeleton>;
  101675. /**
  101676. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101677. * @param id defines the id to search for
  101678. * @return the found morph target manager or null if not found at all.
  101679. */
  101680. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101681. /**
  101682. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101683. * @param id defines the id to search for
  101684. * @return the found morph target or null if not found at all.
  101685. */
  101686. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101687. /**
  101688. * Gets a boolean indicating if the given mesh is active
  101689. * @param mesh defines the mesh to look for
  101690. * @returns true if the mesh is in the active list
  101691. */
  101692. isActiveMesh(mesh: AbstractMesh): boolean;
  101693. /**
  101694. * Return a unique id as a string which can serve as an identifier for the scene
  101695. */
  101696. readonly uid: string;
  101697. /**
  101698. * Add an externaly attached data from its key.
  101699. * This method call will fail and return false, if such key already exists.
  101700. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101701. * @param key the unique key that identifies the data
  101702. * @param data the data object to associate to the key for this Engine instance
  101703. * @return true if no such key were already present and the data was added successfully, false otherwise
  101704. */
  101705. addExternalData<T>(key: string, data: T): boolean;
  101706. /**
  101707. * Get an externaly attached data from its key
  101708. * @param key the unique key that identifies the data
  101709. * @return the associated data, if present (can be null), or undefined if not present
  101710. */
  101711. getExternalData<T>(key: string): Nullable<T>;
  101712. /**
  101713. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101714. * @param key the unique key that identifies the data
  101715. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101716. * @return the associated data, can be null if the factory returned null.
  101717. */
  101718. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101719. /**
  101720. * Remove an externaly attached data from the Engine instance
  101721. * @param key the unique key that identifies the data
  101722. * @return true if the data was successfully removed, false if it doesn't exist
  101723. */
  101724. removeExternalData(key: string): boolean;
  101725. private _evaluateSubMesh;
  101726. /**
  101727. * Clear the processed materials smart array preventing retention point in material dispose.
  101728. */
  101729. freeProcessedMaterials(): void;
  101730. private _preventFreeActiveMeshesAndRenderingGroups;
  101731. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101732. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101733. * when disposing several meshes in a row or a hierarchy of meshes.
  101734. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101735. */
  101736. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101737. /**
  101738. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101739. */
  101740. freeActiveMeshes(): void;
  101741. /**
  101742. * Clear the info related to rendering groups preventing retention points during dispose.
  101743. */
  101744. freeRenderingGroups(): void;
  101745. /** @hidden */
  101746. _isInIntermediateRendering(): boolean;
  101747. /**
  101748. * Lambda returning the list of potentially active meshes.
  101749. */
  101750. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101751. /**
  101752. * Lambda returning the list of potentially active sub meshes.
  101753. */
  101754. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101755. /**
  101756. * Lambda returning the list of potentially intersecting sub meshes.
  101757. */
  101758. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101759. /**
  101760. * Lambda returning the list of potentially colliding sub meshes.
  101761. */
  101762. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101763. private _activeMeshesFrozen;
  101764. /**
  101765. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101766. * @returns the current scene
  101767. */
  101768. freezeActiveMeshes(): Scene;
  101769. /**
  101770. * Use this function to restart evaluating active meshes on every frame
  101771. * @returns the current scene
  101772. */
  101773. unfreezeActiveMeshes(): Scene;
  101774. private _evaluateActiveMeshes;
  101775. private _activeMesh;
  101776. /**
  101777. * Update the transform matrix to update from the current active camera
  101778. * @param force defines a boolean used to force the update even if cache is up to date
  101779. */
  101780. updateTransformMatrix(force?: boolean): void;
  101781. private _bindFrameBuffer;
  101782. /** @hidden */
  101783. _allowPostProcessClearColor: boolean;
  101784. /** @hidden */
  101785. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101786. private _processSubCameras;
  101787. private _checkIntersections;
  101788. /** @hidden */
  101789. _advancePhysicsEngineStep(step: number): void;
  101790. /**
  101791. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101792. */
  101793. getDeterministicFrameTime: () => number;
  101794. /** @hidden */
  101795. _animate(): void;
  101796. /** Execute all animations (for a frame) */
  101797. animate(): void;
  101798. /**
  101799. * Render the scene
  101800. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101801. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101802. */
  101803. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101804. /**
  101805. * Freeze all materials
  101806. * A frozen material will not be updatable but should be faster to render
  101807. */
  101808. freezeMaterials(): void;
  101809. /**
  101810. * Unfreeze all materials
  101811. * A frozen material will not be updatable but should be faster to render
  101812. */
  101813. unfreezeMaterials(): void;
  101814. /**
  101815. * Releases all held ressources
  101816. */
  101817. dispose(): void;
  101818. /**
  101819. * Gets if the scene is already disposed
  101820. */
  101821. readonly isDisposed: boolean;
  101822. /**
  101823. * Call this function to reduce memory footprint of the scene.
  101824. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101825. */
  101826. clearCachedVertexData(): void;
  101827. /**
  101828. * This function will remove the local cached buffer data from texture.
  101829. * It will save memory but will prevent the texture from being rebuilt
  101830. */
  101831. cleanCachedTextureBuffer(): void;
  101832. /**
  101833. * Get the world extend vectors with an optional filter
  101834. *
  101835. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101836. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101837. */
  101838. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101839. min: Vector3;
  101840. max: Vector3;
  101841. };
  101842. /**
  101843. * Creates a ray that can be used to pick in the scene
  101844. * @param x defines the x coordinate of the origin (on-screen)
  101845. * @param y defines the y coordinate of the origin (on-screen)
  101846. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101847. * @param camera defines the camera to use for the picking
  101848. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101849. * @returns a Ray
  101850. */
  101851. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101852. /**
  101853. * Creates a ray that can be used to pick in the scene
  101854. * @param x defines the x coordinate of the origin (on-screen)
  101855. * @param y defines the y coordinate of the origin (on-screen)
  101856. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101857. * @param result defines the ray where to store the picking ray
  101858. * @param camera defines the camera to use for the picking
  101859. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101860. * @returns the current scene
  101861. */
  101862. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101863. /**
  101864. * Creates a ray that can be used to pick in the scene
  101865. * @param x defines the x coordinate of the origin (on-screen)
  101866. * @param y defines the y coordinate of the origin (on-screen)
  101867. * @param camera defines the camera to use for the picking
  101868. * @returns a Ray
  101869. */
  101870. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101871. /**
  101872. * Creates a ray that can be used to pick in the scene
  101873. * @param x defines the x coordinate of the origin (on-screen)
  101874. * @param y defines the y coordinate of the origin (on-screen)
  101875. * @param result defines the ray where to store the picking ray
  101876. * @param camera defines the camera to use for the picking
  101877. * @returns the current scene
  101878. */
  101879. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101880. /** Launch a ray to try to pick a mesh in the scene
  101881. * @param x position on screen
  101882. * @param y position on screen
  101883. * @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
  101884. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101885. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101886. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101887. * @returns a PickingInfo
  101888. */
  101889. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101890. /** Use the given ray to pick a mesh in the scene
  101891. * @param ray The ray to use to pick meshes
  101892. * @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
  101893. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101895. * @returns a PickingInfo
  101896. */
  101897. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101898. /**
  101899. * Launch a ray to try to pick a mesh in the scene
  101900. * @param x X position on screen
  101901. * @param y Y position on screen
  101902. * @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
  101903. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101904. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101905. * @returns an array of PickingInfo
  101906. */
  101907. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101908. /**
  101909. * Launch a ray to try to pick a mesh in the scene
  101910. * @param ray Ray to use
  101911. * @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
  101912. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101913. * @returns an array of PickingInfo
  101914. */
  101915. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101916. /**
  101917. * Force the value of meshUnderPointer
  101918. * @param mesh defines the mesh to use
  101919. */
  101920. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101921. /**
  101922. * Gets the mesh under the pointer
  101923. * @returns a Mesh or null if no mesh is under the pointer
  101924. */
  101925. getPointerOverMesh(): Nullable<AbstractMesh>;
  101926. /** @hidden */
  101927. _rebuildGeometries(): void;
  101928. /** @hidden */
  101929. _rebuildTextures(): void;
  101930. private _getByTags;
  101931. /**
  101932. * Get a list of meshes by tags
  101933. * @param tagsQuery defines the tags query to use
  101934. * @param forEach defines a predicate used to filter results
  101935. * @returns an array of Mesh
  101936. */
  101937. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101938. /**
  101939. * Get a list of cameras by tags
  101940. * @param tagsQuery defines the tags query to use
  101941. * @param forEach defines a predicate used to filter results
  101942. * @returns an array of Camera
  101943. */
  101944. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101945. /**
  101946. * Get a list of lights by tags
  101947. * @param tagsQuery defines the tags query to use
  101948. * @param forEach defines a predicate used to filter results
  101949. * @returns an array of Light
  101950. */
  101951. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101952. /**
  101953. * Get a list of materials by tags
  101954. * @param tagsQuery defines the tags query to use
  101955. * @param forEach defines a predicate used to filter results
  101956. * @returns an array of Material
  101957. */
  101958. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101959. /**
  101960. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101961. * This allowed control for front to back rendering or reversly depending of the special needs.
  101962. *
  101963. * @param renderingGroupId The rendering group id corresponding to its index
  101964. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101965. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101966. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101967. */
  101968. 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;
  101969. /**
  101970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101971. *
  101972. * @param renderingGroupId The rendering group id corresponding to its index
  101973. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101974. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101975. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101976. */
  101977. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101978. /**
  101979. * Gets the current auto clear configuration for one rendering group of the rendering
  101980. * manager.
  101981. * @param index the rendering group index to get the information for
  101982. * @returns The auto clear setup for the requested rendering group
  101983. */
  101984. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101985. private _blockMaterialDirtyMechanism;
  101986. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101987. blockMaterialDirtyMechanism: boolean;
  101988. /**
  101989. * Will flag all materials as dirty to trigger new shader compilation
  101990. * @param flag defines the flag used to specify which material part must be marked as dirty
  101991. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101992. */
  101993. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101994. /** @hidden */
  101995. _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;
  101996. /** @hidden */
  101997. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101998. }
  101999. }
  102000. declare module BABYLON {
  102001. /**
  102002. * Set of assets to keep when moving a scene into an asset container.
  102003. */
  102004. export class KeepAssets extends AbstractScene {
  102005. }
  102006. /**
  102007. * Container with a set of assets that can be added or removed from a scene.
  102008. */
  102009. export class AssetContainer extends AbstractScene {
  102010. /**
  102011. * The scene the AssetContainer belongs to.
  102012. */
  102013. scene: Scene;
  102014. /**
  102015. * Instantiates an AssetContainer.
  102016. * @param scene The scene the AssetContainer belongs to.
  102017. */
  102018. constructor(scene: Scene);
  102019. /**
  102020. * Adds all the assets from the container to the scene.
  102021. */
  102022. addAllToScene(): void;
  102023. /**
  102024. * Removes all the assets in the container from the scene
  102025. */
  102026. removeAllFromScene(): void;
  102027. /**
  102028. * Disposes all the assets in the container
  102029. */
  102030. dispose(): void;
  102031. private _moveAssets;
  102032. /**
  102033. * Removes all the assets contained in the scene and adds them to the container.
  102034. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102035. */
  102036. moveAllFromScene(keepAssets?: KeepAssets): void;
  102037. /**
  102038. * 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.
  102039. * @returns the root mesh
  102040. */
  102041. createRootMesh(): Mesh;
  102042. }
  102043. }
  102044. declare module BABYLON {
  102045. /**
  102046. * Defines how the parser contract is defined.
  102047. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102048. */
  102049. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102050. /**
  102051. * Defines how the individual parser contract is defined.
  102052. * These parser can parse an individual asset
  102053. */
  102054. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102055. /**
  102056. * Base class of the scene acting as a container for the different elements composing a scene.
  102057. * This class is dynamically extended by the different components of the scene increasing
  102058. * flexibility and reducing coupling
  102059. */
  102060. export abstract class AbstractScene {
  102061. /**
  102062. * Stores the list of available parsers in the application.
  102063. */
  102064. private static _BabylonFileParsers;
  102065. /**
  102066. * Stores the list of available individual parsers in the application.
  102067. */
  102068. private static _IndividualBabylonFileParsers;
  102069. /**
  102070. * Adds a parser in the list of available ones
  102071. * @param name Defines the name of the parser
  102072. * @param parser Defines the parser to add
  102073. */
  102074. static AddParser(name: string, parser: BabylonFileParser): void;
  102075. /**
  102076. * Gets a general parser from the list of avaialble ones
  102077. * @param name Defines the name of the parser
  102078. * @returns the requested parser or null
  102079. */
  102080. static GetParser(name: string): Nullable<BabylonFileParser>;
  102081. /**
  102082. * Adds n individual parser in the list of available ones
  102083. * @param name Defines the name of the parser
  102084. * @param parser Defines the parser to add
  102085. */
  102086. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102087. /**
  102088. * Gets an individual parser from the list of avaialble ones
  102089. * @param name Defines the name of the parser
  102090. * @returns the requested parser or null
  102091. */
  102092. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102093. /**
  102094. * Parser json data and populate both a scene and its associated container object
  102095. * @param jsonData Defines the data to parse
  102096. * @param scene Defines the scene to parse the data for
  102097. * @param container Defines the container attached to the parsing sequence
  102098. * @param rootUrl Defines the root url of the data
  102099. */
  102100. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102101. /**
  102102. * Gets the list of root nodes (ie. nodes with no parent)
  102103. */
  102104. rootNodes: Node[];
  102105. /** All of the cameras added to this scene
  102106. * @see http://doc.babylonjs.com/babylon101/cameras
  102107. */
  102108. cameras: Camera[];
  102109. /**
  102110. * All of the lights added to this scene
  102111. * @see http://doc.babylonjs.com/babylon101/lights
  102112. */
  102113. lights: Light[];
  102114. /**
  102115. * All of the (abstract) meshes added to this scene
  102116. */
  102117. meshes: AbstractMesh[];
  102118. /**
  102119. * The list of skeletons added to the scene
  102120. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102121. */
  102122. skeletons: Skeleton[];
  102123. /**
  102124. * All of the particle systems added to this scene
  102125. * @see http://doc.babylonjs.com/babylon101/particles
  102126. */
  102127. particleSystems: IParticleSystem[];
  102128. /**
  102129. * Gets a list of Animations associated with the scene
  102130. */
  102131. animations: Animation[];
  102132. /**
  102133. * All of the animation groups added to this scene
  102134. * @see http://doc.babylonjs.com/how_to/group
  102135. */
  102136. animationGroups: AnimationGroup[];
  102137. /**
  102138. * All of the multi-materials added to this scene
  102139. * @see http://doc.babylonjs.com/how_to/multi_materials
  102140. */
  102141. multiMaterials: MultiMaterial[];
  102142. /**
  102143. * All of the materials added to this scene
  102144. * In the context of a Scene, it is not supposed to be modified manually.
  102145. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102146. * Note also that the order of the Material wihin the array is not significant and might change.
  102147. * @see http://doc.babylonjs.com/babylon101/materials
  102148. */
  102149. materials: Material[];
  102150. /**
  102151. * The list of morph target managers added to the scene
  102152. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102153. */
  102154. morphTargetManagers: MorphTargetManager[];
  102155. /**
  102156. * The list of geometries used in the scene.
  102157. */
  102158. geometries: Geometry[];
  102159. /**
  102160. * All of the tranform nodes added to this scene
  102161. * In the context of a Scene, it is not supposed to be modified manually.
  102162. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102163. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102164. * @see http://doc.babylonjs.com/how_to/transformnode
  102165. */
  102166. transformNodes: TransformNode[];
  102167. /**
  102168. * ActionManagers available on the scene.
  102169. */
  102170. actionManagers: AbstractActionManager[];
  102171. /**
  102172. * Textures to keep.
  102173. */
  102174. textures: BaseTexture[];
  102175. /**
  102176. * Environment texture for the scene
  102177. */
  102178. environmentTexture: Nullable<BaseTexture>;
  102179. }
  102180. }
  102181. declare module BABYLON {
  102182. /**
  102183. * Interface used to define options for Sound class
  102184. */
  102185. export interface ISoundOptions {
  102186. /**
  102187. * Does the sound autoplay once loaded.
  102188. */
  102189. autoplay?: boolean;
  102190. /**
  102191. * Does the sound loop after it finishes playing once.
  102192. */
  102193. loop?: boolean;
  102194. /**
  102195. * Sound's volume
  102196. */
  102197. volume?: number;
  102198. /**
  102199. * Is it a spatial sound?
  102200. */
  102201. spatialSound?: boolean;
  102202. /**
  102203. * Maximum distance to hear that sound
  102204. */
  102205. maxDistance?: number;
  102206. /**
  102207. * Uses user defined attenuation function
  102208. */
  102209. useCustomAttenuation?: boolean;
  102210. /**
  102211. * Define the roll off factor of spatial sounds.
  102212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102213. */
  102214. rolloffFactor?: number;
  102215. /**
  102216. * Define the reference distance the sound should be heard perfectly.
  102217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102218. */
  102219. refDistance?: number;
  102220. /**
  102221. * Define the distance attenuation model the sound will follow.
  102222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102223. */
  102224. distanceModel?: string;
  102225. /**
  102226. * Defines the playback speed (1 by default)
  102227. */
  102228. playbackRate?: number;
  102229. /**
  102230. * Defines if the sound is from a streaming source
  102231. */
  102232. streaming?: boolean;
  102233. /**
  102234. * Defines an optional length (in seconds) inside the sound file
  102235. */
  102236. length?: number;
  102237. /**
  102238. * Defines an optional offset (in seconds) inside the sound file
  102239. */
  102240. offset?: number;
  102241. /**
  102242. * If true, URLs will not be required to state the audio file codec to use.
  102243. */
  102244. skipCodecCheck?: boolean;
  102245. }
  102246. /**
  102247. * Defines a sound that can be played in the application.
  102248. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102250. */
  102251. export class Sound {
  102252. /**
  102253. * The name of the sound in the scene.
  102254. */
  102255. name: string;
  102256. /**
  102257. * Does the sound autoplay once loaded.
  102258. */
  102259. autoplay: boolean;
  102260. /**
  102261. * Does the sound loop after it finishes playing once.
  102262. */
  102263. loop: boolean;
  102264. /**
  102265. * Does the sound use a custom attenuation curve to simulate the falloff
  102266. * happening when the source gets further away from the camera.
  102267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102268. */
  102269. useCustomAttenuation: boolean;
  102270. /**
  102271. * The sound track id this sound belongs to.
  102272. */
  102273. soundTrackId: number;
  102274. /**
  102275. * Is this sound currently played.
  102276. */
  102277. isPlaying: boolean;
  102278. /**
  102279. * Is this sound currently paused.
  102280. */
  102281. isPaused: boolean;
  102282. /**
  102283. * Does this sound enables spatial sound.
  102284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102285. */
  102286. spatialSound: boolean;
  102287. /**
  102288. * Define the reference distance the sound should be heard perfectly.
  102289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102290. */
  102291. refDistance: number;
  102292. /**
  102293. * Define the roll off factor of spatial sounds.
  102294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102295. */
  102296. rolloffFactor: number;
  102297. /**
  102298. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102300. */
  102301. maxDistance: number;
  102302. /**
  102303. * Define the distance attenuation model the sound will follow.
  102304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102305. */
  102306. distanceModel: string;
  102307. /**
  102308. * @hidden
  102309. * Back Compat
  102310. **/
  102311. onended: () => any;
  102312. /**
  102313. * Observable event when the current playing sound finishes.
  102314. */
  102315. onEndedObservable: Observable<Sound>;
  102316. private _panningModel;
  102317. private _playbackRate;
  102318. private _streaming;
  102319. private _startTime;
  102320. private _startOffset;
  102321. private _position;
  102322. /** @hidden */
  102323. _positionInEmitterSpace: boolean;
  102324. private _localDirection;
  102325. private _volume;
  102326. private _isReadyToPlay;
  102327. private _isDirectional;
  102328. private _readyToPlayCallback;
  102329. private _audioBuffer;
  102330. private _soundSource;
  102331. private _streamingSource;
  102332. private _soundPanner;
  102333. private _soundGain;
  102334. private _inputAudioNode;
  102335. private _outputAudioNode;
  102336. private _coneInnerAngle;
  102337. private _coneOuterAngle;
  102338. private _coneOuterGain;
  102339. private _scene;
  102340. private _connectedTransformNode;
  102341. private _customAttenuationFunction;
  102342. private _registerFunc;
  102343. private _isOutputConnected;
  102344. private _htmlAudioElement;
  102345. private _urlType;
  102346. private _length?;
  102347. private _offset?;
  102348. /** @hidden */
  102349. static _SceneComponentInitialization: (scene: Scene) => void;
  102350. /**
  102351. * Create a sound and attach it to a scene
  102352. * @param name Name of your sound
  102353. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102354. * @param scene defines the scene the sound belongs to
  102355. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102356. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102357. */
  102358. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102359. /**
  102360. * Release the sound and its associated resources
  102361. */
  102362. dispose(): void;
  102363. /**
  102364. * Gets if the sounds is ready to be played or not.
  102365. * @returns true if ready, otherwise false
  102366. */
  102367. isReady(): boolean;
  102368. private _soundLoaded;
  102369. /**
  102370. * Sets the data of the sound from an audiobuffer
  102371. * @param audioBuffer The audioBuffer containing the data
  102372. */
  102373. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102374. /**
  102375. * Updates the current sounds options such as maxdistance, loop...
  102376. * @param options A JSON object containing values named as the object properties
  102377. */
  102378. updateOptions(options: ISoundOptions): void;
  102379. private _createSpatialParameters;
  102380. private _updateSpatialParameters;
  102381. /**
  102382. * Switch the panning model to HRTF:
  102383. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102385. */
  102386. switchPanningModelToHRTF(): void;
  102387. /**
  102388. * Switch the panning model to Equal Power:
  102389. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102391. */
  102392. switchPanningModelToEqualPower(): void;
  102393. private _switchPanningModel;
  102394. /**
  102395. * Connect this sound to a sound track audio node like gain...
  102396. * @param soundTrackAudioNode the sound track audio node to connect to
  102397. */
  102398. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102399. /**
  102400. * Transform this sound into a directional source
  102401. * @param coneInnerAngle Size of the inner cone in degree
  102402. * @param coneOuterAngle Size of the outer cone in degree
  102403. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102404. */
  102405. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102406. /**
  102407. * Gets or sets the inner angle for the directional cone.
  102408. */
  102409. /**
  102410. * Gets or sets the inner angle for the directional cone.
  102411. */
  102412. directionalConeInnerAngle: number;
  102413. /**
  102414. * Gets or sets the outer angle for the directional cone.
  102415. */
  102416. /**
  102417. * Gets or sets the outer angle for the directional cone.
  102418. */
  102419. directionalConeOuterAngle: number;
  102420. /**
  102421. * Sets the position of the emitter if spatial sound is enabled
  102422. * @param newPosition Defines the new posisiton
  102423. */
  102424. setPosition(newPosition: Vector3): void;
  102425. /**
  102426. * Sets the local direction of the emitter if spatial sound is enabled
  102427. * @param newLocalDirection Defines the new local direction
  102428. */
  102429. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102430. private _updateDirection;
  102431. /** @hidden */
  102432. updateDistanceFromListener(): void;
  102433. /**
  102434. * Sets a new custom attenuation function for the sound.
  102435. * @param callback Defines the function used for the attenuation
  102436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102437. */
  102438. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102439. /**
  102440. * Play the sound
  102441. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102442. * @param offset (optional) Start the sound at a specific time in seconds
  102443. * @param length (optional) Sound duration (in seconds)
  102444. */
  102445. play(time?: number, offset?: number, length?: number): void;
  102446. private _onended;
  102447. /**
  102448. * Stop the sound
  102449. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102450. */
  102451. stop(time?: number): void;
  102452. /**
  102453. * Put the sound in pause
  102454. */
  102455. pause(): void;
  102456. /**
  102457. * Sets a dedicated volume for this sounds
  102458. * @param newVolume Define the new volume of the sound
  102459. * @param time Define time for gradual change to new volume
  102460. */
  102461. setVolume(newVolume: number, time?: number): void;
  102462. /**
  102463. * Set the sound play back rate
  102464. * @param newPlaybackRate Define the playback rate the sound should be played at
  102465. */
  102466. setPlaybackRate(newPlaybackRate: number): void;
  102467. /**
  102468. * Gets the volume of the sound.
  102469. * @returns the volume of the sound
  102470. */
  102471. getVolume(): number;
  102472. /**
  102473. * Attach the sound to a dedicated mesh
  102474. * @param transformNode The transform node to connect the sound with
  102475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102476. */
  102477. attachToMesh(transformNode: TransformNode): void;
  102478. /**
  102479. * Detach the sound from the previously attached mesh
  102480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102481. */
  102482. detachFromMesh(): void;
  102483. private _onRegisterAfterWorldMatrixUpdate;
  102484. /**
  102485. * Clone the current sound in the scene.
  102486. * @returns the new sound clone
  102487. */
  102488. clone(): Nullable<Sound>;
  102489. /**
  102490. * Gets the current underlying audio buffer containing the data
  102491. * @returns the audio buffer
  102492. */
  102493. getAudioBuffer(): Nullable<AudioBuffer>;
  102494. /**
  102495. * Serializes the Sound in a JSON representation
  102496. * @returns the JSON representation of the sound
  102497. */
  102498. serialize(): any;
  102499. /**
  102500. * Parse a JSON representation of a sound to innstantiate in a given scene
  102501. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102502. * @param scene Define the scene the new parsed sound should be created in
  102503. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102504. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102505. * @returns the newly parsed sound
  102506. */
  102507. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102508. }
  102509. }
  102510. declare module BABYLON {
  102511. /**
  102512. * This defines an action helpful to play a defined sound on a triggered action.
  102513. */
  102514. export class PlaySoundAction extends Action {
  102515. private _sound;
  102516. /**
  102517. * Instantiate the action
  102518. * @param triggerOptions defines the trigger options
  102519. * @param sound defines the sound to play
  102520. * @param condition defines the trigger related conditions
  102521. */
  102522. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102523. /** @hidden */
  102524. _prepare(): void;
  102525. /**
  102526. * Execute the action and play the sound.
  102527. */
  102528. execute(): void;
  102529. /**
  102530. * Serializes the actions and its related information.
  102531. * @param parent defines the object to serialize in
  102532. * @returns the serialized object
  102533. */
  102534. serialize(parent: any): any;
  102535. }
  102536. /**
  102537. * This defines an action helpful to stop a defined sound on a triggered action.
  102538. */
  102539. export class StopSoundAction extends Action {
  102540. private _sound;
  102541. /**
  102542. * Instantiate the action
  102543. * @param triggerOptions defines the trigger options
  102544. * @param sound defines the sound to stop
  102545. * @param condition defines the trigger related conditions
  102546. */
  102547. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102548. /** @hidden */
  102549. _prepare(): void;
  102550. /**
  102551. * Execute the action and stop the sound.
  102552. */
  102553. execute(): void;
  102554. /**
  102555. * Serializes the actions and its related information.
  102556. * @param parent defines the object to serialize in
  102557. * @returns the serialized object
  102558. */
  102559. serialize(parent: any): any;
  102560. }
  102561. }
  102562. declare module BABYLON {
  102563. /**
  102564. * This defines an action responsible to change the value of a property
  102565. * by interpolating between its current value and the newly set one once triggered.
  102566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102567. */
  102568. export class InterpolateValueAction extends Action {
  102569. /**
  102570. * Defines the path of the property where the value should be interpolated
  102571. */
  102572. propertyPath: string;
  102573. /**
  102574. * Defines the target value at the end of the interpolation.
  102575. */
  102576. value: any;
  102577. /**
  102578. * Defines the time it will take for the property to interpolate to the value.
  102579. */
  102580. duration: number;
  102581. /**
  102582. * Defines if the other scene animations should be stopped when the action has been triggered
  102583. */
  102584. stopOtherAnimations?: boolean;
  102585. /**
  102586. * Defines a callback raised once the interpolation animation has been done.
  102587. */
  102588. onInterpolationDone?: () => void;
  102589. /**
  102590. * Observable triggered once the interpolation animation has been done.
  102591. */
  102592. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102593. private _target;
  102594. private _effectiveTarget;
  102595. private _property;
  102596. /**
  102597. * Instantiate the action
  102598. * @param triggerOptions defines the trigger options
  102599. * @param target defines the object containing the value to interpolate
  102600. * @param propertyPath defines the path to the property in the target object
  102601. * @param value defines the target value at the end of the interpolation
  102602. * @param duration deines the time it will take for the property to interpolate to the value.
  102603. * @param condition defines the trigger related conditions
  102604. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102605. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102606. */
  102607. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102608. /** @hidden */
  102609. _prepare(): void;
  102610. /**
  102611. * Execute the action starts the value interpolation.
  102612. */
  102613. execute(): void;
  102614. /**
  102615. * Serializes the actions and its related information.
  102616. * @param parent defines the object to serialize in
  102617. * @returns the serialized object
  102618. */
  102619. serialize(parent: any): any;
  102620. }
  102621. }
  102622. declare module BABYLON {
  102623. /**
  102624. * Options allowed during the creation of a sound track.
  102625. */
  102626. export interface ISoundTrackOptions {
  102627. /**
  102628. * The volume the sound track should take during creation
  102629. */
  102630. volume?: number;
  102631. /**
  102632. * Define if the sound track is the main sound track of the scene
  102633. */
  102634. mainTrack?: boolean;
  102635. }
  102636. /**
  102637. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102638. * It will be also used in a future release to apply effects on a specific track.
  102639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102640. */
  102641. export class SoundTrack {
  102642. /**
  102643. * The unique identifier of the sound track in the scene.
  102644. */
  102645. id: number;
  102646. /**
  102647. * The list of sounds included in the sound track.
  102648. */
  102649. soundCollection: Array<Sound>;
  102650. private _outputAudioNode;
  102651. private _scene;
  102652. private _isMainTrack;
  102653. private _connectedAnalyser;
  102654. private _options;
  102655. private _isInitialized;
  102656. /**
  102657. * Creates a new sound track.
  102658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102659. * @param scene Define the scene the sound track belongs to
  102660. * @param options
  102661. */
  102662. constructor(scene: Scene, options?: ISoundTrackOptions);
  102663. private _initializeSoundTrackAudioGraph;
  102664. /**
  102665. * Release the sound track and its associated resources
  102666. */
  102667. dispose(): void;
  102668. /**
  102669. * Adds a sound to this sound track
  102670. * @param sound define the cound to add
  102671. * @ignoreNaming
  102672. */
  102673. AddSound(sound: Sound): void;
  102674. /**
  102675. * Removes a sound to this sound track
  102676. * @param sound define the cound to remove
  102677. * @ignoreNaming
  102678. */
  102679. RemoveSound(sound: Sound): void;
  102680. /**
  102681. * Set a global volume for the full sound track.
  102682. * @param newVolume Define the new volume of the sound track
  102683. */
  102684. setVolume(newVolume: number): void;
  102685. /**
  102686. * Switch the panning model to HRTF:
  102687. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102689. */
  102690. switchPanningModelToHRTF(): void;
  102691. /**
  102692. * Switch the panning model to Equal Power:
  102693. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102695. */
  102696. switchPanningModelToEqualPower(): void;
  102697. /**
  102698. * Connect the sound track to an audio analyser allowing some amazing
  102699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102701. * @param analyser The analyser to connect to the engine
  102702. */
  102703. connectToAnalyser(analyser: Analyser): void;
  102704. }
  102705. }
  102706. declare module BABYLON {
  102707. interface AbstractScene {
  102708. /**
  102709. * The list of sounds used in the scene.
  102710. */
  102711. sounds: Nullable<Array<Sound>>;
  102712. }
  102713. interface Scene {
  102714. /**
  102715. * @hidden
  102716. * Backing field
  102717. */
  102718. _mainSoundTrack: SoundTrack;
  102719. /**
  102720. * The main sound track played by the scene.
  102721. * It cotains your primary collection of sounds.
  102722. */
  102723. mainSoundTrack: SoundTrack;
  102724. /**
  102725. * The list of sound tracks added to the scene
  102726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102727. */
  102728. soundTracks: Nullable<Array<SoundTrack>>;
  102729. /**
  102730. * Gets a sound using a given name
  102731. * @param name defines the name to search for
  102732. * @return the found sound or null if not found at all.
  102733. */
  102734. getSoundByName(name: string): Nullable<Sound>;
  102735. /**
  102736. * Gets or sets if audio support is enabled
  102737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102738. */
  102739. audioEnabled: boolean;
  102740. /**
  102741. * Gets or sets if audio will be output to headphones
  102742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102743. */
  102744. headphone: boolean;
  102745. /**
  102746. * Gets or sets custom audio listener position provider
  102747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102748. */
  102749. audioListenerPositionProvider: Nullable<() => Vector3>;
  102750. }
  102751. /**
  102752. * Defines the sound scene component responsible to manage any sounds
  102753. * in a given scene.
  102754. */
  102755. export class AudioSceneComponent implements ISceneSerializableComponent {
  102756. /**
  102757. * The component name helpfull to identify the component in the list of scene components.
  102758. */
  102759. readonly name: string;
  102760. /**
  102761. * The scene the component belongs to.
  102762. */
  102763. scene: Scene;
  102764. private _audioEnabled;
  102765. /**
  102766. * Gets whether audio is enabled or not.
  102767. * Please use related enable/disable method to switch state.
  102768. */
  102769. readonly audioEnabled: boolean;
  102770. private _headphone;
  102771. /**
  102772. * Gets whether audio is outputing to headphone or not.
  102773. * Please use the according Switch methods to change output.
  102774. */
  102775. readonly headphone: boolean;
  102776. private _audioListenerPositionProvider;
  102777. /**
  102778. * Gets the current audio listener position provider
  102779. */
  102780. /**
  102781. * Sets a custom listener position for all sounds in the scene
  102782. * By default, this is the position of the first active camera
  102783. */
  102784. audioListenerPositionProvider: Nullable<() => Vector3>;
  102785. /**
  102786. * Creates a new instance of the component for the given scene
  102787. * @param scene Defines the scene to register the component in
  102788. */
  102789. constructor(scene: Scene);
  102790. /**
  102791. * Registers the component in a given scene
  102792. */
  102793. register(): void;
  102794. /**
  102795. * Rebuilds the elements related to this component in case of
  102796. * context lost for instance.
  102797. */
  102798. rebuild(): void;
  102799. /**
  102800. * Serializes the component data to the specified json object
  102801. * @param serializationObject The object to serialize to
  102802. */
  102803. serialize(serializationObject: any): void;
  102804. /**
  102805. * Adds all the elements from the container to the scene
  102806. * @param container the container holding the elements
  102807. */
  102808. addFromContainer(container: AbstractScene): void;
  102809. /**
  102810. * Removes all the elements in the container from the scene
  102811. * @param container contains the elements to remove
  102812. * @param dispose if the removed element should be disposed (default: false)
  102813. */
  102814. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102815. /**
  102816. * Disposes the component and the associated ressources.
  102817. */
  102818. dispose(): void;
  102819. /**
  102820. * Disables audio in the associated scene.
  102821. */
  102822. disableAudio(): void;
  102823. /**
  102824. * Enables audio in the associated scene.
  102825. */
  102826. enableAudio(): void;
  102827. /**
  102828. * Switch audio to headphone output.
  102829. */
  102830. switchAudioModeForHeadphones(): void;
  102831. /**
  102832. * Switch audio to normal speakers.
  102833. */
  102834. switchAudioModeForNormalSpeakers(): void;
  102835. private _afterRender;
  102836. }
  102837. }
  102838. declare module BABYLON {
  102839. /**
  102840. * Wraps one or more Sound objects and selects one with random weight for playback.
  102841. */
  102842. export class WeightedSound {
  102843. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102844. loop: boolean;
  102845. private _coneInnerAngle;
  102846. private _coneOuterAngle;
  102847. private _volume;
  102848. /** A Sound is currently playing. */
  102849. isPlaying: boolean;
  102850. /** A Sound is currently paused. */
  102851. isPaused: boolean;
  102852. private _sounds;
  102853. private _weights;
  102854. private _currentIndex?;
  102855. /**
  102856. * Creates a new WeightedSound from the list of sounds given.
  102857. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102858. * @param sounds Array of Sounds that will be selected from.
  102859. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102860. */
  102861. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102862. /**
  102863. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102864. */
  102865. /**
  102866. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102867. */
  102868. directionalConeInnerAngle: number;
  102869. /**
  102870. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102871. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102872. */
  102873. /**
  102874. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102875. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102876. */
  102877. directionalConeOuterAngle: number;
  102878. /**
  102879. * Playback volume.
  102880. */
  102881. /**
  102882. * Playback volume.
  102883. */
  102884. volume: number;
  102885. private _onended;
  102886. /**
  102887. * Suspend playback
  102888. */
  102889. pause(): void;
  102890. /**
  102891. * Stop playback
  102892. */
  102893. stop(): void;
  102894. /**
  102895. * Start playback.
  102896. * @param startOffset Position the clip head at a specific time in seconds.
  102897. */
  102898. play(startOffset?: number): void;
  102899. }
  102900. }
  102901. declare module BABYLON {
  102902. /**
  102903. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102904. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102905. */
  102906. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102907. /**
  102908. * Gets the name of the behavior.
  102909. */
  102910. readonly name: string;
  102911. /**
  102912. * The easing function used by animations
  102913. */
  102914. static EasingFunction: BackEase;
  102915. /**
  102916. * The easing mode used by animations
  102917. */
  102918. static EasingMode: number;
  102919. /**
  102920. * The duration of the animation, in milliseconds
  102921. */
  102922. transitionDuration: number;
  102923. /**
  102924. * Length of the distance animated by the transition when lower radius is reached
  102925. */
  102926. lowerRadiusTransitionRange: number;
  102927. /**
  102928. * Length of the distance animated by the transition when upper radius is reached
  102929. */
  102930. upperRadiusTransitionRange: number;
  102931. private _autoTransitionRange;
  102932. /**
  102933. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102934. */
  102935. /**
  102936. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102937. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102938. */
  102939. autoTransitionRange: boolean;
  102940. private _attachedCamera;
  102941. private _onAfterCheckInputsObserver;
  102942. private _onMeshTargetChangedObserver;
  102943. /**
  102944. * Initializes the behavior.
  102945. */
  102946. init(): void;
  102947. /**
  102948. * Attaches the behavior to its arc rotate camera.
  102949. * @param camera Defines the camera to attach the behavior to
  102950. */
  102951. attach(camera: ArcRotateCamera): void;
  102952. /**
  102953. * Detaches the behavior from its current arc rotate camera.
  102954. */
  102955. detach(): void;
  102956. private _radiusIsAnimating;
  102957. private _radiusBounceTransition;
  102958. private _animatables;
  102959. private _cachedWheelPrecision;
  102960. /**
  102961. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102962. * @param radiusLimit The limit to check against.
  102963. * @return Bool to indicate if at limit.
  102964. */
  102965. private _isRadiusAtLimit;
  102966. /**
  102967. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102968. * @param radiusDelta The delta by which to animate to. Can be negative.
  102969. */
  102970. private _applyBoundRadiusAnimation;
  102971. /**
  102972. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102973. */
  102974. protected _clearAnimationLocks(): void;
  102975. /**
  102976. * Stops and removes all animations that have been applied to the camera
  102977. */
  102978. stopAllAnimations(): void;
  102979. }
  102980. }
  102981. declare module BABYLON {
  102982. /**
  102983. * 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.
  102984. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102985. */
  102986. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102987. /**
  102988. * Gets the name of the behavior.
  102989. */
  102990. readonly name: string;
  102991. private _mode;
  102992. private _radiusScale;
  102993. private _positionScale;
  102994. private _defaultElevation;
  102995. private _elevationReturnTime;
  102996. private _elevationReturnWaitTime;
  102997. private _zoomStopsAnimation;
  102998. private _framingTime;
  102999. /**
  103000. * The easing function used by animations
  103001. */
  103002. static EasingFunction: ExponentialEase;
  103003. /**
  103004. * The easing mode used by animations
  103005. */
  103006. static EasingMode: number;
  103007. /**
  103008. * Sets the current mode used by the behavior
  103009. */
  103010. /**
  103011. * Gets current mode used by the behavior.
  103012. */
  103013. mode: number;
  103014. /**
  103015. * Sets the scale applied to the radius (1 by default)
  103016. */
  103017. /**
  103018. * Gets the scale applied to the radius
  103019. */
  103020. radiusScale: number;
  103021. /**
  103022. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103023. */
  103024. /**
  103025. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103026. */
  103027. positionScale: number;
  103028. /**
  103029. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103030. * behaviour is triggered, in radians.
  103031. */
  103032. /**
  103033. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103034. * behaviour is triggered, in radians.
  103035. */
  103036. defaultElevation: number;
  103037. /**
  103038. * Sets the time (in milliseconds) taken to return to the default beta position.
  103039. * Negative value indicates camera should not return to default.
  103040. */
  103041. /**
  103042. * Gets the time (in milliseconds) taken to return to the default beta position.
  103043. * Negative value indicates camera should not return to default.
  103044. */
  103045. elevationReturnTime: number;
  103046. /**
  103047. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103048. */
  103049. /**
  103050. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103051. */
  103052. elevationReturnWaitTime: number;
  103053. /**
  103054. * Sets the flag that indicates if user zooming should stop animation.
  103055. */
  103056. /**
  103057. * Gets the flag that indicates if user zooming should stop animation.
  103058. */
  103059. zoomStopsAnimation: boolean;
  103060. /**
  103061. * Sets the transition time when framing the mesh, in milliseconds
  103062. */
  103063. /**
  103064. * Gets the transition time when framing the mesh, in milliseconds
  103065. */
  103066. framingTime: number;
  103067. /**
  103068. * Define if the behavior should automatically change the configured
  103069. * camera limits and sensibilities.
  103070. */
  103071. autoCorrectCameraLimitsAndSensibility: boolean;
  103072. private _onPrePointerObservableObserver;
  103073. private _onAfterCheckInputsObserver;
  103074. private _onMeshTargetChangedObserver;
  103075. private _attachedCamera;
  103076. private _isPointerDown;
  103077. private _lastInteractionTime;
  103078. /**
  103079. * Initializes the behavior.
  103080. */
  103081. init(): void;
  103082. /**
  103083. * Attaches the behavior to its arc rotate camera.
  103084. * @param camera Defines the camera to attach the behavior to
  103085. */
  103086. attach(camera: ArcRotateCamera): void;
  103087. /**
  103088. * Detaches the behavior from its current arc rotate camera.
  103089. */
  103090. detach(): void;
  103091. private _animatables;
  103092. private _betaIsAnimating;
  103093. private _betaTransition;
  103094. private _radiusTransition;
  103095. private _vectorTransition;
  103096. /**
  103097. * Targets the given mesh and updates zoom level accordingly.
  103098. * @param mesh The mesh to target.
  103099. * @param radius Optional. If a cached radius position already exists, overrides default.
  103100. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103101. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103102. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103103. */
  103104. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103105. /**
  103106. * Targets the given mesh with its children and updates zoom level accordingly.
  103107. * @param mesh The mesh to target.
  103108. * @param radius Optional. If a cached radius position already exists, overrides default.
  103109. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103112. */
  103113. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103114. /**
  103115. * Targets the given meshes with their children and updates zoom level accordingly.
  103116. * @param meshes The mesh to target.
  103117. * @param radius Optional. If a cached radius position already exists, overrides default.
  103118. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103119. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103120. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103121. */
  103122. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103123. /**
  103124. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103125. * @param minimumWorld Determines the smaller position of the bounding box extend
  103126. * @param maximumWorld Determines the bigger position of the bounding box extend
  103127. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103128. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103129. */
  103130. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103131. /**
  103132. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103133. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103134. * frustum width.
  103135. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103136. * to fully enclose the mesh in the viewing frustum.
  103137. */
  103138. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103139. /**
  103140. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103141. * is automatically returned to its default position (expected to be above ground plane).
  103142. */
  103143. private _maintainCameraAboveGround;
  103144. /**
  103145. * Returns the frustum slope based on the canvas ratio and camera FOV
  103146. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103147. */
  103148. private _getFrustumSlope;
  103149. /**
  103150. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103151. */
  103152. private _clearAnimationLocks;
  103153. /**
  103154. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103155. */
  103156. private _applyUserInteraction;
  103157. /**
  103158. * Stops and removes all animations that have been applied to the camera
  103159. */
  103160. stopAllAnimations(): void;
  103161. /**
  103162. * Gets a value indicating if the user is moving the camera
  103163. */
  103164. readonly isUserIsMoving: boolean;
  103165. /**
  103166. * The camera can move all the way towards the mesh.
  103167. */
  103168. static IgnoreBoundsSizeMode: number;
  103169. /**
  103170. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103171. */
  103172. static FitFrustumSidesMode: number;
  103173. }
  103174. }
  103175. declare module BABYLON {
  103176. /**
  103177. * Base class for Camera Pointer Inputs.
  103178. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103179. * for example usage.
  103180. */
  103181. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103182. /**
  103183. * Defines the camera the input is attached to.
  103184. */
  103185. abstract camera: Camera;
  103186. /**
  103187. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103188. */
  103189. protected _altKey: boolean;
  103190. protected _ctrlKey: boolean;
  103191. protected _metaKey: boolean;
  103192. protected _shiftKey: boolean;
  103193. /**
  103194. * Which mouse buttons were pressed at time of last mouse event.
  103195. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103196. */
  103197. protected _buttonsPressed: number;
  103198. /**
  103199. * Defines the buttons associated with the input to handle camera move.
  103200. */
  103201. buttons: number[];
  103202. /**
  103203. * Attach the input controls to a specific dom element to get the input from.
  103204. * @param element Defines the element the controls should be listened from
  103205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103206. */
  103207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103208. /**
  103209. * Detach the current controls from the specified dom element.
  103210. * @param element Defines the element to stop listening the inputs from
  103211. */
  103212. detachControl(element: Nullable<HTMLElement>): void;
  103213. /**
  103214. * Gets the class name of the current input.
  103215. * @returns the class name
  103216. */
  103217. getClassName(): string;
  103218. /**
  103219. * Get the friendly name associated with the input class.
  103220. * @returns the input friendly name
  103221. */
  103222. getSimpleName(): string;
  103223. /**
  103224. * Called on pointer POINTERDOUBLETAP event.
  103225. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103226. */
  103227. protected onDoubleTap(type: string): void;
  103228. /**
  103229. * Called on pointer POINTERMOVE event if only a single touch is active.
  103230. * Override this method to provide functionality.
  103231. */
  103232. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103233. /**
  103234. * Called on pointer POINTERMOVE event if multiple touches are active.
  103235. * Override this method to provide functionality.
  103236. */
  103237. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103238. /**
  103239. * Called on JS contextmenu event.
  103240. * Override this method to provide functionality.
  103241. */
  103242. protected onContextMenu(evt: PointerEvent): void;
  103243. /**
  103244. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103245. * press.
  103246. * Override this method to provide functionality.
  103247. */
  103248. protected onButtonDown(evt: PointerEvent): void;
  103249. /**
  103250. * Called each time a new POINTERUP event occurs. Ie, for each button
  103251. * release.
  103252. * Override this method to provide functionality.
  103253. */
  103254. protected onButtonUp(evt: PointerEvent): void;
  103255. /**
  103256. * Called when window becomes inactive.
  103257. * Override this method to provide functionality.
  103258. */
  103259. protected onLostFocus(): void;
  103260. private _pointerInput;
  103261. private _observer;
  103262. private _onLostFocus;
  103263. private pointA;
  103264. private pointB;
  103265. }
  103266. }
  103267. declare module BABYLON {
  103268. /**
  103269. * Manage the pointers inputs to control an arc rotate camera.
  103270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103271. */
  103272. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103273. /**
  103274. * Defines the camera the input is attached to.
  103275. */
  103276. camera: ArcRotateCamera;
  103277. /**
  103278. * Gets the class name of the current input.
  103279. * @returns the class name
  103280. */
  103281. getClassName(): string;
  103282. /**
  103283. * Defines the buttons associated with the input to handle camera move.
  103284. */
  103285. buttons: number[];
  103286. /**
  103287. * Defines the pointer angular sensibility along the X axis or how fast is
  103288. * the camera rotating.
  103289. */
  103290. angularSensibilityX: number;
  103291. /**
  103292. * Defines the pointer angular sensibility along the Y axis or how fast is
  103293. * the camera rotating.
  103294. */
  103295. angularSensibilityY: number;
  103296. /**
  103297. * Defines the pointer pinch precision or how fast is the camera zooming.
  103298. */
  103299. pinchPrecision: number;
  103300. /**
  103301. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103302. * from 0.
  103303. * It defines the percentage of current camera.radius to use as delta when
  103304. * pinch zoom is used.
  103305. */
  103306. pinchDeltaPercentage: number;
  103307. /**
  103308. * Defines the pointer panning sensibility or how fast is the camera moving.
  103309. */
  103310. panningSensibility: number;
  103311. /**
  103312. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103313. */
  103314. multiTouchPanning: boolean;
  103315. /**
  103316. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103317. * zoom (pinch) through multitouch.
  103318. */
  103319. multiTouchPanAndZoom: boolean;
  103320. /**
  103321. * Revers pinch action direction.
  103322. */
  103323. pinchInwards: boolean;
  103324. private _isPanClick;
  103325. private _twoFingerActivityCount;
  103326. private _isPinching;
  103327. /**
  103328. * Called on pointer POINTERMOVE event if only a single touch is active.
  103329. */
  103330. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103331. /**
  103332. * Called on pointer POINTERDOUBLETAP event.
  103333. */
  103334. protected onDoubleTap(type: string): void;
  103335. /**
  103336. * Called on pointer POINTERMOVE event if multiple touches are active.
  103337. */
  103338. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103339. /**
  103340. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103341. * press.
  103342. */
  103343. protected onButtonDown(evt: PointerEvent): void;
  103344. /**
  103345. * Called each time a new POINTERUP event occurs. Ie, for each button
  103346. * release.
  103347. */
  103348. protected onButtonUp(evt: PointerEvent): void;
  103349. /**
  103350. * Called when window becomes inactive.
  103351. */
  103352. protected onLostFocus(): void;
  103353. }
  103354. }
  103355. declare module BABYLON {
  103356. /**
  103357. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103359. */
  103360. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103361. /**
  103362. * Defines the camera the input is attached to.
  103363. */
  103364. camera: ArcRotateCamera;
  103365. /**
  103366. * Defines the list of key codes associated with the up action (increase alpha)
  103367. */
  103368. keysUp: number[];
  103369. /**
  103370. * Defines the list of key codes associated with the down action (decrease alpha)
  103371. */
  103372. keysDown: number[];
  103373. /**
  103374. * Defines the list of key codes associated with the left action (increase beta)
  103375. */
  103376. keysLeft: number[];
  103377. /**
  103378. * Defines the list of key codes associated with the right action (decrease beta)
  103379. */
  103380. keysRight: number[];
  103381. /**
  103382. * Defines the list of key codes associated with the reset action.
  103383. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103384. */
  103385. keysReset: number[];
  103386. /**
  103387. * Defines the panning sensibility of the inputs.
  103388. * (How fast is the camera paning)
  103389. */
  103390. panningSensibility: number;
  103391. /**
  103392. * Defines the zooming sensibility of the inputs.
  103393. * (How fast is the camera zooming)
  103394. */
  103395. zoomingSensibility: number;
  103396. /**
  103397. * Defines wether maintaining the alt key down switch the movement mode from
  103398. * orientation to zoom.
  103399. */
  103400. useAltToZoom: boolean;
  103401. /**
  103402. * Rotation speed of the camera
  103403. */
  103404. angularSpeed: number;
  103405. private _keys;
  103406. private _ctrlPressed;
  103407. private _altPressed;
  103408. private _onCanvasBlurObserver;
  103409. private _onKeyboardObserver;
  103410. private _engine;
  103411. private _scene;
  103412. /**
  103413. * Attach the input controls to a specific dom element to get the input from.
  103414. * @param element Defines the element the controls should be listened from
  103415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103416. */
  103417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103418. /**
  103419. * Detach the current controls from the specified dom element.
  103420. * @param element Defines the element to stop listening the inputs from
  103421. */
  103422. detachControl(element: Nullable<HTMLElement>): void;
  103423. /**
  103424. * Update the current camera state depending on the inputs that have been used this frame.
  103425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103426. */
  103427. checkInputs(): void;
  103428. /**
  103429. * Gets the class name of the current intput.
  103430. * @returns the class name
  103431. */
  103432. getClassName(): string;
  103433. /**
  103434. * Get the friendly name associated with the input class.
  103435. * @returns the input friendly name
  103436. */
  103437. getSimpleName(): string;
  103438. }
  103439. }
  103440. declare module BABYLON {
  103441. /**
  103442. * Manage the mouse wheel inputs to control an arc rotate camera.
  103443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103444. */
  103445. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103446. /**
  103447. * Defines the camera the input is attached to.
  103448. */
  103449. camera: ArcRotateCamera;
  103450. /**
  103451. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103452. */
  103453. wheelPrecision: number;
  103454. /**
  103455. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103456. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103457. */
  103458. wheelDeltaPercentage: number;
  103459. private _wheel;
  103460. private _observer;
  103461. private computeDeltaFromMouseWheelLegacyEvent;
  103462. /**
  103463. * Attach the input controls to a specific dom element to get the input from.
  103464. * @param element Defines the element the controls should be listened from
  103465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103466. */
  103467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103468. /**
  103469. * Detach the current controls from the specified dom element.
  103470. * @param element Defines the element to stop listening the inputs from
  103471. */
  103472. detachControl(element: Nullable<HTMLElement>): void;
  103473. /**
  103474. * Gets the class name of the current intput.
  103475. * @returns the class name
  103476. */
  103477. getClassName(): string;
  103478. /**
  103479. * Get the friendly name associated with the input class.
  103480. * @returns the input friendly name
  103481. */
  103482. getSimpleName(): string;
  103483. }
  103484. }
  103485. declare module BABYLON {
  103486. /**
  103487. * Default Inputs manager for the ArcRotateCamera.
  103488. * It groups all the default supported inputs for ease of use.
  103489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103490. */
  103491. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103492. /**
  103493. * Instantiates a new ArcRotateCameraInputsManager.
  103494. * @param camera Defines the camera the inputs belong to
  103495. */
  103496. constructor(camera: ArcRotateCamera);
  103497. /**
  103498. * Add mouse wheel input support to the input manager.
  103499. * @returns the current input manager
  103500. */
  103501. addMouseWheel(): ArcRotateCameraInputsManager;
  103502. /**
  103503. * Add pointers input support to the input manager.
  103504. * @returns the current input manager
  103505. */
  103506. addPointers(): ArcRotateCameraInputsManager;
  103507. /**
  103508. * Add keyboard input support to the input manager.
  103509. * @returns the current input manager
  103510. */
  103511. addKeyboard(): ArcRotateCameraInputsManager;
  103512. }
  103513. }
  103514. declare module BABYLON {
  103515. /**
  103516. * This represents an orbital type of camera.
  103517. *
  103518. * 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.
  103519. * 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.
  103520. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103521. */
  103522. export class ArcRotateCamera extends TargetCamera {
  103523. /**
  103524. * Defines the rotation angle of the camera along the longitudinal axis.
  103525. */
  103526. alpha: number;
  103527. /**
  103528. * Defines the rotation angle of the camera along the latitudinal axis.
  103529. */
  103530. beta: number;
  103531. /**
  103532. * Defines the radius of the camera from it s target point.
  103533. */
  103534. radius: number;
  103535. protected _target: Vector3;
  103536. protected _targetHost: Nullable<AbstractMesh>;
  103537. /**
  103538. * Defines the target point of the camera.
  103539. * The camera looks towards it form the radius distance.
  103540. */
  103541. target: Vector3;
  103542. /**
  103543. * Define the current local position of the camera in the scene
  103544. */
  103545. position: Vector3;
  103546. protected _upVector: Vector3;
  103547. protected _upToYMatrix: Matrix;
  103548. protected _YToUpMatrix: Matrix;
  103549. /**
  103550. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103551. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103552. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103553. */
  103554. upVector: Vector3;
  103555. /**
  103556. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103557. */
  103558. setMatUp(): void;
  103559. /**
  103560. * Current inertia value on the longitudinal axis.
  103561. * The bigger this number the longer it will take for the camera to stop.
  103562. */
  103563. inertialAlphaOffset: number;
  103564. /**
  103565. * Current inertia value on the latitudinal axis.
  103566. * The bigger this number the longer it will take for the camera to stop.
  103567. */
  103568. inertialBetaOffset: number;
  103569. /**
  103570. * Current inertia value on the radius axis.
  103571. * The bigger this number the longer it will take for the camera to stop.
  103572. */
  103573. inertialRadiusOffset: number;
  103574. /**
  103575. * Minimum allowed angle on the longitudinal axis.
  103576. * This can help limiting how the Camera is able to move in the scene.
  103577. */
  103578. lowerAlphaLimit: Nullable<number>;
  103579. /**
  103580. * Maximum allowed angle on the longitudinal axis.
  103581. * This can help limiting how the Camera is able to move in the scene.
  103582. */
  103583. upperAlphaLimit: Nullable<number>;
  103584. /**
  103585. * Minimum allowed angle on the latitudinal axis.
  103586. * This can help limiting how the Camera is able to move in the scene.
  103587. */
  103588. lowerBetaLimit: number;
  103589. /**
  103590. * Maximum allowed angle on the latitudinal axis.
  103591. * This can help limiting how the Camera is able to move in the scene.
  103592. */
  103593. upperBetaLimit: number;
  103594. /**
  103595. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103596. * This can help limiting how the Camera is able to move in the scene.
  103597. */
  103598. lowerRadiusLimit: Nullable<number>;
  103599. /**
  103600. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103601. * This can help limiting how the Camera is able to move in the scene.
  103602. */
  103603. upperRadiusLimit: Nullable<number>;
  103604. /**
  103605. * Defines the current inertia value used during panning of the camera along the X axis.
  103606. */
  103607. inertialPanningX: number;
  103608. /**
  103609. * Defines the current inertia value used during panning of the camera along the Y axis.
  103610. */
  103611. inertialPanningY: number;
  103612. /**
  103613. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103614. * Basically if your fingers moves away from more than this distance you will be considered
  103615. * in pinch mode.
  103616. */
  103617. pinchToPanMaxDistance: number;
  103618. /**
  103619. * Defines the maximum distance the camera can pan.
  103620. * This could help keeping the cammera always in your scene.
  103621. */
  103622. panningDistanceLimit: Nullable<number>;
  103623. /**
  103624. * Defines the target of the camera before paning.
  103625. */
  103626. panningOriginTarget: Vector3;
  103627. /**
  103628. * Defines the value of the inertia used during panning.
  103629. * 0 would mean stop inertia and one would mean no decelleration at all.
  103630. */
  103631. panningInertia: number;
  103632. /**
  103633. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103634. */
  103635. angularSensibilityX: number;
  103636. /**
  103637. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103638. */
  103639. angularSensibilityY: number;
  103640. /**
  103641. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103642. */
  103643. pinchPrecision: number;
  103644. /**
  103645. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103646. * It will be used instead of pinchDeltaPrecision if different from 0.
  103647. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103648. */
  103649. pinchDeltaPercentage: number;
  103650. /**
  103651. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103652. */
  103653. panningSensibility: number;
  103654. /**
  103655. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103656. */
  103657. keysUp: number[];
  103658. /**
  103659. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103660. */
  103661. keysDown: number[];
  103662. /**
  103663. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103664. */
  103665. keysLeft: number[];
  103666. /**
  103667. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103668. */
  103669. keysRight: number[];
  103670. /**
  103671. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103672. */
  103673. wheelPrecision: number;
  103674. /**
  103675. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103676. * It will be used instead of pinchDeltaPrecision if different from 0.
  103677. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103678. */
  103679. wheelDeltaPercentage: number;
  103680. /**
  103681. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103682. */
  103683. zoomOnFactor: number;
  103684. /**
  103685. * Defines a screen offset for the camera position.
  103686. */
  103687. targetScreenOffset: Vector2;
  103688. /**
  103689. * Allows the camera to be completely reversed.
  103690. * If false the camera can not arrive upside down.
  103691. */
  103692. allowUpsideDown: boolean;
  103693. /**
  103694. * Define if double tap/click is used to restore the previously saved state of the camera.
  103695. */
  103696. useInputToRestoreState: boolean;
  103697. /** @hidden */
  103698. _viewMatrix: Matrix;
  103699. /** @hidden */
  103700. _useCtrlForPanning: boolean;
  103701. /** @hidden */
  103702. _panningMouseButton: number;
  103703. /**
  103704. * Defines the input associated to the camera.
  103705. */
  103706. inputs: ArcRotateCameraInputsManager;
  103707. /** @hidden */
  103708. _reset: () => void;
  103709. /**
  103710. * Defines the allowed panning axis.
  103711. */
  103712. panningAxis: Vector3;
  103713. protected _localDirection: Vector3;
  103714. protected _transformedDirection: Vector3;
  103715. private _bouncingBehavior;
  103716. /**
  103717. * Gets the bouncing behavior of the camera if it has been enabled.
  103718. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103719. */
  103720. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103721. /**
  103722. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103723. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103724. */
  103725. useBouncingBehavior: boolean;
  103726. private _framingBehavior;
  103727. /**
  103728. * Gets the framing behavior of the camera if it has been enabled.
  103729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103730. */
  103731. readonly framingBehavior: Nullable<FramingBehavior>;
  103732. /**
  103733. * Defines if the framing behavior of the camera is enabled on the camera.
  103734. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103735. */
  103736. useFramingBehavior: boolean;
  103737. private _autoRotationBehavior;
  103738. /**
  103739. * Gets the auto rotation behavior of the camera if it has been enabled.
  103740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103741. */
  103742. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103743. /**
  103744. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103745. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103746. */
  103747. useAutoRotationBehavior: boolean;
  103748. /**
  103749. * Observable triggered when the mesh target has been changed on the camera.
  103750. */
  103751. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103752. /**
  103753. * Event raised when the camera is colliding with a mesh.
  103754. */
  103755. onCollide: (collidedMesh: AbstractMesh) => void;
  103756. /**
  103757. * Defines whether the camera should check collision with the objects oh the scene.
  103758. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103759. */
  103760. checkCollisions: boolean;
  103761. /**
  103762. * Defines the collision radius of the camera.
  103763. * This simulates a sphere around the camera.
  103764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103765. */
  103766. collisionRadius: Vector3;
  103767. protected _collider: Collider;
  103768. protected _previousPosition: Vector3;
  103769. protected _collisionVelocity: Vector3;
  103770. protected _newPosition: Vector3;
  103771. protected _previousAlpha: number;
  103772. protected _previousBeta: number;
  103773. protected _previousRadius: number;
  103774. protected _collisionTriggered: boolean;
  103775. protected _targetBoundingCenter: Nullable<Vector3>;
  103776. private _computationVector;
  103777. /**
  103778. * Instantiates a new ArcRotateCamera in a given scene
  103779. * @param name Defines the name of the camera
  103780. * @param alpha Defines the camera rotation along the logitudinal axis
  103781. * @param beta Defines the camera rotation along the latitudinal axis
  103782. * @param radius Defines the camera distance from its target
  103783. * @param target Defines the camera target
  103784. * @param scene Defines the scene the camera belongs to
  103785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103786. */
  103787. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103788. /** @hidden */
  103789. _initCache(): void;
  103790. /** @hidden */
  103791. _updateCache(ignoreParentClass?: boolean): void;
  103792. protected _getTargetPosition(): Vector3;
  103793. private _storedAlpha;
  103794. private _storedBeta;
  103795. private _storedRadius;
  103796. private _storedTarget;
  103797. private _storedTargetScreenOffset;
  103798. /**
  103799. * Stores the current state of the camera (alpha, beta, radius and target)
  103800. * @returns the camera itself
  103801. */
  103802. storeState(): Camera;
  103803. /**
  103804. * @hidden
  103805. * Restored camera state. You must call storeState() first
  103806. */
  103807. _restoreStateValues(): boolean;
  103808. /** @hidden */
  103809. _isSynchronizedViewMatrix(): boolean;
  103810. /**
  103811. * Attached controls to the current camera.
  103812. * @param element Defines the element the controls should be listened from
  103813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103814. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103815. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103816. */
  103817. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103818. /**
  103819. * Detach the current controls from the camera.
  103820. * The camera will stop reacting to inputs.
  103821. * @param element Defines the element to stop listening the inputs from
  103822. */
  103823. detachControl(element: HTMLElement): void;
  103824. /** @hidden */
  103825. _checkInputs(): void;
  103826. protected _checkLimits(): void;
  103827. /**
  103828. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103829. */
  103830. rebuildAnglesAndRadius(): void;
  103831. /**
  103832. * Use a position to define the current camera related information like alpha, beta and radius
  103833. * @param position Defines the position to set the camera at
  103834. */
  103835. setPosition(position: Vector3): void;
  103836. /**
  103837. * Defines the target the camera should look at.
  103838. * This will automatically adapt alpha beta and radius to fit within the new target.
  103839. * @param target Defines the new target as a Vector or a mesh
  103840. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103841. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103842. */
  103843. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103844. /** @hidden */
  103845. _getViewMatrix(): Matrix;
  103846. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103847. /**
  103848. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103849. * @param meshes Defines the mesh to zoom on
  103850. * @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)
  103851. */
  103852. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103853. /**
  103854. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103855. * The target will be changed but the radius
  103856. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103857. * @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)
  103858. */
  103859. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103860. min: Vector3;
  103861. max: Vector3;
  103862. distance: number;
  103863. }, doNotUpdateMaxZ?: boolean): void;
  103864. /**
  103865. * @override
  103866. * Override Camera.createRigCamera
  103867. */
  103868. createRigCamera(name: string, cameraIndex: number): Camera;
  103869. /**
  103870. * @hidden
  103871. * @override
  103872. * Override Camera._updateRigCameras
  103873. */
  103874. _updateRigCameras(): void;
  103875. /**
  103876. * Destroy the camera and release the current resources hold by it.
  103877. */
  103878. dispose(): void;
  103879. /**
  103880. * Gets the current object class name.
  103881. * @return the class name
  103882. */
  103883. getClassName(): string;
  103884. }
  103885. }
  103886. declare module BABYLON {
  103887. /**
  103888. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103890. */
  103891. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103892. /**
  103893. * Gets the name of the behavior.
  103894. */
  103895. readonly name: string;
  103896. private _zoomStopsAnimation;
  103897. private _idleRotationSpeed;
  103898. private _idleRotationWaitTime;
  103899. private _idleRotationSpinupTime;
  103900. /**
  103901. * Sets the flag that indicates if user zooming should stop animation.
  103902. */
  103903. /**
  103904. * Gets the flag that indicates if user zooming should stop animation.
  103905. */
  103906. zoomStopsAnimation: boolean;
  103907. /**
  103908. * Sets the default speed at which the camera rotates around the model.
  103909. */
  103910. /**
  103911. * Gets the default speed at which the camera rotates around the model.
  103912. */
  103913. idleRotationSpeed: number;
  103914. /**
  103915. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103916. */
  103917. /**
  103918. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103919. */
  103920. idleRotationWaitTime: number;
  103921. /**
  103922. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103923. */
  103924. /**
  103925. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103926. */
  103927. idleRotationSpinupTime: number;
  103928. /**
  103929. * Gets a value indicating if the camera is currently rotating because of this behavior
  103930. */
  103931. readonly rotationInProgress: boolean;
  103932. private _onPrePointerObservableObserver;
  103933. private _onAfterCheckInputsObserver;
  103934. private _attachedCamera;
  103935. private _isPointerDown;
  103936. private _lastFrameTime;
  103937. private _lastInteractionTime;
  103938. private _cameraRotationSpeed;
  103939. /**
  103940. * Initializes the behavior.
  103941. */
  103942. init(): void;
  103943. /**
  103944. * Attaches the behavior to its arc rotate camera.
  103945. * @param camera Defines the camera to attach the behavior to
  103946. */
  103947. attach(camera: ArcRotateCamera): void;
  103948. /**
  103949. * Detaches the behavior from its current arc rotate camera.
  103950. */
  103951. detach(): void;
  103952. /**
  103953. * Returns true if user is scrolling.
  103954. * @return true if user is scrolling.
  103955. */
  103956. private _userIsZooming;
  103957. private _lastFrameRadius;
  103958. private _shouldAnimationStopForInteraction;
  103959. /**
  103960. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103961. */
  103962. private _applyUserInteraction;
  103963. private _userIsMoving;
  103964. }
  103965. }
  103966. declare module BABYLON {
  103967. /**
  103968. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103969. */
  103970. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103971. private ui;
  103972. /**
  103973. * The name of the behavior
  103974. */
  103975. name: string;
  103976. /**
  103977. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103978. */
  103979. distanceAwayFromFace: number;
  103980. /**
  103981. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103982. */
  103983. distanceAwayFromBottomOfFace: number;
  103984. private _faceVectors;
  103985. private _target;
  103986. private _scene;
  103987. private _onRenderObserver;
  103988. private _tmpMatrix;
  103989. private _tmpVector;
  103990. /**
  103991. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103992. * @param ui The transform node that should be attched to the mesh
  103993. */
  103994. constructor(ui: TransformNode);
  103995. /**
  103996. * Initializes the behavior
  103997. */
  103998. init(): void;
  103999. private _closestFace;
  104000. private _zeroVector;
  104001. private _lookAtTmpMatrix;
  104002. private _lookAtToRef;
  104003. /**
  104004. * Attaches the AttachToBoxBehavior to the passed in mesh
  104005. * @param target The mesh that the specified node will be attached to
  104006. */
  104007. attach(target: Mesh): void;
  104008. /**
  104009. * Detaches the behavior from the mesh
  104010. */
  104011. detach(): void;
  104012. }
  104013. }
  104014. declare module BABYLON {
  104015. /**
  104016. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104017. */
  104018. export class FadeInOutBehavior implements Behavior<Mesh> {
  104019. /**
  104020. * Time in milliseconds to delay before fading in (Default: 0)
  104021. */
  104022. delay: number;
  104023. /**
  104024. * Time in milliseconds for the mesh to fade in (Default: 300)
  104025. */
  104026. fadeInTime: number;
  104027. private _millisecondsPerFrame;
  104028. private _hovered;
  104029. private _hoverValue;
  104030. private _ownerNode;
  104031. /**
  104032. * Instatiates the FadeInOutBehavior
  104033. */
  104034. constructor();
  104035. /**
  104036. * The name of the behavior
  104037. */
  104038. readonly name: string;
  104039. /**
  104040. * Initializes the behavior
  104041. */
  104042. init(): void;
  104043. /**
  104044. * Attaches the fade behavior on the passed in mesh
  104045. * @param ownerNode The mesh that will be faded in/out once attached
  104046. */
  104047. attach(ownerNode: Mesh): void;
  104048. /**
  104049. * Detaches the behavior from the mesh
  104050. */
  104051. detach(): void;
  104052. /**
  104053. * Triggers the mesh to begin fading in or out
  104054. * @param value if the object should fade in or out (true to fade in)
  104055. */
  104056. fadeIn(value: boolean): void;
  104057. private _update;
  104058. private _setAllVisibility;
  104059. }
  104060. }
  104061. declare module BABYLON {
  104062. /**
  104063. * Class containing a set of static utilities functions for managing Pivots
  104064. * @hidden
  104065. */
  104066. export class PivotTools {
  104067. private static _PivotCached;
  104068. private static _OldPivotPoint;
  104069. private static _PivotTranslation;
  104070. private static _PivotTmpVector;
  104071. /** @hidden */
  104072. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104073. /** @hidden */
  104074. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104075. }
  104076. }
  104077. declare module BABYLON {
  104078. /**
  104079. * Class containing static functions to help procedurally build meshes
  104080. */
  104081. export class PlaneBuilder {
  104082. /**
  104083. * Creates a plane mesh
  104084. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104085. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104086. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104090. * @param name defines the name of the mesh
  104091. * @param options defines the options used to create the mesh
  104092. * @param scene defines the hosting scene
  104093. * @returns the plane mesh
  104094. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104095. */
  104096. static CreatePlane(name: string, options: {
  104097. size?: number;
  104098. width?: number;
  104099. height?: number;
  104100. sideOrientation?: number;
  104101. frontUVs?: Vector4;
  104102. backUVs?: Vector4;
  104103. updatable?: boolean;
  104104. sourcePlane?: Plane;
  104105. }, scene?: Nullable<Scene>): Mesh;
  104106. }
  104107. }
  104108. declare module BABYLON {
  104109. /**
  104110. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104111. */
  104112. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104113. private static _AnyMouseID;
  104114. /**
  104115. * Abstract mesh the behavior is set on
  104116. */
  104117. attachedNode: AbstractMesh;
  104118. private _dragPlane;
  104119. private _scene;
  104120. private _pointerObserver;
  104121. private _beforeRenderObserver;
  104122. private static _planeScene;
  104123. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104124. /**
  104125. * 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)
  104126. */
  104127. maxDragAngle: number;
  104128. /**
  104129. * @hidden
  104130. */
  104131. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104132. /**
  104133. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104134. */
  104135. currentDraggingPointerID: number;
  104136. /**
  104137. * The last position where the pointer hit the drag plane in world space
  104138. */
  104139. lastDragPosition: Vector3;
  104140. /**
  104141. * If the behavior is currently in a dragging state
  104142. */
  104143. dragging: boolean;
  104144. /**
  104145. * 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)
  104146. */
  104147. dragDeltaRatio: number;
  104148. /**
  104149. * If the drag plane orientation should be updated during the dragging (Default: true)
  104150. */
  104151. updateDragPlane: boolean;
  104152. private _debugMode;
  104153. private _moving;
  104154. /**
  104155. * Fires each time the attached mesh is dragged with the pointer
  104156. * * delta between last drag position and current drag position in world space
  104157. * * dragDistance along the drag axis
  104158. * * dragPlaneNormal normal of the current drag plane used during the drag
  104159. * * dragPlanePoint in world space where the drag intersects the drag plane
  104160. */
  104161. onDragObservable: Observable<{
  104162. delta: Vector3;
  104163. dragPlanePoint: Vector3;
  104164. dragPlaneNormal: Vector3;
  104165. dragDistance: number;
  104166. pointerId: number;
  104167. }>;
  104168. /**
  104169. * Fires each time a drag begins (eg. mouse down on mesh)
  104170. */
  104171. onDragStartObservable: Observable<{
  104172. dragPlanePoint: Vector3;
  104173. pointerId: number;
  104174. }>;
  104175. /**
  104176. * Fires each time a drag ends (eg. mouse release after drag)
  104177. */
  104178. onDragEndObservable: Observable<{
  104179. dragPlanePoint: Vector3;
  104180. pointerId: number;
  104181. }>;
  104182. /**
  104183. * If the attached mesh should be moved when dragged
  104184. */
  104185. moveAttached: boolean;
  104186. /**
  104187. * If the drag behavior will react to drag events (Default: true)
  104188. */
  104189. enabled: boolean;
  104190. /**
  104191. * If pointer events should start and release the drag (Default: true)
  104192. */
  104193. startAndReleaseDragOnPointerEvents: boolean;
  104194. /**
  104195. * If camera controls should be detached during the drag
  104196. */
  104197. detachCameraControls: boolean;
  104198. /**
  104199. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104200. */
  104201. useObjectOrienationForDragging: boolean;
  104202. private _options;
  104203. /**
  104204. * Creates a pointer drag behavior that can be attached to a mesh
  104205. * @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)
  104206. */
  104207. constructor(options?: {
  104208. dragAxis?: Vector3;
  104209. dragPlaneNormal?: Vector3;
  104210. });
  104211. /**
  104212. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104213. */
  104214. validateDrag: (targetPosition: Vector3) => boolean;
  104215. /**
  104216. * The name of the behavior
  104217. */
  104218. readonly name: string;
  104219. /**
  104220. * Initializes the behavior
  104221. */
  104222. init(): void;
  104223. private _tmpVector;
  104224. private _alternatePickedPoint;
  104225. private _worldDragAxis;
  104226. private _targetPosition;
  104227. private _attachedElement;
  104228. /**
  104229. * Attaches the drag behavior the passed in mesh
  104230. * @param ownerNode The mesh that will be dragged around once attached
  104231. * @param predicate Predicate to use for pick filtering
  104232. */
  104233. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104234. /**
  104235. * Force relase the drag action by code.
  104236. */
  104237. releaseDrag(): void;
  104238. private _startDragRay;
  104239. private _lastPointerRay;
  104240. /**
  104241. * Simulates the start of a pointer drag event on the behavior
  104242. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104243. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104244. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104245. */
  104246. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104247. private _startDrag;
  104248. private _dragDelta;
  104249. private _moveDrag;
  104250. private _pickWithRayOnDragPlane;
  104251. private _pointA;
  104252. private _pointB;
  104253. private _pointC;
  104254. private _lineA;
  104255. private _lineB;
  104256. private _localAxis;
  104257. private _lookAt;
  104258. private _updateDragPlanePosition;
  104259. /**
  104260. * Detaches the behavior from the mesh
  104261. */
  104262. detach(): void;
  104263. }
  104264. }
  104265. declare module BABYLON {
  104266. /**
  104267. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104268. */
  104269. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104270. private _dragBehaviorA;
  104271. private _dragBehaviorB;
  104272. private _startDistance;
  104273. private _initialScale;
  104274. private _targetScale;
  104275. private _ownerNode;
  104276. private _sceneRenderObserver;
  104277. /**
  104278. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104279. */
  104280. constructor();
  104281. /**
  104282. * The name of the behavior
  104283. */
  104284. readonly name: string;
  104285. /**
  104286. * Initializes the behavior
  104287. */
  104288. init(): void;
  104289. private _getCurrentDistance;
  104290. /**
  104291. * Attaches the scale behavior the passed in mesh
  104292. * @param ownerNode The mesh that will be scaled around once attached
  104293. */
  104294. attach(ownerNode: Mesh): void;
  104295. /**
  104296. * Detaches the behavior from the mesh
  104297. */
  104298. detach(): void;
  104299. }
  104300. }
  104301. declare module BABYLON {
  104302. /**
  104303. * 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
  104304. */
  104305. export class SixDofDragBehavior implements Behavior<Mesh> {
  104306. private static _virtualScene;
  104307. private _ownerNode;
  104308. private _sceneRenderObserver;
  104309. private _scene;
  104310. private _targetPosition;
  104311. private _virtualOriginMesh;
  104312. private _virtualDragMesh;
  104313. private _pointerObserver;
  104314. private _moving;
  104315. private _startingOrientation;
  104316. /**
  104317. * 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)
  104318. */
  104319. private zDragFactor;
  104320. /**
  104321. * If the object should rotate to face the drag origin
  104322. */
  104323. rotateDraggedObject: boolean;
  104324. /**
  104325. * If the behavior is currently in a dragging state
  104326. */
  104327. dragging: boolean;
  104328. /**
  104329. * 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)
  104330. */
  104331. dragDeltaRatio: number;
  104332. /**
  104333. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104334. */
  104335. currentDraggingPointerID: number;
  104336. /**
  104337. * If camera controls should be detached during the drag
  104338. */
  104339. detachCameraControls: boolean;
  104340. /**
  104341. * Fires each time a drag starts
  104342. */
  104343. onDragStartObservable: Observable<{}>;
  104344. /**
  104345. * Fires each time a drag ends (eg. mouse release after drag)
  104346. */
  104347. onDragEndObservable: Observable<{}>;
  104348. /**
  104349. * 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
  104350. */
  104351. constructor();
  104352. /**
  104353. * The name of the behavior
  104354. */
  104355. readonly name: string;
  104356. /**
  104357. * Initializes the behavior
  104358. */
  104359. init(): void;
  104360. /**
  104361. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104362. */
  104363. private readonly _pointerCamera;
  104364. /**
  104365. * Attaches the scale behavior the passed in mesh
  104366. * @param ownerNode The mesh that will be scaled around once attached
  104367. */
  104368. attach(ownerNode: Mesh): void;
  104369. /**
  104370. * Detaches the behavior from the mesh
  104371. */
  104372. detach(): void;
  104373. }
  104374. }
  104375. declare module BABYLON {
  104376. /**
  104377. * Class used to apply inverse kinematics to bones
  104378. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104379. */
  104380. export class BoneIKController {
  104381. private static _tmpVecs;
  104382. private static _tmpQuat;
  104383. private static _tmpMats;
  104384. /**
  104385. * Gets or sets the target mesh
  104386. */
  104387. targetMesh: AbstractMesh;
  104388. /** Gets or sets the mesh used as pole */
  104389. poleTargetMesh: AbstractMesh;
  104390. /**
  104391. * Gets or sets the bone used as pole
  104392. */
  104393. poleTargetBone: Nullable<Bone>;
  104394. /**
  104395. * Gets or sets the target position
  104396. */
  104397. targetPosition: Vector3;
  104398. /**
  104399. * Gets or sets the pole target position
  104400. */
  104401. poleTargetPosition: Vector3;
  104402. /**
  104403. * Gets or sets the pole target local offset
  104404. */
  104405. poleTargetLocalOffset: Vector3;
  104406. /**
  104407. * Gets or sets the pole angle
  104408. */
  104409. poleAngle: number;
  104410. /**
  104411. * Gets or sets the mesh associated with the controller
  104412. */
  104413. mesh: AbstractMesh;
  104414. /**
  104415. * 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)
  104416. */
  104417. slerpAmount: number;
  104418. private _bone1Quat;
  104419. private _bone1Mat;
  104420. private _bone2Ang;
  104421. private _bone1;
  104422. private _bone2;
  104423. private _bone1Length;
  104424. private _bone2Length;
  104425. private _maxAngle;
  104426. private _maxReach;
  104427. private _rightHandedSystem;
  104428. private _bendAxis;
  104429. private _slerping;
  104430. private _adjustRoll;
  104431. /**
  104432. * Gets or sets maximum allowed angle
  104433. */
  104434. maxAngle: number;
  104435. /**
  104436. * Creates a new BoneIKController
  104437. * @param mesh defines the mesh to control
  104438. * @param bone defines the bone to control
  104439. * @param options defines options to set up the controller
  104440. */
  104441. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104442. targetMesh?: AbstractMesh;
  104443. poleTargetMesh?: AbstractMesh;
  104444. poleTargetBone?: Bone;
  104445. poleTargetLocalOffset?: Vector3;
  104446. poleAngle?: number;
  104447. bendAxis?: Vector3;
  104448. maxAngle?: number;
  104449. slerpAmount?: number;
  104450. });
  104451. private _setMaxAngle;
  104452. /**
  104453. * Force the controller to update the bones
  104454. */
  104455. update(): void;
  104456. }
  104457. }
  104458. declare module BABYLON {
  104459. /**
  104460. * Class used to make a bone look toward a point in space
  104461. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104462. */
  104463. export class BoneLookController {
  104464. private static _tmpVecs;
  104465. private static _tmpQuat;
  104466. private static _tmpMats;
  104467. /**
  104468. * The target Vector3 that the bone will look at
  104469. */
  104470. target: Vector3;
  104471. /**
  104472. * The mesh that the bone is attached to
  104473. */
  104474. mesh: AbstractMesh;
  104475. /**
  104476. * The bone that will be looking to the target
  104477. */
  104478. bone: Bone;
  104479. /**
  104480. * The up axis of the coordinate system that is used when the bone is rotated
  104481. */
  104482. upAxis: Vector3;
  104483. /**
  104484. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104485. */
  104486. upAxisSpace: Space;
  104487. /**
  104488. * Used to make an adjustment to the yaw of the bone
  104489. */
  104490. adjustYaw: number;
  104491. /**
  104492. * Used to make an adjustment to the pitch of the bone
  104493. */
  104494. adjustPitch: number;
  104495. /**
  104496. * Used to make an adjustment to the roll of the bone
  104497. */
  104498. adjustRoll: number;
  104499. /**
  104500. * 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)
  104501. */
  104502. slerpAmount: number;
  104503. private _minYaw;
  104504. private _maxYaw;
  104505. private _minPitch;
  104506. private _maxPitch;
  104507. private _minYawSin;
  104508. private _minYawCos;
  104509. private _maxYawSin;
  104510. private _maxYawCos;
  104511. private _midYawConstraint;
  104512. private _minPitchTan;
  104513. private _maxPitchTan;
  104514. private _boneQuat;
  104515. private _slerping;
  104516. private _transformYawPitch;
  104517. private _transformYawPitchInv;
  104518. private _firstFrameSkipped;
  104519. private _yawRange;
  104520. private _fowardAxis;
  104521. /**
  104522. * Gets or sets the minimum yaw angle that the bone can look to
  104523. */
  104524. minYaw: number;
  104525. /**
  104526. * Gets or sets the maximum yaw angle that the bone can look to
  104527. */
  104528. maxYaw: number;
  104529. /**
  104530. * Gets or sets the minimum pitch angle that the bone can look to
  104531. */
  104532. minPitch: number;
  104533. /**
  104534. * Gets or sets the maximum pitch angle that the bone can look to
  104535. */
  104536. maxPitch: number;
  104537. /**
  104538. * Create a BoneLookController
  104539. * @param mesh the mesh that the bone belongs to
  104540. * @param bone the bone that will be looking to the target
  104541. * @param target the target Vector3 to look at
  104542. * @param options optional settings:
  104543. * * maxYaw: the maximum angle the bone will yaw to
  104544. * * minYaw: the minimum angle the bone will yaw to
  104545. * * maxPitch: the maximum angle the bone will pitch to
  104546. * * minPitch: the minimum angle the bone will yaw to
  104547. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104548. * * upAxis: the up axis of the coordinate system
  104549. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104550. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104551. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104552. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104553. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104554. * * adjustRoll: used to make an adjustment to the roll of the bone
  104555. **/
  104556. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104557. maxYaw?: number;
  104558. minYaw?: number;
  104559. maxPitch?: number;
  104560. minPitch?: number;
  104561. slerpAmount?: number;
  104562. upAxis?: Vector3;
  104563. upAxisSpace?: Space;
  104564. yawAxis?: Vector3;
  104565. pitchAxis?: Vector3;
  104566. adjustYaw?: number;
  104567. adjustPitch?: number;
  104568. adjustRoll?: number;
  104569. });
  104570. /**
  104571. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104572. */
  104573. update(): void;
  104574. private _getAngleDiff;
  104575. private _getAngleBetween;
  104576. private _isAngleBetween;
  104577. }
  104578. }
  104579. declare module BABYLON {
  104580. /**
  104581. * Manage the gamepad inputs to control an arc rotate camera.
  104582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104583. */
  104584. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104585. /**
  104586. * Defines the camera the input is attached to.
  104587. */
  104588. camera: ArcRotateCamera;
  104589. /**
  104590. * Defines the gamepad the input is gathering event from.
  104591. */
  104592. gamepad: Nullable<Gamepad>;
  104593. /**
  104594. * Defines the gamepad rotation sensiblity.
  104595. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104596. */
  104597. gamepadRotationSensibility: number;
  104598. /**
  104599. * Defines the gamepad move sensiblity.
  104600. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104601. */
  104602. gamepadMoveSensibility: number;
  104603. private _yAxisScale;
  104604. /**
  104605. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104606. */
  104607. invertYAxis: boolean;
  104608. private _onGamepadConnectedObserver;
  104609. private _onGamepadDisconnectedObserver;
  104610. /**
  104611. * Attach the input controls to a specific dom element to get the input from.
  104612. * @param element Defines the element the controls should be listened from
  104613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104614. */
  104615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104616. /**
  104617. * Detach the current controls from the specified dom element.
  104618. * @param element Defines the element to stop listening the inputs from
  104619. */
  104620. detachControl(element: Nullable<HTMLElement>): void;
  104621. /**
  104622. * Update the current camera state depending on the inputs that have been used this frame.
  104623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104624. */
  104625. checkInputs(): void;
  104626. /**
  104627. * Gets the class name of the current intput.
  104628. * @returns the class name
  104629. */
  104630. getClassName(): string;
  104631. /**
  104632. * Get the friendly name associated with the input class.
  104633. * @returns the input friendly name
  104634. */
  104635. getSimpleName(): string;
  104636. }
  104637. }
  104638. declare module BABYLON {
  104639. interface ArcRotateCameraInputsManager {
  104640. /**
  104641. * Add orientation input support to the input manager.
  104642. * @returns the current input manager
  104643. */
  104644. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104645. }
  104646. /**
  104647. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104649. */
  104650. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104651. /**
  104652. * Defines the camera the input is attached to.
  104653. */
  104654. camera: ArcRotateCamera;
  104655. /**
  104656. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104657. */
  104658. alphaCorrection: number;
  104659. /**
  104660. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104661. */
  104662. gammaCorrection: number;
  104663. private _alpha;
  104664. private _gamma;
  104665. private _dirty;
  104666. private _deviceOrientationHandler;
  104667. /**
  104668. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104669. */
  104670. constructor();
  104671. /**
  104672. * Attach the input controls to a specific dom element to get the input from.
  104673. * @param element Defines the element the controls should be listened from
  104674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104675. */
  104676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104677. /** @hidden */
  104678. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104679. /**
  104680. * Update the current camera state depending on the inputs that have been used this frame.
  104681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104682. */
  104683. checkInputs(): void;
  104684. /**
  104685. * Detach the current controls from the specified dom element.
  104686. * @param element Defines the element to stop listening the inputs from
  104687. */
  104688. detachControl(element: Nullable<HTMLElement>): void;
  104689. /**
  104690. * Gets the class name of the current intput.
  104691. * @returns the class name
  104692. */
  104693. getClassName(): string;
  104694. /**
  104695. * Get the friendly name associated with the input class.
  104696. * @returns the input friendly name
  104697. */
  104698. getSimpleName(): string;
  104699. }
  104700. }
  104701. declare module BABYLON {
  104702. /**
  104703. * Listen to mouse events to control the camera.
  104704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104705. */
  104706. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104707. /**
  104708. * Defines the camera the input is attached to.
  104709. */
  104710. camera: FlyCamera;
  104711. /**
  104712. * Defines if touch is enabled. (Default is true.)
  104713. */
  104714. touchEnabled: boolean;
  104715. /**
  104716. * Defines the buttons associated with the input to handle camera rotation.
  104717. */
  104718. buttons: number[];
  104719. /**
  104720. * Assign buttons for Yaw control.
  104721. */
  104722. buttonsYaw: number[];
  104723. /**
  104724. * Assign buttons for Pitch control.
  104725. */
  104726. buttonsPitch: number[];
  104727. /**
  104728. * Assign buttons for Roll control.
  104729. */
  104730. buttonsRoll: number[];
  104731. /**
  104732. * Detect if any button is being pressed while mouse is moved.
  104733. * -1 = Mouse locked.
  104734. * 0 = Left button.
  104735. * 1 = Middle Button.
  104736. * 2 = Right Button.
  104737. */
  104738. activeButton: number;
  104739. /**
  104740. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104741. * Higher values reduce its sensitivity.
  104742. */
  104743. angularSensibility: number;
  104744. private _mousemoveCallback;
  104745. private _observer;
  104746. private _rollObserver;
  104747. private previousPosition;
  104748. private noPreventDefault;
  104749. private element;
  104750. /**
  104751. * Listen to mouse events to control the camera.
  104752. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104754. */
  104755. constructor(touchEnabled?: boolean);
  104756. /**
  104757. * Attach the mouse control to the HTML DOM element.
  104758. * @param element Defines the element that listens to the input events.
  104759. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104760. */
  104761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104762. /**
  104763. * Detach the current controls from the specified dom element.
  104764. * @param element Defines the element to stop listening the inputs from
  104765. */
  104766. detachControl(element: Nullable<HTMLElement>): void;
  104767. /**
  104768. * Gets the class name of the current input.
  104769. * @returns the class name.
  104770. */
  104771. getClassName(): string;
  104772. /**
  104773. * Get the friendly name associated with the input class.
  104774. * @returns the input's friendly name.
  104775. */
  104776. getSimpleName(): string;
  104777. private _pointerInput;
  104778. private _onMouseMove;
  104779. /**
  104780. * Rotate camera by mouse offset.
  104781. */
  104782. private rotateCamera;
  104783. }
  104784. }
  104785. declare module BABYLON {
  104786. /**
  104787. * Default Inputs manager for the FlyCamera.
  104788. * It groups all the default supported inputs for ease of use.
  104789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104790. */
  104791. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104792. /**
  104793. * Instantiates a new FlyCameraInputsManager.
  104794. * @param camera Defines the camera the inputs belong to.
  104795. */
  104796. constructor(camera: FlyCamera);
  104797. /**
  104798. * Add keyboard input support to the input manager.
  104799. * @returns the new FlyCameraKeyboardMoveInput().
  104800. */
  104801. addKeyboard(): FlyCameraInputsManager;
  104802. /**
  104803. * Add mouse input support to the input manager.
  104804. * @param touchEnabled Enable touch screen support.
  104805. * @returns the new FlyCameraMouseInput().
  104806. */
  104807. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104808. }
  104809. }
  104810. declare module BABYLON {
  104811. /**
  104812. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104813. * such as in a 3D Space Shooter or a Flight Simulator.
  104814. */
  104815. export class FlyCamera extends TargetCamera {
  104816. /**
  104817. * Define the collision ellipsoid of the camera.
  104818. * This is helpful for simulating a camera body, like a player's body.
  104819. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104820. */
  104821. ellipsoid: Vector3;
  104822. /**
  104823. * Define an offset for the position of the ellipsoid around the camera.
  104824. * This can be helpful if the camera is attached away from the player's body center,
  104825. * such as at its head.
  104826. */
  104827. ellipsoidOffset: Vector3;
  104828. /**
  104829. * Enable or disable collisions of the camera with the rest of the scene objects.
  104830. */
  104831. checkCollisions: boolean;
  104832. /**
  104833. * Enable or disable gravity on the camera.
  104834. */
  104835. applyGravity: boolean;
  104836. /**
  104837. * Define the current direction the camera is moving to.
  104838. */
  104839. cameraDirection: Vector3;
  104840. /**
  104841. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104842. * This overrides and empties cameraRotation.
  104843. */
  104844. rotationQuaternion: Quaternion;
  104845. /**
  104846. * Track Roll to maintain the wanted Rolling when looking around.
  104847. */
  104848. _trackRoll: number;
  104849. /**
  104850. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104851. */
  104852. rollCorrect: number;
  104853. /**
  104854. * Mimic a banked turn, Rolling the camera when Yawing.
  104855. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104856. */
  104857. bankedTurn: boolean;
  104858. /**
  104859. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104860. */
  104861. bankedTurnLimit: number;
  104862. /**
  104863. * Value of 0 disables the banked Roll.
  104864. * Value of 1 is equal to the Yaw angle in radians.
  104865. */
  104866. bankedTurnMultiplier: number;
  104867. /**
  104868. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104869. */
  104870. inputs: FlyCameraInputsManager;
  104871. /**
  104872. * Gets the input sensibility for mouse input.
  104873. * Higher values reduce sensitivity.
  104874. */
  104875. /**
  104876. * Sets the input sensibility for a mouse input.
  104877. * Higher values reduce sensitivity.
  104878. */
  104879. angularSensibility: number;
  104880. /**
  104881. * Get the keys for camera movement forward.
  104882. */
  104883. /**
  104884. * Set the keys for camera movement forward.
  104885. */
  104886. keysForward: number[];
  104887. /**
  104888. * Get the keys for camera movement backward.
  104889. */
  104890. keysBackward: number[];
  104891. /**
  104892. * Get the keys for camera movement up.
  104893. */
  104894. /**
  104895. * Set the keys for camera movement up.
  104896. */
  104897. keysUp: number[];
  104898. /**
  104899. * Get the keys for camera movement down.
  104900. */
  104901. /**
  104902. * Set the keys for camera movement down.
  104903. */
  104904. keysDown: number[];
  104905. /**
  104906. * Get the keys for camera movement left.
  104907. */
  104908. /**
  104909. * Set the keys for camera movement left.
  104910. */
  104911. keysLeft: number[];
  104912. /**
  104913. * Set the keys for camera movement right.
  104914. */
  104915. /**
  104916. * Set the keys for camera movement right.
  104917. */
  104918. keysRight: number[];
  104919. /**
  104920. * Event raised when the camera collides with a mesh in the scene.
  104921. */
  104922. onCollide: (collidedMesh: AbstractMesh) => void;
  104923. private _collider;
  104924. private _needMoveForGravity;
  104925. private _oldPosition;
  104926. private _diffPosition;
  104927. private _newPosition;
  104928. /** @hidden */
  104929. _localDirection: Vector3;
  104930. /** @hidden */
  104931. _transformedDirection: Vector3;
  104932. /**
  104933. * Instantiates a FlyCamera.
  104934. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104935. * such as in a 3D Space Shooter or a Flight Simulator.
  104936. * @param name Define the name of the camera in the scene.
  104937. * @param position Define the starting position of the camera in the scene.
  104938. * @param scene Define the scene the camera belongs to.
  104939. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104940. */
  104941. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104942. /**
  104943. * Attach a control to the HTML DOM element.
  104944. * @param element Defines the element that listens to the input events.
  104945. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104946. */
  104947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104948. /**
  104949. * Detach a control from the HTML DOM element.
  104950. * The camera will stop reacting to that input.
  104951. * @param element Defines the element that listens to the input events.
  104952. */
  104953. detachControl(element: HTMLElement): void;
  104954. private _collisionMask;
  104955. /**
  104956. * Get the mask that the camera ignores in collision events.
  104957. */
  104958. /**
  104959. * Set the mask that the camera ignores in collision events.
  104960. */
  104961. collisionMask: number;
  104962. /** @hidden */
  104963. _collideWithWorld(displacement: Vector3): void;
  104964. /** @hidden */
  104965. private _onCollisionPositionChange;
  104966. /** @hidden */
  104967. _checkInputs(): void;
  104968. /** @hidden */
  104969. _decideIfNeedsToMove(): boolean;
  104970. /** @hidden */
  104971. _updatePosition(): void;
  104972. /**
  104973. * Restore the Roll to its target value at the rate specified.
  104974. * @param rate - Higher means slower restoring.
  104975. * @hidden
  104976. */
  104977. restoreRoll(rate: number): void;
  104978. /**
  104979. * Destroy the camera and release the current resources held by it.
  104980. */
  104981. dispose(): void;
  104982. /**
  104983. * Get the current object class name.
  104984. * @returns the class name.
  104985. */
  104986. getClassName(): string;
  104987. }
  104988. }
  104989. declare module BABYLON {
  104990. /**
  104991. * Listen to keyboard events to control the camera.
  104992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104993. */
  104994. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104995. /**
  104996. * Defines the camera the input is attached to.
  104997. */
  104998. camera: FlyCamera;
  104999. /**
  105000. * The list of keyboard keys used to control the forward move of the camera.
  105001. */
  105002. keysForward: number[];
  105003. /**
  105004. * The list of keyboard keys used to control the backward move of the camera.
  105005. */
  105006. keysBackward: number[];
  105007. /**
  105008. * The list of keyboard keys used to control the forward move of the camera.
  105009. */
  105010. keysUp: number[];
  105011. /**
  105012. * The list of keyboard keys used to control the backward move of the camera.
  105013. */
  105014. keysDown: number[];
  105015. /**
  105016. * The list of keyboard keys used to control the right strafe move of the camera.
  105017. */
  105018. keysRight: number[];
  105019. /**
  105020. * The list of keyboard keys used to control the left strafe move of the camera.
  105021. */
  105022. keysLeft: number[];
  105023. private _keys;
  105024. private _onCanvasBlurObserver;
  105025. private _onKeyboardObserver;
  105026. private _engine;
  105027. private _scene;
  105028. /**
  105029. * Attach the input controls to a specific dom element to get the input from.
  105030. * @param element Defines the element the controls should be listened from
  105031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105032. */
  105033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105034. /**
  105035. * Detach the current controls from the specified dom element.
  105036. * @param element Defines the element to stop listening the inputs from
  105037. */
  105038. detachControl(element: Nullable<HTMLElement>): void;
  105039. /**
  105040. * Gets the class name of the current intput.
  105041. * @returns the class name
  105042. */
  105043. getClassName(): string;
  105044. /** @hidden */
  105045. _onLostFocus(e: FocusEvent): void;
  105046. /**
  105047. * Get the friendly name associated with the input class.
  105048. * @returns the input friendly name
  105049. */
  105050. getSimpleName(): string;
  105051. /**
  105052. * Update the current camera state depending on the inputs that have been used this frame.
  105053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105054. */
  105055. checkInputs(): void;
  105056. }
  105057. }
  105058. declare module BABYLON {
  105059. /**
  105060. * Manage the mouse wheel inputs to control a follow camera.
  105061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105062. */
  105063. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105064. /**
  105065. * Defines the camera the input is attached to.
  105066. */
  105067. camera: FollowCamera;
  105068. /**
  105069. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105070. */
  105071. axisControlRadius: boolean;
  105072. /**
  105073. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105074. */
  105075. axisControlHeight: boolean;
  105076. /**
  105077. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105078. */
  105079. axisControlRotation: boolean;
  105080. /**
  105081. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105082. * relation to mouseWheel events.
  105083. */
  105084. wheelPrecision: number;
  105085. /**
  105086. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105087. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105088. */
  105089. wheelDeltaPercentage: number;
  105090. private _wheel;
  105091. private _observer;
  105092. /**
  105093. * Attach the input controls to a specific dom element to get the input from.
  105094. * @param element Defines the element the controls should be listened from
  105095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105096. */
  105097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105098. /**
  105099. * Detach the current controls from the specified dom element.
  105100. * @param element Defines the element to stop listening the inputs from
  105101. */
  105102. detachControl(element: Nullable<HTMLElement>): void;
  105103. /**
  105104. * Gets the class name of the current intput.
  105105. * @returns the class name
  105106. */
  105107. getClassName(): string;
  105108. /**
  105109. * Get the friendly name associated with the input class.
  105110. * @returns the input friendly name
  105111. */
  105112. getSimpleName(): string;
  105113. }
  105114. }
  105115. declare module BABYLON {
  105116. /**
  105117. * Manage the pointers inputs to control an follow camera.
  105118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105119. */
  105120. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105121. /**
  105122. * Defines the camera the input is attached to.
  105123. */
  105124. camera: FollowCamera;
  105125. /**
  105126. * Gets the class name of the current input.
  105127. * @returns the class name
  105128. */
  105129. getClassName(): string;
  105130. /**
  105131. * Defines the pointer angular sensibility along the X axis or how fast is
  105132. * the camera rotating.
  105133. * A negative number will reverse the axis direction.
  105134. */
  105135. angularSensibilityX: number;
  105136. /**
  105137. * Defines the pointer angular sensibility along the Y axis or how fast is
  105138. * the camera rotating.
  105139. * A negative number will reverse the axis direction.
  105140. */
  105141. angularSensibilityY: number;
  105142. /**
  105143. * Defines the pointer pinch precision or how fast is the camera zooming.
  105144. * A negative number will reverse the axis direction.
  105145. */
  105146. pinchPrecision: number;
  105147. /**
  105148. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105149. * from 0.
  105150. * It defines the percentage of current camera.radius to use as delta when
  105151. * pinch zoom is used.
  105152. */
  105153. pinchDeltaPercentage: number;
  105154. /**
  105155. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105156. */
  105157. axisXControlRadius: boolean;
  105158. /**
  105159. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105160. */
  105161. axisXControlHeight: boolean;
  105162. /**
  105163. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105164. */
  105165. axisXControlRotation: boolean;
  105166. /**
  105167. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105168. */
  105169. axisYControlRadius: boolean;
  105170. /**
  105171. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105172. */
  105173. axisYControlHeight: boolean;
  105174. /**
  105175. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105176. */
  105177. axisYControlRotation: boolean;
  105178. /**
  105179. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105180. */
  105181. axisPinchControlRadius: boolean;
  105182. /**
  105183. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105184. */
  105185. axisPinchControlHeight: boolean;
  105186. /**
  105187. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105188. */
  105189. axisPinchControlRotation: boolean;
  105190. /**
  105191. * Log error messages if basic misconfiguration has occurred.
  105192. */
  105193. warningEnable: boolean;
  105194. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105195. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105196. private _warningCounter;
  105197. private _warning;
  105198. }
  105199. }
  105200. declare module BABYLON {
  105201. /**
  105202. * Default Inputs manager for the FollowCamera.
  105203. * It groups all the default supported inputs for ease of use.
  105204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105205. */
  105206. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105207. /**
  105208. * Instantiates a new FollowCameraInputsManager.
  105209. * @param camera Defines the camera the inputs belong to
  105210. */
  105211. constructor(camera: FollowCamera);
  105212. /**
  105213. * Add keyboard input support to the input manager.
  105214. * @returns the current input manager
  105215. */
  105216. addKeyboard(): FollowCameraInputsManager;
  105217. /**
  105218. * Add mouse wheel input support to the input manager.
  105219. * @returns the current input manager
  105220. */
  105221. addMouseWheel(): FollowCameraInputsManager;
  105222. /**
  105223. * Add pointers input support to the input manager.
  105224. * @returns the current input manager
  105225. */
  105226. addPointers(): FollowCameraInputsManager;
  105227. /**
  105228. * Add orientation input support to the input manager.
  105229. * @returns the current input manager
  105230. */
  105231. addVRDeviceOrientation(): FollowCameraInputsManager;
  105232. }
  105233. }
  105234. declare module BABYLON {
  105235. /**
  105236. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105237. * an arc rotate version arcFollowCamera are available.
  105238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105239. */
  105240. export class FollowCamera extends TargetCamera {
  105241. /**
  105242. * Distance the follow camera should follow an object at
  105243. */
  105244. radius: number;
  105245. /**
  105246. * Minimum allowed distance of the camera to the axis of rotation
  105247. * (The camera can not get closer).
  105248. * This can help limiting how the Camera is able to move in the scene.
  105249. */
  105250. lowerRadiusLimit: Nullable<number>;
  105251. /**
  105252. * Maximum allowed distance of the camera to the axis of rotation
  105253. * (The camera can not get further).
  105254. * This can help limiting how the Camera is able to move in the scene.
  105255. */
  105256. upperRadiusLimit: Nullable<number>;
  105257. /**
  105258. * Define a rotation offset between the camera and the object it follows
  105259. */
  105260. rotationOffset: number;
  105261. /**
  105262. * Minimum allowed angle to camera position relative to target object.
  105263. * This can help limiting how the Camera is able to move in the scene.
  105264. */
  105265. lowerRotationOffsetLimit: Nullable<number>;
  105266. /**
  105267. * Maximum allowed angle to camera position relative to target object.
  105268. * This can help limiting how the Camera is able to move in the scene.
  105269. */
  105270. upperRotationOffsetLimit: Nullable<number>;
  105271. /**
  105272. * Define a height offset between the camera and the object it follows.
  105273. * It can help following an object from the top (like a car chaing a plane)
  105274. */
  105275. heightOffset: number;
  105276. /**
  105277. * Minimum allowed height of camera position relative to target object.
  105278. * This can help limiting how the Camera is able to move in the scene.
  105279. */
  105280. lowerHeightOffsetLimit: Nullable<number>;
  105281. /**
  105282. * Maximum allowed height of camera position relative to target object.
  105283. * This can help limiting how the Camera is able to move in the scene.
  105284. */
  105285. upperHeightOffsetLimit: Nullable<number>;
  105286. /**
  105287. * Define how fast the camera can accelerate to follow it s target.
  105288. */
  105289. cameraAcceleration: number;
  105290. /**
  105291. * Define the speed limit of the camera following an object.
  105292. */
  105293. maxCameraSpeed: number;
  105294. /**
  105295. * Define the target of the camera.
  105296. */
  105297. lockedTarget: Nullable<AbstractMesh>;
  105298. /**
  105299. * Defines the input associated with the camera.
  105300. */
  105301. inputs: FollowCameraInputsManager;
  105302. /**
  105303. * Instantiates the follow camera.
  105304. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105305. * @param name Define the name of the camera in the scene
  105306. * @param position Define the position of the camera
  105307. * @param scene Define the scene the camera belong to
  105308. * @param lockedTarget Define the target of the camera
  105309. */
  105310. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105311. private _follow;
  105312. /**
  105313. * Attached controls to the current camera.
  105314. * @param element Defines the element the controls should be listened from
  105315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105316. */
  105317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105318. /**
  105319. * Detach the current controls from the camera.
  105320. * The camera will stop reacting to inputs.
  105321. * @param element Defines the element to stop listening the inputs from
  105322. */
  105323. detachControl(element: HTMLElement): void;
  105324. /** @hidden */
  105325. _checkInputs(): void;
  105326. private _checkLimits;
  105327. /**
  105328. * Gets the camera class name.
  105329. * @returns the class name
  105330. */
  105331. getClassName(): string;
  105332. }
  105333. /**
  105334. * Arc Rotate version of the follow camera.
  105335. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105336. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105337. */
  105338. export class ArcFollowCamera extends TargetCamera {
  105339. /** The longitudinal angle of the camera */
  105340. alpha: number;
  105341. /** The latitudinal angle of the camera */
  105342. beta: number;
  105343. /** The radius of the camera from its target */
  105344. radius: number;
  105345. /** Define the camera target (the messh it should follow) */
  105346. target: Nullable<AbstractMesh>;
  105347. private _cartesianCoordinates;
  105348. /**
  105349. * Instantiates a new ArcFollowCamera
  105350. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105351. * @param name Define the name of the camera
  105352. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105353. * @param beta Define the rotation angle of the camera around the elevation axis
  105354. * @param radius Define the radius of the camera from its target point
  105355. * @param target Define the target of the camera
  105356. * @param scene Define the scene the camera belongs to
  105357. */
  105358. constructor(name: string,
  105359. /** The longitudinal angle of the camera */
  105360. alpha: number,
  105361. /** The latitudinal angle of the camera */
  105362. beta: number,
  105363. /** The radius of the camera from its target */
  105364. radius: number,
  105365. /** Define the camera target (the messh it should follow) */
  105366. target: Nullable<AbstractMesh>, scene: Scene);
  105367. private _follow;
  105368. /** @hidden */
  105369. _checkInputs(): void;
  105370. /**
  105371. * Returns the class name of the object.
  105372. * It is mostly used internally for serialization purposes.
  105373. */
  105374. getClassName(): string;
  105375. }
  105376. }
  105377. declare module BABYLON {
  105378. /**
  105379. * Manage the keyboard inputs to control the movement of a follow camera.
  105380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105381. */
  105382. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105383. /**
  105384. * Defines the camera the input is attached to.
  105385. */
  105386. camera: FollowCamera;
  105387. /**
  105388. * Defines the list of key codes associated with the up action (increase heightOffset)
  105389. */
  105390. keysHeightOffsetIncr: number[];
  105391. /**
  105392. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105393. */
  105394. keysHeightOffsetDecr: number[];
  105395. /**
  105396. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105397. */
  105398. keysHeightOffsetModifierAlt: boolean;
  105399. /**
  105400. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105401. */
  105402. keysHeightOffsetModifierCtrl: boolean;
  105403. /**
  105404. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105405. */
  105406. keysHeightOffsetModifierShift: boolean;
  105407. /**
  105408. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105409. */
  105410. keysRotationOffsetIncr: number[];
  105411. /**
  105412. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105413. */
  105414. keysRotationOffsetDecr: number[];
  105415. /**
  105416. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105417. */
  105418. keysRotationOffsetModifierAlt: boolean;
  105419. /**
  105420. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105421. */
  105422. keysRotationOffsetModifierCtrl: boolean;
  105423. /**
  105424. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105425. */
  105426. keysRotationOffsetModifierShift: boolean;
  105427. /**
  105428. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105429. */
  105430. keysRadiusIncr: number[];
  105431. /**
  105432. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105433. */
  105434. keysRadiusDecr: number[];
  105435. /**
  105436. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105437. */
  105438. keysRadiusModifierAlt: boolean;
  105439. /**
  105440. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105441. */
  105442. keysRadiusModifierCtrl: boolean;
  105443. /**
  105444. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105445. */
  105446. keysRadiusModifierShift: boolean;
  105447. /**
  105448. * Defines the rate of change of heightOffset.
  105449. */
  105450. heightSensibility: number;
  105451. /**
  105452. * Defines the rate of change of rotationOffset.
  105453. */
  105454. rotationSensibility: number;
  105455. /**
  105456. * Defines the rate of change of radius.
  105457. */
  105458. radiusSensibility: number;
  105459. private _keys;
  105460. private _ctrlPressed;
  105461. private _altPressed;
  105462. private _shiftPressed;
  105463. private _onCanvasBlurObserver;
  105464. private _onKeyboardObserver;
  105465. private _engine;
  105466. private _scene;
  105467. /**
  105468. * Attach the input controls to a specific dom element to get the input from.
  105469. * @param element Defines the element the controls should be listened from
  105470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105471. */
  105472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105473. /**
  105474. * Detach the current controls from the specified dom element.
  105475. * @param element Defines the element to stop listening the inputs from
  105476. */
  105477. detachControl(element: Nullable<HTMLElement>): void;
  105478. /**
  105479. * Update the current camera state depending on the inputs that have been used this frame.
  105480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105481. */
  105482. checkInputs(): void;
  105483. /**
  105484. * Gets the class name of the current input.
  105485. * @returns the class name
  105486. */
  105487. getClassName(): string;
  105488. /**
  105489. * Get the friendly name associated with the input class.
  105490. * @returns the input friendly name
  105491. */
  105492. getSimpleName(): string;
  105493. /**
  105494. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105495. * allow modification of the heightOffset value.
  105496. */
  105497. private _modifierHeightOffset;
  105498. /**
  105499. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105500. * allow modification of the rotationOffset value.
  105501. */
  105502. private _modifierRotationOffset;
  105503. /**
  105504. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105505. * allow modification of the radius value.
  105506. */
  105507. private _modifierRadius;
  105508. }
  105509. }
  105510. declare module BABYLON {
  105511. interface FreeCameraInputsManager {
  105512. /**
  105513. * @hidden
  105514. */
  105515. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105516. /**
  105517. * Add orientation input support to the input manager.
  105518. * @returns the current input manager
  105519. */
  105520. addDeviceOrientation(): FreeCameraInputsManager;
  105521. }
  105522. /**
  105523. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105524. * Screen rotation is taken into account.
  105525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105526. */
  105527. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105528. private _camera;
  105529. private _screenOrientationAngle;
  105530. private _constantTranform;
  105531. private _screenQuaternion;
  105532. private _alpha;
  105533. private _beta;
  105534. private _gamma;
  105535. /**
  105536. * Can be used to detect if a device orientation sensor is availible on a device
  105537. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105538. * @returns a promise that will resolve on orientation change
  105539. */
  105540. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105541. /**
  105542. * @hidden
  105543. */
  105544. _onDeviceOrientationChangedObservable: Observable<void>;
  105545. /**
  105546. * Instantiates a new input
  105547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105548. */
  105549. constructor();
  105550. /**
  105551. * Define the camera controlled by the input.
  105552. */
  105553. camera: FreeCamera;
  105554. /**
  105555. * Attach the input controls to a specific dom element to get the input from.
  105556. * @param element Defines the element the controls should be listened from
  105557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105558. */
  105559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105560. private _orientationChanged;
  105561. private _deviceOrientation;
  105562. /**
  105563. * Detach the current controls from the specified dom element.
  105564. * @param element Defines the element to stop listening the inputs from
  105565. */
  105566. detachControl(element: Nullable<HTMLElement>): void;
  105567. /**
  105568. * Update the current camera state depending on the inputs that have been used this frame.
  105569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105570. */
  105571. checkInputs(): void;
  105572. /**
  105573. * Gets the class name of the current intput.
  105574. * @returns the class name
  105575. */
  105576. getClassName(): string;
  105577. /**
  105578. * Get the friendly name associated with the input class.
  105579. * @returns the input friendly name
  105580. */
  105581. getSimpleName(): string;
  105582. }
  105583. }
  105584. declare module BABYLON {
  105585. /**
  105586. * Manage the gamepad inputs to control a free camera.
  105587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105588. */
  105589. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105590. /**
  105591. * Define the camera the input is attached to.
  105592. */
  105593. camera: FreeCamera;
  105594. /**
  105595. * Define the Gamepad controlling the input
  105596. */
  105597. gamepad: Nullable<Gamepad>;
  105598. /**
  105599. * Defines the gamepad rotation sensiblity.
  105600. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105601. */
  105602. gamepadAngularSensibility: number;
  105603. /**
  105604. * Defines the gamepad move sensiblity.
  105605. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105606. */
  105607. gamepadMoveSensibility: number;
  105608. private _yAxisScale;
  105609. /**
  105610. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105611. */
  105612. invertYAxis: boolean;
  105613. private _onGamepadConnectedObserver;
  105614. private _onGamepadDisconnectedObserver;
  105615. private _cameraTransform;
  105616. private _deltaTransform;
  105617. private _vector3;
  105618. private _vector2;
  105619. /**
  105620. * Attach the input controls to a specific dom element to get the input from.
  105621. * @param element Defines the element the controls should be listened from
  105622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105623. */
  105624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105625. /**
  105626. * Detach the current controls from the specified dom element.
  105627. * @param element Defines the element to stop listening the inputs from
  105628. */
  105629. detachControl(element: Nullable<HTMLElement>): void;
  105630. /**
  105631. * Update the current camera state depending on the inputs that have been used this frame.
  105632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105633. */
  105634. checkInputs(): void;
  105635. /**
  105636. * Gets the class name of the current intput.
  105637. * @returns the class name
  105638. */
  105639. getClassName(): string;
  105640. /**
  105641. * Get the friendly name associated with the input class.
  105642. * @returns the input friendly name
  105643. */
  105644. getSimpleName(): string;
  105645. }
  105646. }
  105647. declare module BABYLON {
  105648. /**
  105649. * Defines the potential axis of a Joystick
  105650. */
  105651. export enum JoystickAxis {
  105652. /** X axis */
  105653. X = 0,
  105654. /** Y axis */
  105655. Y = 1,
  105656. /** Z axis */
  105657. Z = 2
  105658. }
  105659. /**
  105660. * Class used to define virtual joystick (used in touch mode)
  105661. */
  105662. export class VirtualJoystick {
  105663. /**
  105664. * Gets or sets a boolean indicating that left and right values must be inverted
  105665. */
  105666. reverseLeftRight: boolean;
  105667. /**
  105668. * Gets or sets a boolean indicating that up and down values must be inverted
  105669. */
  105670. reverseUpDown: boolean;
  105671. /**
  105672. * Gets the offset value for the position (ie. the change of the position value)
  105673. */
  105674. deltaPosition: Vector3;
  105675. /**
  105676. * Gets a boolean indicating if the virtual joystick was pressed
  105677. */
  105678. pressed: boolean;
  105679. /**
  105680. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105681. */
  105682. static Canvas: Nullable<HTMLCanvasElement>;
  105683. private static _globalJoystickIndex;
  105684. private static vjCanvasContext;
  105685. private static vjCanvasWidth;
  105686. private static vjCanvasHeight;
  105687. private static halfWidth;
  105688. private _action;
  105689. private _axisTargetedByLeftAndRight;
  105690. private _axisTargetedByUpAndDown;
  105691. private _joystickSensibility;
  105692. private _inversedSensibility;
  105693. private _joystickPointerID;
  105694. private _joystickColor;
  105695. private _joystickPointerPos;
  105696. private _joystickPreviousPointerPos;
  105697. private _joystickPointerStartPos;
  105698. private _deltaJoystickVector;
  105699. private _leftJoystick;
  105700. private _touches;
  105701. private _onPointerDownHandlerRef;
  105702. private _onPointerMoveHandlerRef;
  105703. private _onPointerUpHandlerRef;
  105704. private _onResize;
  105705. /**
  105706. * Creates a new virtual joystick
  105707. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105708. */
  105709. constructor(leftJoystick?: boolean);
  105710. /**
  105711. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105712. * @param newJoystickSensibility defines the new sensibility
  105713. */
  105714. setJoystickSensibility(newJoystickSensibility: number): void;
  105715. private _onPointerDown;
  105716. private _onPointerMove;
  105717. private _onPointerUp;
  105718. /**
  105719. * Change the color of the virtual joystick
  105720. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105721. */
  105722. setJoystickColor(newColor: string): void;
  105723. /**
  105724. * Defines a callback to call when the joystick is touched
  105725. * @param action defines the callback
  105726. */
  105727. setActionOnTouch(action: () => any): void;
  105728. /**
  105729. * Defines which axis you'd like to control for left & right
  105730. * @param axis defines the axis to use
  105731. */
  105732. setAxisForLeftRight(axis: JoystickAxis): void;
  105733. /**
  105734. * Defines which axis you'd like to control for up & down
  105735. * @param axis defines the axis to use
  105736. */
  105737. setAxisForUpDown(axis: JoystickAxis): void;
  105738. private _drawVirtualJoystick;
  105739. /**
  105740. * Release internal HTML canvas
  105741. */
  105742. releaseCanvas(): void;
  105743. }
  105744. }
  105745. declare module BABYLON {
  105746. interface FreeCameraInputsManager {
  105747. /**
  105748. * Add virtual joystick input support to the input manager.
  105749. * @returns the current input manager
  105750. */
  105751. addVirtualJoystick(): FreeCameraInputsManager;
  105752. }
  105753. /**
  105754. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105756. */
  105757. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105758. /**
  105759. * Defines the camera the input is attached to.
  105760. */
  105761. camera: FreeCamera;
  105762. private _leftjoystick;
  105763. private _rightjoystick;
  105764. /**
  105765. * Gets the left stick of the virtual joystick.
  105766. * @returns The virtual Joystick
  105767. */
  105768. getLeftJoystick(): VirtualJoystick;
  105769. /**
  105770. * Gets the right stick of the virtual joystick.
  105771. * @returns The virtual Joystick
  105772. */
  105773. getRightJoystick(): VirtualJoystick;
  105774. /**
  105775. * Update the current camera state depending on the inputs that have been used this frame.
  105776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105777. */
  105778. checkInputs(): void;
  105779. /**
  105780. * Attach the input controls to a specific dom element to get the input from.
  105781. * @param element Defines the element the controls should be listened from
  105782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105783. */
  105784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105785. /**
  105786. * Detach the current controls from the specified dom element.
  105787. * @param element Defines the element to stop listening the inputs from
  105788. */
  105789. detachControl(element: Nullable<HTMLElement>): void;
  105790. /**
  105791. * Gets the class name of the current intput.
  105792. * @returns the class name
  105793. */
  105794. getClassName(): string;
  105795. /**
  105796. * Get the friendly name associated with the input class.
  105797. * @returns the input friendly name
  105798. */
  105799. getSimpleName(): string;
  105800. }
  105801. }
  105802. declare module BABYLON {
  105803. /**
  105804. * This represents a FPS type of camera controlled by touch.
  105805. * This is like a universal camera minus the Gamepad controls.
  105806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105807. */
  105808. export class TouchCamera extends FreeCamera {
  105809. /**
  105810. * Defines the touch sensibility for rotation.
  105811. * The higher the faster.
  105812. */
  105813. touchAngularSensibility: number;
  105814. /**
  105815. * Defines the touch sensibility for move.
  105816. * The higher the faster.
  105817. */
  105818. touchMoveSensibility: number;
  105819. /**
  105820. * Instantiates a new touch camera.
  105821. * This represents a FPS type of camera controlled by touch.
  105822. * This is like a universal camera minus the Gamepad controls.
  105823. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105824. * @param name Define the name of the camera in the scene
  105825. * @param position Define the start position of the camera in the scene
  105826. * @param scene Define the scene the camera belongs to
  105827. */
  105828. constructor(name: string, position: Vector3, scene: Scene);
  105829. /**
  105830. * Gets the current object class name.
  105831. * @return the class name
  105832. */
  105833. getClassName(): string;
  105834. /** @hidden */
  105835. _setupInputs(): void;
  105836. }
  105837. }
  105838. declare module BABYLON {
  105839. /**
  105840. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105841. * being tilted forward or back and left or right.
  105842. */
  105843. export class DeviceOrientationCamera extends FreeCamera {
  105844. private _initialQuaternion;
  105845. private _quaternionCache;
  105846. private _tmpDragQuaternion;
  105847. private _disablePointerInputWhenUsingDeviceOrientation;
  105848. /**
  105849. * Creates a new device orientation camera
  105850. * @param name The name of the camera
  105851. * @param position The start position camera
  105852. * @param scene The scene the camera belongs to
  105853. */
  105854. constructor(name: string, position: Vector3, scene: Scene);
  105855. /**
  105856. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105857. */
  105858. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105859. private _dragFactor;
  105860. /**
  105861. * Enabled turning on the y axis when the orientation sensor is active
  105862. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105863. */
  105864. enableHorizontalDragging(dragFactor?: number): void;
  105865. /**
  105866. * Gets the current instance class name ("DeviceOrientationCamera").
  105867. * This helps avoiding instanceof at run time.
  105868. * @returns the class name
  105869. */
  105870. getClassName(): string;
  105871. /**
  105872. * @hidden
  105873. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105874. */
  105875. _checkInputs(): void;
  105876. /**
  105877. * Reset the camera to its default orientation on the specified axis only.
  105878. * @param axis The axis to reset
  105879. */
  105880. resetToCurrentRotation(axis?: Axis): void;
  105881. }
  105882. }
  105883. declare module BABYLON {
  105884. /**
  105885. * Defines supported buttons for XBox360 compatible gamepads
  105886. */
  105887. export enum Xbox360Button {
  105888. /** A */
  105889. A = 0,
  105890. /** B */
  105891. B = 1,
  105892. /** X */
  105893. X = 2,
  105894. /** Y */
  105895. Y = 3,
  105896. /** Start */
  105897. Start = 4,
  105898. /** Back */
  105899. Back = 5,
  105900. /** Left button */
  105901. LB = 6,
  105902. /** Right button */
  105903. RB = 7,
  105904. /** Left stick */
  105905. LeftStick = 8,
  105906. /** Right stick */
  105907. RightStick = 9
  105908. }
  105909. /** Defines values for XBox360 DPad */
  105910. export enum Xbox360Dpad {
  105911. /** Up */
  105912. Up = 0,
  105913. /** Down */
  105914. Down = 1,
  105915. /** Left */
  105916. Left = 2,
  105917. /** Right */
  105918. Right = 3
  105919. }
  105920. /**
  105921. * Defines a XBox360 gamepad
  105922. */
  105923. export class Xbox360Pad extends Gamepad {
  105924. private _leftTrigger;
  105925. private _rightTrigger;
  105926. private _onlefttriggerchanged;
  105927. private _onrighttriggerchanged;
  105928. private _onbuttondown;
  105929. private _onbuttonup;
  105930. private _ondpaddown;
  105931. private _ondpadup;
  105932. /** Observable raised when a button is pressed */
  105933. onButtonDownObservable: Observable<Xbox360Button>;
  105934. /** Observable raised when a button is released */
  105935. onButtonUpObservable: Observable<Xbox360Button>;
  105936. /** Observable raised when a pad is pressed */
  105937. onPadDownObservable: Observable<Xbox360Dpad>;
  105938. /** Observable raised when a pad is released */
  105939. onPadUpObservable: Observable<Xbox360Dpad>;
  105940. private _buttonA;
  105941. private _buttonB;
  105942. private _buttonX;
  105943. private _buttonY;
  105944. private _buttonBack;
  105945. private _buttonStart;
  105946. private _buttonLB;
  105947. private _buttonRB;
  105948. private _buttonLeftStick;
  105949. private _buttonRightStick;
  105950. private _dPadUp;
  105951. private _dPadDown;
  105952. private _dPadLeft;
  105953. private _dPadRight;
  105954. private _isXboxOnePad;
  105955. /**
  105956. * Creates a new XBox360 gamepad object
  105957. * @param id defines the id of this gamepad
  105958. * @param index defines its index
  105959. * @param gamepad defines the internal HTML gamepad object
  105960. * @param xboxOne defines if it is a XBox One gamepad
  105961. */
  105962. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105963. /**
  105964. * Defines the callback to call when left trigger is pressed
  105965. * @param callback defines the callback to use
  105966. */
  105967. onlefttriggerchanged(callback: (value: number) => void): void;
  105968. /**
  105969. * Defines the callback to call when right trigger is pressed
  105970. * @param callback defines the callback to use
  105971. */
  105972. onrighttriggerchanged(callback: (value: number) => void): void;
  105973. /**
  105974. * Gets the left trigger value
  105975. */
  105976. /**
  105977. * Sets the left trigger value
  105978. */
  105979. leftTrigger: number;
  105980. /**
  105981. * Gets the right trigger value
  105982. */
  105983. /**
  105984. * Sets the right trigger value
  105985. */
  105986. rightTrigger: number;
  105987. /**
  105988. * Defines the callback to call when a button is pressed
  105989. * @param callback defines the callback to use
  105990. */
  105991. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105992. /**
  105993. * Defines the callback to call when a button is released
  105994. * @param callback defines the callback to use
  105995. */
  105996. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105997. /**
  105998. * Defines the callback to call when a pad is pressed
  105999. * @param callback defines the callback to use
  106000. */
  106001. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106002. /**
  106003. * Defines the callback to call when a pad is released
  106004. * @param callback defines the callback to use
  106005. */
  106006. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106007. private _setButtonValue;
  106008. private _setDPadValue;
  106009. /**
  106010. * Gets the value of the `A` button
  106011. */
  106012. /**
  106013. * Sets the value of the `A` button
  106014. */
  106015. buttonA: number;
  106016. /**
  106017. * Gets the value of the `B` button
  106018. */
  106019. /**
  106020. * Sets the value of the `B` button
  106021. */
  106022. buttonB: number;
  106023. /**
  106024. * Gets the value of the `X` button
  106025. */
  106026. /**
  106027. * Sets the value of the `X` button
  106028. */
  106029. buttonX: number;
  106030. /**
  106031. * Gets the value of the `Y` button
  106032. */
  106033. /**
  106034. * Sets the value of the `Y` button
  106035. */
  106036. buttonY: number;
  106037. /**
  106038. * Gets the value of the `Start` button
  106039. */
  106040. /**
  106041. * Sets the value of the `Start` button
  106042. */
  106043. buttonStart: number;
  106044. /**
  106045. * Gets the value of the `Back` button
  106046. */
  106047. /**
  106048. * Sets the value of the `Back` button
  106049. */
  106050. buttonBack: number;
  106051. /**
  106052. * Gets the value of the `Left` button
  106053. */
  106054. /**
  106055. * Sets the value of the `Left` button
  106056. */
  106057. buttonLB: number;
  106058. /**
  106059. * Gets the value of the `Right` button
  106060. */
  106061. /**
  106062. * Sets the value of the `Right` button
  106063. */
  106064. buttonRB: number;
  106065. /**
  106066. * Gets the value of the Left joystick
  106067. */
  106068. /**
  106069. * Sets the value of the Left joystick
  106070. */
  106071. buttonLeftStick: number;
  106072. /**
  106073. * Gets the value of the Right joystick
  106074. */
  106075. /**
  106076. * Sets the value of the Right joystick
  106077. */
  106078. buttonRightStick: number;
  106079. /**
  106080. * Gets the value of D-pad up
  106081. */
  106082. /**
  106083. * Sets the value of D-pad up
  106084. */
  106085. dPadUp: number;
  106086. /**
  106087. * Gets the value of D-pad down
  106088. */
  106089. /**
  106090. * Sets the value of D-pad down
  106091. */
  106092. dPadDown: number;
  106093. /**
  106094. * Gets the value of D-pad left
  106095. */
  106096. /**
  106097. * Sets the value of D-pad left
  106098. */
  106099. dPadLeft: number;
  106100. /**
  106101. * Gets the value of D-pad right
  106102. */
  106103. /**
  106104. * Sets the value of D-pad right
  106105. */
  106106. dPadRight: number;
  106107. /**
  106108. * Force the gamepad to synchronize with device values
  106109. */
  106110. update(): void;
  106111. /**
  106112. * Disposes the gamepad
  106113. */
  106114. dispose(): void;
  106115. }
  106116. }
  106117. declare module BABYLON {
  106118. /**
  106119. * Defines supported buttons for DualShock compatible gamepads
  106120. */
  106121. export enum DualShockButton {
  106122. /** Cross */
  106123. Cross = 0,
  106124. /** Circle */
  106125. Circle = 1,
  106126. /** Square */
  106127. Square = 2,
  106128. /** Triangle */
  106129. Triangle = 3,
  106130. /** Options */
  106131. Options = 4,
  106132. /** Share */
  106133. Share = 5,
  106134. /** L1 */
  106135. L1 = 6,
  106136. /** R1 */
  106137. R1 = 7,
  106138. /** Left stick */
  106139. LeftStick = 8,
  106140. /** Right stick */
  106141. RightStick = 9
  106142. }
  106143. /** Defines values for DualShock DPad */
  106144. export enum DualShockDpad {
  106145. /** Up */
  106146. Up = 0,
  106147. /** Down */
  106148. Down = 1,
  106149. /** Left */
  106150. Left = 2,
  106151. /** Right */
  106152. Right = 3
  106153. }
  106154. /**
  106155. * Defines a DualShock gamepad
  106156. */
  106157. export class DualShockPad extends Gamepad {
  106158. private _leftTrigger;
  106159. private _rightTrigger;
  106160. private _onlefttriggerchanged;
  106161. private _onrighttriggerchanged;
  106162. private _onbuttondown;
  106163. private _onbuttonup;
  106164. private _ondpaddown;
  106165. private _ondpadup;
  106166. /** Observable raised when a button is pressed */
  106167. onButtonDownObservable: Observable<DualShockButton>;
  106168. /** Observable raised when a button is released */
  106169. onButtonUpObservable: Observable<DualShockButton>;
  106170. /** Observable raised when a pad is pressed */
  106171. onPadDownObservable: Observable<DualShockDpad>;
  106172. /** Observable raised when a pad is released */
  106173. onPadUpObservable: Observable<DualShockDpad>;
  106174. private _buttonCross;
  106175. private _buttonCircle;
  106176. private _buttonSquare;
  106177. private _buttonTriangle;
  106178. private _buttonShare;
  106179. private _buttonOptions;
  106180. private _buttonL1;
  106181. private _buttonR1;
  106182. private _buttonLeftStick;
  106183. private _buttonRightStick;
  106184. private _dPadUp;
  106185. private _dPadDown;
  106186. private _dPadLeft;
  106187. private _dPadRight;
  106188. /**
  106189. * Creates a new DualShock gamepad object
  106190. * @param id defines the id of this gamepad
  106191. * @param index defines its index
  106192. * @param gamepad defines the internal HTML gamepad object
  106193. */
  106194. constructor(id: string, index: number, gamepad: any);
  106195. /**
  106196. * Defines the callback to call when left trigger is pressed
  106197. * @param callback defines the callback to use
  106198. */
  106199. onlefttriggerchanged(callback: (value: number) => void): void;
  106200. /**
  106201. * Defines the callback to call when right trigger is pressed
  106202. * @param callback defines the callback to use
  106203. */
  106204. onrighttriggerchanged(callback: (value: number) => void): void;
  106205. /**
  106206. * Gets the left trigger value
  106207. */
  106208. /**
  106209. * Sets the left trigger value
  106210. */
  106211. leftTrigger: number;
  106212. /**
  106213. * Gets the right trigger value
  106214. */
  106215. /**
  106216. * Sets the right trigger value
  106217. */
  106218. rightTrigger: number;
  106219. /**
  106220. * Defines the callback to call when a button is pressed
  106221. * @param callback defines the callback to use
  106222. */
  106223. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106224. /**
  106225. * Defines the callback to call when a button is released
  106226. * @param callback defines the callback to use
  106227. */
  106228. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106229. /**
  106230. * Defines the callback to call when a pad is pressed
  106231. * @param callback defines the callback to use
  106232. */
  106233. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106234. /**
  106235. * Defines the callback to call when a pad is released
  106236. * @param callback defines the callback to use
  106237. */
  106238. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106239. private _setButtonValue;
  106240. private _setDPadValue;
  106241. /**
  106242. * Gets the value of the `Cross` button
  106243. */
  106244. /**
  106245. * Sets the value of the `Cross` button
  106246. */
  106247. buttonCross: number;
  106248. /**
  106249. * Gets the value of the `Circle` button
  106250. */
  106251. /**
  106252. * Sets the value of the `Circle` button
  106253. */
  106254. buttonCircle: number;
  106255. /**
  106256. * Gets the value of the `Square` button
  106257. */
  106258. /**
  106259. * Sets the value of the `Square` button
  106260. */
  106261. buttonSquare: number;
  106262. /**
  106263. * Gets the value of the `Triangle` button
  106264. */
  106265. /**
  106266. * Sets the value of the `Triangle` button
  106267. */
  106268. buttonTriangle: number;
  106269. /**
  106270. * Gets the value of the `Options` button
  106271. */
  106272. /**
  106273. * Sets the value of the `Options` button
  106274. */
  106275. buttonOptions: number;
  106276. /**
  106277. * Gets the value of the `Share` button
  106278. */
  106279. /**
  106280. * Sets the value of the `Share` button
  106281. */
  106282. buttonShare: number;
  106283. /**
  106284. * Gets the value of the `L1` button
  106285. */
  106286. /**
  106287. * Sets the value of the `L1` button
  106288. */
  106289. buttonL1: number;
  106290. /**
  106291. * Gets the value of the `R1` button
  106292. */
  106293. /**
  106294. * Sets the value of the `R1` button
  106295. */
  106296. buttonR1: number;
  106297. /**
  106298. * Gets the value of the Left joystick
  106299. */
  106300. /**
  106301. * Sets the value of the Left joystick
  106302. */
  106303. buttonLeftStick: number;
  106304. /**
  106305. * Gets the value of the Right joystick
  106306. */
  106307. /**
  106308. * Sets the value of the Right joystick
  106309. */
  106310. buttonRightStick: number;
  106311. /**
  106312. * Gets the value of D-pad up
  106313. */
  106314. /**
  106315. * Sets the value of D-pad up
  106316. */
  106317. dPadUp: number;
  106318. /**
  106319. * Gets the value of D-pad down
  106320. */
  106321. /**
  106322. * Sets the value of D-pad down
  106323. */
  106324. dPadDown: number;
  106325. /**
  106326. * Gets the value of D-pad left
  106327. */
  106328. /**
  106329. * Sets the value of D-pad left
  106330. */
  106331. dPadLeft: number;
  106332. /**
  106333. * Gets the value of D-pad right
  106334. */
  106335. /**
  106336. * Sets the value of D-pad right
  106337. */
  106338. dPadRight: number;
  106339. /**
  106340. * Force the gamepad to synchronize with device values
  106341. */
  106342. update(): void;
  106343. /**
  106344. * Disposes the gamepad
  106345. */
  106346. dispose(): void;
  106347. }
  106348. }
  106349. declare module BABYLON {
  106350. /**
  106351. * Manager for handling gamepads
  106352. */
  106353. export class GamepadManager {
  106354. private _scene?;
  106355. private _babylonGamepads;
  106356. private _oneGamepadConnected;
  106357. /** @hidden */
  106358. _isMonitoring: boolean;
  106359. private _gamepadEventSupported;
  106360. private _gamepadSupport;
  106361. /**
  106362. * observable to be triggered when the gamepad controller has been connected
  106363. */
  106364. onGamepadConnectedObservable: Observable<Gamepad>;
  106365. /**
  106366. * observable to be triggered when the gamepad controller has been disconnected
  106367. */
  106368. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106369. private _onGamepadConnectedEvent;
  106370. private _onGamepadDisconnectedEvent;
  106371. /**
  106372. * Initializes the gamepad manager
  106373. * @param _scene BabylonJS scene
  106374. */
  106375. constructor(_scene?: Scene | undefined);
  106376. /**
  106377. * The gamepads in the game pad manager
  106378. */
  106379. readonly gamepads: Gamepad[];
  106380. /**
  106381. * Get the gamepad controllers based on type
  106382. * @param type The type of gamepad controller
  106383. * @returns Nullable gamepad
  106384. */
  106385. getGamepadByType(type?: number): Nullable<Gamepad>;
  106386. /**
  106387. * Disposes the gamepad manager
  106388. */
  106389. dispose(): void;
  106390. private _addNewGamepad;
  106391. private _startMonitoringGamepads;
  106392. private _stopMonitoringGamepads;
  106393. /** @hidden */
  106394. _checkGamepadsStatus(): void;
  106395. private _updateGamepadObjects;
  106396. }
  106397. }
  106398. declare module BABYLON {
  106399. interface Scene {
  106400. /** @hidden */
  106401. _gamepadManager: Nullable<GamepadManager>;
  106402. /**
  106403. * Gets the gamepad manager associated with the scene
  106404. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106405. */
  106406. gamepadManager: GamepadManager;
  106407. }
  106408. /**
  106409. * Interface representing a free camera inputs manager
  106410. */
  106411. interface FreeCameraInputsManager {
  106412. /**
  106413. * Adds gamepad input support to the FreeCameraInputsManager.
  106414. * @returns the FreeCameraInputsManager
  106415. */
  106416. addGamepad(): FreeCameraInputsManager;
  106417. }
  106418. /**
  106419. * Interface representing an arc rotate camera inputs manager
  106420. */
  106421. interface ArcRotateCameraInputsManager {
  106422. /**
  106423. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106424. * @returns the camera inputs manager
  106425. */
  106426. addGamepad(): ArcRotateCameraInputsManager;
  106427. }
  106428. /**
  106429. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106430. */
  106431. export class GamepadSystemSceneComponent implements ISceneComponent {
  106432. /**
  106433. * The component name helpfull to identify the component in the list of scene components.
  106434. */
  106435. readonly name: string;
  106436. /**
  106437. * The scene the component belongs to.
  106438. */
  106439. scene: Scene;
  106440. /**
  106441. * Creates a new instance of the component for the given scene
  106442. * @param scene Defines the scene to register the component in
  106443. */
  106444. constructor(scene: Scene);
  106445. /**
  106446. * Registers the component in a given scene
  106447. */
  106448. register(): void;
  106449. /**
  106450. * Rebuilds the elements related to this component in case of
  106451. * context lost for instance.
  106452. */
  106453. rebuild(): void;
  106454. /**
  106455. * Disposes the component and the associated ressources
  106456. */
  106457. dispose(): void;
  106458. private _beforeCameraUpdate;
  106459. }
  106460. }
  106461. declare module BABYLON {
  106462. /**
  106463. * 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,
  106464. * which still works and will still be found in many Playgrounds.
  106465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106466. */
  106467. export class UniversalCamera extends TouchCamera {
  106468. /**
  106469. * Defines the gamepad rotation sensiblity.
  106470. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106471. */
  106472. gamepadAngularSensibility: number;
  106473. /**
  106474. * Defines the gamepad move sensiblity.
  106475. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106476. */
  106477. gamepadMoveSensibility: number;
  106478. /**
  106479. * 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,
  106480. * which still works and will still be found in many Playgrounds.
  106481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106482. * @param name Define the name of the camera in the scene
  106483. * @param position Define the start position of the camera in the scene
  106484. * @param scene Define the scene the camera belongs to
  106485. */
  106486. constructor(name: string, position: Vector3, scene: Scene);
  106487. /**
  106488. * Gets the current object class name.
  106489. * @return the class name
  106490. */
  106491. getClassName(): string;
  106492. }
  106493. }
  106494. declare module BABYLON {
  106495. /**
  106496. * This represents a FPS type of camera. This is only here for back compat purpose.
  106497. * Please use the UniversalCamera instead as both are identical.
  106498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106499. */
  106500. export class GamepadCamera extends UniversalCamera {
  106501. /**
  106502. * Instantiates a new Gamepad Camera
  106503. * This represents a FPS type of camera. This is only here for back compat purpose.
  106504. * Please use the UniversalCamera instead as both are identical.
  106505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106506. * @param name Define the name of the camera in the scene
  106507. * @param position Define the start position of the camera in the scene
  106508. * @param scene Define the scene the camera belongs to
  106509. */
  106510. constructor(name: string, position: Vector3, scene: Scene);
  106511. /**
  106512. * Gets the current object class name.
  106513. * @return the class name
  106514. */
  106515. getClassName(): string;
  106516. }
  106517. }
  106518. declare module BABYLON {
  106519. /** @hidden */
  106520. export var passPixelShader: {
  106521. name: string;
  106522. shader: string;
  106523. };
  106524. }
  106525. declare module BABYLON {
  106526. /** @hidden */
  106527. export var passCubePixelShader: {
  106528. name: string;
  106529. shader: string;
  106530. };
  106531. }
  106532. declare module BABYLON {
  106533. /**
  106534. * PassPostProcess which produces an output the same as it's input
  106535. */
  106536. export class PassPostProcess extends PostProcess {
  106537. /**
  106538. * Creates the PassPostProcess
  106539. * @param name The name of the effect.
  106540. * @param options The required width/height ratio to downsize to before computing the render pass.
  106541. * @param camera The camera to apply the render pass to.
  106542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106543. * @param engine The engine which the post process will be applied. (default: current engine)
  106544. * @param reusable If the post process can be reused on the same frame. (default: false)
  106545. * @param textureType The type of texture to be used when performing the post processing.
  106546. * @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)
  106547. */
  106548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106549. }
  106550. /**
  106551. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106552. */
  106553. export class PassCubePostProcess extends PostProcess {
  106554. private _face;
  106555. /**
  106556. * Gets or sets the cube face to display.
  106557. * * 0 is +X
  106558. * * 1 is -X
  106559. * * 2 is +Y
  106560. * * 3 is -Y
  106561. * * 4 is +Z
  106562. * * 5 is -Z
  106563. */
  106564. face: number;
  106565. /**
  106566. * Creates the PassCubePostProcess
  106567. * @param name The name of the effect.
  106568. * @param options The required width/height ratio to downsize to before computing the render pass.
  106569. * @param camera The camera to apply the render pass to.
  106570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106571. * @param engine The engine which the post process will be applied. (default: current engine)
  106572. * @param reusable If the post process can be reused on the same frame. (default: false)
  106573. * @param textureType The type of texture to be used when performing the post processing.
  106574. * @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)
  106575. */
  106576. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106577. }
  106578. }
  106579. declare module BABYLON {
  106580. /** @hidden */
  106581. export var anaglyphPixelShader: {
  106582. name: string;
  106583. shader: string;
  106584. };
  106585. }
  106586. declare module BABYLON {
  106587. /**
  106588. * Postprocess used to generate anaglyphic rendering
  106589. */
  106590. export class AnaglyphPostProcess extends PostProcess {
  106591. private _passedProcess;
  106592. /**
  106593. * Creates a new AnaglyphPostProcess
  106594. * @param name defines postprocess name
  106595. * @param options defines creation options or target ratio scale
  106596. * @param rigCameras defines cameras using this postprocess
  106597. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106598. * @param engine defines hosting engine
  106599. * @param reusable defines if the postprocess will be reused multiple times per frame
  106600. */
  106601. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106602. }
  106603. }
  106604. declare module BABYLON {
  106605. /**
  106606. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106607. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106608. */
  106609. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106610. /**
  106611. * Creates a new AnaglyphArcRotateCamera
  106612. * @param name defines camera name
  106613. * @param alpha defines alpha angle (in radians)
  106614. * @param beta defines beta angle (in radians)
  106615. * @param radius defines radius
  106616. * @param target defines camera target
  106617. * @param interaxialDistance defines distance between each color axis
  106618. * @param scene defines the hosting scene
  106619. */
  106620. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106621. /**
  106622. * Gets camera class name
  106623. * @returns AnaglyphArcRotateCamera
  106624. */
  106625. getClassName(): string;
  106626. }
  106627. }
  106628. declare module BABYLON {
  106629. /**
  106630. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106632. */
  106633. export class AnaglyphFreeCamera extends FreeCamera {
  106634. /**
  106635. * Creates a new AnaglyphFreeCamera
  106636. * @param name defines camera name
  106637. * @param position defines initial position
  106638. * @param interaxialDistance defines distance between each color axis
  106639. * @param scene defines the hosting scene
  106640. */
  106641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106642. /**
  106643. * Gets camera class name
  106644. * @returns AnaglyphFreeCamera
  106645. */
  106646. getClassName(): string;
  106647. }
  106648. }
  106649. declare module BABYLON {
  106650. /**
  106651. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106652. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106653. */
  106654. export class AnaglyphGamepadCamera extends GamepadCamera {
  106655. /**
  106656. * Creates a new AnaglyphGamepadCamera
  106657. * @param name defines camera name
  106658. * @param position defines initial position
  106659. * @param interaxialDistance defines distance between each color axis
  106660. * @param scene defines the hosting scene
  106661. */
  106662. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106663. /**
  106664. * Gets camera class name
  106665. * @returns AnaglyphGamepadCamera
  106666. */
  106667. getClassName(): string;
  106668. }
  106669. }
  106670. declare module BABYLON {
  106671. /**
  106672. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106673. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106674. */
  106675. export class AnaglyphUniversalCamera extends UniversalCamera {
  106676. /**
  106677. * Creates a new AnaglyphUniversalCamera
  106678. * @param name defines camera name
  106679. * @param position defines initial position
  106680. * @param interaxialDistance defines distance between each color axis
  106681. * @param scene defines the hosting scene
  106682. */
  106683. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106684. /**
  106685. * Gets camera class name
  106686. * @returns AnaglyphUniversalCamera
  106687. */
  106688. getClassName(): string;
  106689. }
  106690. }
  106691. declare module BABYLON {
  106692. /** @hidden */
  106693. export var stereoscopicInterlacePixelShader: {
  106694. name: string;
  106695. shader: string;
  106696. };
  106697. }
  106698. declare module BABYLON {
  106699. /**
  106700. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106701. */
  106702. export class StereoscopicInterlacePostProcess extends PostProcess {
  106703. private _stepSize;
  106704. private _passedProcess;
  106705. /**
  106706. * Initializes a StereoscopicInterlacePostProcess
  106707. * @param name The name of the effect.
  106708. * @param rigCameras The rig cameras to be appled to the post process
  106709. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106711. * @param engine The engine which the post process will be applied. (default: current engine)
  106712. * @param reusable If the post process can be reused on the same frame. (default: false)
  106713. */
  106714. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106715. }
  106716. }
  106717. declare module BABYLON {
  106718. /**
  106719. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106720. * @see http://doc.babylonjs.com/features/cameras
  106721. */
  106722. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106723. /**
  106724. * Creates a new StereoscopicArcRotateCamera
  106725. * @param name defines camera name
  106726. * @param alpha defines alpha angle (in radians)
  106727. * @param beta defines beta angle (in radians)
  106728. * @param radius defines radius
  106729. * @param target defines camera target
  106730. * @param interaxialDistance defines distance between each color axis
  106731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106732. * @param scene defines the hosting scene
  106733. */
  106734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106735. /**
  106736. * Gets camera class name
  106737. * @returns StereoscopicArcRotateCamera
  106738. */
  106739. getClassName(): string;
  106740. }
  106741. }
  106742. declare module BABYLON {
  106743. /**
  106744. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106745. * @see http://doc.babylonjs.com/features/cameras
  106746. */
  106747. export class StereoscopicFreeCamera extends FreeCamera {
  106748. /**
  106749. * Creates a new StereoscopicFreeCamera
  106750. * @param name defines camera name
  106751. * @param position defines initial position
  106752. * @param interaxialDistance defines distance between each color axis
  106753. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106754. * @param scene defines the hosting scene
  106755. */
  106756. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106757. /**
  106758. * Gets camera class name
  106759. * @returns StereoscopicFreeCamera
  106760. */
  106761. getClassName(): string;
  106762. }
  106763. }
  106764. declare module BABYLON {
  106765. /**
  106766. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106767. * @see http://doc.babylonjs.com/features/cameras
  106768. */
  106769. export class StereoscopicGamepadCamera extends GamepadCamera {
  106770. /**
  106771. * Creates a new StereoscopicGamepadCamera
  106772. * @param name defines camera name
  106773. * @param position defines initial position
  106774. * @param interaxialDistance defines distance between each color axis
  106775. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106776. * @param scene defines the hosting scene
  106777. */
  106778. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106779. /**
  106780. * Gets camera class name
  106781. * @returns StereoscopicGamepadCamera
  106782. */
  106783. getClassName(): string;
  106784. }
  106785. }
  106786. declare module BABYLON {
  106787. /**
  106788. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106789. * @see http://doc.babylonjs.com/features/cameras
  106790. */
  106791. export class StereoscopicUniversalCamera extends UniversalCamera {
  106792. /**
  106793. * Creates a new StereoscopicUniversalCamera
  106794. * @param name defines camera name
  106795. * @param position defines initial position
  106796. * @param interaxialDistance defines distance between each color axis
  106797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106798. * @param scene defines the hosting scene
  106799. */
  106800. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106801. /**
  106802. * Gets camera class name
  106803. * @returns StereoscopicUniversalCamera
  106804. */
  106805. getClassName(): string;
  106806. }
  106807. }
  106808. declare module BABYLON {
  106809. /**
  106810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106814. */
  106815. export class VirtualJoysticksCamera extends FreeCamera {
  106816. /**
  106817. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106818. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106819. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106820. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106821. * @param name Define the name of the camera in the scene
  106822. * @param position Define the start position of the camera in the scene
  106823. * @param scene Define the scene the camera belongs to
  106824. */
  106825. constructor(name: string, position: Vector3, scene: Scene);
  106826. /**
  106827. * Gets the current object class name.
  106828. * @return the class name
  106829. */
  106830. getClassName(): string;
  106831. }
  106832. }
  106833. declare module BABYLON {
  106834. /**
  106835. * This represents all the required metrics to create a VR camera.
  106836. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106837. */
  106838. export class VRCameraMetrics {
  106839. /**
  106840. * Define the horizontal resolution off the screen.
  106841. */
  106842. hResolution: number;
  106843. /**
  106844. * Define the vertical resolution off the screen.
  106845. */
  106846. vResolution: number;
  106847. /**
  106848. * Define the horizontal screen size.
  106849. */
  106850. hScreenSize: number;
  106851. /**
  106852. * Define the vertical screen size.
  106853. */
  106854. vScreenSize: number;
  106855. /**
  106856. * Define the vertical screen center position.
  106857. */
  106858. vScreenCenter: number;
  106859. /**
  106860. * Define the distance of the eyes to the screen.
  106861. */
  106862. eyeToScreenDistance: number;
  106863. /**
  106864. * Define the distance between both lenses
  106865. */
  106866. lensSeparationDistance: number;
  106867. /**
  106868. * Define the distance between both viewer's eyes.
  106869. */
  106870. interpupillaryDistance: number;
  106871. /**
  106872. * Define the distortion factor of the VR postprocess.
  106873. * Please, touch with care.
  106874. */
  106875. distortionK: number[];
  106876. /**
  106877. * Define the chromatic aberration correction factors for the VR post process.
  106878. */
  106879. chromaAbCorrection: number[];
  106880. /**
  106881. * Define the scale factor of the post process.
  106882. * The smaller the better but the slower.
  106883. */
  106884. postProcessScaleFactor: number;
  106885. /**
  106886. * Define an offset for the lens center.
  106887. */
  106888. lensCenterOffset: number;
  106889. /**
  106890. * Define if the current vr camera should compensate the distortion of the lense or not.
  106891. */
  106892. compensateDistortion: boolean;
  106893. /**
  106894. * Defines if multiview should be enabled when rendering (Default: false)
  106895. */
  106896. multiviewEnabled: boolean;
  106897. /**
  106898. * Gets the rendering aspect ratio based on the provided resolutions.
  106899. */
  106900. readonly aspectRatio: number;
  106901. /**
  106902. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106903. */
  106904. readonly aspectRatioFov: number;
  106905. /**
  106906. * @hidden
  106907. */
  106908. readonly leftHMatrix: Matrix;
  106909. /**
  106910. * @hidden
  106911. */
  106912. readonly rightHMatrix: Matrix;
  106913. /**
  106914. * @hidden
  106915. */
  106916. readonly leftPreViewMatrix: Matrix;
  106917. /**
  106918. * @hidden
  106919. */
  106920. readonly rightPreViewMatrix: Matrix;
  106921. /**
  106922. * Get the default VRMetrics based on the most generic setup.
  106923. * @returns the default vr metrics
  106924. */
  106925. static GetDefault(): VRCameraMetrics;
  106926. }
  106927. }
  106928. declare module BABYLON {
  106929. /** @hidden */
  106930. export var vrDistortionCorrectionPixelShader: {
  106931. name: string;
  106932. shader: string;
  106933. };
  106934. }
  106935. declare module BABYLON {
  106936. /**
  106937. * VRDistortionCorrectionPostProcess used for mobile VR
  106938. */
  106939. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106940. private _isRightEye;
  106941. private _distortionFactors;
  106942. private _postProcessScaleFactor;
  106943. private _lensCenterOffset;
  106944. private _scaleIn;
  106945. private _scaleFactor;
  106946. private _lensCenter;
  106947. /**
  106948. * Initializes the VRDistortionCorrectionPostProcess
  106949. * @param name The name of the effect.
  106950. * @param camera The camera to apply the render pass to.
  106951. * @param isRightEye If this is for the right eye distortion
  106952. * @param vrMetrics All the required metrics for the VR camera
  106953. */
  106954. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106955. }
  106956. }
  106957. declare module BABYLON {
  106958. /**
  106959. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106960. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106961. */
  106962. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106963. /**
  106964. * Creates a new VRDeviceOrientationArcRotateCamera
  106965. * @param name defines camera name
  106966. * @param alpha defines the camera rotation along the logitudinal axis
  106967. * @param beta defines the camera rotation along the latitudinal axis
  106968. * @param radius defines the camera distance from its target
  106969. * @param target defines the camera target
  106970. * @param scene defines the scene the camera belongs to
  106971. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106972. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106973. */
  106974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106975. /**
  106976. * Gets camera class name
  106977. * @returns VRDeviceOrientationArcRotateCamera
  106978. */
  106979. getClassName(): string;
  106980. }
  106981. }
  106982. declare module BABYLON {
  106983. /**
  106984. * Camera used to simulate VR rendering (based on FreeCamera)
  106985. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106986. */
  106987. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106988. /**
  106989. * Creates a new VRDeviceOrientationFreeCamera
  106990. * @param name defines camera name
  106991. * @param position defines the start position of the camera
  106992. * @param scene defines the scene the camera belongs to
  106993. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106994. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106995. */
  106996. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106997. /**
  106998. * Gets camera class name
  106999. * @returns VRDeviceOrientationFreeCamera
  107000. */
  107001. getClassName(): string;
  107002. }
  107003. }
  107004. declare module BABYLON {
  107005. /**
  107006. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107007. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107008. */
  107009. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107010. /**
  107011. * Creates a new VRDeviceOrientationGamepadCamera
  107012. * @param name defines camera name
  107013. * @param position defines the start position of the camera
  107014. * @param scene defines the scene the camera belongs to
  107015. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107016. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107017. */
  107018. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107019. /**
  107020. * Gets camera class name
  107021. * @returns VRDeviceOrientationGamepadCamera
  107022. */
  107023. getClassName(): string;
  107024. }
  107025. }
  107026. declare module BABYLON {
  107027. /**
  107028. * Base class of materials working in push mode in babylon JS
  107029. * @hidden
  107030. */
  107031. export class PushMaterial extends Material {
  107032. protected _activeEffect: Effect;
  107033. protected _normalMatrix: Matrix;
  107034. /**
  107035. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107036. * This means that the material can keep using a previous shader while a new one is being compiled.
  107037. * This is mostly used when shader parallel compilation is supported (true by default)
  107038. */
  107039. allowShaderHotSwapping: boolean;
  107040. constructor(name: string, scene: Scene);
  107041. getEffect(): Effect;
  107042. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107043. /**
  107044. * Binds the given world matrix to the active effect
  107045. *
  107046. * @param world the matrix to bind
  107047. */
  107048. bindOnlyWorldMatrix(world: Matrix): void;
  107049. /**
  107050. * Binds the given normal matrix to the active effect
  107051. *
  107052. * @param normalMatrix the matrix to bind
  107053. */
  107054. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107055. bind(world: Matrix, mesh?: Mesh): void;
  107056. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107057. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107058. }
  107059. }
  107060. declare module BABYLON {
  107061. /**
  107062. * This groups all the flags used to control the materials channel.
  107063. */
  107064. export class MaterialFlags {
  107065. private static _DiffuseTextureEnabled;
  107066. /**
  107067. * Are diffuse textures enabled in the application.
  107068. */
  107069. static DiffuseTextureEnabled: boolean;
  107070. private static _AmbientTextureEnabled;
  107071. /**
  107072. * Are ambient textures enabled in the application.
  107073. */
  107074. static AmbientTextureEnabled: boolean;
  107075. private static _OpacityTextureEnabled;
  107076. /**
  107077. * Are opacity textures enabled in the application.
  107078. */
  107079. static OpacityTextureEnabled: boolean;
  107080. private static _ReflectionTextureEnabled;
  107081. /**
  107082. * Are reflection textures enabled in the application.
  107083. */
  107084. static ReflectionTextureEnabled: boolean;
  107085. private static _EmissiveTextureEnabled;
  107086. /**
  107087. * Are emissive textures enabled in the application.
  107088. */
  107089. static EmissiveTextureEnabled: boolean;
  107090. private static _SpecularTextureEnabled;
  107091. /**
  107092. * Are specular textures enabled in the application.
  107093. */
  107094. static SpecularTextureEnabled: boolean;
  107095. private static _BumpTextureEnabled;
  107096. /**
  107097. * Are bump textures enabled in the application.
  107098. */
  107099. static BumpTextureEnabled: boolean;
  107100. private static _LightmapTextureEnabled;
  107101. /**
  107102. * Are lightmap textures enabled in the application.
  107103. */
  107104. static LightmapTextureEnabled: boolean;
  107105. private static _RefractionTextureEnabled;
  107106. /**
  107107. * Are refraction textures enabled in the application.
  107108. */
  107109. static RefractionTextureEnabled: boolean;
  107110. private static _ColorGradingTextureEnabled;
  107111. /**
  107112. * Are color grading textures enabled in the application.
  107113. */
  107114. static ColorGradingTextureEnabled: boolean;
  107115. private static _FresnelEnabled;
  107116. /**
  107117. * Are fresnels enabled in the application.
  107118. */
  107119. static FresnelEnabled: boolean;
  107120. private static _ClearCoatTextureEnabled;
  107121. /**
  107122. * Are clear coat textures enabled in the application.
  107123. */
  107124. static ClearCoatTextureEnabled: boolean;
  107125. private static _ClearCoatBumpTextureEnabled;
  107126. /**
  107127. * Are clear coat bump textures enabled in the application.
  107128. */
  107129. static ClearCoatBumpTextureEnabled: boolean;
  107130. private static _ClearCoatTintTextureEnabled;
  107131. /**
  107132. * Are clear coat tint textures enabled in the application.
  107133. */
  107134. static ClearCoatTintTextureEnabled: boolean;
  107135. private static _SheenTextureEnabled;
  107136. /**
  107137. * Are sheen textures enabled in the application.
  107138. */
  107139. static SheenTextureEnabled: boolean;
  107140. private static _AnisotropicTextureEnabled;
  107141. /**
  107142. * Are anisotropic textures enabled in the application.
  107143. */
  107144. static AnisotropicTextureEnabled: boolean;
  107145. private static _ThicknessTextureEnabled;
  107146. /**
  107147. * Are thickness textures enabled in the application.
  107148. */
  107149. static ThicknessTextureEnabled: boolean;
  107150. }
  107151. }
  107152. declare module BABYLON {
  107153. /** @hidden */
  107154. export var defaultFragmentDeclaration: {
  107155. name: string;
  107156. shader: string;
  107157. };
  107158. }
  107159. declare module BABYLON {
  107160. /** @hidden */
  107161. export var defaultUboDeclaration: {
  107162. name: string;
  107163. shader: string;
  107164. };
  107165. }
  107166. declare module BABYLON {
  107167. /** @hidden */
  107168. export var lightFragmentDeclaration: {
  107169. name: string;
  107170. shader: string;
  107171. };
  107172. }
  107173. declare module BABYLON {
  107174. /** @hidden */
  107175. export var lightUboDeclaration: {
  107176. name: string;
  107177. shader: string;
  107178. };
  107179. }
  107180. declare module BABYLON {
  107181. /** @hidden */
  107182. export var lightsFragmentFunctions: {
  107183. name: string;
  107184. shader: string;
  107185. };
  107186. }
  107187. declare module BABYLON {
  107188. /** @hidden */
  107189. export var shadowsFragmentFunctions: {
  107190. name: string;
  107191. shader: string;
  107192. };
  107193. }
  107194. declare module BABYLON {
  107195. /** @hidden */
  107196. export var fresnelFunction: {
  107197. name: string;
  107198. shader: string;
  107199. };
  107200. }
  107201. declare module BABYLON {
  107202. /** @hidden */
  107203. export var reflectionFunction: {
  107204. name: string;
  107205. shader: string;
  107206. };
  107207. }
  107208. declare module BABYLON {
  107209. /** @hidden */
  107210. export var bumpFragmentFunctions: {
  107211. name: string;
  107212. shader: string;
  107213. };
  107214. }
  107215. declare module BABYLON {
  107216. /** @hidden */
  107217. export var logDepthDeclaration: {
  107218. name: string;
  107219. shader: string;
  107220. };
  107221. }
  107222. declare module BABYLON {
  107223. /** @hidden */
  107224. export var bumpFragment: {
  107225. name: string;
  107226. shader: string;
  107227. };
  107228. }
  107229. declare module BABYLON {
  107230. /** @hidden */
  107231. export var depthPrePass: {
  107232. name: string;
  107233. shader: string;
  107234. };
  107235. }
  107236. declare module BABYLON {
  107237. /** @hidden */
  107238. export var lightFragment: {
  107239. name: string;
  107240. shader: string;
  107241. };
  107242. }
  107243. declare module BABYLON {
  107244. /** @hidden */
  107245. export var logDepthFragment: {
  107246. name: string;
  107247. shader: string;
  107248. };
  107249. }
  107250. declare module BABYLON {
  107251. /** @hidden */
  107252. export var defaultPixelShader: {
  107253. name: string;
  107254. shader: string;
  107255. };
  107256. }
  107257. declare module BABYLON {
  107258. /** @hidden */
  107259. export var defaultVertexDeclaration: {
  107260. name: string;
  107261. shader: string;
  107262. };
  107263. }
  107264. declare module BABYLON {
  107265. /** @hidden */
  107266. export var bumpVertexDeclaration: {
  107267. name: string;
  107268. shader: string;
  107269. };
  107270. }
  107271. declare module BABYLON {
  107272. /** @hidden */
  107273. export var bumpVertex: {
  107274. name: string;
  107275. shader: string;
  107276. };
  107277. }
  107278. declare module BABYLON {
  107279. /** @hidden */
  107280. export var fogVertex: {
  107281. name: string;
  107282. shader: string;
  107283. };
  107284. }
  107285. declare module BABYLON {
  107286. /** @hidden */
  107287. export var shadowsVertex: {
  107288. name: string;
  107289. shader: string;
  107290. };
  107291. }
  107292. declare module BABYLON {
  107293. /** @hidden */
  107294. export var pointCloudVertex: {
  107295. name: string;
  107296. shader: string;
  107297. };
  107298. }
  107299. declare module BABYLON {
  107300. /** @hidden */
  107301. export var logDepthVertex: {
  107302. name: string;
  107303. shader: string;
  107304. };
  107305. }
  107306. declare module BABYLON {
  107307. /** @hidden */
  107308. export var defaultVertexShader: {
  107309. name: string;
  107310. shader: string;
  107311. };
  107312. }
  107313. declare module BABYLON {
  107314. /** @hidden */
  107315. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107316. MAINUV1: boolean;
  107317. MAINUV2: boolean;
  107318. DIFFUSE: boolean;
  107319. DIFFUSEDIRECTUV: number;
  107320. AMBIENT: boolean;
  107321. AMBIENTDIRECTUV: number;
  107322. OPACITY: boolean;
  107323. OPACITYDIRECTUV: number;
  107324. OPACITYRGB: boolean;
  107325. REFLECTION: boolean;
  107326. EMISSIVE: boolean;
  107327. EMISSIVEDIRECTUV: number;
  107328. SPECULAR: boolean;
  107329. SPECULARDIRECTUV: number;
  107330. BUMP: boolean;
  107331. BUMPDIRECTUV: number;
  107332. PARALLAX: boolean;
  107333. PARALLAXOCCLUSION: boolean;
  107334. SPECULAROVERALPHA: boolean;
  107335. CLIPPLANE: boolean;
  107336. CLIPPLANE2: boolean;
  107337. CLIPPLANE3: boolean;
  107338. CLIPPLANE4: boolean;
  107339. ALPHATEST: boolean;
  107340. DEPTHPREPASS: boolean;
  107341. ALPHAFROMDIFFUSE: boolean;
  107342. POINTSIZE: boolean;
  107343. FOG: boolean;
  107344. SPECULARTERM: boolean;
  107345. DIFFUSEFRESNEL: boolean;
  107346. OPACITYFRESNEL: boolean;
  107347. REFLECTIONFRESNEL: boolean;
  107348. REFRACTIONFRESNEL: boolean;
  107349. EMISSIVEFRESNEL: boolean;
  107350. FRESNEL: boolean;
  107351. NORMAL: boolean;
  107352. UV1: boolean;
  107353. UV2: boolean;
  107354. VERTEXCOLOR: boolean;
  107355. VERTEXALPHA: boolean;
  107356. NUM_BONE_INFLUENCERS: number;
  107357. BonesPerMesh: number;
  107358. BONETEXTURE: boolean;
  107359. INSTANCES: boolean;
  107360. GLOSSINESS: boolean;
  107361. ROUGHNESS: boolean;
  107362. EMISSIVEASILLUMINATION: boolean;
  107363. LINKEMISSIVEWITHDIFFUSE: boolean;
  107364. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107365. LIGHTMAP: boolean;
  107366. LIGHTMAPDIRECTUV: number;
  107367. OBJECTSPACE_NORMALMAP: boolean;
  107368. USELIGHTMAPASSHADOWMAP: boolean;
  107369. REFLECTIONMAP_3D: boolean;
  107370. REFLECTIONMAP_SPHERICAL: boolean;
  107371. REFLECTIONMAP_PLANAR: boolean;
  107372. REFLECTIONMAP_CUBIC: boolean;
  107373. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107374. REFLECTIONMAP_PROJECTION: boolean;
  107375. REFLECTIONMAP_SKYBOX: boolean;
  107376. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107377. REFLECTIONMAP_EXPLICIT: boolean;
  107378. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107379. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107380. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107381. INVERTCUBICMAP: boolean;
  107382. LOGARITHMICDEPTH: boolean;
  107383. REFRACTION: boolean;
  107384. REFRACTIONMAP_3D: boolean;
  107385. REFLECTIONOVERALPHA: boolean;
  107386. TWOSIDEDLIGHTING: boolean;
  107387. SHADOWFLOAT: boolean;
  107388. MORPHTARGETS: boolean;
  107389. MORPHTARGETS_NORMAL: boolean;
  107390. MORPHTARGETS_TANGENT: boolean;
  107391. MORPHTARGETS_UV: boolean;
  107392. NUM_MORPH_INFLUENCERS: number;
  107393. NONUNIFORMSCALING: boolean;
  107394. PREMULTIPLYALPHA: boolean;
  107395. IMAGEPROCESSING: boolean;
  107396. VIGNETTE: boolean;
  107397. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107398. VIGNETTEBLENDMODEOPAQUE: boolean;
  107399. TONEMAPPING: boolean;
  107400. TONEMAPPING_ACES: boolean;
  107401. CONTRAST: boolean;
  107402. COLORCURVES: boolean;
  107403. COLORGRADING: boolean;
  107404. COLORGRADING3D: boolean;
  107405. SAMPLER3DGREENDEPTH: boolean;
  107406. SAMPLER3DBGRMAP: boolean;
  107407. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107408. MULTIVIEW: boolean;
  107409. /**
  107410. * If the reflection texture on this material is in linear color space
  107411. * @hidden
  107412. */
  107413. IS_REFLECTION_LINEAR: boolean;
  107414. /**
  107415. * If the refraction texture on this material is in linear color space
  107416. * @hidden
  107417. */
  107418. IS_REFRACTION_LINEAR: boolean;
  107419. EXPOSURE: boolean;
  107420. constructor();
  107421. setReflectionMode(modeToEnable: string): void;
  107422. }
  107423. /**
  107424. * This is the default material used in Babylon. It is the best trade off between quality
  107425. * and performances.
  107426. * @see http://doc.babylonjs.com/babylon101/materials
  107427. */
  107428. export class StandardMaterial extends PushMaterial {
  107429. private _diffuseTexture;
  107430. /**
  107431. * The basic texture of the material as viewed under a light.
  107432. */
  107433. diffuseTexture: Nullable<BaseTexture>;
  107434. private _ambientTexture;
  107435. /**
  107436. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107437. */
  107438. ambientTexture: Nullable<BaseTexture>;
  107439. private _opacityTexture;
  107440. /**
  107441. * Define the transparency of the material from a texture.
  107442. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107443. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107444. */
  107445. opacityTexture: Nullable<BaseTexture>;
  107446. private _reflectionTexture;
  107447. /**
  107448. * Define the texture used to display the reflection.
  107449. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107450. */
  107451. reflectionTexture: Nullable<BaseTexture>;
  107452. private _emissiveTexture;
  107453. /**
  107454. * Define texture of the material as if self lit.
  107455. * This will be mixed in the final result even in the absence of light.
  107456. */
  107457. emissiveTexture: Nullable<BaseTexture>;
  107458. private _specularTexture;
  107459. /**
  107460. * Define how the color and intensity of the highlight given by the light in the material.
  107461. */
  107462. specularTexture: Nullable<BaseTexture>;
  107463. private _bumpTexture;
  107464. /**
  107465. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107466. * 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.
  107467. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107468. */
  107469. bumpTexture: Nullable<BaseTexture>;
  107470. private _lightmapTexture;
  107471. /**
  107472. * Complex lighting can be computationally expensive to compute at runtime.
  107473. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107474. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107475. */
  107476. lightmapTexture: Nullable<BaseTexture>;
  107477. private _refractionTexture;
  107478. /**
  107479. * Define the texture used to display the refraction.
  107480. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107481. */
  107482. refractionTexture: Nullable<BaseTexture>;
  107483. /**
  107484. * The color of the material lit by the environmental background lighting.
  107485. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107486. */
  107487. ambientColor: Color3;
  107488. /**
  107489. * The basic color of the material as viewed under a light.
  107490. */
  107491. diffuseColor: Color3;
  107492. /**
  107493. * Define how the color and intensity of the highlight given by the light in the material.
  107494. */
  107495. specularColor: Color3;
  107496. /**
  107497. * Define the color of the material as if self lit.
  107498. * This will be mixed in the final result even in the absence of light.
  107499. */
  107500. emissiveColor: Color3;
  107501. /**
  107502. * Defines how sharp are the highlights in the material.
  107503. * The bigger the value the sharper giving a more glossy feeling to the result.
  107504. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107505. */
  107506. specularPower: number;
  107507. private _useAlphaFromDiffuseTexture;
  107508. /**
  107509. * Does the transparency come from the diffuse texture alpha channel.
  107510. */
  107511. useAlphaFromDiffuseTexture: boolean;
  107512. private _useEmissiveAsIllumination;
  107513. /**
  107514. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107515. */
  107516. useEmissiveAsIllumination: boolean;
  107517. private _linkEmissiveWithDiffuse;
  107518. /**
  107519. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107520. * the emissive level when the final color is close to one.
  107521. */
  107522. linkEmissiveWithDiffuse: boolean;
  107523. private _useSpecularOverAlpha;
  107524. /**
  107525. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107526. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107527. */
  107528. useSpecularOverAlpha: boolean;
  107529. private _useReflectionOverAlpha;
  107530. /**
  107531. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107532. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107533. */
  107534. useReflectionOverAlpha: boolean;
  107535. private _disableLighting;
  107536. /**
  107537. * Does lights from the scene impacts this material.
  107538. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107539. */
  107540. disableLighting: boolean;
  107541. private _useObjectSpaceNormalMap;
  107542. /**
  107543. * Allows using an object space normal map (instead of tangent space).
  107544. */
  107545. useObjectSpaceNormalMap: boolean;
  107546. private _useParallax;
  107547. /**
  107548. * Is parallax enabled or not.
  107549. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107550. */
  107551. useParallax: boolean;
  107552. private _useParallaxOcclusion;
  107553. /**
  107554. * Is parallax occlusion enabled or not.
  107555. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107556. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107557. */
  107558. useParallaxOcclusion: boolean;
  107559. /**
  107560. * 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.
  107561. */
  107562. parallaxScaleBias: number;
  107563. private _roughness;
  107564. /**
  107565. * Helps to define how blurry the reflections should appears in the material.
  107566. */
  107567. roughness: number;
  107568. /**
  107569. * In case of refraction, define the value of the index of refraction.
  107570. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107571. */
  107572. indexOfRefraction: number;
  107573. /**
  107574. * Invert the refraction texture alongside the y axis.
  107575. * It can be useful with procedural textures or probe for instance.
  107576. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107577. */
  107578. invertRefractionY: boolean;
  107579. /**
  107580. * Defines the alpha limits in alpha test mode.
  107581. */
  107582. alphaCutOff: number;
  107583. private _useLightmapAsShadowmap;
  107584. /**
  107585. * In case of light mapping, define whether the map contains light or shadow informations.
  107586. */
  107587. useLightmapAsShadowmap: boolean;
  107588. private _diffuseFresnelParameters;
  107589. /**
  107590. * Define the diffuse fresnel parameters of the material.
  107591. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107592. */
  107593. diffuseFresnelParameters: FresnelParameters;
  107594. private _opacityFresnelParameters;
  107595. /**
  107596. * Define the opacity fresnel parameters of the material.
  107597. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107598. */
  107599. opacityFresnelParameters: FresnelParameters;
  107600. private _reflectionFresnelParameters;
  107601. /**
  107602. * Define the reflection fresnel parameters of the material.
  107603. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107604. */
  107605. reflectionFresnelParameters: FresnelParameters;
  107606. private _refractionFresnelParameters;
  107607. /**
  107608. * Define the refraction fresnel parameters of the material.
  107609. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107610. */
  107611. refractionFresnelParameters: FresnelParameters;
  107612. private _emissiveFresnelParameters;
  107613. /**
  107614. * Define the emissive fresnel parameters of the material.
  107615. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107616. */
  107617. emissiveFresnelParameters: FresnelParameters;
  107618. private _useReflectionFresnelFromSpecular;
  107619. /**
  107620. * If true automatically deducts the fresnels values from the material specularity.
  107621. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107622. */
  107623. useReflectionFresnelFromSpecular: boolean;
  107624. private _useGlossinessFromSpecularMapAlpha;
  107625. /**
  107626. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107627. */
  107628. useGlossinessFromSpecularMapAlpha: boolean;
  107629. private _maxSimultaneousLights;
  107630. /**
  107631. * Defines the maximum number of lights that can be used in the material
  107632. */
  107633. maxSimultaneousLights: number;
  107634. private _invertNormalMapX;
  107635. /**
  107636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107637. */
  107638. invertNormalMapX: boolean;
  107639. private _invertNormalMapY;
  107640. /**
  107641. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107642. */
  107643. invertNormalMapY: boolean;
  107644. private _twoSidedLighting;
  107645. /**
  107646. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107647. */
  107648. twoSidedLighting: boolean;
  107649. /**
  107650. * Default configuration related to image processing available in the standard Material.
  107651. */
  107652. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107653. /**
  107654. * Gets the image processing configuration used either in this material.
  107655. */
  107656. /**
  107657. * Sets the Default image processing configuration used either in the this material.
  107658. *
  107659. * If sets to null, the scene one is in use.
  107660. */
  107661. imageProcessingConfiguration: ImageProcessingConfiguration;
  107662. /**
  107663. * Keep track of the image processing observer to allow dispose and replace.
  107664. */
  107665. private _imageProcessingObserver;
  107666. /**
  107667. * Attaches a new image processing configuration to the Standard Material.
  107668. * @param configuration
  107669. */
  107670. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107671. /**
  107672. * Gets wether the color curves effect is enabled.
  107673. */
  107674. /**
  107675. * Sets wether the color curves effect is enabled.
  107676. */
  107677. cameraColorCurvesEnabled: boolean;
  107678. /**
  107679. * Gets wether the color grading effect is enabled.
  107680. */
  107681. /**
  107682. * Gets wether the color grading effect is enabled.
  107683. */
  107684. cameraColorGradingEnabled: boolean;
  107685. /**
  107686. * Gets wether tonemapping is enabled or not.
  107687. */
  107688. /**
  107689. * Sets wether tonemapping is enabled or not
  107690. */
  107691. cameraToneMappingEnabled: boolean;
  107692. /**
  107693. * The camera exposure used on this material.
  107694. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107695. * This corresponds to a photographic exposure.
  107696. */
  107697. /**
  107698. * The camera exposure used on this material.
  107699. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107700. * This corresponds to a photographic exposure.
  107701. */
  107702. cameraExposure: number;
  107703. /**
  107704. * Gets The camera contrast used on this material.
  107705. */
  107706. /**
  107707. * Sets The camera contrast used on this material.
  107708. */
  107709. cameraContrast: number;
  107710. /**
  107711. * Gets the Color Grading 2D Lookup Texture.
  107712. */
  107713. /**
  107714. * Sets the Color Grading 2D Lookup Texture.
  107715. */
  107716. cameraColorGradingTexture: Nullable<BaseTexture>;
  107717. /**
  107718. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107719. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107720. * 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;
  107721. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107722. */
  107723. /**
  107724. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107725. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107726. * 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;
  107727. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107728. */
  107729. cameraColorCurves: Nullable<ColorCurves>;
  107730. /**
  107731. * Custom callback helping to override the default shader used in the material.
  107732. */
  107733. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107734. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107735. protected _worldViewProjectionMatrix: Matrix;
  107736. protected _globalAmbientColor: Color3;
  107737. protected _useLogarithmicDepth: boolean;
  107738. protected _rebuildInParallel: boolean;
  107739. /**
  107740. * Instantiates a new standard material.
  107741. * This is the default material used in Babylon. It is the best trade off between quality
  107742. * and performances.
  107743. * @see http://doc.babylonjs.com/babylon101/materials
  107744. * @param name Define the name of the material in the scene
  107745. * @param scene Define the scene the material belong to
  107746. */
  107747. constructor(name: string, scene: Scene);
  107748. /**
  107749. * Gets a boolean indicating that current material needs to register RTT
  107750. */
  107751. readonly hasRenderTargetTextures: boolean;
  107752. /**
  107753. * Gets the current class name of the material e.g. "StandardMaterial"
  107754. * Mainly use in serialization.
  107755. * @returns the class name
  107756. */
  107757. getClassName(): string;
  107758. /**
  107759. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107760. * You can try switching to logarithmic depth.
  107761. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107762. */
  107763. useLogarithmicDepth: boolean;
  107764. /**
  107765. * Specifies if the material will require alpha blending
  107766. * @returns a boolean specifying if alpha blending is needed
  107767. */
  107768. needAlphaBlending(): boolean;
  107769. /**
  107770. * Specifies if this material should be rendered in alpha test mode
  107771. * @returns a boolean specifying if an alpha test is needed.
  107772. */
  107773. needAlphaTesting(): boolean;
  107774. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107775. /**
  107776. * Get the texture used for alpha test purpose.
  107777. * @returns the diffuse texture in case of the standard material.
  107778. */
  107779. getAlphaTestTexture(): Nullable<BaseTexture>;
  107780. /**
  107781. * Get if the submesh is ready to be used and all its information available.
  107782. * Child classes can use it to update shaders
  107783. * @param mesh defines the mesh to check
  107784. * @param subMesh defines which submesh to check
  107785. * @param useInstances specifies that instances should be used
  107786. * @returns a boolean indicating that the submesh is ready or not
  107787. */
  107788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107789. /**
  107790. * Builds the material UBO layouts.
  107791. * Used internally during the effect preparation.
  107792. */
  107793. buildUniformLayout(): void;
  107794. /**
  107795. * Unbinds the material from the mesh
  107796. */
  107797. unbind(): void;
  107798. /**
  107799. * Binds the submesh to this material by preparing the effect and shader to draw
  107800. * @param world defines the world transformation matrix
  107801. * @param mesh defines the mesh containing the submesh
  107802. * @param subMesh defines the submesh to bind the material to
  107803. */
  107804. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107805. /**
  107806. * Get the list of animatables in the material.
  107807. * @returns the list of animatables object used in the material
  107808. */
  107809. getAnimatables(): IAnimatable[];
  107810. /**
  107811. * Gets the active textures from the material
  107812. * @returns an array of textures
  107813. */
  107814. getActiveTextures(): BaseTexture[];
  107815. /**
  107816. * Specifies if the material uses a texture
  107817. * @param texture defines the texture to check against the material
  107818. * @returns a boolean specifying if the material uses the texture
  107819. */
  107820. hasTexture(texture: BaseTexture): boolean;
  107821. /**
  107822. * Disposes the material
  107823. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107824. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107825. */
  107826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107827. /**
  107828. * Makes a duplicate of the material, and gives it a new name
  107829. * @param name defines the new name for the duplicated material
  107830. * @returns the cloned material
  107831. */
  107832. clone(name: string): StandardMaterial;
  107833. /**
  107834. * Serializes this material in a JSON representation
  107835. * @returns the serialized material object
  107836. */
  107837. serialize(): any;
  107838. /**
  107839. * Creates a standard material from parsed material data
  107840. * @param source defines the JSON representation of the material
  107841. * @param scene defines the hosting scene
  107842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107843. * @returns a new standard material
  107844. */
  107845. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107846. /**
  107847. * Are diffuse textures enabled in the application.
  107848. */
  107849. static DiffuseTextureEnabled: boolean;
  107850. /**
  107851. * Are ambient textures enabled in the application.
  107852. */
  107853. static AmbientTextureEnabled: boolean;
  107854. /**
  107855. * Are opacity textures enabled in the application.
  107856. */
  107857. static OpacityTextureEnabled: boolean;
  107858. /**
  107859. * Are reflection textures enabled in the application.
  107860. */
  107861. static ReflectionTextureEnabled: boolean;
  107862. /**
  107863. * Are emissive textures enabled in the application.
  107864. */
  107865. static EmissiveTextureEnabled: boolean;
  107866. /**
  107867. * Are specular textures enabled in the application.
  107868. */
  107869. static SpecularTextureEnabled: boolean;
  107870. /**
  107871. * Are bump textures enabled in the application.
  107872. */
  107873. static BumpTextureEnabled: boolean;
  107874. /**
  107875. * Are lightmap textures enabled in the application.
  107876. */
  107877. static LightmapTextureEnabled: boolean;
  107878. /**
  107879. * Are refraction textures enabled in the application.
  107880. */
  107881. static RefractionTextureEnabled: boolean;
  107882. /**
  107883. * Are color grading textures enabled in the application.
  107884. */
  107885. static ColorGradingTextureEnabled: boolean;
  107886. /**
  107887. * Are fresnels enabled in the application.
  107888. */
  107889. static FresnelEnabled: boolean;
  107890. }
  107891. }
  107892. declare module BABYLON {
  107893. /** @hidden */
  107894. export var imageProcessingPixelShader: {
  107895. name: string;
  107896. shader: string;
  107897. };
  107898. }
  107899. declare module BABYLON {
  107900. /**
  107901. * ImageProcessingPostProcess
  107902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107903. */
  107904. export class ImageProcessingPostProcess extends PostProcess {
  107905. /**
  107906. * Default configuration related to image processing available in the PBR Material.
  107907. */
  107908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107909. /**
  107910. * Gets the image processing configuration used either in this material.
  107911. */
  107912. /**
  107913. * Sets the Default image processing configuration used either in the this material.
  107914. *
  107915. * If sets to null, the scene one is in use.
  107916. */
  107917. imageProcessingConfiguration: ImageProcessingConfiguration;
  107918. /**
  107919. * Keep track of the image processing observer to allow dispose and replace.
  107920. */
  107921. private _imageProcessingObserver;
  107922. /**
  107923. * Attaches a new image processing configuration to the PBR Material.
  107924. * @param configuration
  107925. */
  107926. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107927. /**
  107928. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107929. */
  107930. /**
  107931. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107932. */
  107933. colorCurves: Nullable<ColorCurves>;
  107934. /**
  107935. * Gets wether the color curves effect is enabled.
  107936. */
  107937. /**
  107938. * Sets wether the color curves effect is enabled.
  107939. */
  107940. colorCurvesEnabled: boolean;
  107941. /**
  107942. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107943. */
  107944. /**
  107945. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107946. */
  107947. colorGradingTexture: Nullable<BaseTexture>;
  107948. /**
  107949. * Gets wether the color grading effect is enabled.
  107950. */
  107951. /**
  107952. * Gets wether the color grading effect is enabled.
  107953. */
  107954. colorGradingEnabled: boolean;
  107955. /**
  107956. * Gets exposure used in the effect.
  107957. */
  107958. /**
  107959. * Sets exposure used in the effect.
  107960. */
  107961. exposure: number;
  107962. /**
  107963. * Gets wether tonemapping is enabled or not.
  107964. */
  107965. /**
  107966. * Sets wether tonemapping is enabled or not
  107967. */
  107968. toneMappingEnabled: boolean;
  107969. /**
  107970. * Gets the type of tone mapping effect.
  107971. */
  107972. /**
  107973. * Sets the type of tone mapping effect.
  107974. */
  107975. toneMappingType: number;
  107976. /**
  107977. * Gets contrast used in the effect.
  107978. */
  107979. /**
  107980. * Sets contrast used in the effect.
  107981. */
  107982. contrast: number;
  107983. /**
  107984. * Gets Vignette stretch size.
  107985. */
  107986. /**
  107987. * Sets Vignette stretch size.
  107988. */
  107989. vignetteStretch: number;
  107990. /**
  107991. * Gets Vignette centre X Offset.
  107992. */
  107993. /**
  107994. * Sets Vignette centre X Offset.
  107995. */
  107996. vignetteCentreX: number;
  107997. /**
  107998. * Gets Vignette centre Y Offset.
  107999. */
  108000. /**
  108001. * Sets Vignette centre Y Offset.
  108002. */
  108003. vignetteCentreY: number;
  108004. /**
  108005. * Gets Vignette weight or intensity of the vignette effect.
  108006. */
  108007. /**
  108008. * Sets Vignette weight or intensity of the vignette effect.
  108009. */
  108010. vignetteWeight: number;
  108011. /**
  108012. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108013. * if vignetteEnabled is set to true.
  108014. */
  108015. /**
  108016. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108017. * if vignetteEnabled is set to true.
  108018. */
  108019. vignetteColor: Color4;
  108020. /**
  108021. * Gets Camera field of view used by the Vignette effect.
  108022. */
  108023. /**
  108024. * Sets Camera field of view used by the Vignette effect.
  108025. */
  108026. vignetteCameraFov: number;
  108027. /**
  108028. * Gets the vignette blend mode allowing different kind of effect.
  108029. */
  108030. /**
  108031. * Sets the vignette blend mode allowing different kind of effect.
  108032. */
  108033. vignetteBlendMode: number;
  108034. /**
  108035. * Gets wether the vignette effect is enabled.
  108036. */
  108037. /**
  108038. * Sets wether the vignette effect is enabled.
  108039. */
  108040. vignetteEnabled: boolean;
  108041. private _fromLinearSpace;
  108042. /**
  108043. * Gets wether the input of the processing is in Gamma or Linear Space.
  108044. */
  108045. /**
  108046. * Sets wether the input of the processing is in Gamma or Linear Space.
  108047. */
  108048. fromLinearSpace: boolean;
  108049. /**
  108050. * Defines cache preventing GC.
  108051. */
  108052. private _defines;
  108053. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108054. /**
  108055. * "ImageProcessingPostProcess"
  108056. * @returns "ImageProcessingPostProcess"
  108057. */
  108058. getClassName(): string;
  108059. protected _updateParameters(): void;
  108060. dispose(camera?: Camera): void;
  108061. }
  108062. }
  108063. declare module BABYLON {
  108064. /**
  108065. * Class containing static functions to help procedurally build meshes
  108066. */
  108067. export class GroundBuilder {
  108068. /**
  108069. * Creates a ground mesh
  108070. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108071. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108073. * @param name defines the name of the mesh
  108074. * @param options defines the options used to create the mesh
  108075. * @param scene defines the hosting scene
  108076. * @returns the ground mesh
  108077. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108078. */
  108079. static CreateGround(name: string, options: {
  108080. width?: number;
  108081. height?: number;
  108082. subdivisions?: number;
  108083. subdivisionsX?: number;
  108084. subdivisionsY?: number;
  108085. updatable?: boolean;
  108086. }, scene: any): Mesh;
  108087. /**
  108088. * Creates a tiled ground mesh
  108089. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108090. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108091. * * 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
  108092. * * 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
  108093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108094. * @param name defines the name of the mesh
  108095. * @param options defines the options used to create the mesh
  108096. * @param scene defines the hosting scene
  108097. * @returns the tiled ground mesh
  108098. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108099. */
  108100. static CreateTiledGround(name: string, options: {
  108101. xmin: number;
  108102. zmin: number;
  108103. xmax: number;
  108104. zmax: number;
  108105. subdivisions?: {
  108106. w: number;
  108107. h: number;
  108108. };
  108109. precision?: {
  108110. w: number;
  108111. h: number;
  108112. };
  108113. updatable?: boolean;
  108114. }, scene?: Nullable<Scene>): Mesh;
  108115. /**
  108116. * Creates a ground mesh from a height map
  108117. * * The parameter `url` sets the URL of the height map image resource.
  108118. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108119. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108120. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108121. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108122. * * 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.
  108123. * * 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).
  108124. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108126. * @param name defines the name of the mesh
  108127. * @param url defines the url to the height map
  108128. * @param options defines the options used to create the mesh
  108129. * @param scene defines the hosting scene
  108130. * @returns the ground mesh
  108131. * @see https://doc.babylonjs.com/babylon101/height_map
  108132. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108133. */
  108134. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108135. width?: number;
  108136. height?: number;
  108137. subdivisions?: number;
  108138. minHeight?: number;
  108139. maxHeight?: number;
  108140. colorFilter?: Color3;
  108141. alphaFilter?: number;
  108142. updatable?: boolean;
  108143. onReady?: (mesh: GroundMesh) => void;
  108144. }, scene?: Nullable<Scene>): GroundMesh;
  108145. }
  108146. }
  108147. declare module BABYLON {
  108148. /**
  108149. * Class containing static functions to help procedurally build meshes
  108150. */
  108151. export class TorusBuilder {
  108152. /**
  108153. * Creates a torus mesh
  108154. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108155. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108156. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108160. * @param name defines the name of the mesh
  108161. * @param options defines the options used to create the mesh
  108162. * @param scene defines the hosting scene
  108163. * @returns the torus mesh
  108164. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108165. */
  108166. static CreateTorus(name: string, options: {
  108167. diameter?: number;
  108168. thickness?: number;
  108169. tessellation?: number;
  108170. updatable?: boolean;
  108171. sideOrientation?: number;
  108172. frontUVs?: Vector4;
  108173. backUVs?: Vector4;
  108174. }, scene: any): Mesh;
  108175. }
  108176. }
  108177. declare module BABYLON {
  108178. /**
  108179. * Class containing static functions to help procedurally build meshes
  108180. */
  108181. export class CylinderBuilder {
  108182. /**
  108183. * Creates a cylinder or a cone mesh
  108184. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108185. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108186. * * 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.
  108187. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108188. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108189. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108190. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108191. * * 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).
  108192. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108193. * * 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).
  108194. * * 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
  108195. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108196. * * 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
  108197. * * 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.
  108198. * * If `enclose` is false, a ring surface is one element.
  108199. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108200. * * 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
  108201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108204. * @param name defines the name of the mesh
  108205. * @param options defines the options used to create the mesh
  108206. * @param scene defines the hosting scene
  108207. * @returns the cylinder mesh
  108208. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108209. */
  108210. static CreateCylinder(name: string, options: {
  108211. height?: number;
  108212. diameterTop?: number;
  108213. diameterBottom?: number;
  108214. diameter?: number;
  108215. tessellation?: number;
  108216. subdivisions?: number;
  108217. arc?: number;
  108218. faceColors?: Color4[];
  108219. faceUV?: Vector4[];
  108220. updatable?: boolean;
  108221. hasRings?: boolean;
  108222. enclose?: boolean;
  108223. cap?: number;
  108224. sideOrientation?: number;
  108225. frontUVs?: Vector4;
  108226. backUVs?: Vector4;
  108227. }, scene: any): Mesh;
  108228. }
  108229. }
  108230. declare module BABYLON {
  108231. /**
  108232. * Options to modify the vr teleportation behavior.
  108233. */
  108234. export interface VRTeleportationOptions {
  108235. /**
  108236. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108237. */
  108238. floorMeshName?: string;
  108239. /**
  108240. * A list of meshes to be used as the teleportation floor. (default: empty)
  108241. */
  108242. floorMeshes?: Mesh[];
  108243. }
  108244. /**
  108245. * Options to modify the vr experience helper's behavior.
  108246. */
  108247. export interface VRExperienceHelperOptions extends WebVROptions {
  108248. /**
  108249. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108250. */
  108251. createDeviceOrientationCamera?: boolean;
  108252. /**
  108253. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108254. */
  108255. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108256. /**
  108257. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108258. */
  108259. laserToggle?: boolean;
  108260. /**
  108261. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108262. */
  108263. floorMeshes?: Mesh[];
  108264. /**
  108265. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108266. */
  108267. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108268. }
  108269. /**
  108270. * Event containing information after VR has been entered
  108271. */
  108272. export class OnAfterEnteringVRObservableEvent {
  108273. /**
  108274. * If entering vr was successful
  108275. */
  108276. success: boolean;
  108277. }
  108278. /**
  108279. * Helps to quickly add VR support to an existing scene.
  108280. * See http://doc.babylonjs.com/how_to/webvr_helper
  108281. */
  108282. export class VRExperienceHelper {
  108283. /** Options to modify the vr experience helper's behavior. */
  108284. webVROptions: VRExperienceHelperOptions;
  108285. private _scene;
  108286. private _position;
  108287. private _btnVR;
  108288. private _btnVRDisplayed;
  108289. private _webVRsupported;
  108290. private _webVRready;
  108291. private _webVRrequesting;
  108292. private _webVRpresenting;
  108293. private _hasEnteredVR;
  108294. private _fullscreenVRpresenting;
  108295. private _canvas;
  108296. private _webVRCamera;
  108297. private _vrDeviceOrientationCamera;
  108298. private _deviceOrientationCamera;
  108299. private _existingCamera;
  108300. private _onKeyDown;
  108301. private _onVrDisplayPresentChange;
  108302. private _onVRDisplayChanged;
  108303. private _onVRRequestPresentStart;
  108304. private _onVRRequestPresentComplete;
  108305. /**
  108306. * 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)
  108307. */
  108308. enableGazeEvenWhenNoPointerLock: boolean;
  108309. /**
  108310. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108311. */
  108312. exitVROnDoubleTap: boolean;
  108313. /**
  108314. * Observable raised right before entering VR.
  108315. */
  108316. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108317. /**
  108318. * Observable raised when entering VR has completed.
  108319. */
  108320. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108321. /**
  108322. * Observable raised when exiting VR.
  108323. */
  108324. onExitingVRObservable: Observable<VRExperienceHelper>;
  108325. /**
  108326. * Observable raised when controller mesh is loaded.
  108327. */
  108328. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108329. /** Return this.onEnteringVRObservable
  108330. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108331. */
  108332. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108333. /** Return this.onExitingVRObservable
  108334. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108335. */
  108336. readonly onExitingVR: Observable<VRExperienceHelper>;
  108337. /** Return this.onControllerMeshLoadedObservable
  108338. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108339. */
  108340. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108341. private _rayLength;
  108342. private _useCustomVRButton;
  108343. private _teleportationRequested;
  108344. private _teleportActive;
  108345. private _floorMeshName;
  108346. private _floorMeshesCollection;
  108347. private _rotationAllowed;
  108348. private _teleportBackwardsVector;
  108349. private _teleportationTarget;
  108350. private _isDefaultTeleportationTarget;
  108351. private _postProcessMove;
  108352. private _teleportationFillColor;
  108353. private _teleportationBorderColor;
  108354. private _rotationAngle;
  108355. private _haloCenter;
  108356. private _cameraGazer;
  108357. private _padSensibilityUp;
  108358. private _padSensibilityDown;
  108359. private _leftController;
  108360. private _rightController;
  108361. /**
  108362. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108363. */
  108364. onNewMeshSelected: Observable<AbstractMesh>;
  108365. /**
  108366. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108367. * This observable will provide the mesh and the controller used to select the mesh
  108368. */
  108369. onMeshSelectedWithController: Observable<{
  108370. mesh: AbstractMesh;
  108371. controller: WebVRController;
  108372. }>;
  108373. /**
  108374. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108375. */
  108376. onNewMeshPicked: Observable<PickingInfo>;
  108377. private _circleEase;
  108378. /**
  108379. * Observable raised before camera teleportation
  108380. */
  108381. onBeforeCameraTeleport: Observable<Vector3>;
  108382. /**
  108383. * Observable raised after camera teleportation
  108384. */
  108385. onAfterCameraTeleport: Observable<Vector3>;
  108386. /**
  108387. * Observable raised when current selected mesh gets unselected
  108388. */
  108389. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108390. private _raySelectionPredicate;
  108391. /**
  108392. * To be optionaly changed by user to define custom ray selection
  108393. */
  108394. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108395. /**
  108396. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108397. */
  108398. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108399. /**
  108400. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108401. */
  108402. teleportationEnabled: boolean;
  108403. private _defaultHeight;
  108404. private _teleportationInitialized;
  108405. private _interactionsEnabled;
  108406. private _interactionsRequested;
  108407. private _displayGaze;
  108408. private _displayLaserPointer;
  108409. /**
  108410. * The mesh used to display where the user is going to teleport.
  108411. */
  108412. /**
  108413. * Sets the mesh to be used to display where the user is going to teleport.
  108414. */
  108415. teleportationTarget: Mesh;
  108416. /**
  108417. * 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
  108418. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108419. * See http://doc.babylonjs.com/resources/baking_transformations
  108420. */
  108421. gazeTrackerMesh: Mesh;
  108422. /**
  108423. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108424. */
  108425. updateGazeTrackerScale: boolean;
  108426. /**
  108427. * If the gaze trackers color should be updated when selecting meshes
  108428. */
  108429. updateGazeTrackerColor: boolean;
  108430. /**
  108431. * If the controller laser color should be updated when selecting meshes
  108432. */
  108433. updateControllerLaserColor: boolean;
  108434. /**
  108435. * The gaze tracking mesh corresponding to the left controller
  108436. */
  108437. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108438. /**
  108439. * The gaze tracking mesh corresponding to the right controller
  108440. */
  108441. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108442. /**
  108443. * If the ray of the gaze should be displayed.
  108444. */
  108445. /**
  108446. * Sets if the ray of the gaze should be displayed.
  108447. */
  108448. displayGaze: boolean;
  108449. /**
  108450. * If the ray of the LaserPointer should be displayed.
  108451. */
  108452. /**
  108453. * Sets if the ray of the LaserPointer should be displayed.
  108454. */
  108455. displayLaserPointer: boolean;
  108456. /**
  108457. * The deviceOrientationCamera used as the camera when not in VR.
  108458. */
  108459. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108460. /**
  108461. * Based on the current WebVR support, returns the current VR camera used.
  108462. */
  108463. readonly currentVRCamera: Nullable<Camera>;
  108464. /**
  108465. * The webVRCamera which is used when in VR.
  108466. */
  108467. readonly webVRCamera: WebVRFreeCamera;
  108468. /**
  108469. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108470. */
  108471. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108472. /**
  108473. * The html button that is used to trigger entering into VR.
  108474. */
  108475. readonly vrButton: Nullable<HTMLButtonElement>;
  108476. private readonly _teleportationRequestInitiated;
  108477. /**
  108478. * Defines wether or not Pointer lock should be requested when switching to
  108479. * full screen.
  108480. */
  108481. requestPointerLockOnFullScreen: boolean;
  108482. /**
  108483. * Instantiates a VRExperienceHelper.
  108484. * Helps to quickly add VR support to an existing scene.
  108485. * @param scene The scene the VRExperienceHelper belongs to.
  108486. * @param webVROptions Options to modify the vr experience helper's behavior.
  108487. */
  108488. constructor(scene: Scene,
  108489. /** Options to modify the vr experience helper's behavior. */
  108490. webVROptions?: VRExperienceHelperOptions);
  108491. private _onDefaultMeshLoaded;
  108492. private _onResize;
  108493. private _onFullscreenChange;
  108494. /**
  108495. * Gets a value indicating if we are currently in VR mode.
  108496. */
  108497. readonly isInVRMode: boolean;
  108498. private onVrDisplayPresentChange;
  108499. private onVRDisplayChanged;
  108500. private moveButtonToBottomRight;
  108501. private displayVRButton;
  108502. private updateButtonVisibility;
  108503. private _cachedAngularSensibility;
  108504. /**
  108505. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108506. * Otherwise, will use the fullscreen API.
  108507. */
  108508. enterVR(): void;
  108509. /**
  108510. * Attempt to exit VR, or fullscreen.
  108511. */
  108512. exitVR(): void;
  108513. /**
  108514. * The position of the vr experience helper.
  108515. */
  108516. /**
  108517. * Sets the position of the vr experience helper.
  108518. */
  108519. position: Vector3;
  108520. /**
  108521. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108522. */
  108523. enableInteractions(): void;
  108524. private readonly _noControllerIsActive;
  108525. private beforeRender;
  108526. private _isTeleportationFloor;
  108527. /**
  108528. * Adds a floor mesh to be used for teleportation.
  108529. * @param floorMesh the mesh to be used for teleportation.
  108530. */
  108531. addFloorMesh(floorMesh: Mesh): void;
  108532. /**
  108533. * Removes a floor mesh from being used for teleportation.
  108534. * @param floorMesh the mesh to be removed.
  108535. */
  108536. removeFloorMesh(floorMesh: Mesh): void;
  108537. /**
  108538. * Enables interactions and teleportation using the VR controllers and gaze.
  108539. * @param vrTeleportationOptions options to modify teleportation behavior.
  108540. */
  108541. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108542. private _onNewGamepadConnected;
  108543. private _tryEnableInteractionOnController;
  108544. private _onNewGamepadDisconnected;
  108545. private _enableInteractionOnController;
  108546. private _checkTeleportWithRay;
  108547. private _checkRotate;
  108548. private _checkTeleportBackwards;
  108549. private _enableTeleportationOnController;
  108550. private _createTeleportationCircles;
  108551. private _displayTeleportationTarget;
  108552. private _hideTeleportationTarget;
  108553. private _rotateCamera;
  108554. private _moveTeleportationSelectorTo;
  108555. private _workingVector;
  108556. private _workingQuaternion;
  108557. private _workingMatrix;
  108558. /**
  108559. * Teleports the users feet to the desired location
  108560. * @param location The location where the user's feet should be placed
  108561. */
  108562. teleportCamera(location: Vector3): void;
  108563. private _convertNormalToDirectionOfRay;
  108564. private _castRayAndSelectObject;
  108565. private _notifySelectedMeshUnselected;
  108566. /**
  108567. * Sets the color of the laser ray from the vr controllers.
  108568. * @param color new color for the ray.
  108569. */
  108570. changeLaserColor(color: Color3): void;
  108571. /**
  108572. * Sets the color of the ray from the vr headsets gaze.
  108573. * @param color new color for the ray.
  108574. */
  108575. changeGazeColor(color: Color3): void;
  108576. /**
  108577. * Exits VR and disposes of the vr experience helper
  108578. */
  108579. dispose(): void;
  108580. /**
  108581. * Gets the name of the VRExperienceHelper class
  108582. * @returns "VRExperienceHelper"
  108583. */
  108584. getClassName(): string;
  108585. }
  108586. }
  108587. declare module BABYLON {
  108588. /**
  108589. * Manages an XRSession to work with Babylon's engine
  108590. * @see https://doc.babylonjs.com/how_to/webxr
  108591. */
  108592. export class WebXRSessionManager implements IDisposable {
  108593. private scene;
  108594. /**
  108595. * Fires every time a new xrFrame arrives which can be used to update the camera
  108596. */
  108597. onXRFrameObservable: Observable<any>;
  108598. /**
  108599. * Fires when the xr session is ended either by the device or manually done
  108600. */
  108601. onXRSessionEnded: Observable<any>;
  108602. /**
  108603. * Underlying xr session
  108604. */
  108605. session: XRSession;
  108606. /**
  108607. * Type of reference space used when creating the session
  108608. */
  108609. referenceSpace: XRReferenceSpace;
  108610. /** @hidden */
  108611. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108612. /**
  108613. * Current XR frame
  108614. */
  108615. currentFrame: Nullable<XRFrame>;
  108616. private _xrNavigator;
  108617. private baseLayer;
  108618. /**
  108619. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108620. * @param scene The scene which the session should be created for
  108621. */
  108622. constructor(scene: Scene);
  108623. /**
  108624. * Initializes the manager
  108625. * After initialization enterXR can be called to start an XR session
  108626. * @returns Promise which resolves after it is initialized
  108627. */
  108628. initializeAsync(): Promise<void>;
  108629. /**
  108630. * Initializes an xr session
  108631. * @param xrSessionMode mode to initialize
  108632. * @returns a promise which will resolve once the session has been initialized
  108633. */
  108634. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108635. /**
  108636. * Sets the reference space on the xr session
  108637. * @param referenceSpace space to set
  108638. * @returns a promise that will resolve once the reference space has been set
  108639. */
  108640. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108641. /**
  108642. * Updates the render state of the session
  108643. * @param state state to set
  108644. * @returns a promise that resolves once the render state has been updated
  108645. */
  108646. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108647. /**
  108648. * Starts rendering to the xr layer
  108649. * @returns a promise that will resolve once rendering has started
  108650. */
  108651. startRenderingToXRAsync(): Promise<void>;
  108652. /**
  108653. * Stops the xrSession and restores the renderloop
  108654. * @returns Promise which resolves after it exits XR
  108655. */
  108656. exitXRAsync(): Promise<unknown>;
  108657. /**
  108658. * Checks if a session would be supported for the creation options specified
  108659. * @param sessionMode session mode to check if supported eg. immersive-vr
  108660. * @returns true if supported
  108661. */
  108662. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108663. /**
  108664. * @hidden
  108665. * Converts the render layer of xrSession to a render target
  108666. * @param session session to create render target for
  108667. * @param scene scene the new render target should be created for
  108668. */
  108669. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108670. /**
  108671. * Disposes of the session manager
  108672. */
  108673. dispose(): void;
  108674. }
  108675. }
  108676. declare module BABYLON {
  108677. /**
  108678. * WebXR Camera which holds the views for the xrSession
  108679. * @see https://doc.babylonjs.com/how_to/webxr
  108680. */
  108681. export class WebXRCamera extends FreeCamera {
  108682. private static _TmpMatrix;
  108683. /**
  108684. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108685. * @param name the name of the camera
  108686. * @param scene the scene to add the camera to
  108687. */
  108688. constructor(name: string, scene: Scene);
  108689. private _updateNumberOfRigCameras;
  108690. /** @hidden */
  108691. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108692. /**
  108693. * Updates the cameras position from the current pose information of the XR session
  108694. * @param xrSessionManager the session containing pose information
  108695. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108696. */
  108697. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108698. }
  108699. }
  108700. declare module BABYLON {
  108701. /**
  108702. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108703. */
  108704. export class WebXRManagedOutputCanvas implements IDisposable {
  108705. private helper;
  108706. private _canvas;
  108707. /**
  108708. * xrpresent context of the canvas which can be used to display/mirror xr content
  108709. */
  108710. canvasContext: WebGLRenderingContext;
  108711. /**
  108712. * xr layer for the canvas
  108713. */
  108714. xrLayer: Nullable<XRWebGLLayer>;
  108715. /**
  108716. * Initializes the xr layer for the session
  108717. * @param xrSession xr session
  108718. * @returns a promise that will resolve once the XR Layer has been created
  108719. */
  108720. initializeXRLayerAsync(xrSession: any): any;
  108721. /**
  108722. * Initializes the canvas to be added/removed upon entering/exiting xr
  108723. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108724. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108725. */
  108726. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108727. /**
  108728. * Disposes of the object
  108729. */
  108730. dispose(): void;
  108731. private _setManagedOutputCanvas;
  108732. private _addCanvas;
  108733. private _removeCanvas;
  108734. }
  108735. }
  108736. declare module BABYLON {
  108737. /**
  108738. * States of the webXR experience
  108739. */
  108740. export enum WebXRState {
  108741. /**
  108742. * Transitioning to being in XR mode
  108743. */
  108744. ENTERING_XR = 0,
  108745. /**
  108746. * Transitioning to non XR mode
  108747. */
  108748. EXITING_XR = 1,
  108749. /**
  108750. * In XR mode and presenting
  108751. */
  108752. IN_XR = 2,
  108753. /**
  108754. * Not entered XR mode
  108755. */
  108756. NOT_IN_XR = 3
  108757. }
  108758. /**
  108759. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108760. * @see https://doc.babylonjs.com/how_to/webxr
  108761. */
  108762. export class WebXRExperienceHelper implements IDisposable {
  108763. private scene;
  108764. /**
  108765. * 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
  108766. */
  108767. container: AbstractMesh;
  108768. /**
  108769. * Camera used to render xr content
  108770. */
  108771. camera: WebXRCamera;
  108772. /**
  108773. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108774. */
  108775. state: WebXRState;
  108776. private _setState;
  108777. private static _TmpVector;
  108778. /**
  108779. * Fires when the state of the experience helper has changed
  108780. */
  108781. onStateChangedObservable: Observable<WebXRState>;
  108782. /** Session manager used to keep track of xr session */
  108783. sessionManager: WebXRSessionManager;
  108784. private _nonVRCamera;
  108785. private _originalSceneAutoClear;
  108786. private _supported;
  108787. /**
  108788. * Creates the experience helper
  108789. * @param scene the scene to attach the experience helper to
  108790. * @returns a promise for the experience helper
  108791. */
  108792. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108793. /**
  108794. * Creates a WebXRExperienceHelper
  108795. * @param scene The scene the helper should be created in
  108796. */
  108797. private constructor();
  108798. /**
  108799. * Exits XR mode and returns the scene to its original state
  108800. * @returns promise that resolves after xr mode has exited
  108801. */
  108802. exitXRAsync(): Promise<unknown>;
  108803. /**
  108804. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108805. * @param sessionCreationOptions options for the XR session
  108806. * @param referenceSpaceType frame of reference of the XR session
  108807. * @param outputCanvas the output canvas that will be used to enter XR mode
  108808. * @returns promise that resolves after xr mode has entered
  108809. */
  108810. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108811. /**
  108812. * Updates the global position of the camera by moving the camera's container
  108813. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108814. * @param position The desired global position of the camera
  108815. */
  108816. setPositionOfCameraUsingContainer(position: Vector3): void;
  108817. /**
  108818. * Rotates the xr camera by rotating the camera's container around the camera's position
  108819. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108820. * @param rotation the desired quaternion rotation to apply to the camera
  108821. */
  108822. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108823. /**
  108824. * Disposes of the experience helper
  108825. */
  108826. dispose(): void;
  108827. }
  108828. }
  108829. declare module BABYLON {
  108830. /**
  108831. * Button which can be used to enter a different mode of XR
  108832. */
  108833. export class WebXREnterExitUIButton {
  108834. /** button element */
  108835. element: HTMLElement;
  108836. /** XR initialization options for the button */
  108837. sessionMode: XRSessionMode;
  108838. /** Reference space type */
  108839. referenceSpaceType: XRReferenceSpaceType;
  108840. /**
  108841. * Creates a WebXREnterExitUIButton
  108842. * @param element button element
  108843. * @param sessionMode XR initialization session mode
  108844. * @param referenceSpaceType the type of reference space to be used
  108845. */
  108846. constructor(
  108847. /** button element */
  108848. element: HTMLElement,
  108849. /** XR initialization options for the button */
  108850. sessionMode: XRSessionMode,
  108851. /** Reference space type */
  108852. referenceSpaceType: XRReferenceSpaceType);
  108853. /**
  108854. * Overwritable function which can be used to update the button's visuals when the state changes
  108855. * @param activeButton the current active button in the UI
  108856. */
  108857. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108858. }
  108859. /**
  108860. * Options to create the webXR UI
  108861. */
  108862. export class WebXREnterExitUIOptions {
  108863. /**
  108864. * Context to enter xr with
  108865. */
  108866. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108867. /**
  108868. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108869. */
  108870. customButtons?: Array<WebXREnterExitUIButton>;
  108871. }
  108872. /**
  108873. * UI to allow the user to enter/exit XR mode
  108874. */
  108875. export class WebXREnterExitUI implements IDisposable {
  108876. private scene;
  108877. private _overlay;
  108878. private _buttons;
  108879. private _activeButton;
  108880. /**
  108881. * Fired every time the active button is changed.
  108882. *
  108883. * When xr is entered via a button that launches xr that button will be the callback parameter
  108884. *
  108885. * When exiting xr the callback parameter will be null)
  108886. */
  108887. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108888. /**
  108889. * Creates UI to allow the user to enter/exit XR mode
  108890. * @param scene the scene to add the ui to
  108891. * @param helper the xr experience helper to enter/exit xr with
  108892. * @param options options to configure the UI
  108893. * @returns the created ui
  108894. */
  108895. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108896. private constructor();
  108897. private _updateButtons;
  108898. /**
  108899. * Disposes of the object
  108900. */
  108901. dispose(): void;
  108902. }
  108903. }
  108904. declare module BABYLON {
  108905. /**
  108906. * Represents an XR input
  108907. */
  108908. export class WebXRController {
  108909. private scene;
  108910. /** The underlying input source for the controller */
  108911. inputSource: XRInputSource;
  108912. private parentContainer;
  108913. /**
  108914. * 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
  108915. */
  108916. grip?: AbstractMesh;
  108917. /**
  108918. * Pointer which can be used to select objects or attach a visible laser to
  108919. */
  108920. pointer: AbstractMesh;
  108921. /**
  108922. * Event that fires when the controller is removed/disposed
  108923. */
  108924. onDisposeObservable: Observable<{}>;
  108925. private _tmpMatrix;
  108926. private _tmpQuaternion;
  108927. private _tmpVector;
  108928. /**
  108929. * Creates the controller
  108930. * @see https://doc.babylonjs.com/how_to/webxr
  108931. * @param scene the scene which the controller should be associated to
  108932. * @param inputSource the underlying input source for the controller
  108933. * @param parentContainer parent that the controller meshes should be children of
  108934. */
  108935. constructor(scene: Scene,
  108936. /** The underlying input source for the controller */
  108937. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108938. /**
  108939. * Updates the controller pose based on the given XRFrame
  108940. * @param xrFrame xr frame to update the pose with
  108941. * @param referenceSpace reference space to use
  108942. */
  108943. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108944. /**
  108945. * Gets a world space ray coming from the controller
  108946. * @param result the resulting ray
  108947. */
  108948. getWorldPointerRayToRef(result: Ray): void;
  108949. /**
  108950. * Disposes of the object
  108951. */
  108952. dispose(): void;
  108953. }
  108954. }
  108955. declare module BABYLON {
  108956. /**
  108957. * XR input used to track XR inputs such as controllers/rays
  108958. */
  108959. export class WebXRInput implements IDisposable {
  108960. /**
  108961. * Base experience the input listens to
  108962. */
  108963. baseExperience: WebXRExperienceHelper;
  108964. /**
  108965. * XR controllers being tracked
  108966. */
  108967. controllers: Array<WebXRController>;
  108968. private _frameObserver;
  108969. private _stateObserver;
  108970. /**
  108971. * Event when a controller has been connected/added
  108972. */
  108973. onControllerAddedObservable: Observable<WebXRController>;
  108974. /**
  108975. * Event when a controller has been removed/disconnected
  108976. */
  108977. onControllerRemovedObservable: Observable<WebXRController>;
  108978. /**
  108979. * Initializes the WebXRInput
  108980. * @param baseExperience experience helper which the input should be created for
  108981. */
  108982. constructor(
  108983. /**
  108984. * Base experience the input listens to
  108985. */
  108986. baseExperience: WebXRExperienceHelper);
  108987. private _onInputSourcesChange;
  108988. private _addAndRemoveControllers;
  108989. /**
  108990. * Disposes of the object
  108991. */
  108992. dispose(): void;
  108993. }
  108994. }
  108995. declare module BABYLON {
  108996. /**
  108997. * Enables teleportation
  108998. */
  108999. export class WebXRControllerTeleportation {
  109000. private _teleportationFillColor;
  109001. private _teleportationBorderColor;
  109002. private _tmpRay;
  109003. private _tmpVector;
  109004. /**
  109005. * Creates a WebXRControllerTeleportation
  109006. * @param input input manager to add teleportation to
  109007. * @param floorMeshes floormeshes which can be teleported to
  109008. */
  109009. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109010. }
  109011. }
  109012. declare module BABYLON {
  109013. /**
  109014. * Handles pointer input automatically for the pointer of XR controllers
  109015. */
  109016. export class WebXRControllerPointerSelection {
  109017. private static _idCounter;
  109018. private _tmpRay;
  109019. /**
  109020. * Creates a WebXRControllerPointerSelection
  109021. * @param input input manager to setup pointer selection
  109022. */
  109023. constructor(input: WebXRInput);
  109024. private _convertNormalToDirectionOfRay;
  109025. private _updatePointerDistance;
  109026. }
  109027. }
  109028. declare module BABYLON {
  109029. /**
  109030. * Class used to represent data loading progression
  109031. */
  109032. export class SceneLoaderProgressEvent {
  109033. /** defines if data length to load can be evaluated */
  109034. readonly lengthComputable: boolean;
  109035. /** defines the loaded data length */
  109036. readonly loaded: number;
  109037. /** defines the data length to load */
  109038. readonly total: number;
  109039. /**
  109040. * Create a new progress event
  109041. * @param lengthComputable defines if data length to load can be evaluated
  109042. * @param loaded defines the loaded data length
  109043. * @param total defines the data length to load
  109044. */
  109045. constructor(
  109046. /** defines if data length to load can be evaluated */
  109047. lengthComputable: boolean,
  109048. /** defines the loaded data length */
  109049. loaded: number,
  109050. /** defines the data length to load */
  109051. total: number);
  109052. /**
  109053. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109054. * @param event defines the source event
  109055. * @returns a new SceneLoaderProgressEvent
  109056. */
  109057. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109058. }
  109059. /**
  109060. * Interface used by SceneLoader plugins to define supported file extensions
  109061. */
  109062. export interface ISceneLoaderPluginExtensions {
  109063. /**
  109064. * Defines the list of supported extensions
  109065. */
  109066. [extension: string]: {
  109067. isBinary: boolean;
  109068. };
  109069. }
  109070. /**
  109071. * Interface used by SceneLoader plugin factory
  109072. */
  109073. export interface ISceneLoaderPluginFactory {
  109074. /**
  109075. * Defines the name of the factory
  109076. */
  109077. name: string;
  109078. /**
  109079. * Function called to create a new plugin
  109080. * @return the new plugin
  109081. */
  109082. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109083. /**
  109084. * Boolean indicating if the plugin can direct load specific data
  109085. */
  109086. canDirectLoad?: (data: string) => boolean;
  109087. }
  109088. /**
  109089. * Interface used to define a SceneLoader plugin
  109090. */
  109091. export interface ISceneLoaderPlugin {
  109092. /**
  109093. * The friendly name of this plugin.
  109094. */
  109095. name: string;
  109096. /**
  109097. * The file extensions supported by this plugin.
  109098. */
  109099. extensions: string | ISceneLoaderPluginExtensions;
  109100. /**
  109101. * Import meshes into a scene.
  109102. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109103. * @param scene The scene to import into
  109104. * @param data The data to import
  109105. * @param rootUrl The root url for scene and resources
  109106. * @param meshes The meshes array to import into
  109107. * @param particleSystems The particle systems array to import into
  109108. * @param skeletons The skeletons array to import into
  109109. * @param onError The callback when import fails
  109110. * @returns True if successful or false otherwise
  109111. */
  109112. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109113. /**
  109114. * Load into a scene.
  109115. * @param scene The scene to load into
  109116. * @param data The data to import
  109117. * @param rootUrl The root url for scene and resources
  109118. * @param onError The callback when import fails
  109119. * @returns true if successful or false otherwise
  109120. */
  109121. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109122. /**
  109123. * The callback that returns true if the data can be directly loaded.
  109124. */
  109125. canDirectLoad?: (data: string) => boolean;
  109126. /**
  109127. * The callback that allows custom handling of the root url based on the response url.
  109128. */
  109129. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  109130. /**
  109131. * Load into an asset container.
  109132. * @param scene The scene to load into
  109133. * @param data The data to import
  109134. * @param rootUrl The root url for scene and resources
  109135. * @param onError The callback when import fails
  109136. * @returns The loaded asset container
  109137. */
  109138. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109139. }
  109140. /**
  109141. * Interface used to define an async SceneLoader plugin
  109142. */
  109143. export interface ISceneLoaderPluginAsync {
  109144. /**
  109145. * The friendly name of this plugin.
  109146. */
  109147. name: string;
  109148. /**
  109149. * The file extensions supported by this plugin.
  109150. */
  109151. extensions: string | ISceneLoaderPluginExtensions;
  109152. /**
  109153. * Import meshes into a scene.
  109154. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109155. * @param scene The scene to import into
  109156. * @param data The data to import
  109157. * @param rootUrl The root url for scene and resources
  109158. * @param onProgress The callback when the load progresses
  109159. * @param fileName Defines the name of the file to load
  109160. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109161. */
  109162. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109163. meshes: AbstractMesh[];
  109164. particleSystems: IParticleSystem[];
  109165. skeletons: Skeleton[];
  109166. animationGroups: AnimationGroup[];
  109167. }>;
  109168. /**
  109169. * Load into a scene.
  109170. * @param scene The scene to load into
  109171. * @param data The data to import
  109172. * @param rootUrl The root url for scene and resources
  109173. * @param onProgress The callback when the load progresses
  109174. * @param fileName Defines the name of the file to load
  109175. * @returns Nothing
  109176. */
  109177. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109178. /**
  109179. * The callback that returns true if the data can be directly loaded.
  109180. */
  109181. canDirectLoad?: (data: string) => boolean;
  109182. /**
  109183. * The callback that allows custom handling of the root url based on the response url.
  109184. */
  109185. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  109186. /**
  109187. * Load into an asset container.
  109188. * @param scene The scene to load into
  109189. * @param data The data to import
  109190. * @param rootUrl The root url for scene and resources
  109191. * @param onProgress The callback when the load progresses
  109192. * @param fileName Defines the name of the file to load
  109193. * @returns The loaded asset container
  109194. */
  109195. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109196. }
  109197. /**
  109198. * Class used to load scene from various file formats using registered plugins
  109199. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109200. */
  109201. export class SceneLoader {
  109202. /**
  109203. * No logging while loading
  109204. */
  109205. static readonly NO_LOGGING: number;
  109206. /**
  109207. * Minimal logging while loading
  109208. */
  109209. static readonly MINIMAL_LOGGING: number;
  109210. /**
  109211. * Summary logging while loading
  109212. */
  109213. static readonly SUMMARY_LOGGING: number;
  109214. /**
  109215. * Detailled logging while loading
  109216. */
  109217. static readonly DETAILED_LOGGING: number;
  109218. /**
  109219. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109220. */
  109221. static ForceFullSceneLoadingForIncremental: boolean;
  109222. /**
  109223. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109224. */
  109225. static ShowLoadingScreen: boolean;
  109226. /**
  109227. * Defines the current logging level (while loading the scene)
  109228. * @ignorenaming
  109229. */
  109230. static loggingLevel: number;
  109231. /**
  109232. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109233. */
  109234. static CleanBoneMatrixWeights: boolean;
  109235. /**
  109236. * Event raised when a plugin is used to load a scene
  109237. */
  109238. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109239. private static _registeredPlugins;
  109240. private static _getDefaultPlugin;
  109241. private static _getPluginForExtension;
  109242. private static _getPluginForDirectLoad;
  109243. private static _getPluginForFilename;
  109244. private static _getDirectLoad;
  109245. private static _loadData;
  109246. private static _getFileInfo;
  109247. /**
  109248. * Gets a plugin that can load the given extension
  109249. * @param extension defines the extension to load
  109250. * @returns a plugin or null if none works
  109251. */
  109252. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109253. /**
  109254. * Gets a boolean indicating that the given extension can be loaded
  109255. * @param extension defines the extension to load
  109256. * @returns true if the extension is supported
  109257. */
  109258. static IsPluginForExtensionAvailable(extension: string): boolean;
  109259. /**
  109260. * Adds a new plugin to the list of registered plugins
  109261. * @param plugin defines the plugin to add
  109262. */
  109263. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109264. /**
  109265. * Import meshes into a scene
  109266. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109267. * @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)
  109268. * @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)
  109269. * @param scene the instance of BABYLON.Scene to append to
  109270. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109271. * @param onProgress a callback with a progress event for each file being loaded
  109272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109273. * @param pluginExtension the extension used to determine the plugin
  109274. * @returns The loaded plugin
  109275. */
  109276. 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>;
  109277. /**
  109278. * Import meshes into a scene
  109279. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109280. * @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)
  109281. * @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)
  109282. * @param scene the instance of BABYLON.Scene to append to
  109283. * @param onProgress a callback with a progress event for each file being loaded
  109284. * @param pluginExtension the extension used to determine the plugin
  109285. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109286. */
  109287. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109288. meshes: AbstractMesh[];
  109289. particleSystems: IParticleSystem[];
  109290. skeletons: Skeleton[];
  109291. animationGroups: AnimationGroup[];
  109292. }>;
  109293. /**
  109294. * Load a scene
  109295. * @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)
  109296. * @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)
  109297. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109298. * @param onSuccess a callback with the scene when import succeeds
  109299. * @param onProgress a callback with a progress event for each file being loaded
  109300. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109301. * @param pluginExtension the extension used to determine the plugin
  109302. * @returns The loaded plugin
  109303. */
  109304. 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>;
  109305. /**
  109306. * Load a scene
  109307. * @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)
  109308. * @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)
  109309. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109310. * @param onProgress a callback with a progress event for each file being loaded
  109311. * @param pluginExtension the extension used to determine the plugin
  109312. * @returns The loaded scene
  109313. */
  109314. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109315. /**
  109316. * Append a scene
  109317. * @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)
  109318. * @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)
  109319. * @param scene is the instance of BABYLON.Scene to append to
  109320. * @param onSuccess a callback with the scene when import succeeds
  109321. * @param onProgress a callback with a progress event for each file being loaded
  109322. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109323. * @param pluginExtension the extension used to determine the plugin
  109324. * @returns The loaded plugin
  109325. */
  109326. 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>;
  109327. /**
  109328. * Append a scene
  109329. * @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)
  109330. * @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)
  109331. * @param scene is the instance of BABYLON.Scene to append to
  109332. * @param onProgress a callback with a progress event for each file being loaded
  109333. * @param pluginExtension the extension used to determine the plugin
  109334. * @returns The given scene
  109335. */
  109336. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109337. /**
  109338. * Load a scene into an asset container
  109339. * @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)
  109340. * @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)
  109341. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109342. * @param onSuccess a callback with the scene when import succeeds
  109343. * @param onProgress a callback with a progress event for each file being loaded
  109344. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109345. * @param pluginExtension the extension used to determine the plugin
  109346. * @returns The loaded plugin
  109347. */
  109348. 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>;
  109349. /**
  109350. * Load a scene into an asset container
  109351. * @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)
  109352. * @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)
  109353. * @param scene is the instance of Scene to append to
  109354. * @param onProgress a callback with a progress event for each file being loaded
  109355. * @param pluginExtension the extension used to determine the plugin
  109356. * @returns The loaded asset container
  109357. */
  109358. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109359. }
  109360. }
  109361. declare module BABYLON {
  109362. /**
  109363. * Generic Controller
  109364. */
  109365. export class GenericController extends WebVRController {
  109366. /**
  109367. * Base Url for the controller model.
  109368. */
  109369. static readonly MODEL_BASE_URL: string;
  109370. /**
  109371. * File name for the controller model.
  109372. */
  109373. static readonly MODEL_FILENAME: string;
  109374. /**
  109375. * Creates a new GenericController from a gamepad
  109376. * @param vrGamepad the gamepad that the controller should be created from
  109377. */
  109378. constructor(vrGamepad: any);
  109379. /**
  109380. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109381. * @param scene scene in which to add meshes
  109382. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109383. */
  109384. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109385. /**
  109386. * Called once for each button that changed state since the last frame
  109387. * @param buttonIdx Which button index changed
  109388. * @param state New state of the button
  109389. * @param changes Which properties on the state changed since last frame
  109390. */
  109391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109392. }
  109393. }
  109394. declare module BABYLON {
  109395. /**
  109396. * Defines the WindowsMotionController object that the state of the windows motion controller
  109397. */
  109398. export class WindowsMotionController extends WebVRController {
  109399. /**
  109400. * The base url used to load the left and right controller models
  109401. */
  109402. static MODEL_BASE_URL: string;
  109403. /**
  109404. * The name of the left controller model file
  109405. */
  109406. static MODEL_LEFT_FILENAME: string;
  109407. /**
  109408. * The name of the right controller model file
  109409. */
  109410. static MODEL_RIGHT_FILENAME: string;
  109411. /**
  109412. * The controller name prefix for this controller type
  109413. */
  109414. static readonly GAMEPAD_ID_PREFIX: string;
  109415. /**
  109416. * The controller id pattern for this controller type
  109417. */
  109418. private static readonly GAMEPAD_ID_PATTERN;
  109419. private _loadedMeshInfo;
  109420. private readonly _mapping;
  109421. /**
  109422. * Fired when the trackpad on this controller is clicked
  109423. */
  109424. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109425. /**
  109426. * Fired when the trackpad on this controller is modified
  109427. */
  109428. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109429. /**
  109430. * The current x and y values of this controller's trackpad
  109431. */
  109432. trackpad: StickValues;
  109433. /**
  109434. * Creates a new WindowsMotionController from a gamepad
  109435. * @param vrGamepad the gamepad that the controller should be created from
  109436. */
  109437. constructor(vrGamepad: any);
  109438. /**
  109439. * Fired when the trigger on this controller is modified
  109440. */
  109441. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109442. /**
  109443. * Fired when the menu button on this controller is modified
  109444. */
  109445. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109446. /**
  109447. * Fired when the grip button on this controller is modified
  109448. */
  109449. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109450. /**
  109451. * Fired when the thumbstick button on this controller is modified
  109452. */
  109453. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109454. /**
  109455. * Fired when the touchpad button on this controller is modified
  109456. */
  109457. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109458. /**
  109459. * Fired when the touchpad values on this controller are modified
  109460. */
  109461. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109462. private _updateTrackpad;
  109463. /**
  109464. * Called once per frame by the engine.
  109465. */
  109466. update(): void;
  109467. /**
  109468. * Called once for each button that changed state since the last frame
  109469. * @param buttonIdx Which button index changed
  109470. * @param state New state of the button
  109471. * @param changes Which properties on the state changed since last frame
  109472. */
  109473. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109474. /**
  109475. * Moves the buttons on the controller mesh based on their current state
  109476. * @param buttonName the name of the button to move
  109477. * @param buttonValue the value of the button which determines the buttons new position
  109478. */
  109479. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109480. /**
  109481. * Moves the axis on the controller mesh based on its current state
  109482. * @param axis the index of the axis
  109483. * @param axisValue the value of the axis which determines the meshes new position
  109484. * @hidden
  109485. */
  109486. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109487. /**
  109488. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109489. * @param scene scene in which to add meshes
  109490. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109491. */
  109492. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109493. /**
  109494. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109495. * can be transformed by button presses and axes values, based on this._mapping.
  109496. *
  109497. * @param scene scene in which the meshes exist
  109498. * @param meshes list of meshes that make up the controller model to process
  109499. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109500. */
  109501. private processModel;
  109502. private createMeshInfo;
  109503. /**
  109504. * Gets the ray of the controller in the direction the controller is pointing
  109505. * @param length the length the resulting ray should be
  109506. * @returns a ray in the direction the controller is pointing
  109507. */
  109508. getForwardRay(length?: number): Ray;
  109509. /**
  109510. * Disposes of the controller
  109511. */
  109512. dispose(): void;
  109513. }
  109514. }
  109515. declare module BABYLON {
  109516. /**
  109517. * Oculus Touch Controller
  109518. */
  109519. export class OculusTouchController extends WebVRController {
  109520. /**
  109521. * Base Url for the controller model.
  109522. */
  109523. static MODEL_BASE_URL: string;
  109524. /**
  109525. * File name for the left controller model.
  109526. */
  109527. static MODEL_LEFT_FILENAME: string;
  109528. /**
  109529. * File name for the right controller model.
  109530. */
  109531. static MODEL_RIGHT_FILENAME: string;
  109532. /**
  109533. * Base Url for the Quest controller model.
  109534. */
  109535. static QUEST_MODEL_BASE_URL: string;
  109536. /**
  109537. * @hidden
  109538. * If the controllers are running on a device that needs the updated Quest controller models
  109539. */
  109540. static _IsQuest: boolean;
  109541. /**
  109542. * Fired when the secondary trigger on this controller is modified
  109543. */
  109544. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109545. /**
  109546. * Fired when the thumb rest on this controller is modified
  109547. */
  109548. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109549. /**
  109550. * Creates a new OculusTouchController from a gamepad
  109551. * @param vrGamepad the gamepad that the controller should be created from
  109552. */
  109553. constructor(vrGamepad: any);
  109554. /**
  109555. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109556. * @param scene scene in which to add meshes
  109557. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109558. */
  109559. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109560. /**
  109561. * Fired when the A button on this controller is modified
  109562. */
  109563. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109564. /**
  109565. * Fired when the B button on this controller is modified
  109566. */
  109567. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109568. /**
  109569. * Fired when the X button on this controller is modified
  109570. */
  109571. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109572. /**
  109573. * Fired when the Y button on this controller is modified
  109574. */
  109575. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109576. /**
  109577. * Called once for each button that changed state since the last frame
  109578. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109579. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109580. * 2) secondary trigger (same)
  109581. * 3) A (right) X (left), touch, pressed = value
  109582. * 4) B / Y
  109583. * 5) thumb rest
  109584. * @param buttonIdx Which button index changed
  109585. * @param state New state of the button
  109586. * @param changes Which properties on the state changed since last frame
  109587. */
  109588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109589. }
  109590. }
  109591. declare module BABYLON {
  109592. /**
  109593. * Vive Controller
  109594. */
  109595. export class ViveController extends WebVRController {
  109596. /**
  109597. * Base Url for the controller model.
  109598. */
  109599. static MODEL_BASE_URL: string;
  109600. /**
  109601. * File name for the controller model.
  109602. */
  109603. static MODEL_FILENAME: string;
  109604. /**
  109605. * Creates a new ViveController from a gamepad
  109606. * @param vrGamepad the gamepad that the controller should be created from
  109607. */
  109608. constructor(vrGamepad: any);
  109609. /**
  109610. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109611. * @param scene scene in which to add meshes
  109612. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109613. */
  109614. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109615. /**
  109616. * Fired when the left button on this controller is modified
  109617. */
  109618. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109619. /**
  109620. * Fired when the right button on this controller is modified
  109621. */
  109622. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109623. /**
  109624. * Fired when the menu button on this controller is modified
  109625. */
  109626. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109627. /**
  109628. * Called once for each button that changed state since the last frame
  109629. * Vive mapping:
  109630. * 0: touchpad
  109631. * 1: trigger
  109632. * 2: left AND right buttons
  109633. * 3: menu button
  109634. * @param buttonIdx Which button index changed
  109635. * @param state New state of the button
  109636. * @param changes Which properties on the state changed since last frame
  109637. */
  109638. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109639. }
  109640. }
  109641. declare module BABYLON {
  109642. /**
  109643. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109644. */
  109645. export class WebXRControllerModelLoader {
  109646. /**
  109647. * Creates the WebXRControllerModelLoader
  109648. * @param input xr input that creates the controllers
  109649. */
  109650. constructor(input: WebXRInput);
  109651. }
  109652. }
  109653. declare module BABYLON {
  109654. /**
  109655. * Contains an array of blocks representing the octree
  109656. */
  109657. export interface IOctreeContainer<T> {
  109658. /**
  109659. * Blocks within the octree
  109660. */
  109661. blocks: Array<OctreeBlock<T>>;
  109662. }
  109663. /**
  109664. * Class used to store a cell in an octree
  109665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109666. */
  109667. export class OctreeBlock<T> {
  109668. /**
  109669. * Gets the content of the current block
  109670. */
  109671. entries: T[];
  109672. /**
  109673. * Gets the list of block children
  109674. */
  109675. blocks: Array<OctreeBlock<T>>;
  109676. private _depth;
  109677. private _maxDepth;
  109678. private _capacity;
  109679. private _minPoint;
  109680. private _maxPoint;
  109681. private _boundingVectors;
  109682. private _creationFunc;
  109683. /**
  109684. * Creates a new block
  109685. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109686. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109687. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109688. * @param depth defines the current depth of this block in the octree
  109689. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109690. * @param creationFunc defines a callback to call when an element is added to the block
  109691. */
  109692. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109693. /**
  109694. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109695. */
  109696. readonly capacity: number;
  109697. /**
  109698. * Gets the minimum vector (in world space) of the block's bounding box
  109699. */
  109700. readonly minPoint: Vector3;
  109701. /**
  109702. * Gets the maximum vector (in world space) of the block's bounding box
  109703. */
  109704. readonly maxPoint: Vector3;
  109705. /**
  109706. * Add a new element to this block
  109707. * @param entry defines the element to add
  109708. */
  109709. addEntry(entry: T): void;
  109710. /**
  109711. * Remove an element from this block
  109712. * @param entry defines the element to remove
  109713. */
  109714. removeEntry(entry: T): void;
  109715. /**
  109716. * Add an array of elements to this block
  109717. * @param entries defines the array of elements to add
  109718. */
  109719. addEntries(entries: T[]): void;
  109720. /**
  109721. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109722. * @param frustumPlanes defines the frustum planes to test
  109723. * @param selection defines the array to store current content if selection is positive
  109724. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109725. */
  109726. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109727. /**
  109728. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109729. * @param sphereCenter defines the bounding sphere center
  109730. * @param sphereRadius defines the bounding sphere radius
  109731. * @param selection defines the array to store current content if selection is positive
  109732. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109733. */
  109734. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109735. /**
  109736. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109737. * @param ray defines the ray to test with
  109738. * @param selection defines the array to store current content if selection is positive
  109739. */
  109740. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109741. /**
  109742. * Subdivide the content into child blocks (this block will then be empty)
  109743. */
  109744. createInnerBlocks(): void;
  109745. /**
  109746. * @hidden
  109747. */
  109748. 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;
  109749. }
  109750. }
  109751. declare module BABYLON {
  109752. /**
  109753. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109755. */
  109756. export class Octree<T> {
  109757. /** 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.) */
  109758. maxDepth: number;
  109759. /**
  109760. * Blocks within the octree containing objects
  109761. */
  109762. blocks: Array<OctreeBlock<T>>;
  109763. /**
  109764. * Content stored in the octree
  109765. */
  109766. dynamicContent: T[];
  109767. private _maxBlockCapacity;
  109768. private _selectionContent;
  109769. private _creationFunc;
  109770. /**
  109771. * Creates a octree
  109772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109773. * @param creationFunc function to be used to instatiate the octree
  109774. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109775. * @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.)
  109776. */
  109777. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109778. /** 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.) */
  109779. maxDepth?: number);
  109780. /**
  109781. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109782. * @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);
  109783. * @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);
  109784. * @param entries meshes to be added to the octree blocks
  109785. */
  109786. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109787. /**
  109788. * Adds a mesh to the octree
  109789. * @param entry Mesh to add to the octree
  109790. */
  109791. addMesh(entry: T): void;
  109792. /**
  109793. * Remove an element from the octree
  109794. * @param entry defines the element to remove
  109795. */
  109796. removeMesh(entry: T): void;
  109797. /**
  109798. * Selects an array of meshes within the frustum
  109799. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109800. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109801. * @returns array of meshes within the frustum
  109802. */
  109803. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109804. /**
  109805. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109806. * @param sphereCenter defines the bounding sphere center
  109807. * @param sphereRadius defines the bounding sphere radius
  109808. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109809. * @returns an array of objects that intersect the sphere
  109810. */
  109811. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109812. /**
  109813. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109814. * @param ray defines the ray to test with
  109815. * @returns array of intersected objects
  109816. */
  109817. intersectsRay(ray: Ray): SmartArray<T>;
  109818. /**
  109819. * Adds a mesh into the octree block if it intersects the block
  109820. */
  109821. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109822. /**
  109823. * Adds a submesh into the octree block if it intersects the block
  109824. */
  109825. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109826. }
  109827. }
  109828. declare module BABYLON {
  109829. interface Scene {
  109830. /**
  109831. * @hidden
  109832. * Backing Filed
  109833. */
  109834. _selectionOctree: Octree<AbstractMesh>;
  109835. /**
  109836. * Gets the octree used to boost mesh selection (picking)
  109837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109838. */
  109839. selectionOctree: Octree<AbstractMesh>;
  109840. /**
  109841. * Creates or updates the octree used to boost selection (picking)
  109842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109843. * @param maxCapacity defines the maximum capacity per leaf
  109844. * @param maxDepth defines the maximum depth of the octree
  109845. * @returns an octree of AbstractMesh
  109846. */
  109847. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109848. }
  109849. interface AbstractMesh {
  109850. /**
  109851. * @hidden
  109852. * Backing Field
  109853. */
  109854. _submeshesOctree: Octree<SubMesh>;
  109855. /**
  109856. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109857. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109858. * @param maxCapacity defines the maximum size of each block (64 by default)
  109859. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109860. * @returns the new octree
  109861. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109863. */
  109864. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109865. }
  109866. /**
  109867. * Defines the octree scene component responsible to manage any octrees
  109868. * in a given scene.
  109869. */
  109870. export class OctreeSceneComponent {
  109871. /**
  109872. * The component name help to identify the component in the list of scene components.
  109873. */
  109874. readonly name: string;
  109875. /**
  109876. * The scene the component belongs to.
  109877. */
  109878. scene: Scene;
  109879. /**
  109880. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109881. */
  109882. readonly checksIsEnabled: boolean;
  109883. /**
  109884. * Creates a new instance of the component for the given scene
  109885. * @param scene Defines the scene to register the component in
  109886. */
  109887. constructor(scene: Scene);
  109888. /**
  109889. * Registers the component in a given scene
  109890. */
  109891. register(): void;
  109892. /**
  109893. * Return the list of active meshes
  109894. * @returns the list of active meshes
  109895. */
  109896. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109897. /**
  109898. * Return the list of active sub meshes
  109899. * @param mesh The mesh to get the candidates sub meshes from
  109900. * @returns the list of active sub meshes
  109901. */
  109902. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109903. private _tempRay;
  109904. /**
  109905. * Return the list of sub meshes intersecting with a given local ray
  109906. * @param mesh defines the mesh to find the submesh for
  109907. * @param localRay defines the ray in local space
  109908. * @returns the list of intersecting sub meshes
  109909. */
  109910. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109911. /**
  109912. * Return the list of sub meshes colliding with a collider
  109913. * @param mesh defines the mesh to find the submesh for
  109914. * @param collider defines the collider to evaluate the collision against
  109915. * @returns the list of colliding sub meshes
  109916. */
  109917. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109918. /**
  109919. * Rebuilds the elements related to this component in case of
  109920. * context lost for instance.
  109921. */
  109922. rebuild(): void;
  109923. /**
  109924. * Disposes the component and the associated ressources.
  109925. */
  109926. dispose(): void;
  109927. }
  109928. }
  109929. declare module BABYLON {
  109930. /**
  109931. * Renders a layer on top of an existing scene
  109932. */
  109933. export class UtilityLayerRenderer implements IDisposable {
  109934. /** the original scene that will be rendered on top of */
  109935. originalScene: Scene;
  109936. private _pointerCaptures;
  109937. private _lastPointerEvents;
  109938. private static _DefaultUtilityLayer;
  109939. private static _DefaultKeepDepthUtilityLayer;
  109940. private _sharedGizmoLight;
  109941. private _renderCamera;
  109942. /**
  109943. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109944. * @returns the camera that is used when rendering the utility layer
  109945. */
  109946. getRenderCamera(): Nullable<Camera>;
  109947. /**
  109948. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109949. * @param cam the camera that should be used when rendering the utility layer
  109950. */
  109951. setRenderCamera(cam: Nullable<Camera>): void;
  109952. /**
  109953. * @hidden
  109954. * Light which used by gizmos to get light shading
  109955. */
  109956. _getSharedGizmoLight(): HemisphericLight;
  109957. /**
  109958. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109959. */
  109960. pickUtilitySceneFirst: boolean;
  109961. /**
  109962. * 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)
  109963. */
  109964. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109965. /**
  109966. * 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)
  109967. */
  109968. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109969. /**
  109970. * The scene that is rendered on top of the original scene
  109971. */
  109972. utilityLayerScene: Scene;
  109973. /**
  109974. * If the utility layer should automatically be rendered on top of existing scene
  109975. */
  109976. shouldRender: boolean;
  109977. /**
  109978. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109979. */
  109980. onlyCheckPointerDownEvents: boolean;
  109981. /**
  109982. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109983. */
  109984. processAllEvents: boolean;
  109985. /**
  109986. * Observable raised when the pointer move from the utility layer scene to the main scene
  109987. */
  109988. onPointerOutObservable: Observable<number>;
  109989. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109990. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109991. private _afterRenderObserver;
  109992. private _sceneDisposeObserver;
  109993. private _originalPointerObserver;
  109994. /**
  109995. * Instantiates a UtilityLayerRenderer
  109996. * @param originalScene the original scene that will be rendered on top of
  109997. * @param handleEvents boolean indicating if the utility layer should handle events
  109998. */
  109999. constructor(
  110000. /** the original scene that will be rendered on top of */
  110001. originalScene: Scene, handleEvents?: boolean);
  110002. private _notifyObservers;
  110003. /**
  110004. * Renders the utility layers scene on top of the original scene
  110005. */
  110006. render(): void;
  110007. /**
  110008. * Disposes of the renderer
  110009. */
  110010. dispose(): void;
  110011. private _updateCamera;
  110012. }
  110013. }
  110014. declare module BABYLON {
  110015. /**
  110016. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110017. */
  110018. export class Gizmo implements IDisposable {
  110019. /** The utility layer the gizmo will be added to */
  110020. gizmoLayer: UtilityLayerRenderer;
  110021. /**
  110022. * The root mesh of the gizmo
  110023. */
  110024. _rootMesh: Mesh;
  110025. private _attachedMesh;
  110026. /**
  110027. * Ratio for the scale of the gizmo (Default: 1)
  110028. */
  110029. scaleRatio: number;
  110030. /**
  110031. * If a custom mesh has been set (Default: false)
  110032. */
  110033. protected _customMeshSet: boolean;
  110034. /**
  110035. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110036. * * When set, interactions will be enabled
  110037. */
  110038. attachedMesh: Nullable<AbstractMesh>;
  110039. /**
  110040. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110041. * @param mesh The mesh to replace the default mesh of the gizmo
  110042. */
  110043. setCustomMesh(mesh: Mesh): void;
  110044. /**
  110045. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110046. */
  110047. updateGizmoRotationToMatchAttachedMesh: boolean;
  110048. /**
  110049. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110050. */
  110051. updateGizmoPositionToMatchAttachedMesh: boolean;
  110052. /**
  110053. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110054. */
  110055. updateScale: boolean;
  110056. protected _interactionsEnabled: boolean;
  110057. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110058. private _beforeRenderObserver;
  110059. private _tempVector;
  110060. /**
  110061. * Creates a gizmo
  110062. * @param gizmoLayer The utility layer the gizmo will be added to
  110063. */
  110064. constructor(
  110065. /** The utility layer the gizmo will be added to */
  110066. gizmoLayer?: UtilityLayerRenderer);
  110067. /**
  110068. * Updates the gizmo to match the attached mesh's position/rotation
  110069. */
  110070. protected _update(): void;
  110071. /**
  110072. * Disposes of the gizmo
  110073. */
  110074. dispose(): void;
  110075. }
  110076. }
  110077. declare module BABYLON {
  110078. /**
  110079. * Single plane drag gizmo
  110080. */
  110081. export class PlaneDragGizmo extends Gizmo {
  110082. /**
  110083. * Drag behavior responsible for the gizmos dragging interactions
  110084. */
  110085. dragBehavior: PointerDragBehavior;
  110086. private _pointerObserver;
  110087. /**
  110088. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110089. */
  110090. snapDistance: number;
  110091. /**
  110092. * Event that fires each time the gizmo snaps to a new location.
  110093. * * snapDistance is the the change in distance
  110094. */
  110095. onSnapObservable: Observable<{
  110096. snapDistance: number;
  110097. }>;
  110098. private _plane;
  110099. private _coloredMaterial;
  110100. private _hoverMaterial;
  110101. private _isEnabled;
  110102. private _parent;
  110103. /** @hidden */
  110104. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110105. /** @hidden */
  110106. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110107. /**
  110108. * Creates a PlaneDragGizmo
  110109. * @param gizmoLayer The utility layer the gizmo will be added to
  110110. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110111. * @param color The color of the gizmo
  110112. */
  110113. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110114. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110115. /**
  110116. * If the gizmo is enabled
  110117. */
  110118. isEnabled: boolean;
  110119. /**
  110120. * Disposes of the gizmo
  110121. */
  110122. dispose(): void;
  110123. }
  110124. }
  110125. declare module BABYLON {
  110126. /**
  110127. * Gizmo that enables dragging a mesh along 3 axis
  110128. */
  110129. export class PositionGizmo extends Gizmo {
  110130. /**
  110131. * Internal gizmo used for interactions on the x axis
  110132. */
  110133. xGizmo: AxisDragGizmo;
  110134. /**
  110135. * Internal gizmo used for interactions on the y axis
  110136. */
  110137. yGizmo: AxisDragGizmo;
  110138. /**
  110139. * Internal gizmo used for interactions on the z axis
  110140. */
  110141. zGizmo: AxisDragGizmo;
  110142. /**
  110143. * Internal gizmo used for interactions on the yz plane
  110144. */
  110145. xPlaneGizmo: PlaneDragGizmo;
  110146. /**
  110147. * Internal gizmo used for interactions on the xz plane
  110148. */
  110149. yPlaneGizmo: PlaneDragGizmo;
  110150. /**
  110151. * Internal gizmo used for interactions on the xy plane
  110152. */
  110153. zPlaneGizmo: PlaneDragGizmo;
  110154. /**
  110155. * private variables
  110156. */
  110157. private _meshAttached;
  110158. private _updateGizmoRotationToMatchAttachedMesh;
  110159. private _snapDistance;
  110160. private _scaleRatio;
  110161. /** Fires an event when any of it's sub gizmos are dragged */
  110162. onDragStartObservable: Observable<unknown>;
  110163. /** Fires an event when any of it's sub gizmos are released from dragging */
  110164. onDragEndObservable: Observable<unknown>;
  110165. /**
  110166. * If set to true, planar drag is enabled
  110167. */
  110168. private _planarGizmoEnabled;
  110169. attachedMesh: Nullable<AbstractMesh>;
  110170. /**
  110171. * Creates a PositionGizmo
  110172. * @param gizmoLayer The utility layer the gizmo will be added to
  110173. */
  110174. constructor(gizmoLayer?: UtilityLayerRenderer);
  110175. /**
  110176. * If the planar drag gizmo is enabled
  110177. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110178. */
  110179. planarGizmoEnabled: boolean;
  110180. updateGizmoRotationToMatchAttachedMesh: boolean;
  110181. /**
  110182. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110183. */
  110184. snapDistance: number;
  110185. /**
  110186. * Ratio for the scale of the gizmo (Default: 1)
  110187. */
  110188. scaleRatio: number;
  110189. /**
  110190. * Disposes of the gizmo
  110191. */
  110192. dispose(): void;
  110193. /**
  110194. * CustomMeshes are not supported by this gizmo
  110195. * @param mesh The mesh to replace the default mesh of the gizmo
  110196. */
  110197. setCustomMesh(mesh: Mesh): void;
  110198. }
  110199. }
  110200. declare module BABYLON {
  110201. /**
  110202. * Single axis drag gizmo
  110203. */
  110204. export class AxisDragGizmo extends Gizmo {
  110205. /**
  110206. * Drag behavior responsible for the gizmos dragging interactions
  110207. */
  110208. dragBehavior: PointerDragBehavior;
  110209. private _pointerObserver;
  110210. /**
  110211. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110212. */
  110213. snapDistance: number;
  110214. /**
  110215. * Event that fires each time the gizmo snaps to a new location.
  110216. * * snapDistance is the the change in distance
  110217. */
  110218. onSnapObservable: Observable<{
  110219. snapDistance: number;
  110220. }>;
  110221. private _isEnabled;
  110222. private _parent;
  110223. private _arrow;
  110224. private _coloredMaterial;
  110225. private _hoverMaterial;
  110226. /** @hidden */
  110227. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110228. /** @hidden */
  110229. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110230. /**
  110231. * Creates an AxisDragGizmo
  110232. * @param gizmoLayer The utility layer the gizmo will be added to
  110233. * @param dragAxis The axis which the gizmo will be able to drag on
  110234. * @param color The color of the gizmo
  110235. */
  110236. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110237. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110238. /**
  110239. * If the gizmo is enabled
  110240. */
  110241. isEnabled: boolean;
  110242. /**
  110243. * Disposes of the gizmo
  110244. */
  110245. dispose(): void;
  110246. }
  110247. }
  110248. declare module BABYLON.Debug {
  110249. /**
  110250. * The Axes viewer will show 3 axes in a specific point in space
  110251. */
  110252. export class AxesViewer {
  110253. private _xAxis;
  110254. private _yAxis;
  110255. private _zAxis;
  110256. private _scaleLinesFactor;
  110257. private _instanced;
  110258. /**
  110259. * Gets the hosting scene
  110260. */
  110261. scene: Scene;
  110262. /**
  110263. * Gets or sets a number used to scale line length
  110264. */
  110265. scaleLines: number;
  110266. /** Gets the node hierarchy used to render x-axis */
  110267. readonly xAxis: TransformNode;
  110268. /** Gets the node hierarchy used to render y-axis */
  110269. readonly yAxis: TransformNode;
  110270. /** Gets the node hierarchy used to render z-axis */
  110271. readonly zAxis: TransformNode;
  110272. /**
  110273. * Creates a new AxesViewer
  110274. * @param scene defines the hosting scene
  110275. * @param scaleLines defines a number used to scale line length (1 by default)
  110276. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110277. * @param xAxis defines the node hierarchy used to render the x-axis
  110278. * @param yAxis defines the node hierarchy used to render the y-axis
  110279. * @param zAxis defines the node hierarchy used to render the z-axis
  110280. */
  110281. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110282. /**
  110283. * Force the viewer to update
  110284. * @param position defines the position of the viewer
  110285. * @param xaxis defines the x axis of the viewer
  110286. * @param yaxis defines the y axis of the viewer
  110287. * @param zaxis defines the z axis of the viewer
  110288. */
  110289. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110290. /**
  110291. * Creates an instance of this axes viewer.
  110292. * @returns a new axes viewer with instanced meshes
  110293. */
  110294. createInstance(): AxesViewer;
  110295. /** Releases resources */
  110296. dispose(): void;
  110297. private static _SetRenderingGroupId;
  110298. }
  110299. }
  110300. declare module BABYLON.Debug {
  110301. /**
  110302. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110303. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110304. */
  110305. export class BoneAxesViewer extends AxesViewer {
  110306. /**
  110307. * Gets or sets the target mesh where to display the axes viewer
  110308. */
  110309. mesh: Nullable<Mesh>;
  110310. /**
  110311. * Gets or sets the target bone where to display the axes viewer
  110312. */
  110313. bone: Nullable<Bone>;
  110314. /** Gets current position */
  110315. pos: Vector3;
  110316. /** Gets direction of X axis */
  110317. xaxis: Vector3;
  110318. /** Gets direction of Y axis */
  110319. yaxis: Vector3;
  110320. /** Gets direction of Z axis */
  110321. zaxis: Vector3;
  110322. /**
  110323. * Creates a new BoneAxesViewer
  110324. * @param scene defines the hosting scene
  110325. * @param bone defines the target bone
  110326. * @param mesh defines the target mesh
  110327. * @param scaleLines defines a scaling factor for line length (1 by default)
  110328. */
  110329. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110330. /**
  110331. * Force the viewer to update
  110332. */
  110333. update(): void;
  110334. /** Releases resources */
  110335. dispose(): void;
  110336. }
  110337. }
  110338. declare module BABYLON {
  110339. /**
  110340. * Interface used to define scene explorer extensibility option
  110341. */
  110342. export interface IExplorerExtensibilityOption {
  110343. /**
  110344. * Define the option label
  110345. */
  110346. label: string;
  110347. /**
  110348. * Defines the action to execute on click
  110349. */
  110350. action: (entity: any) => void;
  110351. }
  110352. /**
  110353. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110354. */
  110355. export interface IExplorerExtensibilityGroup {
  110356. /**
  110357. * Defines a predicate to test if a given type mut be extended
  110358. */
  110359. predicate: (entity: any) => boolean;
  110360. /**
  110361. * Gets the list of options added to a type
  110362. */
  110363. entries: IExplorerExtensibilityOption[];
  110364. }
  110365. /**
  110366. * Interface used to define the options to use to create the Inspector
  110367. */
  110368. export interface IInspectorOptions {
  110369. /**
  110370. * Display in overlay mode (default: false)
  110371. */
  110372. overlay?: boolean;
  110373. /**
  110374. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110375. */
  110376. globalRoot?: HTMLElement;
  110377. /**
  110378. * Display the Scene explorer
  110379. */
  110380. showExplorer?: boolean;
  110381. /**
  110382. * Display the property inspector
  110383. */
  110384. showInspector?: boolean;
  110385. /**
  110386. * Display in embed mode (both panes on the right)
  110387. */
  110388. embedMode?: boolean;
  110389. /**
  110390. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110391. */
  110392. handleResize?: boolean;
  110393. /**
  110394. * Allow the panes to popup (default: true)
  110395. */
  110396. enablePopup?: boolean;
  110397. /**
  110398. * Allow the panes to be closed by users (default: true)
  110399. */
  110400. enableClose?: boolean;
  110401. /**
  110402. * Optional list of extensibility entries
  110403. */
  110404. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110405. /**
  110406. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110407. */
  110408. inspectorURL?: string;
  110409. }
  110410. interface Scene {
  110411. /**
  110412. * @hidden
  110413. * Backing field
  110414. */
  110415. _debugLayer: DebugLayer;
  110416. /**
  110417. * Gets the debug layer (aka Inspector) associated with the scene
  110418. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110419. */
  110420. debugLayer: DebugLayer;
  110421. }
  110422. /**
  110423. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110424. * what is happening in your scene
  110425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110426. */
  110427. export class DebugLayer {
  110428. /**
  110429. * Define the url to get the inspector script from.
  110430. * By default it uses the babylonjs CDN.
  110431. * @ignoreNaming
  110432. */
  110433. static InspectorURL: string;
  110434. private _scene;
  110435. private BJSINSPECTOR;
  110436. private _onPropertyChangedObservable?;
  110437. /**
  110438. * Observable triggered when a property is changed through the inspector.
  110439. */
  110440. readonly onPropertyChangedObservable: any;
  110441. /**
  110442. * Instantiates a new debug layer.
  110443. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110444. * what is happening in your scene
  110445. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110446. * @param scene Defines the scene to inspect
  110447. */
  110448. constructor(scene: Scene);
  110449. /** Creates the inspector window. */
  110450. private _createInspector;
  110451. /**
  110452. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110453. * @param entity defines the entity to select
  110454. * @param lineContainerTitle defines the specific block to highlight
  110455. */
  110456. select(entity: any, lineContainerTitle?: string): void;
  110457. /** Get the inspector from bundle or global */
  110458. private _getGlobalInspector;
  110459. /**
  110460. * Get if the inspector is visible or not.
  110461. * @returns true if visible otherwise, false
  110462. */
  110463. isVisible(): boolean;
  110464. /**
  110465. * Hide the inspector and close its window.
  110466. */
  110467. hide(): void;
  110468. /**
  110469. * Launch the debugLayer.
  110470. * @param config Define the configuration of the inspector
  110471. * @return a promise fulfilled when the debug layer is visible
  110472. */
  110473. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110474. }
  110475. }
  110476. declare module BABYLON {
  110477. /**
  110478. * Class containing static functions to help procedurally build meshes
  110479. */
  110480. export class BoxBuilder {
  110481. /**
  110482. * Creates a box mesh
  110483. * * The parameter `size` sets the size (float) of each box side (default 1)
  110484. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110485. * * 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)
  110486. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110490. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110491. * @param name defines the name of the mesh
  110492. * @param options defines the options used to create the mesh
  110493. * @param scene defines the hosting scene
  110494. * @returns the box mesh
  110495. */
  110496. static CreateBox(name: string, options: {
  110497. size?: number;
  110498. width?: number;
  110499. height?: number;
  110500. depth?: number;
  110501. faceUV?: Vector4[];
  110502. faceColors?: Color4[];
  110503. sideOrientation?: number;
  110504. frontUVs?: Vector4;
  110505. backUVs?: Vector4;
  110506. wrap?: boolean;
  110507. topBaseAt?: number;
  110508. bottomBaseAt?: number;
  110509. updatable?: boolean;
  110510. }, scene?: Nullable<Scene>): Mesh;
  110511. }
  110512. }
  110513. declare module BABYLON {
  110514. /**
  110515. * Class containing static functions to help procedurally build meshes
  110516. */
  110517. export class SphereBuilder {
  110518. /**
  110519. * Creates a sphere mesh
  110520. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110521. * * 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`)
  110522. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110523. * * 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
  110524. * * 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)
  110525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110528. * @param name defines the name of the mesh
  110529. * @param options defines the options used to create the mesh
  110530. * @param scene defines the hosting scene
  110531. * @returns the sphere mesh
  110532. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110533. */
  110534. static CreateSphere(name: string, options: {
  110535. segments?: number;
  110536. diameter?: number;
  110537. diameterX?: number;
  110538. diameterY?: number;
  110539. diameterZ?: number;
  110540. arc?: number;
  110541. slice?: number;
  110542. sideOrientation?: number;
  110543. frontUVs?: Vector4;
  110544. backUVs?: Vector4;
  110545. updatable?: boolean;
  110546. }, scene?: Nullable<Scene>): Mesh;
  110547. }
  110548. }
  110549. declare module BABYLON.Debug {
  110550. /**
  110551. * Used to show the physics impostor around the specific mesh
  110552. */
  110553. export class PhysicsViewer {
  110554. /** @hidden */
  110555. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110556. /** @hidden */
  110557. protected _meshes: Array<Nullable<AbstractMesh>>;
  110558. /** @hidden */
  110559. protected _scene: Nullable<Scene>;
  110560. /** @hidden */
  110561. protected _numMeshes: number;
  110562. /** @hidden */
  110563. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110564. private _renderFunction;
  110565. private _utilityLayer;
  110566. private _debugBoxMesh;
  110567. private _debugSphereMesh;
  110568. private _debugCylinderMesh;
  110569. private _debugMaterial;
  110570. private _debugMeshMeshes;
  110571. /**
  110572. * Creates a new PhysicsViewer
  110573. * @param scene defines the hosting scene
  110574. */
  110575. constructor(scene: Scene);
  110576. /** @hidden */
  110577. protected _updateDebugMeshes(): void;
  110578. /**
  110579. * Renders a specified physic impostor
  110580. * @param impostor defines the impostor to render
  110581. * @param targetMesh defines the mesh represented by the impostor
  110582. * @returns the new debug mesh used to render the impostor
  110583. */
  110584. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110585. /**
  110586. * Hides a specified physic impostor
  110587. * @param impostor defines the impostor to hide
  110588. */
  110589. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110590. private _getDebugMaterial;
  110591. private _getDebugBoxMesh;
  110592. private _getDebugSphereMesh;
  110593. private _getDebugCylinderMesh;
  110594. private _getDebugMeshMesh;
  110595. private _getDebugMesh;
  110596. /** Releases all resources */
  110597. dispose(): void;
  110598. }
  110599. }
  110600. declare module BABYLON {
  110601. /**
  110602. * Class containing static functions to help procedurally build meshes
  110603. */
  110604. export class LinesBuilder {
  110605. /**
  110606. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110607. * * 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
  110608. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110609. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110610. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110611. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110612. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110613. * * 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
  110614. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110617. * @param name defines the name of the new line system
  110618. * @param options defines the options used to create the line system
  110619. * @param scene defines the hosting scene
  110620. * @returns a new line system mesh
  110621. */
  110622. static CreateLineSystem(name: string, options: {
  110623. lines: Vector3[][];
  110624. updatable?: boolean;
  110625. instance?: Nullable<LinesMesh>;
  110626. colors?: Nullable<Color4[][]>;
  110627. useVertexAlpha?: boolean;
  110628. }, scene: Nullable<Scene>): LinesMesh;
  110629. /**
  110630. * Creates a line mesh
  110631. * 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
  110632. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110633. * * The parameter `points` is an array successive Vector3
  110634. * * 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
  110635. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110636. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110637. * * When updating an instance, remember that only point positions can change, not the number of points
  110638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110640. * @param name defines the name of the new line system
  110641. * @param options defines the options used to create the line system
  110642. * @param scene defines the hosting scene
  110643. * @returns a new line mesh
  110644. */
  110645. static CreateLines(name: string, options: {
  110646. points: Vector3[];
  110647. updatable?: boolean;
  110648. instance?: Nullable<LinesMesh>;
  110649. colors?: Color4[];
  110650. useVertexAlpha?: boolean;
  110651. }, scene?: Nullable<Scene>): LinesMesh;
  110652. /**
  110653. * Creates a dashed line mesh
  110654. * * 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
  110655. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110656. * * The parameter `points` is an array successive Vector3
  110657. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110658. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110659. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110660. * * 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
  110661. * * When updating an instance, remember that only point positions can change, not the number of points
  110662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110663. * @param name defines the name of the mesh
  110664. * @param options defines the options used to create the mesh
  110665. * @param scene defines the hosting scene
  110666. * @returns the dashed line mesh
  110667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110668. */
  110669. static CreateDashedLines(name: string, options: {
  110670. points: Vector3[];
  110671. dashSize?: number;
  110672. gapSize?: number;
  110673. dashNb?: number;
  110674. updatable?: boolean;
  110675. instance?: LinesMesh;
  110676. }, scene?: Nullable<Scene>): LinesMesh;
  110677. }
  110678. }
  110679. declare module BABYLON {
  110680. /**
  110681. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110682. * in order to better appreciate the issue one might have.
  110683. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110684. */
  110685. export class RayHelper {
  110686. /**
  110687. * Defines the ray we are currently tryin to visualize.
  110688. */
  110689. ray: Nullable<Ray>;
  110690. private _renderPoints;
  110691. private _renderLine;
  110692. private _renderFunction;
  110693. private _scene;
  110694. private _updateToMeshFunction;
  110695. private _attachedToMesh;
  110696. private _meshSpaceDirection;
  110697. private _meshSpaceOrigin;
  110698. /**
  110699. * Helper function to create a colored helper in a scene in one line.
  110700. * @param ray Defines the ray we are currently tryin to visualize
  110701. * @param scene Defines the scene the ray is used in
  110702. * @param color Defines the color we want to see the ray in
  110703. * @returns The newly created ray helper.
  110704. */
  110705. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110706. /**
  110707. * Instantiate a new ray helper.
  110708. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110709. * in order to better appreciate the issue one might have.
  110710. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110711. * @param ray Defines the ray we are currently tryin to visualize
  110712. */
  110713. constructor(ray: Ray);
  110714. /**
  110715. * Shows the ray we are willing to debug.
  110716. * @param scene Defines the scene the ray needs to be rendered in
  110717. * @param color Defines the color the ray needs to be rendered in
  110718. */
  110719. show(scene: Scene, color?: Color3): void;
  110720. /**
  110721. * Hides the ray we are debugging.
  110722. */
  110723. hide(): void;
  110724. private _render;
  110725. /**
  110726. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110727. * @param mesh Defines the mesh we want the helper attached to
  110728. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110729. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110730. * @param length Defines the length of the ray
  110731. */
  110732. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110733. /**
  110734. * Detach the ray helper from the mesh it has previously been attached to.
  110735. */
  110736. detachFromMesh(): void;
  110737. private _updateToMesh;
  110738. /**
  110739. * Dispose the helper and release its associated resources.
  110740. */
  110741. dispose(): void;
  110742. }
  110743. }
  110744. declare module BABYLON.Debug {
  110745. /**
  110746. * Class used to render a debug view of a given skeleton
  110747. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110748. */
  110749. export class SkeletonViewer {
  110750. /** defines the skeleton to render */
  110751. skeleton: Skeleton;
  110752. /** defines the mesh attached to the skeleton */
  110753. mesh: AbstractMesh;
  110754. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110755. autoUpdateBonesMatrices: boolean;
  110756. /** defines the rendering group id to use with the viewer */
  110757. renderingGroupId: number;
  110758. /** Gets or sets the color used to render the skeleton */
  110759. color: Color3;
  110760. private _scene;
  110761. private _debugLines;
  110762. private _debugMesh;
  110763. private _isEnabled;
  110764. private _renderFunction;
  110765. private _utilityLayer;
  110766. /**
  110767. * Returns the mesh used to render the bones
  110768. */
  110769. readonly debugMesh: Nullable<LinesMesh>;
  110770. /**
  110771. * Creates a new SkeletonViewer
  110772. * @param skeleton defines the skeleton to render
  110773. * @param mesh defines the mesh attached to the skeleton
  110774. * @param scene defines the hosting scene
  110775. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110776. * @param renderingGroupId defines the rendering group id to use with the viewer
  110777. */
  110778. constructor(
  110779. /** defines the skeleton to render */
  110780. skeleton: Skeleton,
  110781. /** defines the mesh attached to the skeleton */
  110782. mesh: AbstractMesh, scene: Scene,
  110783. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110784. autoUpdateBonesMatrices?: boolean,
  110785. /** defines the rendering group id to use with the viewer */
  110786. renderingGroupId?: number);
  110787. /** Gets or sets a boolean indicating if the viewer is enabled */
  110788. isEnabled: boolean;
  110789. private _getBonePosition;
  110790. private _getLinesForBonesWithLength;
  110791. private _getLinesForBonesNoLength;
  110792. /** Update the viewer to sync with current skeleton state */
  110793. update(): void;
  110794. /** Release associated resources */
  110795. dispose(): void;
  110796. }
  110797. }
  110798. declare module BABYLON {
  110799. /**
  110800. * Options to create the null engine
  110801. */
  110802. export class NullEngineOptions {
  110803. /**
  110804. * Render width (Default: 512)
  110805. */
  110806. renderWidth: number;
  110807. /**
  110808. * Render height (Default: 256)
  110809. */
  110810. renderHeight: number;
  110811. /**
  110812. * Texture size (Default: 512)
  110813. */
  110814. textureSize: number;
  110815. /**
  110816. * If delta time between frames should be constant
  110817. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110818. */
  110819. deterministicLockstep: boolean;
  110820. /**
  110821. * Maximum about of steps between frames (Default: 4)
  110822. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110823. */
  110824. lockstepMaxSteps: number;
  110825. }
  110826. /**
  110827. * The null engine class provides support for headless version of babylon.js.
  110828. * This can be used in server side scenario or for testing purposes
  110829. */
  110830. export class NullEngine extends Engine {
  110831. private _options;
  110832. /**
  110833. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110834. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110835. * @returns true if engine is in deterministic lock step mode
  110836. */
  110837. isDeterministicLockStep(): boolean;
  110838. /**
  110839. * Gets the max steps when engine is running in deterministic lock step
  110840. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110841. * @returns the max steps
  110842. */
  110843. getLockstepMaxSteps(): number;
  110844. /**
  110845. * Gets the current hardware scaling level.
  110846. * By default the hardware scaling level is computed from the window device ratio.
  110847. * 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.
  110848. * @returns a number indicating the current hardware scaling level
  110849. */
  110850. getHardwareScalingLevel(): number;
  110851. constructor(options?: NullEngineOptions);
  110852. /**
  110853. * Creates a vertex buffer
  110854. * @param vertices the data for the vertex buffer
  110855. * @returns the new WebGL static buffer
  110856. */
  110857. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110858. /**
  110859. * Creates a new index buffer
  110860. * @param indices defines the content of the index buffer
  110861. * @param updatable defines if the index buffer must be updatable
  110862. * @returns a new webGL buffer
  110863. */
  110864. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110865. /**
  110866. * Clear the current render buffer or the current render target (if any is set up)
  110867. * @param color defines the color to use
  110868. * @param backBuffer defines if the back buffer must be cleared
  110869. * @param depth defines if the depth buffer must be cleared
  110870. * @param stencil defines if the stencil buffer must be cleared
  110871. */
  110872. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110873. /**
  110874. * Gets the current render width
  110875. * @param useScreen defines if screen size must be used (or the current render target if any)
  110876. * @returns a number defining the current render width
  110877. */
  110878. getRenderWidth(useScreen?: boolean): number;
  110879. /**
  110880. * Gets the current render height
  110881. * @param useScreen defines if screen size must be used (or the current render target if any)
  110882. * @returns a number defining the current render height
  110883. */
  110884. getRenderHeight(useScreen?: boolean): number;
  110885. /**
  110886. * Set the WebGL's viewport
  110887. * @param viewport defines the viewport element to be used
  110888. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110889. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110890. */
  110891. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110892. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110893. /**
  110894. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110895. * @param pipelineContext defines the pipeline context to use
  110896. * @param uniformsNames defines the list of uniform names
  110897. * @returns an array of webGL uniform locations
  110898. */
  110899. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110900. /**
  110901. * Gets the lsit of active attributes for a given webGL program
  110902. * @param pipelineContext defines the pipeline context to use
  110903. * @param attributesNames defines the list of attribute names to get
  110904. * @returns an array of indices indicating the offset of each attribute
  110905. */
  110906. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110907. /**
  110908. * Binds an effect to the webGL context
  110909. * @param effect defines the effect to bind
  110910. */
  110911. bindSamplers(effect: Effect): void;
  110912. /**
  110913. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110914. * @param effect defines the effect to activate
  110915. */
  110916. enableEffect(effect: Effect): void;
  110917. /**
  110918. * Set various states to the webGL context
  110919. * @param culling defines backface culling state
  110920. * @param zOffset defines the value to apply to zOffset (0 by default)
  110921. * @param force defines if states must be applied even if cache is up to date
  110922. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110923. */
  110924. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110925. /**
  110926. * Set the value of an uniform to an array of int32
  110927. * @param uniform defines the webGL uniform location where to store the value
  110928. * @param array defines the array of int32 to store
  110929. */
  110930. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110931. /**
  110932. * Set the value of an uniform to an array of int32 (stored as vec2)
  110933. * @param uniform defines the webGL uniform location where to store the value
  110934. * @param array defines the array of int32 to store
  110935. */
  110936. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110937. /**
  110938. * Set the value of an uniform to an array of int32 (stored as vec3)
  110939. * @param uniform defines the webGL uniform location where to store the value
  110940. * @param array defines the array of int32 to store
  110941. */
  110942. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110943. /**
  110944. * Set the value of an uniform to an array of int32 (stored as vec4)
  110945. * @param uniform defines the webGL uniform location where to store the value
  110946. * @param array defines the array of int32 to store
  110947. */
  110948. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110949. /**
  110950. * Set the value of an uniform to an array of float32
  110951. * @param uniform defines the webGL uniform location where to store the value
  110952. * @param array defines the array of float32 to store
  110953. */
  110954. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110955. /**
  110956. * Set the value of an uniform to an array of float32 (stored as vec2)
  110957. * @param uniform defines the webGL uniform location where to store the value
  110958. * @param array defines the array of float32 to store
  110959. */
  110960. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110961. /**
  110962. * Set the value of an uniform to an array of float32 (stored as vec3)
  110963. * @param uniform defines the webGL uniform location where to store the value
  110964. * @param array defines the array of float32 to store
  110965. */
  110966. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110967. /**
  110968. * Set the value of an uniform to an array of float32 (stored as vec4)
  110969. * @param uniform defines the webGL uniform location where to store the value
  110970. * @param array defines the array of float32 to store
  110971. */
  110972. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110973. /**
  110974. * Set the value of an uniform to an array of number
  110975. * @param uniform defines the webGL uniform location where to store the value
  110976. * @param array defines the array of number to store
  110977. */
  110978. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110979. /**
  110980. * Set the value of an uniform to an array of number (stored as vec2)
  110981. * @param uniform defines the webGL uniform location where to store the value
  110982. * @param array defines the array of number to store
  110983. */
  110984. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110985. /**
  110986. * Set the value of an uniform to an array of number (stored as vec3)
  110987. * @param uniform defines the webGL uniform location where to store the value
  110988. * @param array defines the array of number to store
  110989. */
  110990. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110991. /**
  110992. * Set the value of an uniform to an array of number (stored as vec4)
  110993. * @param uniform defines the webGL uniform location where to store the value
  110994. * @param array defines the array of number to store
  110995. */
  110996. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110997. /**
  110998. * Set the value of an uniform to an array of float32 (stored as matrices)
  110999. * @param uniform defines the webGL uniform location where to store the value
  111000. * @param matrices defines the array of float32 to store
  111001. */
  111002. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111003. /**
  111004. * Set the value of an uniform to a matrix (3x3)
  111005. * @param uniform defines the webGL uniform location where to store the value
  111006. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111007. */
  111008. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111009. /**
  111010. * Set the value of an uniform to a matrix (2x2)
  111011. * @param uniform defines the webGL uniform location where to store the value
  111012. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111013. */
  111014. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111015. /**
  111016. * Set the value of an uniform to a number (float)
  111017. * @param uniform defines the webGL uniform location where to store the value
  111018. * @param value defines the float number to store
  111019. */
  111020. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111021. /**
  111022. * Set the value of an uniform to a vec2
  111023. * @param uniform defines the webGL uniform location where to store the value
  111024. * @param x defines the 1st component of the value
  111025. * @param y defines the 2nd component of the value
  111026. */
  111027. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111028. /**
  111029. * Set the value of an uniform to a vec3
  111030. * @param uniform defines the webGL uniform location where to store the value
  111031. * @param x defines the 1st component of the value
  111032. * @param y defines the 2nd component of the value
  111033. * @param z defines the 3rd component of the value
  111034. */
  111035. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111036. /**
  111037. * Set the value of an uniform to a boolean
  111038. * @param uniform defines the webGL uniform location where to store the value
  111039. * @param bool defines the boolean to store
  111040. */
  111041. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111042. /**
  111043. * Set the value of an uniform to a vec4
  111044. * @param uniform defines the webGL uniform location where to store the value
  111045. * @param x defines the 1st component of the value
  111046. * @param y defines the 2nd component of the value
  111047. * @param z defines the 3rd component of the value
  111048. * @param w defines the 4th component of the value
  111049. */
  111050. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111051. /**
  111052. * Sets the current alpha mode
  111053. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111054. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111055. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111056. */
  111057. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111058. /**
  111059. * Bind webGl buffers directly to the webGL context
  111060. * @param vertexBuffers defines the vertex buffer to bind
  111061. * @param indexBuffer defines the index buffer to bind
  111062. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111063. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111064. * @param effect defines the effect associated with the vertex buffer
  111065. */
  111066. bindBuffers(vertexBuffers: {
  111067. [key: string]: VertexBuffer;
  111068. }, indexBuffer: DataBuffer, effect: Effect): void;
  111069. /**
  111070. * Force the entire cache to be cleared
  111071. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111072. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111073. */
  111074. wipeCaches(bruteForce?: boolean): void;
  111075. /**
  111076. * Send a draw order
  111077. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111078. * @param indexStart defines the starting index
  111079. * @param indexCount defines the number of index to draw
  111080. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111081. */
  111082. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111083. /**
  111084. * Draw a list of indexed primitives
  111085. * @param fillMode defines the primitive to use
  111086. * @param indexStart defines the starting index
  111087. * @param indexCount defines the number of index to draw
  111088. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111089. */
  111090. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111091. /**
  111092. * Draw a list of unindexed primitives
  111093. * @param fillMode defines the primitive to use
  111094. * @param verticesStart defines the index of first vertex to draw
  111095. * @param verticesCount defines the count of vertices to draw
  111096. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111097. */
  111098. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111099. /** @hidden */
  111100. _createTexture(): WebGLTexture;
  111101. /** @hidden */
  111102. _releaseTexture(texture: InternalTexture): void;
  111103. /**
  111104. * Usually called from Texture.ts.
  111105. * Passed information to create a WebGLTexture
  111106. * @param urlArg defines a value which contains one of the following:
  111107. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111108. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111109. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111110. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111111. * @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)
  111112. * @param scene needed for loading to the correct scene
  111113. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111114. * @param onLoad optional callback to be called upon successful completion
  111115. * @param onError optional callback to be called upon failure
  111116. * @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
  111117. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111118. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111119. * @param forcedExtension defines the extension to use to pick the right loader
  111120. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111121. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111122. */
  111123. 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;
  111124. /**
  111125. * Creates a new render target texture
  111126. * @param size defines the size of the texture
  111127. * @param options defines the options used to create the texture
  111128. * @returns a new render target texture stored in an InternalTexture
  111129. */
  111130. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111131. /**
  111132. * Update the sampling mode of a given texture
  111133. * @param samplingMode defines the required sampling mode
  111134. * @param texture defines the texture to update
  111135. */
  111136. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111137. /**
  111138. * Binds the frame buffer to the specified texture.
  111139. * @param texture The texture to render to or null for the default canvas
  111140. * @param faceIndex The face of the texture to render to in case of cube texture
  111141. * @param requiredWidth The width of the target to render to
  111142. * @param requiredHeight The height of the target to render to
  111143. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111144. * @param depthStencilTexture The depth stencil texture to use to render
  111145. * @param lodLevel defines le lod level to bind to the frame buffer
  111146. */
  111147. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111148. /**
  111149. * Unbind the current render target texture from the webGL context
  111150. * @param texture defines the render target texture to unbind
  111151. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111152. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111153. */
  111154. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111155. /**
  111156. * Creates a dynamic vertex buffer
  111157. * @param vertices the data for the dynamic vertex buffer
  111158. * @returns the new WebGL dynamic buffer
  111159. */
  111160. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111161. /**
  111162. * Update the content of a dynamic texture
  111163. * @param texture defines the texture to update
  111164. * @param canvas defines the canvas containing the source
  111165. * @param invertY defines if data must be stored with Y axis inverted
  111166. * @param premulAlpha defines if alpha is stored as premultiplied
  111167. * @param format defines the format of the data
  111168. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111169. */
  111170. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111171. /**
  111172. * Gets a boolean indicating if all created effects are ready
  111173. * @returns true if all effects are ready
  111174. */
  111175. areAllEffectsReady(): boolean;
  111176. /**
  111177. * @hidden
  111178. * Get the current error code of the webGL context
  111179. * @returns the error code
  111180. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111181. */
  111182. getError(): number;
  111183. /** @hidden */
  111184. _getUnpackAlignement(): number;
  111185. /** @hidden */
  111186. _unpackFlipY(value: boolean): void;
  111187. /**
  111188. * Update a dynamic index buffer
  111189. * @param indexBuffer defines the target index buffer
  111190. * @param indices defines the data to update
  111191. * @param offset defines the offset in the target index buffer where update should start
  111192. */
  111193. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111194. /**
  111195. * Updates a dynamic vertex buffer.
  111196. * @param vertexBuffer the vertex buffer to update
  111197. * @param vertices the data used to update the vertex buffer
  111198. * @param byteOffset the byte offset of the data (optional)
  111199. * @param byteLength the byte length of the data (optional)
  111200. */
  111201. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111202. /** @hidden */
  111203. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111204. /** @hidden */
  111205. _bindTexture(channel: number, texture: InternalTexture): void;
  111206. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111207. /**
  111208. * 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
  111209. */
  111210. releaseEffects(): void;
  111211. displayLoadingUI(): void;
  111212. hideLoadingUI(): void;
  111213. /** @hidden */
  111214. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111215. /** @hidden */
  111216. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111217. /** @hidden */
  111218. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111219. /** @hidden */
  111220. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111221. }
  111222. }
  111223. declare module BABYLON {
  111224. /** @hidden */
  111225. export class _OcclusionDataStorage {
  111226. /** @hidden */
  111227. occlusionInternalRetryCounter: number;
  111228. /** @hidden */
  111229. isOcclusionQueryInProgress: boolean;
  111230. /** @hidden */
  111231. isOccluded: boolean;
  111232. /** @hidden */
  111233. occlusionRetryCount: number;
  111234. /** @hidden */
  111235. occlusionType: number;
  111236. /** @hidden */
  111237. occlusionQueryAlgorithmType: number;
  111238. }
  111239. interface Engine {
  111240. /**
  111241. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111242. * @return the new query
  111243. */
  111244. createQuery(): WebGLQuery;
  111245. /**
  111246. * Delete and release a webGL query
  111247. * @param query defines the query to delete
  111248. * @return the current engine
  111249. */
  111250. deleteQuery(query: WebGLQuery): Engine;
  111251. /**
  111252. * Check if a given query has resolved and got its value
  111253. * @param query defines the query to check
  111254. * @returns true if the query got its value
  111255. */
  111256. isQueryResultAvailable(query: WebGLQuery): boolean;
  111257. /**
  111258. * Gets the value of a given query
  111259. * @param query defines the query to check
  111260. * @returns the value of the query
  111261. */
  111262. getQueryResult(query: WebGLQuery): number;
  111263. /**
  111264. * Initiates an occlusion query
  111265. * @param algorithmType defines the algorithm to use
  111266. * @param query defines the query to use
  111267. * @returns the current engine
  111268. * @see http://doc.babylonjs.com/features/occlusionquery
  111269. */
  111270. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111271. /**
  111272. * Ends an occlusion query
  111273. * @see http://doc.babylonjs.com/features/occlusionquery
  111274. * @param algorithmType defines the algorithm to use
  111275. * @returns the current engine
  111276. */
  111277. endOcclusionQuery(algorithmType: number): Engine;
  111278. /**
  111279. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111280. * Please note that only one query can be issued at a time
  111281. * @returns a time token used to track the time span
  111282. */
  111283. startTimeQuery(): Nullable<_TimeToken>;
  111284. /**
  111285. * Ends a time query
  111286. * @param token defines the token used to measure the time span
  111287. * @returns the time spent (in ns)
  111288. */
  111289. endTimeQuery(token: _TimeToken): int;
  111290. /** @hidden */
  111291. _currentNonTimestampToken: Nullable<_TimeToken>;
  111292. /** @hidden */
  111293. _createTimeQuery(): WebGLQuery;
  111294. /** @hidden */
  111295. _deleteTimeQuery(query: WebGLQuery): void;
  111296. /** @hidden */
  111297. _getGlAlgorithmType(algorithmType: number): number;
  111298. /** @hidden */
  111299. _getTimeQueryResult(query: WebGLQuery): any;
  111300. /** @hidden */
  111301. _getTimeQueryAvailability(query: WebGLQuery): any;
  111302. }
  111303. interface AbstractMesh {
  111304. /**
  111305. * Backing filed
  111306. * @hidden
  111307. */
  111308. __occlusionDataStorage: _OcclusionDataStorage;
  111309. /**
  111310. * Access property
  111311. * @hidden
  111312. */
  111313. _occlusionDataStorage: _OcclusionDataStorage;
  111314. /**
  111315. * 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.
  111316. * The default value is -1 which means don't break the query and wait till the result
  111317. * @see http://doc.babylonjs.com/features/occlusionquery
  111318. */
  111319. occlusionRetryCount: number;
  111320. /**
  111321. * 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:
  111322. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111323. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111324. * * 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.
  111325. * @see http://doc.babylonjs.com/features/occlusionquery
  111326. */
  111327. occlusionType: number;
  111328. /**
  111329. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111330. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111331. * * 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.
  111332. * @see http://doc.babylonjs.com/features/occlusionquery
  111333. */
  111334. occlusionQueryAlgorithmType: number;
  111335. /**
  111336. * 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
  111337. * @see http://doc.babylonjs.com/features/occlusionquery
  111338. */
  111339. isOccluded: boolean;
  111340. /**
  111341. * Flag to check the progress status of the query
  111342. * @see http://doc.babylonjs.com/features/occlusionquery
  111343. */
  111344. isOcclusionQueryInProgress: boolean;
  111345. }
  111346. }
  111347. declare module BABYLON {
  111348. /** @hidden */
  111349. export var _forceTransformFeedbackToBundle: boolean;
  111350. interface Engine {
  111351. /**
  111352. * Creates a webGL transform feedback object
  111353. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111354. * @returns the webGL transform feedback object
  111355. */
  111356. createTransformFeedback(): WebGLTransformFeedback;
  111357. /**
  111358. * Delete a webGL transform feedback object
  111359. * @param value defines the webGL transform feedback object to delete
  111360. */
  111361. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111362. /**
  111363. * Bind a webGL transform feedback object to the webgl context
  111364. * @param value defines the webGL transform feedback object to bind
  111365. */
  111366. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111367. /**
  111368. * Begins a transform feedback operation
  111369. * @param usePoints defines if points or triangles must be used
  111370. */
  111371. beginTransformFeedback(usePoints: boolean): void;
  111372. /**
  111373. * Ends a transform feedback operation
  111374. */
  111375. endTransformFeedback(): void;
  111376. /**
  111377. * Specify the varyings to use with transform feedback
  111378. * @param program defines the associated webGL program
  111379. * @param value defines the list of strings representing the varying names
  111380. */
  111381. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111382. /**
  111383. * Bind a webGL buffer for a transform feedback operation
  111384. * @param value defines the webGL buffer to bind
  111385. */
  111386. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111387. }
  111388. }
  111389. declare module BABYLON {
  111390. /**
  111391. * Creation options of the multi render target texture.
  111392. */
  111393. export interface IMultiRenderTargetOptions {
  111394. /**
  111395. * Define if the texture needs to create mip maps after render.
  111396. */
  111397. generateMipMaps?: boolean;
  111398. /**
  111399. * Define the types of all the draw buffers we want to create
  111400. */
  111401. types?: number[];
  111402. /**
  111403. * Define the sampling modes of all the draw buffers we want to create
  111404. */
  111405. samplingModes?: number[];
  111406. /**
  111407. * Define if a depth buffer is required
  111408. */
  111409. generateDepthBuffer?: boolean;
  111410. /**
  111411. * Define if a stencil buffer is required
  111412. */
  111413. generateStencilBuffer?: boolean;
  111414. /**
  111415. * Define if a depth texture is required instead of a depth buffer
  111416. */
  111417. generateDepthTexture?: boolean;
  111418. /**
  111419. * Define the number of desired draw buffers
  111420. */
  111421. textureCount?: number;
  111422. /**
  111423. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111424. */
  111425. doNotChangeAspectRatio?: boolean;
  111426. /**
  111427. * Define the default type of the buffers we are creating
  111428. */
  111429. defaultType?: number;
  111430. }
  111431. /**
  111432. * A multi render target, like a render target provides the ability to render to a texture.
  111433. * Unlike the render target, it can render to several draw buffers in one draw.
  111434. * This is specially interesting in deferred rendering or for any effects requiring more than
  111435. * just one color from a single pass.
  111436. */
  111437. export class MultiRenderTarget extends RenderTargetTexture {
  111438. private _internalTextures;
  111439. private _textures;
  111440. private _multiRenderTargetOptions;
  111441. /**
  111442. * Get if draw buffers are currently supported by the used hardware and browser.
  111443. */
  111444. readonly isSupported: boolean;
  111445. /**
  111446. * Get the list of textures generated by the multi render target.
  111447. */
  111448. readonly textures: Texture[];
  111449. /**
  111450. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111451. */
  111452. readonly depthTexture: Texture;
  111453. /**
  111454. * Set the wrapping mode on U of all the textures we are rendering to.
  111455. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111456. */
  111457. wrapU: number;
  111458. /**
  111459. * Set the wrapping mode on V of all the textures we are rendering to.
  111460. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111461. */
  111462. wrapV: number;
  111463. /**
  111464. * Instantiate a new multi render target texture.
  111465. * A multi render target, like a render target provides the ability to render to a texture.
  111466. * Unlike the render target, it can render to several draw buffers in one draw.
  111467. * This is specially interesting in deferred rendering or for any effects requiring more than
  111468. * just one color from a single pass.
  111469. * @param name Define the name of the texture
  111470. * @param size Define the size of the buffers to render to
  111471. * @param count Define the number of target we are rendering into
  111472. * @param scene Define the scene the texture belongs to
  111473. * @param options Define the options used to create the multi render target
  111474. */
  111475. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111476. /** @hidden */
  111477. _rebuild(): void;
  111478. private _createInternalTextures;
  111479. private _createTextures;
  111480. /**
  111481. * Define the number of samples used if MSAA is enabled.
  111482. */
  111483. samples: number;
  111484. /**
  111485. * Resize all the textures in the multi render target.
  111486. * Be carrefull as it will recreate all the data in the new texture.
  111487. * @param size Define the new size
  111488. */
  111489. resize(size: any): void;
  111490. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111491. /**
  111492. * Dispose the render targets and their associated resources
  111493. */
  111494. dispose(): void;
  111495. /**
  111496. * Release all the underlying texture used as draw buffers.
  111497. */
  111498. releaseInternalTextures(): void;
  111499. }
  111500. }
  111501. declare module BABYLON {
  111502. interface ThinEngine {
  111503. /**
  111504. * Unbind a list of render target textures from the webGL context
  111505. * This is used only when drawBuffer extension or webGL2 are active
  111506. * @param textures defines the render target textures to unbind
  111507. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111508. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111509. */
  111510. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111511. /**
  111512. * Create a multi render target texture
  111513. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111514. * @param size defines the size of the texture
  111515. * @param options defines the creation options
  111516. * @returns the cube texture as an InternalTexture
  111517. */
  111518. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111519. /**
  111520. * Update the sample count for a given multiple render target texture
  111521. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111522. * @param textures defines the textures to update
  111523. * @param samples defines the sample count to set
  111524. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111525. */
  111526. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111527. }
  111528. }
  111529. declare module BABYLON {
  111530. /**
  111531. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111532. */
  111533. export interface CubeMapInfo {
  111534. /**
  111535. * The pixel array for the front face.
  111536. * This is stored in format, left to right, up to down format.
  111537. */
  111538. front: Nullable<ArrayBufferView>;
  111539. /**
  111540. * The pixel array for the back face.
  111541. * This is stored in format, left to right, up to down format.
  111542. */
  111543. back: Nullable<ArrayBufferView>;
  111544. /**
  111545. * The pixel array for the left face.
  111546. * This is stored in format, left to right, up to down format.
  111547. */
  111548. left: Nullable<ArrayBufferView>;
  111549. /**
  111550. * The pixel array for the right face.
  111551. * This is stored in format, left to right, up to down format.
  111552. */
  111553. right: Nullable<ArrayBufferView>;
  111554. /**
  111555. * The pixel array for the up face.
  111556. * This is stored in format, left to right, up to down format.
  111557. */
  111558. up: Nullable<ArrayBufferView>;
  111559. /**
  111560. * The pixel array for the down face.
  111561. * This is stored in format, left to right, up to down format.
  111562. */
  111563. down: Nullable<ArrayBufferView>;
  111564. /**
  111565. * The size of the cubemap stored.
  111566. *
  111567. * Each faces will be size * size pixels.
  111568. */
  111569. size: number;
  111570. /**
  111571. * The format of the texture.
  111572. *
  111573. * RGBA, RGB.
  111574. */
  111575. format: number;
  111576. /**
  111577. * The type of the texture data.
  111578. *
  111579. * UNSIGNED_INT, FLOAT.
  111580. */
  111581. type: number;
  111582. /**
  111583. * Specifies whether the texture is in gamma space.
  111584. */
  111585. gammaSpace: boolean;
  111586. }
  111587. /**
  111588. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111589. */
  111590. export class PanoramaToCubeMapTools {
  111591. private static FACE_FRONT;
  111592. private static FACE_BACK;
  111593. private static FACE_RIGHT;
  111594. private static FACE_LEFT;
  111595. private static FACE_DOWN;
  111596. private static FACE_UP;
  111597. /**
  111598. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111599. *
  111600. * @param float32Array The source data.
  111601. * @param inputWidth The width of the input panorama.
  111602. * @param inputHeight The height of the input panorama.
  111603. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111604. * @return The cubemap data
  111605. */
  111606. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111607. private static CreateCubemapTexture;
  111608. private static CalcProjectionSpherical;
  111609. }
  111610. }
  111611. declare module BABYLON {
  111612. /**
  111613. * Helper class dealing with the extraction of spherical polynomial dataArray
  111614. * from a cube map.
  111615. */
  111616. export class CubeMapToSphericalPolynomialTools {
  111617. private static FileFaces;
  111618. /**
  111619. * Converts a texture to the according Spherical Polynomial data.
  111620. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111621. *
  111622. * @param texture The texture to extract the information from.
  111623. * @return The Spherical Polynomial data.
  111624. */
  111625. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111626. /**
  111627. * Converts a cubemap to the according Spherical Polynomial data.
  111628. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111629. *
  111630. * @param cubeInfo The Cube map to extract the information from.
  111631. * @return The Spherical Polynomial data.
  111632. */
  111633. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111634. }
  111635. }
  111636. declare module BABYLON {
  111637. interface BaseTexture {
  111638. /**
  111639. * Get the polynomial representation of the texture data.
  111640. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111641. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111642. */
  111643. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111644. }
  111645. }
  111646. declare module BABYLON {
  111647. /** @hidden */
  111648. export var rgbdEncodePixelShader: {
  111649. name: string;
  111650. shader: string;
  111651. };
  111652. }
  111653. declare module BABYLON {
  111654. /** @hidden */
  111655. export var rgbdDecodePixelShader: {
  111656. name: string;
  111657. shader: string;
  111658. };
  111659. }
  111660. declare module BABYLON {
  111661. /**
  111662. * Raw texture data and descriptor sufficient for WebGL texture upload
  111663. */
  111664. export interface EnvironmentTextureInfo {
  111665. /**
  111666. * Version of the environment map
  111667. */
  111668. version: number;
  111669. /**
  111670. * Width of image
  111671. */
  111672. width: number;
  111673. /**
  111674. * Irradiance information stored in the file.
  111675. */
  111676. irradiance: any;
  111677. /**
  111678. * Specular information stored in the file.
  111679. */
  111680. specular: any;
  111681. }
  111682. /**
  111683. * Defines One Image in the file. It requires only the position in the file
  111684. * as well as the length.
  111685. */
  111686. interface BufferImageData {
  111687. /**
  111688. * Length of the image data.
  111689. */
  111690. length: number;
  111691. /**
  111692. * Position of the data from the null terminator delimiting the end of the JSON.
  111693. */
  111694. position: number;
  111695. }
  111696. /**
  111697. * Defines the specular data enclosed in the file.
  111698. * This corresponds to the version 1 of the data.
  111699. */
  111700. export interface EnvironmentTextureSpecularInfoV1 {
  111701. /**
  111702. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111703. */
  111704. specularDataPosition?: number;
  111705. /**
  111706. * This contains all the images data needed to reconstruct the cubemap.
  111707. */
  111708. mipmaps: Array<BufferImageData>;
  111709. /**
  111710. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111711. */
  111712. lodGenerationScale: number;
  111713. }
  111714. /**
  111715. * Sets of helpers addressing the serialization and deserialization of environment texture
  111716. * stored in a BabylonJS env file.
  111717. * Those files are usually stored as .env files.
  111718. */
  111719. export class EnvironmentTextureTools {
  111720. /**
  111721. * Magic number identifying the env file.
  111722. */
  111723. private static _MagicBytes;
  111724. /**
  111725. * Gets the environment info from an env file.
  111726. * @param data The array buffer containing the .env bytes.
  111727. * @returns the environment file info (the json header) if successfully parsed.
  111728. */
  111729. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111730. /**
  111731. * Creates an environment texture from a loaded cube texture.
  111732. * @param texture defines the cube texture to convert in env file
  111733. * @return a promise containing the environment data if succesfull.
  111734. */
  111735. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111736. /**
  111737. * Creates a JSON representation of the spherical data.
  111738. * @param texture defines the texture containing the polynomials
  111739. * @return the JSON representation of the spherical info
  111740. */
  111741. private static _CreateEnvTextureIrradiance;
  111742. /**
  111743. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111744. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111745. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111746. * @return the views described by info providing access to the underlying buffer
  111747. */
  111748. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111749. /**
  111750. * Uploads the texture info contained in the env file to the GPU.
  111751. * @param texture defines the internal texture to upload to
  111752. * @param arrayBuffer defines the buffer cotaining the data to load
  111753. * @param info defines the texture info retrieved through the GetEnvInfo method
  111754. * @returns a promise
  111755. */
  111756. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111757. /**
  111758. * Uploads the levels of image data to the GPU.
  111759. * @param texture defines the internal texture to upload to
  111760. * @param imageData defines the array buffer views of image data [mipmap][face]
  111761. * @returns a promise
  111762. */
  111763. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111764. /**
  111765. * Uploads spherical polynomials information to the texture.
  111766. * @param texture defines the texture we are trying to upload the information to
  111767. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111768. */
  111769. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111770. /** @hidden */
  111771. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111772. }
  111773. }
  111774. declare module BABYLON {
  111775. /**
  111776. * Contains position and normal vectors for a vertex
  111777. */
  111778. export class PositionNormalVertex {
  111779. /** the position of the vertex (defaut: 0,0,0) */
  111780. position: Vector3;
  111781. /** the normal of the vertex (defaut: 0,1,0) */
  111782. normal: Vector3;
  111783. /**
  111784. * Creates a PositionNormalVertex
  111785. * @param position the position of the vertex (defaut: 0,0,0)
  111786. * @param normal the normal of the vertex (defaut: 0,1,0)
  111787. */
  111788. constructor(
  111789. /** the position of the vertex (defaut: 0,0,0) */
  111790. position?: Vector3,
  111791. /** the normal of the vertex (defaut: 0,1,0) */
  111792. normal?: Vector3);
  111793. /**
  111794. * Clones the PositionNormalVertex
  111795. * @returns the cloned PositionNormalVertex
  111796. */
  111797. clone(): PositionNormalVertex;
  111798. }
  111799. /**
  111800. * Contains position, normal and uv vectors for a vertex
  111801. */
  111802. export class PositionNormalTextureVertex {
  111803. /** the position of the vertex (defaut: 0,0,0) */
  111804. position: Vector3;
  111805. /** the normal of the vertex (defaut: 0,1,0) */
  111806. normal: Vector3;
  111807. /** the uv of the vertex (default: 0,0) */
  111808. uv: Vector2;
  111809. /**
  111810. * Creates a PositionNormalTextureVertex
  111811. * @param position the position of the vertex (defaut: 0,0,0)
  111812. * @param normal the normal of the vertex (defaut: 0,1,0)
  111813. * @param uv the uv of the vertex (default: 0,0)
  111814. */
  111815. constructor(
  111816. /** the position of the vertex (defaut: 0,0,0) */
  111817. position?: Vector3,
  111818. /** the normal of the vertex (defaut: 0,1,0) */
  111819. normal?: Vector3,
  111820. /** the uv of the vertex (default: 0,0) */
  111821. uv?: Vector2);
  111822. /**
  111823. * Clones the PositionNormalTextureVertex
  111824. * @returns the cloned PositionNormalTextureVertex
  111825. */
  111826. clone(): PositionNormalTextureVertex;
  111827. }
  111828. }
  111829. declare module BABYLON {
  111830. /** @hidden */
  111831. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111832. private _genericAttributeLocation;
  111833. private _varyingLocationCount;
  111834. private _varyingLocationMap;
  111835. private _replacements;
  111836. private _textureCount;
  111837. private _uniforms;
  111838. lineProcessor(line: string): string;
  111839. attributeProcessor(attribute: string): string;
  111840. varyingProcessor(varying: string, isFragment: boolean): string;
  111841. uniformProcessor(uniform: string): string;
  111842. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111843. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111844. }
  111845. }
  111846. declare module BABYLON {
  111847. /**
  111848. * Container for accessors for natively-stored mesh data buffers.
  111849. */
  111850. class NativeDataBuffer extends DataBuffer {
  111851. /**
  111852. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111853. */
  111854. nativeIndexBuffer?: any;
  111855. /**
  111856. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111857. */
  111858. nativeVertexBuffer?: any;
  111859. }
  111860. /** @hidden */
  111861. export class NativeEngine extends Engine {
  111862. private readonly _native;
  111863. getHardwareScalingLevel(): number;
  111864. constructor();
  111865. /**
  111866. * Can be used to override the current requestAnimationFrame requester.
  111867. * @hidden
  111868. */
  111869. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111870. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111871. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111872. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111873. recordVertexArrayObject(vertexBuffers: {
  111874. [key: string]: VertexBuffer;
  111875. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111876. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111877. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111878. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111879. /**
  111880. * Draw a list of indexed primitives
  111881. * @param fillMode defines the primitive to use
  111882. * @param indexStart defines the starting index
  111883. * @param indexCount defines the number of index to draw
  111884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111885. */
  111886. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111887. /**
  111888. * Draw a list of unindexed primitives
  111889. * @param fillMode defines the primitive to use
  111890. * @param verticesStart defines the index of first vertex to draw
  111891. * @param verticesCount defines the count of vertices to draw
  111892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111893. */
  111894. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111895. createPipelineContext(): IPipelineContext;
  111896. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111897. /** @hidden */
  111898. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111899. /** @hidden */
  111900. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111901. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111902. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111903. protected _setProgram(program: WebGLProgram): void;
  111904. _releaseEffect(effect: Effect): void;
  111905. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111906. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111907. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111908. bindSamplers(effect: Effect): void;
  111909. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111910. getRenderWidth(useScreen?: boolean): number;
  111911. getRenderHeight(useScreen?: boolean): number;
  111912. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111913. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111914. /**
  111915. * Set the z offset to apply to current rendering
  111916. * @param value defines the offset to apply
  111917. */
  111918. setZOffset(value: number): void;
  111919. /**
  111920. * Gets the current value of the zOffset
  111921. * @returns the current zOffset state
  111922. */
  111923. getZOffset(): number;
  111924. /**
  111925. * Enable or disable depth buffering
  111926. * @param enable defines the state to set
  111927. */
  111928. setDepthBuffer(enable: boolean): void;
  111929. /**
  111930. * Gets a boolean indicating if depth writing is enabled
  111931. * @returns the current depth writing state
  111932. */
  111933. getDepthWrite(): boolean;
  111934. /**
  111935. * Enable or disable depth writing
  111936. * @param enable defines the state to set
  111937. */
  111938. setDepthWrite(enable: boolean): void;
  111939. /**
  111940. * Enable or disable color writing
  111941. * @param enable defines the state to set
  111942. */
  111943. setColorWrite(enable: boolean): void;
  111944. /**
  111945. * Gets a boolean indicating if color writing is enabled
  111946. * @returns the current color writing state
  111947. */
  111948. getColorWrite(): boolean;
  111949. /**
  111950. * Sets alpha constants used by some alpha blending modes
  111951. * @param r defines the red component
  111952. * @param g defines the green component
  111953. * @param b defines the blue component
  111954. * @param a defines the alpha component
  111955. */
  111956. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111957. /**
  111958. * Sets the current alpha mode
  111959. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111960. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111962. */
  111963. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111964. /**
  111965. * Gets the current alpha mode
  111966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111967. * @returns the current alpha mode
  111968. */
  111969. getAlphaMode(): number;
  111970. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111971. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111972. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111973. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111974. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111975. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111976. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111977. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111978. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111979. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111980. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111981. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111982. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111983. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111984. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111985. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111986. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111987. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111988. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111989. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111990. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111991. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111992. wipeCaches(bruteForce?: boolean): void;
  111993. _createTexture(): WebGLTexture;
  111994. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111995. /**
  111996. * Usually called from BABYLON.Texture.ts.
  111997. * Passed information to create a WebGLTexture
  111998. * @param urlArg defines a value which contains one of the following:
  111999. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112000. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112001. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112002. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112003. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112004. * @param scene needed for loading to the correct scene
  112005. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112006. * @param onLoad optional callback to be called upon successful completion
  112007. * @param onError optional callback to be called upon failure
  112008. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112009. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112010. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112011. * @param forcedExtension defines the extension to use to pick the right loader
  112012. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112013. */
  112014. 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;
  112015. /**
  112016. * Creates a cube texture
  112017. * @param rootUrl defines the url where the files to load is located
  112018. * @param scene defines the current scene
  112019. * @param files defines the list of files to load (1 per face)
  112020. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112021. * @param onLoad defines an optional callback raised when the texture is loaded
  112022. * @param onError defines an optional callback raised if there is an issue to load the texture
  112023. * @param format defines the format of the data
  112024. * @param forcedExtension defines the extension to use to pick the right loader
  112025. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112028. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112029. * @returns the cube texture as an InternalTexture
  112030. */
  112031. 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;
  112032. private _getSamplingFilter;
  112033. private static _GetNativeTextureFormat;
  112034. createRenderTargetTexture(size: number | {
  112035. width: number;
  112036. height: number;
  112037. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112038. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112039. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112040. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112041. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112042. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112043. /**
  112044. * Updates a dynamic vertex buffer.
  112045. * @param vertexBuffer the vertex buffer to update
  112046. * @param data the data used to update the vertex buffer
  112047. * @param byteOffset the byte offset of the data (optional)
  112048. * @param byteLength the byte length of the data (optional)
  112049. */
  112050. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112051. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112052. private _updateAnisotropicLevel;
  112053. private _getAddressMode;
  112054. /** @hidden */
  112055. _bindTexture(channel: number, texture: InternalTexture): void;
  112056. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112057. releaseEffects(): void;
  112058. /** @hidden */
  112059. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112060. /** @hidden */
  112061. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112062. /** @hidden */
  112063. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112064. /** @hidden */
  112065. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112066. }
  112067. }
  112068. declare module BABYLON {
  112069. /**
  112070. * Gather the list of clipboard event types as constants.
  112071. */
  112072. export class ClipboardEventTypes {
  112073. /**
  112074. * The clipboard event is fired when a copy command is active (pressed).
  112075. */
  112076. static readonly COPY: number;
  112077. /**
  112078. * The clipboard event is fired when a cut command is active (pressed).
  112079. */
  112080. static readonly CUT: number;
  112081. /**
  112082. * The clipboard event is fired when a paste command is active (pressed).
  112083. */
  112084. static readonly PASTE: number;
  112085. }
  112086. /**
  112087. * This class is used to store clipboard related info for the onClipboardObservable event.
  112088. */
  112089. export class ClipboardInfo {
  112090. /**
  112091. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112092. */
  112093. type: number;
  112094. /**
  112095. * Defines the related dom event
  112096. */
  112097. event: ClipboardEvent;
  112098. /**
  112099. *Creates an instance of ClipboardInfo.
  112100. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112101. * @param event Defines the related dom event
  112102. */
  112103. constructor(
  112104. /**
  112105. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112106. */
  112107. type: number,
  112108. /**
  112109. * Defines the related dom event
  112110. */
  112111. event: ClipboardEvent);
  112112. /**
  112113. * Get the clipboard event's type from the keycode.
  112114. * @param keyCode Defines the keyCode for the current keyboard event.
  112115. * @return {number}
  112116. */
  112117. static GetTypeFromCharacter(keyCode: number): number;
  112118. }
  112119. }
  112120. declare module BABYLON {
  112121. /**
  112122. * Google Daydream controller
  112123. */
  112124. export class DaydreamController extends WebVRController {
  112125. /**
  112126. * Base Url for the controller model.
  112127. */
  112128. static MODEL_BASE_URL: string;
  112129. /**
  112130. * File name for the controller model.
  112131. */
  112132. static MODEL_FILENAME: string;
  112133. /**
  112134. * Gamepad Id prefix used to identify Daydream Controller.
  112135. */
  112136. static readonly GAMEPAD_ID_PREFIX: string;
  112137. /**
  112138. * Creates a new DaydreamController from a gamepad
  112139. * @param vrGamepad the gamepad that the controller should be created from
  112140. */
  112141. constructor(vrGamepad: any);
  112142. /**
  112143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112144. * @param scene scene in which to add meshes
  112145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112146. */
  112147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112148. /**
  112149. * Called once for each button that changed state since the last frame
  112150. * @param buttonIdx Which button index changed
  112151. * @param state New state of the button
  112152. * @param changes Which properties on the state changed since last frame
  112153. */
  112154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112155. }
  112156. }
  112157. declare module BABYLON {
  112158. /**
  112159. * Gear VR Controller
  112160. */
  112161. export class GearVRController extends WebVRController {
  112162. /**
  112163. * Base Url for the controller model.
  112164. */
  112165. static MODEL_BASE_URL: string;
  112166. /**
  112167. * File name for the controller model.
  112168. */
  112169. static MODEL_FILENAME: string;
  112170. /**
  112171. * Gamepad Id prefix used to identify this controller.
  112172. */
  112173. static readonly GAMEPAD_ID_PREFIX: string;
  112174. private readonly _buttonIndexToObservableNameMap;
  112175. /**
  112176. * Creates a new GearVRController from a gamepad
  112177. * @param vrGamepad the gamepad that the controller should be created from
  112178. */
  112179. constructor(vrGamepad: any);
  112180. /**
  112181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112182. * @param scene scene in which to add meshes
  112183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112184. */
  112185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112186. /**
  112187. * Called once for each button that changed state since the last frame
  112188. * @param buttonIdx Which button index changed
  112189. * @param state New state of the button
  112190. * @param changes Which properties on the state changed since last frame
  112191. */
  112192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112193. }
  112194. }
  112195. declare module BABYLON {
  112196. /**
  112197. * Class containing static functions to help procedurally build meshes
  112198. */
  112199. export class PolyhedronBuilder {
  112200. /**
  112201. * Creates a polyhedron mesh
  112202. * * 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
  112203. * * The parameter `size` (positive float, default 1) sets the polygon size
  112204. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112205. * * 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`
  112206. * * 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
  112207. * * 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)`)
  112208. * * 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
  112209. * * 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
  112210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112213. * @param name defines the name of the mesh
  112214. * @param options defines the options used to create the mesh
  112215. * @param scene defines the hosting scene
  112216. * @returns the polyhedron mesh
  112217. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112218. */
  112219. static CreatePolyhedron(name: string, options: {
  112220. type?: number;
  112221. size?: number;
  112222. sizeX?: number;
  112223. sizeY?: number;
  112224. sizeZ?: number;
  112225. custom?: any;
  112226. faceUV?: Vector4[];
  112227. faceColors?: Color4[];
  112228. flat?: boolean;
  112229. updatable?: boolean;
  112230. sideOrientation?: number;
  112231. frontUVs?: Vector4;
  112232. backUVs?: Vector4;
  112233. }, scene?: Nullable<Scene>): Mesh;
  112234. }
  112235. }
  112236. declare module BABYLON {
  112237. /**
  112238. * Gizmo that enables scaling a mesh along 3 axis
  112239. */
  112240. export class ScaleGizmo extends Gizmo {
  112241. /**
  112242. * Internal gizmo used for interactions on the x axis
  112243. */
  112244. xGizmo: AxisScaleGizmo;
  112245. /**
  112246. * Internal gizmo used for interactions on the y axis
  112247. */
  112248. yGizmo: AxisScaleGizmo;
  112249. /**
  112250. * Internal gizmo used for interactions on the z axis
  112251. */
  112252. zGizmo: AxisScaleGizmo;
  112253. /**
  112254. * Internal gizmo used to scale all axis equally
  112255. */
  112256. uniformScaleGizmo: AxisScaleGizmo;
  112257. private _meshAttached;
  112258. private _updateGizmoRotationToMatchAttachedMesh;
  112259. private _snapDistance;
  112260. private _scaleRatio;
  112261. private _uniformScalingMesh;
  112262. private _octahedron;
  112263. /** Fires an event when any of it's sub gizmos are dragged */
  112264. onDragStartObservable: Observable<unknown>;
  112265. /** Fires an event when any of it's sub gizmos are released from dragging */
  112266. onDragEndObservable: Observable<unknown>;
  112267. attachedMesh: Nullable<AbstractMesh>;
  112268. /**
  112269. * Creates a ScaleGizmo
  112270. * @param gizmoLayer The utility layer the gizmo will be added to
  112271. */
  112272. constructor(gizmoLayer?: UtilityLayerRenderer);
  112273. updateGizmoRotationToMatchAttachedMesh: boolean;
  112274. /**
  112275. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112276. */
  112277. snapDistance: number;
  112278. /**
  112279. * Ratio for the scale of the gizmo (Default: 1)
  112280. */
  112281. scaleRatio: number;
  112282. /**
  112283. * Disposes of the gizmo
  112284. */
  112285. dispose(): void;
  112286. }
  112287. }
  112288. declare module BABYLON {
  112289. /**
  112290. * Single axis scale gizmo
  112291. */
  112292. export class AxisScaleGizmo extends Gizmo {
  112293. /**
  112294. * Drag behavior responsible for the gizmos dragging interactions
  112295. */
  112296. dragBehavior: PointerDragBehavior;
  112297. private _pointerObserver;
  112298. /**
  112299. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112300. */
  112301. snapDistance: number;
  112302. /**
  112303. * Event that fires each time the gizmo snaps to a new location.
  112304. * * snapDistance is the the change in distance
  112305. */
  112306. onSnapObservable: Observable<{
  112307. snapDistance: number;
  112308. }>;
  112309. /**
  112310. * If the scaling operation should be done on all axis (default: false)
  112311. */
  112312. uniformScaling: boolean;
  112313. private _isEnabled;
  112314. private _parent;
  112315. private _arrow;
  112316. private _coloredMaterial;
  112317. private _hoverMaterial;
  112318. /**
  112319. * Creates an AxisScaleGizmo
  112320. * @param gizmoLayer The utility layer the gizmo will be added to
  112321. * @param dragAxis The axis which the gizmo will be able to scale on
  112322. * @param color The color of the gizmo
  112323. */
  112324. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112325. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112326. /**
  112327. * If the gizmo is enabled
  112328. */
  112329. isEnabled: boolean;
  112330. /**
  112331. * Disposes of the gizmo
  112332. */
  112333. dispose(): void;
  112334. /**
  112335. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112336. * @param mesh The mesh to replace the default mesh of the gizmo
  112337. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112338. */
  112339. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112340. }
  112341. }
  112342. declare module BABYLON {
  112343. /**
  112344. * Bounding box gizmo
  112345. */
  112346. export class BoundingBoxGizmo extends Gizmo {
  112347. private _lineBoundingBox;
  112348. private _rotateSpheresParent;
  112349. private _scaleBoxesParent;
  112350. private _boundingDimensions;
  112351. private _renderObserver;
  112352. private _pointerObserver;
  112353. private _scaleDragSpeed;
  112354. private _tmpQuaternion;
  112355. private _tmpVector;
  112356. private _tmpRotationMatrix;
  112357. /**
  112358. * 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)
  112359. */
  112360. ignoreChildren: boolean;
  112361. /**
  112362. * 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)
  112363. */
  112364. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112365. /**
  112366. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112367. */
  112368. rotationSphereSize: number;
  112369. /**
  112370. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112371. */
  112372. scaleBoxSize: number;
  112373. /**
  112374. * 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)
  112375. */
  112376. fixedDragMeshScreenSize: boolean;
  112377. /**
  112378. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112379. */
  112380. fixedDragMeshScreenSizeDistanceFactor: number;
  112381. /**
  112382. * Fired when a rotation sphere or scale box is dragged
  112383. */
  112384. onDragStartObservable: Observable<{}>;
  112385. /**
  112386. * Fired when a scale box is dragged
  112387. */
  112388. onScaleBoxDragObservable: Observable<{}>;
  112389. /**
  112390. * Fired when a scale box drag is ended
  112391. */
  112392. onScaleBoxDragEndObservable: Observable<{}>;
  112393. /**
  112394. * Fired when a rotation sphere is dragged
  112395. */
  112396. onRotationSphereDragObservable: Observable<{}>;
  112397. /**
  112398. * Fired when a rotation sphere drag is ended
  112399. */
  112400. onRotationSphereDragEndObservable: Observable<{}>;
  112401. /**
  112402. * 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)
  112403. */
  112404. scalePivot: Nullable<Vector3>;
  112405. /**
  112406. * Mesh used as a pivot to rotate the attached mesh
  112407. */
  112408. private _anchorMesh;
  112409. private _existingMeshScale;
  112410. private _dragMesh;
  112411. private pointerDragBehavior;
  112412. private coloredMaterial;
  112413. private hoverColoredMaterial;
  112414. /**
  112415. * Sets the color of the bounding box gizmo
  112416. * @param color the color to set
  112417. */
  112418. setColor(color: Color3): void;
  112419. /**
  112420. * Creates an BoundingBoxGizmo
  112421. * @param gizmoLayer The utility layer the gizmo will be added to
  112422. * @param color The color of the gizmo
  112423. */
  112424. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112425. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112426. private _selectNode;
  112427. /**
  112428. * Updates the bounding box information for the Gizmo
  112429. */
  112430. updateBoundingBox(): void;
  112431. private _updateRotationSpheres;
  112432. private _updateScaleBoxes;
  112433. /**
  112434. * Enables rotation on the specified axis and disables rotation on the others
  112435. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112436. */
  112437. setEnabledRotationAxis(axis: string): void;
  112438. /**
  112439. * Enables/disables scaling
  112440. * @param enable if scaling should be enabled
  112441. */
  112442. setEnabledScaling(enable: boolean): void;
  112443. private _updateDummy;
  112444. /**
  112445. * Enables a pointer drag behavior on the bounding box of the gizmo
  112446. */
  112447. enableDragBehavior(): void;
  112448. /**
  112449. * Disposes of the gizmo
  112450. */
  112451. dispose(): void;
  112452. /**
  112453. * 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)
  112454. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112455. * @returns the bounding box mesh with the passed in mesh as a child
  112456. */
  112457. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112458. /**
  112459. * CustomMeshes are not supported by this gizmo
  112460. * @param mesh The mesh to replace the default mesh of the gizmo
  112461. */
  112462. setCustomMesh(mesh: Mesh): void;
  112463. }
  112464. }
  112465. declare module BABYLON {
  112466. /**
  112467. * Single plane rotation gizmo
  112468. */
  112469. export class PlaneRotationGizmo extends Gizmo {
  112470. /**
  112471. * Drag behavior responsible for the gizmos dragging interactions
  112472. */
  112473. dragBehavior: PointerDragBehavior;
  112474. private _pointerObserver;
  112475. /**
  112476. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112477. */
  112478. snapDistance: number;
  112479. /**
  112480. * Event that fires each time the gizmo snaps to a new location.
  112481. * * snapDistance is the the change in distance
  112482. */
  112483. onSnapObservable: Observable<{
  112484. snapDistance: number;
  112485. }>;
  112486. private _isEnabled;
  112487. private _parent;
  112488. /**
  112489. * Creates a PlaneRotationGizmo
  112490. * @param gizmoLayer The utility layer the gizmo will be added to
  112491. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112492. * @param color The color of the gizmo
  112493. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112494. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112495. */
  112496. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112498. /**
  112499. * If the gizmo is enabled
  112500. */
  112501. isEnabled: boolean;
  112502. /**
  112503. * Disposes of the gizmo
  112504. */
  112505. dispose(): void;
  112506. }
  112507. }
  112508. declare module BABYLON {
  112509. /**
  112510. * Gizmo that enables rotating a mesh along 3 axis
  112511. */
  112512. export class RotationGizmo extends Gizmo {
  112513. /**
  112514. * Internal gizmo used for interactions on the x axis
  112515. */
  112516. xGizmo: PlaneRotationGizmo;
  112517. /**
  112518. * Internal gizmo used for interactions on the y axis
  112519. */
  112520. yGizmo: PlaneRotationGizmo;
  112521. /**
  112522. * Internal gizmo used for interactions on the z axis
  112523. */
  112524. zGizmo: PlaneRotationGizmo;
  112525. /** Fires an event when any of it's sub gizmos are dragged */
  112526. onDragStartObservable: Observable<unknown>;
  112527. /** Fires an event when any of it's sub gizmos are released from dragging */
  112528. onDragEndObservable: Observable<unknown>;
  112529. private _meshAttached;
  112530. attachedMesh: Nullable<AbstractMesh>;
  112531. /**
  112532. * Creates a RotationGizmo
  112533. * @param gizmoLayer The utility layer the gizmo will be added to
  112534. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112535. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112536. */
  112537. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112538. updateGizmoRotationToMatchAttachedMesh: boolean;
  112539. /**
  112540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112541. */
  112542. snapDistance: number;
  112543. /**
  112544. * Ratio for the scale of the gizmo (Default: 1)
  112545. */
  112546. scaleRatio: number;
  112547. /**
  112548. * Disposes of the gizmo
  112549. */
  112550. dispose(): void;
  112551. /**
  112552. * CustomMeshes are not supported by this gizmo
  112553. * @param mesh The mesh to replace the default mesh of the gizmo
  112554. */
  112555. setCustomMesh(mesh: Mesh): void;
  112556. }
  112557. }
  112558. declare module BABYLON {
  112559. /**
  112560. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112561. */
  112562. export class GizmoManager implements IDisposable {
  112563. private scene;
  112564. /**
  112565. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112566. */
  112567. gizmos: {
  112568. positionGizmo: Nullable<PositionGizmo>;
  112569. rotationGizmo: Nullable<RotationGizmo>;
  112570. scaleGizmo: Nullable<ScaleGizmo>;
  112571. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112572. };
  112573. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112574. clearGizmoOnEmptyPointerEvent: boolean;
  112575. /** Fires an event when the manager is attached to a mesh */
  112576. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112577. private _gizmosEnabled;
  112578. private _pointerObserver;
  112579. private _attachedMesh;
  112580. private _boundingBoxColor;
  112581. private _defaultUtilityLayer;
  112582. private _defaultKeepDepthUtilityLayer;
  112583. /**
  112584. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112585. */
  112586. boundingBoxDragBehavior: SixDofDragBehavior;
  112587. /**
  112588. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112589. */
  112590. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112591. /**
  112592. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112593. */
  112594. usePointerToAttachGizmos: boolean;
  112595. /**
  112596. * Utility layer that the bounding box gizmo belongs to
  112597. */
  112598. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112599. /**
  112600. * Utility layer that all gizmos besides bounding box belong to
  112601. */
  112602. readonly utilityLayer: UtilityLayerRenderer;
  112603. /**
  112604. * Instatiates a gizmo manager
  112605. * @param scene the scene to overlay the gizmos on top of
  112606. */
  112607. constructor(scene: Scene);
  112608. /**
  112609. * Attaches a set of gizmos to the specified mesh
  112610. * @param mesh The mesh the gizmo's should be attached to
  112611. */
  112612. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112613. /**
  112614. * If the position gizmo is enabled
  112615. */
  112616. positionGizmoEnabled: boolean;
  112617. /**
  112618. * If the rotation gizmo is enabled
  112619. */
  112620. rotationGizmoEnabled: boolean;
  112621. /**
  112622. * If the scale gizmo is enabled
  112623. */
  112624. scaleGizmoEnabled: boolean;
  112625. /**
  112626. * If the boundingBox gizmo is enabled
  112627. */
  112628. boundingBoxGizmoEnabled: boolean;
  112629. /**
  112630. * Disposes of the gizmo manager
  112631. */
  112632. dispose(): void;
  112633. }
  112634. }
  112635. declare module BABYLON {
  112636. /**
  112637. * A directional light is defined by a direction (what a surprise!).
  112638. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112639. * 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.
  112640. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112641. */
  112642. export class DirectionalLight extends ShadowLight {
  112643. private _shadowFrustumSize;
  112644. /**
  112645. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112646. */
  112647. /**
  112648. * Specifies a fix frustum size for the shadow generation.
  112649. */
  112650. shadowFrustumSize: number;
  112651. private _shadowOrthoScale;
  112652. /**
  112653. * Gets the shadow projection scale against the optimal computed one.
  112654. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112655. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112656. */
  112657. /**
  112658. * Sets the shadow projection scale against the optimal computed one.
  112659. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112660. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112661. */
  112662. shadowOrthoScale: number;
  112663. /**
  112664. * Automatically compute the projection matrix to best fit (including all the casters)
  112665. * on each frame.
  112666. */
  112667. autoUpdateExtends: boolean;
  112668. private _orthoLeft;
  112669. private _orthoRight;
  112670. private _orthoTop;
  112671. private _orthoBottom;
  112672. /**
  112673. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112674. * The directional light is emitted from everywhere in the given direction.
  112675. * It can cast shadows.
  112676. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112677. * @param name The friendly name of the light
  112678. * @param direction The direction of the light
  112679. * @param scene The scene the light belongs to
  112680. */
  112681. constructor(name: string, direction: Vector3, scene: Scene);
  112682. /**
  112683. * Returns the string "DirectionalLight".
  112684. * @return The class name
  112685. */
  112686. getClassName(): string;
  112687. /**
  112688. * Returns the integer 1.
  112689. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112690. */
  112691. getTypeID(): number;
  112692. /**
  112693. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112694. * Returns the DirectionalLight Shadow projection matrix.
  112695. */
  112696. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112697. /**
  112698. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112699. * Returns the DirectionalLight Shadow projection matrix.
  112700. */
  112701. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112702. /**
  112703. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112704. * Returns the DirectionalLight Shadow projection matrix.
  112705. */
  112706. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112707. protected _buildUniformLayout(): void;
  112708. /**
  112709. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112710. * @param effect The effect to update
  112711. * @param lightIndex The index of the light in the effect to update
  112712. * @returns The directional light
  112713. */
  112714. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112715. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112716. /**
  112717. * Gets the minZ used for shadow according to both the scene and the light.
  112718. *
  112719. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112720. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112721. * @param activeCamera The camera we are returning the min for
  112722. * @returns the depth min z
  112723. */
  112724. getDepthMinZ(activeCamera: Camera): number;
  112725. /**
  112726. * Gets the maxZ used for shadow according to both the scene and the light.
  112727. *
  112728. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112729. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112730. * @param activeCamera The camera we are returning the max for
  112731. * @returns the depth max z
  112732. */
  112733. getDepthMaxZ(activeCamera: Camera): number;
  112734. /**
  112735. * Prepares the list of defines specific to the light type.
  112736. * @param defines the list of defines
  112737. * @param lightIndex defines the index of the light for the effect
  112738. */
  112739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112740. }
  112741. }
  112742. declare module BABYLON {
  112743. /**
  112744. * Class containing static functions to help procedurally build meshes
  112745. */
  112746. export class HemisphereBuilder {
  112747. /**
  112748. * Creates a hemisphere mesh
  112749. * @param name defines the name of the mesh
  112750. * @param options defines the options used to create the mesh
  112751. * @param scene defines the hosting scene
  112752. * @returns the hemisphere mesh
  112753. */
  112754. static CreateHemisphere(name: string, options: {
  112755. segments?: number;
  112756. diameter?: number;
  112757. sideOrientation?: number;
  112758. }, scene: any): Mesh;
  112759. }
  112760. }
  112761. declare module BABYLON {
  112762. /**
  112763. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112764. * These values define a cone of light starting from the position, emitting toward the direction.
  112765. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112766. * and the exponent defines the speed of the decay of the light with distance (reach).
  112767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112768. */
  112769. export class SpotLight extends ShadowLight {
  112770. private _angle;
  112771. private _innerAngle;
  112772. private _cosHalfAngle;
  112773. private _lightAngleScale;
  112774. private _lightAngleOffset;
  112775. /**
  112776. * Gets the cone angle of the spot light in Radians.
  112777. */
  112778. /**
  112779. * Sets the cone angle of the spot light in Radians.
  112780. */
  112781. angle: number;
  112782. /**
  112783. * Only used in gltf falloff mode, this defines the angle where
  112784. * the directional falloff will start before cutting at angle which could be seen
  112785. * as outer angle.
  112786. */
  112787. /**
  112788. * Only used in gltf falloff mode, this defines the angle where
  112789. * the directional falloff will start before cutting at angle which could be seen
  112790. * as outer angle.
  112791. */
  112792. innerAngle: number;
  112793. private _shadowAngleScale;
  112794. /**
  112795. * Allows scaling the angle of the light for shadow generation only.
  112796. */
  112797. /**
  112798. * Allows scaling the angle of the light for shadow generation only.
  112799. */
  112800. shadowAngleScale: number;
  112801. /**
  112802. * The light decay speed with the distance from the emission spot.
  112803. */
  112804. exponent: number;
  112805. private _projectionTextureMatrix;
  112806. /**
  112807. * Allows reading the projecton texture
  112808. */
  112809. readonly projectionTextureMatrix: Matrix;
  112810. protected _projectionTextureLightNear: number;
  112811. /**
  112812. * Gets the near clip of the Spotlight for texture projection.
  112813. */
  112814. /**
  112815. * Sets the near clip of the Spotlight for texture projection.
  112816. */
  112817. projectionTextureLightNear: number;
  112818. protected _projectionTextureLightFar: number;
  112819. /**
  112820. * Gets the far clip of the Spotlight for texture projection.
  112821. */
  112822. /**
  112823. * Sets the far clip of the Spotlight for texture projection.
  112824. */
  112825. projectionTextureLightFar: number;
  112826. protected _projectionTextureUpDirection: Vector3;
  112827. /**
  112828. * Gets the Up vector of the Spotlight for texture projection.
  112829. */
  112830. /**
  112831. * Sets the Up vector of the Spotlight for texture projection.
  112832. */
  112833. projectionTextureUpDirection: Vector3;
  112834. private _projectionTexture;
  112835. /**
  112836. * Gets the projection texture of the light.
  112837. */
  112838. /**
  112839. * Sets the projection texture of the light.
  112840. */
  112841. projectionTexture: Nullable<BaseTexture>;
  112842. private _projectionTextureViewLightDirty;
  112843. private _projectionTextureProjectionLightDirty;
  112844. private _projectionTextureDirty;
  112845. private _projectionTextureViewTargetVector;
  112846. private _projectionTextureViewLightMatrix;
  112847. private _projectionTextureProjectionLightMatrix;
  112848. private _projectionTextureScalingMatrix;
  112849. /**
  112850. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112851. * It can cast shadows.
  112852. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112853. * @param name The light friendly name
  112854. * @param position The position of the spot light in the scene
  112855. * @param direction The direction of the light in the scene
  112856. * @param angle The cone angle of the light in Radians
  112857. * @param exponent The light decay speed with the distance from the emission spot
  112858. * @param scene The scene the lights belongs to
  112859. */
  112860. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112861. /**
  112862. * Returns the string "SpotLight".
  112863. * @returns the class name
  112864. */
  112865. getClassName(): string;
  112866. /**
  112867. * Returns the integer 2.
  112868. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112869. */
  112870. getTypeID(): number;
  112871. /**
  112872. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112873. */
  112874. protected _setDirection(value: Vector3): void;
  112875. /**
  112876. * Overrides the position setter to recompute the projection texture view light Matrix.
  112877. */
  112878. protected _setPosition(value: Vector3): void;
  112879. /**
  112880. * 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.
  112881. * Returns the SpotLight.
  112882. */
  112883. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112884. protected _computeProjectionTextureViewLightMatrix(): void;
  112885. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112886. /**
  112887. * Main function for light texture projection matrix computing.
  112888. */
  112889. protected _computeProjectionTextureMatrix(): void;
  112890. protected _buildUniformLayout(): void;
  112891. private _computeAngleValues;
  112892. /**
  112893. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112894. * @param effect The effect to update
  112895. * @param lightIndex The index of the light in the effect to update
  112896. * @returns The spot light
  112897. */
  112898. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112899. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112900. /**
  112901. * Disposes the light and the associated resources.
  112902. */
  112903. dispose(): void;
  112904. /**
  112905. * Prepares the list of defines specific to the light type.
  112906. * @param defines the list of defines
  112907. * @param lightIndex defines the index of the light for the effect
  112908. */
  112909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112910. }
  112911. }
  112912. declare module BABYLON {
  112913. /**
  112914. * Gizmo that enables viewing a light
  112915. */
  112916. export class LightGizmo extends Gizmo {
  112917. private _lightMesh;
  112918. private _material;
  112919. private cachedPosition;
  112920. private cachedForward;
  112921. /**
  112922. * Creates a LightGizmo
  112923. * @param gizmoLayer The utility layer the gizmo will be added to
  112924. */
  112925. constructor(gizmoLayer?: UtilityLayerRenderer);
  112926. private _light;
  112927. /**
  112928. * The light that the gizmo is attached to
  112929. */
  112930. light: Nullable<Light>;
  112931. /**
  112932. * Gets the material used to render the light gizmo
  112933. */
  112934. readonly material: StandardMaterial;
  112935. /**
  112936. * @hidden
  112937. * Updates the gizmo to match the attached mesh's position/rotation
  112938. */
  112939. protected _update(): void;
  112940. private static _Scale;
  112941. /**
  112942. * Creates the lines for a light mesh
  112943. */
  112944. private static _createLightLines;
  112945. /**
  112946. * Disposes of the light gizmo
  112947. */
  112948. dispose(): void;
  112949. private static _CreateHemisphericLightMesh;
  112950. private static _CreatePointLightMesh;
  112951. private static _CreateSpotLightMesh;
  112952. private static _CreateDirectionalLightMesh;
  112953. }
  112954. }
  112955. declare module BABYLON {
  112956. /** @hidden */
  112957. export var backgroundFragmentDeclaration: {
  112958. name: string;
  112959. shader: string;
  112960. };
  112961. }
  112962. declare module BABYLON {
  112963. /** @hidden */
  112964. export var backgroundUboDeclaration: {
  112965. name: string;
  112966. shader: string;
  112967. };
  112968. }
  112969. declare module BABYLON {
  112970. /** @hidden */
  112971. export var backgroundPixelShader: {
  112972. name: string;
  112973. shader: string;
  112974. };
  112975. }
  112976. declare module BABYLON {
  112977. /** @hidden */
  112978. export var backgroundVertexDeclaration: {
  112979. name: string;
  112980. shader: string;
  112981. };
  112982. }
  112983. declare module BABYLON {
  112984. /** @hidden */
  112985. export var backgroundVertexShader: {
  112986. name: string;
  112987. shader: string;
  112988. };
  112989. }
  112990. declare module BABYLON {
  112991. /**
  112992. * Background material used to create an efficient environement around your scene.
  112993. */
  112994. export class BackgroundMaterial extends PushMaterial {
  112995. /**
  112996. * Standard reflectance value at parallel view angle.
  112997. */
  112998. static StandardReflectance0: number;
  112999. /**
  113000. * Standard reflectance value at grazing angle.
  113001. */
  113002. static StandardReflectance90: number;
  113003. protected _primaryColor: Color3;
  113004. /**
  113005. * Key light Color (multiply against the environement texture)
  113006. */
  113007. primaryColor: Color3;
  113008. protected __perceptualColor: Nullable<Color3>;
  113009. /**
  113010. * Experimental Internal Use Only.
  113011. *
  113012. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113013. * This acts as a helper to set the primary color to a more "human friendly" value.
  113014. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113015. * output color as close as possible from the chosen value.
  113016. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113017. * part of lighting setup.)
  113018. */
  113019. _perceptualColor: Nullable<Color3>;
  113020. protected _primaryColorShadowLevel: float;
  113021. /**
  113022. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113023. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113024. */
  113025. primaryColorShadowLevel: float;
  113026. protected _primaryColorHighlightLevel: float;
  113027. /**
  113028. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113029. * The primary color is used at the level chosen to define what the white area would look.
  113030. */
  113031. primaryColorHighlightLevel: float;
  113032. protected _reflectionTexture: Nullable<BaseTexture>;
  113033. /**
  113034. * Reflection Texture used in the material.
  113035. * Should be author in a specific way for the best result (refer to the documentation).
  113036. */
  113037. reflectionTexture: Nullable<BaseTexture>;
  113038. protected _reflectionBlur: float;
  113039. /**
  113040. * Reflection Texture level of blur.
  113041. *
  113042. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113043. * texture twice.
  113044. */
  113045. reflectionBlur: float;
  113046. protected _diffuseTexture: Nullable<BaseTexture>;
  113047. /**
  113048. * Diffuse Texture used in the material.
  113049. * Should be author in a specific way for the best result (refer to the documentation).
  113050. */
  113051. diffuseTexture: Nullable<BaseTexture>;
  113052. protected _shadowLights: Nullable<IShadowLight[]>;
  113053. /**
  113054. * Specify the list of lights casting shadow on the material.
  113055. * All scene shadow lights will be included if null.
  113056. */
  113057. shadowLights: Nullable<IShadowLight[]>;
  113058. protected _shadowLevel: float;
  113059. /**
  113060. * Helps adjusting the shadow to a softer level if required.
  113061. * 0 means black shadows and 1 means no shadows.
  113062. */
  113063. shadowLevel: float;
  113064. protected _sceneCenter: Vector3;
  113065. /**
  113066. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113067. * It is usually zero but might be interesting to modify according to your setup.
  113068. */
  113069. sceneCenter: Vector3;
  113070. protected _opacityFresnel: boolean;
  113071. /**
  113072. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113073. * This helps ensuring a nice transition when the camera goes under the ground.
  113074. */
  113075. opacityFresnel: boolean;
  113076. protected _reflectionFresnel: boolean;
  113077. /**
  113078. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113079. * This helps adding a mirror texture on the ground.
  113080. */
  113081. reflectionFresnel: boolean;
  113082. protected _reflectionFalloffDistance: number;
  113083. /**
  113084. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113085. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113086. */
  113087. reflectionFalloffDistance: number;
  113088. protected _reflectionAmount: number;
  113089. /**
  113090. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113091. */
  113092. reflectionAmount: number;
  113093. protected _reflectionReflectance0: number;
  113094. /**
  113095. * This specifies the weight of the reflection at grazing angle.
  113096. */
  113097. reflectionReflectance0: number;
  113098. protected _reflectionReflectance90: number;
  113099. /**
  113100. * This specifies the weight of the reflection at a perpendicular point of view.
  113101. */
  113102. reflectionReflectance90: number;
  113103. /**
  113104. * Sets the reflection reflectance fresnel values according to the default standard
  113105. * empirically know to work well :-)
  113106. */
  113107. reflectionStandardFresnelWeight: number;
  113108. protected _useRGBColor: boolean;
  113109. /**
  113110. * Helps to directly use the maps channels instead of their level.
  113111. */
  113112. useRGBColor: boolean;
  113113. protected _enableNoise: boolean;
  113114. /**
  113115. * This helps reducing the banding effect that could occur on the background.
  113116. */
  113117. enableNoise: boolean;
  113118. /**
  113119. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113120. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113121. * Recommended to be keep at 1.0 except for special cases.
  113122. */
  113123. fovMultiplier: number;
  113124. private _fovMultiplier;
  113125. /**
  113126. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113127. */
  113128. useEquirectangularFOV: boolean;
  113129. private _maxSimultaneousLights;
  113130. /**
  113131. * Number of Simultaneous lights allowed on the material.
  113132. */
  113133. maxSimultaneousLights: int;
  113134. /**
  113135. * Default configuration related to image processing available in the Background Material.
  113136. */
  113137. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113138. /**
  113139. * Keep track of the image processing observer to allow dispose and replace.
  113140. */
  113141. private _imageProcessingObserver;
  113142. /**
  113143. * Attaches a new image processing configuration to the PBR Material.
  113144. * @param configuration (if null the scene configuration will be use)
  113145. */
  113146. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113147. /**
  113148. * Gets the image processing configuration used either in this material.
  113149. */
  113150. /**
  113151. * Sets the Default image processing configuration used either in the this material.
  113152. *
  113153. * If sets to null, the scene one is in use.
  113154. */
  113155. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113156. /**
  113157. * Gets wether the color curves effect is enabled.
  113158. */
  113159. /**
  113160. * Sets wether the color curves effect is enabled.
  113161. */
  113162. cameraColorCurvesEnabled: boolean;
  113163. /**
  113164. * Gets wether the color grading effect is enabled.
  113165. */
  113166. /**
  113167. * Gets wether the color grading effect is enabled.
  113168. */
  113169. cameraColorGradingEnabled: boolean;
  113170. /**
  113171. * Gets wether tonemapping is enabled or not.
  113172. */
  113173. /**
  113174. * Sets wether tonemapping is enabled or not
  113175. */
  113176. cameraToneMappingEnabled: boolean;
  113177. /**
  113178. * The camera exposure used on this material.
  113179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113180. * This corresponds to a photographic exposure.
  113181. */
  113182. /**
  113183. * The camera exposure used on this material.
  113184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113185. * This corresponds to a photographic exposure.
  113186. */
  113187. cameraExposure: float;
  113188. /**
  113189. * Gets The camera contrast used on this material.
  113190. */
  113191. /**
  113192. * Sets The camera contrast used on this material.
  113193. */
  113194. cameraContrast: float;
  113195. /**
  113196. * Gets the Color Grading 2D Lookup Texture.
  113197. */
  113198. /**
  113199. * Sets the Color Grading 2D Lookup Texture.
  113200. */
  113201. cameraColorGradingTexture: Nullable<BaseTexture>;
  113202. /**
  113203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113205. * 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;
  113206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113207. */
  113208. /**
  113209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113211. * 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;
  113212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113213. */
  113214. cameraColorCurves: Nullable<ColorCurves>;
  113215. /**
  113216. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113217. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113218. */
  113219. switchToBGR: boolean;
  113220. private _renderTargets;
  113221. private _reflectionControls;
  113222. private _white;
  113223. private _primaryShadowColor;
  113224. private _primaryHighlightColor;
  113225. /**
  113226. * Instantiates a Background Material in the given scene
  113227. * @param name The friendly name of the material
  113228. * @param scene The scene to add the material to
  113229. */
  113230. constructor(name: string, scene: Scene);
  113231. /**
  113232. * Gets a boolean indicating that current material needs to register RTT
  113233. */
  113234. readonly hasRenderTargetTextures: boolean;
  113235. /**
  113236. * The entire material has been created in order to prevent overdraw.
  113237. * @returns false
  113238. */
  113239. needAlphaTesting(): boolean;
  113240. /**
  113241. * The entire material has been created in order to prevent overdraw.
  113242. * @returns true if blending is enable
  113243. */
  113244. needAlphaBlending(): boolean;
  113245. /**
  113246. * Checks wether the material is ready to be rendered for a given mesh.
  113247. * @param mesh The mesh to render
  113248. * @param subMesh The submesh to check against
  113249. * @param useInstances Specify wether or not the material is used with instances
  113250. * @returns true if all the dependencies are ready (Textures, Effects...)
  113251. */
  113252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113253. /**
  113254. * Compute the primary color according to the chosen perceptual color.
  113255. */
  113256. private _computePrimaryColorFromPerceptualColor;
  113257. /**
  113258. * Compute the highlights and shadow colors according to their chosen levels.
  113259. */
  113260. private _computePrimaryColors;
  113261. /**
  113262. * Build the uniform buffer used in the material.
  113263. */
  113264. buildUniformLayout(): void;
  113265. /**
  113266. * Unbind the material.
  113267. */
  113268. unbind(): void;
  113269. /**
  113270. * Bind only the world matrix to the material.
  113271. * @param world The world matrix to bind.
  113272. */
  113273. bindOnlyWorldMatrix(world: Matrix): void;
  113274. /**
  113275. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113276. * @param world The world matrix to bind.
  113277. * @param subMesh The submesh to bind for.
  113278. */
  113279. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113280. /**
  113281. * Checks to see if a texture is used in the material.
  113282. * @param texture - Base texture to use.
  113283. * @returns - Boolean specifying if a texture is used in the material.
  113284. */
  113285. hasTexture(texture: BaseTexture): boolean;
  113286. /**
  113287. * Dispose the material.
  113288. * @param forceDisposeEffect Force disposal of the associated effect.
  113289. * @param forceDisposeTextures Force disposal of the associated textures.
  113290. */
  113291. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113292. /**
  113293. * Clones the material.
  113294. * @param name The cloned name.
  113295. * @returns The cloned material.
  113296. */
  113297. clone(name: string): BackgroundMaterial;
  113298. /**
  113299. * Serializes the current material to its JSON representation.
  113300. * @returns The JSON representation.
  113301. */
  113302. serialize(): any;
  113303. /**
  113304. * Gets the class name of the material
  113305. * @returns "BackgroundMaterial"
  113306. */
  113307. getClassName(): string;
  113308. /**
  113309. * Parse a JSON input to create back a background material.
  113310. * @param source The JSON data to parse
  113311. * @param scene The scene to create the parsed material in
  113312. * @param rootUrl The root url of the assets the material depends upon
  113313. * @returns the instantiated BackgroundMaterial.
  113314. */
  113315. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113316. }
  113317. }
  113318. declare module BABYLON {
  113319. /**
  113320. * Represents the different options available during the creation of
  113321. * a Environment helper.
  113322. *
  113323. * This can control the default ground, skybox and image processing setup of your scene.
  113324. */
  113325. export interface IEnvironmentHelperOptions {
  113326. /**
  113327. * Specifies wether or not to create a ground.
  113328. * True by default.
  113329. */
  113330. createGround: boolean;
  113331. /**
  113332. * Specifies the ground size.
  113333. * 15 by default.
  113334. */
  113335. groundSize: number;
  113336. /**
  113337. * The texture used on the ground for the main color.
  113338. * Comes from the BabylonJS CDN by default.
  113339. *
  113340. * Remarks: Can be either a texture or a url.
  113341. */
  113342. groundTexture: string | BaseTexture;
  113343. /**
  113344. * The color mixed in the ground texture by default.
  113345. * BabylonJS clearColor by default.
  113346. */
  113347. groundColor: Color3;
  113348. /**
  113349. * Specifies the ground opacity.
  113350. * 1 by default.
  113351. */
  113352. groundOpacity: number;
  113353. /**
  113354. * Enables the ground to receive shadows.
  113355. * True by default.
  113356. */
  113357. enableGroundShadow: boolean;
  113358. /**
  113359. * Helps preventing the shadow to be fully black on the ground.
  113360. * 0.5 by default.
  113361. */
  113362. groundShadowLevel: number;
  113363. /**
  113364. * Creates a mirror texture attach to the ground.
  113365. * false by default.
  113366. */
  113367. enableGroundMirror: boolean;
  113368. /**
  113369. * Specifies the ground mirror size ratio.
  113370. * 0.3 by default as the default kernel is 64.
  113371. */
  113372. groundMirrorSizeRatio: number;
  113373. /**
  113374. * Specifies the ground mirror blur kernel size.
  113375. * 64 by default.
  113376. */
  113377. groundMirrorBlurKernel: number;
  113378. /**
  113379. * Specifies the ground mirror visibility amount.
  113380. * 1 by default
  113381. */
  113382. groundMirrorAmount: number;
  113383. /**
  113384. * Specifies the ground mirror reflectance weight.
  113385. * This uses the standard weight of the background material to setup the fresnel effect
  113386. * of the mirror.
  113387. * 1 by default.
  113388. */
  113389. groundMirrorFresnelWeight: number;
  113390. /**
  113391. * Specifies the ground mirror Falloff distance.
  113392. * This can helps reducing the size of the reflection.
  113393. * 0 by Default.
  113394. */
  113395. groundMirrorFallOffDistance: number;
  113396. /**
  113397. * Specifies the ground mirror texture type.
  113398. * Unsigned Int by Default.
  113399. */
  113400. groundMirrorTextureType: number;
  113401. /**
  113402. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113403. * the shown objects.
  113404. */
  113405. groundYBias: number;
  113406. /**
  113407. * Specifies wether or not to create a skybox.
  113408. * True by default.
  113409. */
  113410. createSkybox: boolean;
  113411. /**
  113412. * Specifies the skybox size.
  113413. * 20 by default.
  113414. */
  113415. skyboxSize: number;
  113416. /**
  113417. * The texture used on the skybox for the main color.
  113418. * Comes from the BabylonJS CDN by default.
  113419. *
  113420. * Remarks: Can be either a texture or a url.
  113421. */
  113422. skyboxTexture: string | BaseTexture;
  113423. /**
  113424. * The color mixed in the skybox texture by default.
  113425. * BabylonJS clearColor by default.
  113426. */
  113427. skyboxColor: Color3;
  113428. /**
  113429. * The background rotation around the Y axis of the scene.
  113430. * This helps aligning the key lights of your scene with the background.
  113431. * 0 by default.
  113432. */
  113433. backgroundYRotation: number;
  113434. /**
  113435. * Compute automatically the size of the elements to best fit with the scene.
  113436. */
  113437. sizeAuto: boolean;
  113438. /**
  113439. * Default position of the rootMesh if autoSize is not true.
  113440. */
  113441. rootPosition: Vector3;
  113442. /**
  113443. * Sets up the image processing in the scene.
  113444. * true by default.
  113445. */
  113446. setupImageProcessing: boolean;
  113447. /**
  113448. * The texture used as your environment texture in the scene.
  113449. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113450. *
  113451. * Remarks: Can be either a texture or a url.
  113452. */
  113453. environmentTexture: string | BaseTexture;
  113454. /**
  113455. * The value of the exposure to apply to the scene.
  113456. * 0.6 by default if setupImageProcessing is true.
  113457. */
  113458. cameraExposure: number;
  113459. /**
  113460. * The value of the contrast to apply to the scene.
  113461. * 1.6 by default if setupImageProcessing is true.
  113462. */
  113463. cameraContrast: number;
  113464. /**
  113465. * Specifies wether or not tonemapping should be enabled in the scene.
  113466. * true by default if setupImageProcessing is true.
  113467. */
  113468. toneMappingEnabled: boolean;
  113469. }
  113470. /**
  113471. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113472. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113473. * It also helps with the default setup of your imageProcessing configuration.
  113474. */
  113475. export class EnvironmentHelper {
  113476. /**
  113477. * Default ground texture URL.
  113478. */
  113479. private static _groundTextureCDNUrl;
  113480. /**
  113481. * Default skybox texture URL.
  113482. */
  113483. private static _skyboxTextureCDNUrl;
  113484. /**
  113485. * Default environment texture URL.
  113486. */
  113487. private static _environmentTextureCDNUrl;
  113488. /**
  113489. * Creates the default options for the helper.
  113490. */
  113491. private static _getDefaultOptions;
  113492. private _rootMesh;
  113493. /**
  113494. * Gets the root mesh created by the helper.
  113495. */
  113496. readonly rootMesh: Mesh;
  113497. private _skybox;
  113498. /**
  113499. * Gets the skybox created by the helper.
  113500. */
  113501. readonly skybox: Nullable<Mesh>;
  113502. private _skyboxTexture;
  113503. /**
  113504. * Gets the skybox texture created by the helper.
  113505. */
  113506. readonly skyboxTexture: Nullable<BaseTexture>;
  113507. private _skyboxMaterial;
  113508. /**
  113509. * Gets the skybox material created by the helper.
  113510. */
  113511. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113512. private _ground;
  113513. /**
  113514. * Gets the ground mesh created by the helper.
  113515. */
  113516. readonly ground: Nullable<Mesh>;
  113517. private _groundTexture;
  113518. /**
  113519. * Gets the ground texture created by the helper.
  113520. */
  113521. readonly groundTexture: Nullable<BaseTexture>;
  113522. private _groundMirror;
  113523. /**
  113524. * Gets the ground mirror created by the helper.
  113525. */
  113526. readonly groundMirror: Nullable<MirrorTexture>;
  113527. /**
  113528. * Gets the ground mirror render list to helps pushing the meshes
  113529. * you wish in the ground reflection.
  113530. */
  113531. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113532. private _groundMaterial;
  113533. /**
  113534. * Gets the ground material created by the helper.
  113535. */
  113536. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113537. /**
  113538. * Stores the creation options.
  113539. */
  113540. private readonly _scene;
  113541. private _options;
  113542. /**
  113543. * This observable will be notified with any error during the creation of the environment,
  113544. * mainly texture creation errors.
  113545. */
  113546. onErrorObservable: Observable<{
  113547. message?: string;
  113548. exception?: any;
  113549. }>;
  113550. /**
  113551. * constructor
  113552. * @param options Defines the options we want to customize the helper
  113553. * @param scene The scene to add the material to
  113554. */
  113555. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113556. /**
  113557. * Updates the background according to the new options
  113558. * @param options
  113559. */
  113560. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113561. /**
  113562. * Sets the primary color of all the available elements.
  113563. * @param color the main color to affect to the ground and the background
  113564. */
  113565. setMainColor(color: Color3): void;
  113566. /**
  113567. * Setup the image processing according to the specified options.
  113568. */
  113569. private _setupImageProcessing;
  113570. /**
  113571. * Setup the environment texture according to the specified options.
  113572. */
  113573. private _setupEnvironmentTexture;
  113574. /**
  113575. * Setup the background according to the specified options.
  113576. */
  113577. private _setupBackground;
  113578. /**
  113579. * Get the scene sizes according to the setup.
  113580. */
  113581. private _getSceneSize;
  113582. /**
  113583. * Setup the ground according to the specified options.
  113584. */
  113585. private _setupGround;
  113586. /**
  113587. * Setup the ground material according to the specified options.
  113588. */
  113589. private _setupGroundMaterial;
  113590. /**
  113591. * Setup the ground diffuse texture according to the specified options.
  113592. */
  113593. private _setupGroundDiffuseTexture;
  113594. /**
  113595. * Setup the ground mirror texture according to the specified options.
  113596. */
  113597. private _setupGroundMirrorTexture;
  113598. /**
  113599. * Setup the ground to receive the mirror texture.
  113600. */
  113601. private _setupMirrorInGroundMaterial;
  113602. /**
  113603. * Setup the skybox according to the specified options.
  113604. */
  113605. private _setupSkybox;
  113606. /**
  113607. * Setup the skybox material according to the specified options.
  113608. */
  113609. private _setupSkyboxMaterial;
  113610. /**
  113611. * Setup the skybox reflection texture according to the specified options.
  113612. */
  113613. private _setupSkyboxReflectionTexture;
  113614. private _errorHandler;
  113615. /**
  113616. * Dispose all the elements created by the Helper.
  113617. */
  113618. dispose(): void;
  113619. }
  113620. }
  113621. declare module BABYLON {
  113622. /**
  113623. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113624. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113625. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113626. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113627. */
  113628. export class PhotoDome extends TransformNode {
  113629. /**
  113630. * Define the image as a Monoscopic panoramic 360 image.
  113631. */
  113632. static readonly MODE_MONOSCOPIC: number;
  113633. /**
  113634. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113635. */
  113636. static readonly MODE_TOPBOTTOM: number;
  113637. /**
  113638. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113639. */
  113640. static readonly MODE_SIDEBYSIDE: number;
  113641. private _useDirectMapping;
  113642. /**
  113643. * The texture being displayed on the sphere
  113644. */
  113645. protected _photoTexture: Texture;
  113646. /**
  113647. * Gets or sets the texture being displayed on the sphere
  113648. */
  113649. photoTexture: Texture;
  113650. /**
  113651. * Observable raised when an error occured while loading the 360 image
  113652. */
  113653. onLoadErrorObservable: Observable<string>;
  113654. /**
  113655. * The skybox material
  113656. */
  113657. protected _material: BackgroundMaterial;
  113658. /**
  113659. * The surface used for the skybox
  113660. */
  113661. protected _mesh: Mesh;
  113662. /**
  113663. * Gets the mesh used for the skybox.
  113664. */
  113665. readonly mesh: Mesh;
  113666. /**
  113667. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113668. * Also see the options.resolution property.
  113669. */
  113670. fovMultiplier: number;
  113671. private _imageMode;
  113672. /**
  113673. * Gets or set the current video mode for the video. It can be:
  113674. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113675. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113676. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113677. */
  113678. imageMode: number;
  113679. /**
  113680. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113681. * @param name Element's name, child elements will append suffixes for their own names.
  113682. * @param urlsOfPhoto defines the url of the photo to display
  113683. * @param options defines an object containing optional or exposed sub element properties
  113684. * @param onError defines a callback called when an error occured while loading the texture
  113685. */
  113686. constructor(name: string, urlOfPhoto: string, options: {
  113687. resolution?: number;
  113688. size?: number;
  113689. useDirectMapping?: boolean;
  113690. faceForward?: boolean;
  113691. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113692. private _onBeforeCameraRenderObserver;
  113693. private _changeImageMode;
  113694. /**
  113695. * Releases resources associated with this node.
  113696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113698. */
  113699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113700. }
  113701. }
  113702. declare module BABYLON {
  113703. /**
  113704. * Class used to host RGBD texture specific utilities
  113705. */
  113706. export class RGBDTextureTools {
  113707. /**
  113708. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113709. * @param texture the texture to expand.
  113710. */
  113711. static ExpandRGBDTexture(texture: Texture): void;
  113712. }
  113713. }
  113714. declare module BABYLON {
  113715. /**
  113716. * Class used to host texture specific utilities
  113717. */
  113718. export class BRDFTextureTools {
  113719. /**
  113720. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113721. * @param scene defines the hosting scene
  113722. * @returns the environment BRDF texture
  113723. */
  113724. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113725. private static _environmentBRDFBase64Texture;
  113726. }
  113727. }
  113728. declare module BABYLON {
  113729. /**
  113730. * @hidden
  113731. */
  113732. export interface IMaterialClearCoatDefines {
  113733. CLEARCOAT: boolean;
  113734. CLEARCOAT_DEFAULTIOR: boolean;
  113735. CLEARCOAT_TEXTURE: boolean;
  113736. CLEARCOAT_TEXTUREDIRECTUV: number;
  113737. CLEARCOAT_BUMP: boolean;
  113738. CLEARCOAT_BUMPDIRECTUV: number;
  113739. CLEARCOAT_TINT: boolean;
  113740. CLEARCOAT_TINT_TEXTURE: boolean;
  113741. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113742. /** @hidden */
  113743. _areTexturesDirty: boolean;
  113744. }
  113745. /**
  113746. * Define the code related to the clear coat parameters of the pbr material.
  113747. */
  113748. export class PBRClearCoatConfiguration {
  113749. /**
  113750. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113751. * The default fits with a polyurethane material.
  113752. */
  113753. private static readonly _DefaultIndexOfRefraction;
  113754. private _isEnabled;
  113755. /**
  113756. * Defines if the clear coat is enabled in the material.
  113757. */
  113758. isEnabled: boolean;
  113759. /**
  113760. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113761. */
  113762. intensity: number;
  113763. /**
  113764. * Defines the clear coat layer roughness.
  113765. */
  113766. roughness: number;
  113767. private _indexOfRefraction;
  113768. /**
  113769. * Defines the index of refraction of the clear coat.
  113770. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113771. * The default fits with a polyurethane material.
  113772. * Changing the default value is more performance intensive.
  113773. */
  113774. indexOfRefraction: number;
  113775. private _texture;
  113776. /**
  113777. * Stores the clear coat values in a texture.
  113778. */
  113779. texture: Nullable<BaseTexture>;
  113780. private _bumpTexture;
  113781. /**
  113782. * Define the clear coat specific bump texture.
  113783. */
  113784. bumpTexture: Nullable<BaseTexture>;
  113785. private _isTintEnabled;
  113786. /**
  113787. * Defines if the clear coat tint is enabled in the material.
  113788. */
  113789. isTintEnabled: boolean;
  113790. /**
  113791. * Defines the clear coat tint of the material.
  113792. * This is only use if tint is enabled
  113793. */
  113794. tintColor: Color3;
  113795. /**
  113796. * Defines the distance at which the tint color should be found in the
  113797. * clear coat media.
  113798. * This is only use if tint is enabled
  113799. */
  113800. tintColorAtDistance: number;
  113801. /**
  113802. * Defines the clear coat layer thickness.
  113803. * This is only use if tint is enabled
  113804. */
  113805. tintThickness: number;
  113806. private _tintTexture;
  113807. /**
  113808. * Stores the clear tint values in a texture.
  113809. * rgb is tint
  113810. * a is a thickness factor
  113811. */
  113812. tintTexture: Nullable<BaseTexture>;
  113813. /** @hidden */
  113814. private _internalMarkAllSubMeshesAsTexturesDirty;
  113815. /** @hidden */
  113816. _markAllSubMeshesAsTexturesDirty(): void;
  113817. /**
  113818. * Instantiate a new istance of clear coat configuration.
  113819. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113820. */
  113821. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113822. /**
  113823. * Gets wehter the submesh is ready to be used or not.
  113824. * @param defines the list of "defines" to update.
  113825. * @param scene defines the scene the material belongs to.
  113826. * @param engine defines the engine the material belongs to.
  113827. * @param disableBumpMap defines wether the material disables bump or not.
  113828. * @returns - boolean indicating that the submesh is ready or not.
  113829. */
  113830. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113831. /**
  113832. * Checks to see if a texture is used in the material.
  113833. * @param defines the list of "defines" to update.
  113834. * @param scene defines the scene to the material belongs to.
  113835. */
  113836. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113837. /**
  113838. * Binds the material data.
  113839. * @param uniformBuffer defines the Uniform buffer to fill in.
  113840. * @param scene defines the scene the material belongs to.
  113841. * @param engine defines the engine the material belongs to.
  113842. * @param disableBumpMap defines wether the material disables bump or not.
  113843. * @param isFrozen defines wether the material is frozen or not.
  113844. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113845. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113846. */
  113847. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113848. /**
  113849. * Checks to see if a texture is used in the material.
  113850. * @param texture - Base texture to use.
  113851. * @returns - Boolean specifying if a texture is used in the material.
  113852. */
  113853. hasTexture(texture: BaseTexture): boolean;
  113854. /**
  113855. * Returns an array of the actively used textures.
  113856. * @param activeTextures Array of BaseTextures
  113857. */
  113858. getActiveTextures(activeTextures: BaseTexture[]): void;
  113859. /**
  113860. * Returns the animatable textures.
  113861. * @param animatables Array of animatable textures.
  113862. */
  113863. getAnimatables(animatables: IAnimatable[]): void;
  113864. /**
  113865. * Disposes the resources of the material.
  113866. * @param forceDisposeTextures - Forces the disposal of all textures.
  113867. */
  113868. dispose(forceDisposeTextures?: boolean): void;
  113869. /**
  113870. * Get the current class name of the texture useful for serialization or dynamic coding.
  113871. * @returns "PBRClearCoatConfiguration"
  113872. */
  113873. getClassName(): string;
  113874. /**
  113875. * Add fallbacks to the effect fallbacks list.
  113876. * @param defines defines the Base texture to use.
  113877. * @param fallbacks defines the current fallback list.
  113878. * @param currentRank defines the current fallback rank.
  113879. * @returns the new fallback rank.
  113880. */
  113881. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113882. /**
  113883. * Add the required uniforms to the current list.
  113884. * @param uniforms defines the current uniform list.
  113885. */
  113886. static AddUniforms(uniforms: string[]): void;
  113887. /**
  113888. * Add the required samplers to the current list.
  113889. * @param samplers defines the current sampler list.
  113890. */
  113891. static AddSamplers(samplers: string[]): void;
  113892. /**
  113893. * Add the required uniforms to the current buffer.
  113894. * @param uniformBuffer defines the current uniform buffer.
  113895. */
  113896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113897. /**
  113898. * Makes a duplicate of the current configuration into another one.
  113899. * @param clearCoatConfiguration define the config where to copy the info
  113900. */
  113901. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113902. /**
  113903. * Serializes this clear coat configuration.
  113904. * @returns - An object with the serialized config.
  113905. */
  113906. serialize(): any;
  113907. /**
  113908. * Parses a anisotropy Configuration from a serialized object.
  113909. * @param source - Serialized object.
  113910. * @param scene Defines the scene we are parsing for
  113911. * @param rootUrl Defines the rootUrl to load from
  113912. */
  113913. parse(source: any, scene: Scene, rootUrl: string): void;
  113914. }
  113915. }
  113916. declare module BABYLON {
  113917. /**
  113918. * @hidden
  113919. */
  113920. export interface IMaterialAnisotropicDefines {
  113921. ANISOTROPIC: boolean;
  113922. ANISOTROPIC_TEXTURE: boolean;
  113923. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113924. MAINUV1: boolean;
  113925. _areTexturesDirty: boolean;
  113926. _needUVs: boolean;
  113927. }
  113928. /**
  113929. * Define the code related to the anisotropic parameters of the pbr material.
  113930. */
  113931. export class PBRAnisotropicConfiguration {
  113932. private _isEnabled;
  113933. /**
  113934. * Defines if the anisotropy is enabled in the material.
  113935. */
  113936. isEnabled: boolean;
  113937. /**
  113938. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113939. */
  113940. intensity: number;
  113941. /**
  113942. * Defines if the effect is along the tangents, bitangents or in between.
  113943. * By default, the effect is "strectching" the highlights along the tangents.
  113944. */
  113945. direction: Vector2;
  113946. private _texture;
  113947. /**
  113948. * Stores the anisotropy values in a texture.
  113949. * rg is direction (like normal from -1 to 1)
  113950. * b is a intensity
  113951. */
  113952. texture: Nullable<BaseTexture>;
  113953. /** @hidden */
  113954. private _internalMarkAllSubMeshesAsTexturesDirty;
  113955. /** @hidden */
  113956. _markAllSubMeshesAsTexturesDirty(): void;
  113957. /**
  113958. * Instantiate a new istance of anisotropy configuration.
  113959. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113960. */
  113961. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113962. /**
  113963. * Specifies that the submesh is ready to be used.
  113964. * @param defines the list of "defines" to update.
  113965. * @param scene defines the scene the material belongs to.
  113966. * @returns - boolean indicating that the submesh is ready or not.
  113967. */
  113968. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113969. /**
  113970. * Checks to see if a texture is used in the material.
  113971. * @param defines the list of "defines" to update.
  113972. * @param mesh the mesh we are preparing the defines for.
  113973. * @param scene defines the scene the material belongs to.
  113974. */
  113975. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113976. /**
  113977. * Binds the material data.
  113978. * @param uniformBuffer defines the Uniform buffer to fill in.
  113979. * @param scene defines the scene the material belongs to.
  113980. * @param isFrozen defines wether the material is frozen or not.
  113981. */
  113982. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113983. /**
  113984. * Checks to see if a texture is used in the material.
  113985. * @param texture - Base texture to use.
  113986. * @returns - Boolean specifying if a texture is used in the material.
  113987. */
  113988. hasTexture(texture: BaseTexture): boolean;
  113989. /**
  113990. * Returns an array of the actively used textures.
  113991. * @param activeTextures Array of BaseTextures
  113992. */
  113993. getActiveTextures(activeTextures: BaseTexture[]): void;
  113994. /**
  113995. * Returns the animatable textures.
  113996. * @param animatables Array of animatable textures.
  113997. */
  113998. getAnimatables(animatables: IAnimatable[]): void;
  113999. /**
  114000. * Disposes the resources of the material.
  114001. * @param forceDisposeTextures - Forces the disposal of all textures.
  114002. */
  114003. dispose(forceDisposeTextures?: boolean): void;
  114004. /**
  114005. * Get the current class name of the texture useful for serialization or dynamic coding.
  114006. * @returns "PBRAnisotropicConfiguration"
  114007. */
  114008. getClassName(): string;
  114009. /**
  114010. * Add fallbacks to the effect fallbacks list.
  114011. * @param defines defines the Base texture to use.
  114012. * @param fallbacks defines the current fallback list.
  114013. * @param currentRank defines the current fallback rank.
  114014. * @returns the new fallback rank.
  114015. */
  114016. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114017. /**
  114018. * Add the required uniforms to the current list.
  114019. * @param uniforms defines the current uniform list.
  114020. */
  114021. static AddUniforms(uniforms: string[]): void;
  114022. /**
  114023. * Add the required uniforms to the current buffer.
  114024. * @param uniformBuffer defines the current uniform buffer.
  114025. */
  114026. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114027. /**
  114028. * Add the required samplers to the current list.
  114029. * @param samplers defines the current sampler list.
  114030. */
  114031. static AddSamplers(samplers: string[]): void;
  114032. /**
  114033. * Makes a duplicate of the current configuration into another one.
  114034. * @param anisotropicConfiguration define the config where to copy the info
  114035. */
  114036. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114037. /**
  114038. * Serializes this anisotropy configuration.
  114039. * @returns - An object with the serialized config.
  114040. */
  114041. serialize(): any;
  114042. /**
  114043. * Parses a anisotropy Configuration from a serialized object.
  114044. * @param source - Serialized object.
  114045. * @param scene Defines the scene we are parsing for
  114046. * @param rootUrl Defines the rootUrl to load from
  114047. */
  114048. parse(source: any, scene: Scene, rootUrl: string): void;
  114049. }
  114050. }
  114051. declare module BABYLON {
  114052. /**
  114053. * @hidden
  114054. */
  114055. export interface IMaterialBRDFDefines {
  114056. BRDF_V_HEIGHT_CORRELATED: boolean;
  114057. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114058. SPHERICAL_HARMONICS: boolean;
  114059. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114060. /** @hidden */
  114061. _areMiscDirty: boolean;
  114062. }
  114063. /**
  114064. * Define the code related to the BRDF parameters of the pbr material.
  114065. */
  114066. export class PBRBRDFConfiguration {
  114067. /**
  114068. * Default value used for the energy conservation.
  114069. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114070. */
  114071. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114072. /**
  114073. * Default value used for the Smith Visibility Height Correlated mode.
  114074. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114075. */
  114076. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114077. /**
  114078. * Default value used for the IBL diffuse part.
  114079. * This can help switching back to the polynomials mode globally which is a tiny bit
  114080. * less GPU intensive at the drawback of a lower quality.
  114081. */
  114082. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114083. /**
  114084. * Default value used for activating energy conservation for the specular workflow.
  114085. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114086. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114087. */
  114088. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114089. private _useEnergyConservation;
  114090. /**
  114091. * Defines if the material uses energy conservation.
  114092. */
  114093. useEnergyConservation: boolean;
  114094. private _useSmithVisibilityHeightCorrelated;
  114095. /**
  114096. * LEGACY Mode set to false
  114097. * Defines if the material uses height smith correlated visibility term.
  114098. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114099. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114100. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114101. * Not relying on height correlated will also disable energy conservation.
  114102. */
  114103. useSmithVisibilityHeightCorrelated: boolean;
  114104. private _useSphericalHarmonics;
  114105. /**
  114106. * LEGACY Mode set to false
  114107. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114108. * diffuse part of the IBL.
  114109. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114110. * to the ground truth.
  114111. */
  114112. useSphericalHarmonics: boolean;
  114113. private _useSpecularGlossinessInputEnergyConservation;
  114114. /**
  114115. * Defines if the material uses energy conservation, when the specular workflow is active.
  114116. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114117. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114118. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114119. */
  114120. useSpecularGlossinessInputEnergyConservation: boolean;
  114121. /** @hidden */
  114122. private _internalMarkAllSubMeshesAsMiscDirty;
  114123. /** @hidden */
  114124. _markAllSubMeshesAsMiscDirty(): void;
  114125. /**
  114126. * Instantiate a new istance of clear coat configuration.
  114127. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114128. */
  114129. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114130. /**
  114131. * Checks to see if a texture is used in the material.
  114132. * @param defines the list of "defines" to update.
  114133. */
  114134. prepareDefines(defines: IMaterialBRDFDefines): void;
  114135. /**
  114136. * Get the current class name of the texture useful for serialization or dynamic coding.
  114137. * @returns "PBRClearCoatConfiguration"
  114138. */
  114139. getClassName(): string;
  114140. /**
  114141. * Makes a duplicate of the current configuration into another one.
  114142. * @param brdfConfiguration define the config where to copy the info
  114143. */
  114144. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114145. /**
  114146. * Serializes this BRDF configuration.
  114147. * @returns - An object with the serialized config.
  114148. */
  114149. serialize(): any;
  114150. /**
  114151. * Parses a anisotropy Configuration from a serialized object.
  114152. * @param source - Serialized object.
  114153. * @param scene Defines the scene we are parsing for
  114154. * @param rootUrl Defines the rootUrl to load from
  114155. */
  114156. parse(source: any, scene: Scene, rootUrl: string): void;
  114157. }
  114158. }
  114159. declare module BABYLON {
  114160. /**
  114161. * @hidden
  114162. */
  114163. export interface IMaterialSheenDefines {
  114164. SHEEN: boolean;
  114165. SHEEN_TEXTURE: boolean;
  114166. SHEEN_TEXTUREDIRECTUV: number;
  114167. SHEEN_LINKWITHALBEDO: boolean;
  114168. /** @hidden */
  114169. _areTexturesDirty: boolean;
  114170. }
  114171. /**
  114172. * Define the code related to the Sheen parameters of the pbr material.
  114173. */
  114174. export class PBRSheenConfiguration {
  114175. private _isEnabled;
  114176. /**
  114177. * Defines if the material uses sheen.
  114178. */
  114179. isEnabled: boolean;
  114180. private _linkSheenWithAlbedo;
  114181. /**
  114182. * Defines if the sheen is linked to the sheen color.
  114183. */
  114184. linkSheenWithAlbedo: boolean;
  114185. /**
  114186. * Defines the sheen intensity.
  114187. */
  114188. intensity: number;
  114189. /**
  114190. * Defines the sheen color.
  114191. */
  114192. color: Color3;
  114193. private _texture;
  114194. /**
  114195. * Stores the sheen tint values in a texture.
  114196. * rgb is tint
  114197. * a is a intensity
  114198. */
  114199. texture: Nullable<BaseTexture>;
  114200. /** @hidden */
  114201. private _internalMarkAllSubMeshesAsTexturesDirty;
  114202. /** @hidden */
  114203. _markAllSubMeshesAsTexturesDirty(): void;
  114204. /**
  114205. * Instantiate a new istance of clear coat configuration.
  114206. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114207. */
  114208. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114209. /**
  114210. * Specifies that the submesh is ready to be used.
  114211. * @param defines the list of "defines" to update.
  114212. * @param scene defines the scene the material belongs to.
  114213. * @returns - boolean indicating that the submesh is ready or not.
  114214. */
  114215. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114216. /**
  114217. * Checks to see if a texture is used in the material.
  114218. * @param defines the list of "defines" to update.
  114219. * @param scene defines the scene the material belongs to.
  114220. */
  114221. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114222. /**
  114223. * Binds the material data.
  114224. * @param uniformBuffer defines the Uniform buffer to fill in.
  114225. * @param scene defines the scene the material belongs to.
  114226. * @param isFrozen defines wether the material is frozen or not.
  114227. */
  114228. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114229. /**
  114230. * Checks to see if a texture is used in the material.
  114231. * @param texture - Base texture to use.
  114232. * @returns - Boolean specifying if a texture is used in the material.
  114233. */
  114234. hasTexture(texture: BaseTexture): boolean;
  114235. /**
  114236. * Returns an array of the actively used textures.
  114237. * @param activeTextures Array of BaseTextures
  114238. */
  114239. getActiveTextures(activeTextures: BaseTexture[]): void;
  114240. /**
  114241. * Returns the animatable textures.
  114242. * @param animatables Array of animatable textures.
  114243. */
  114244. getAnimatables(animatables: IAnimatable[]): void;
  114245. /**
  114246. * Disposes the resources of the material.
  114247. * @param forceDisposeTextures - Forces the disposal of all textures.
  114248. */
  114249. dispose(forceDisposeTextures?: boolean): void;
  114250. /**
  114251. * Get the current class name of the texture useful for serialization or dynamic coding.
  114252. * @returns "PBRSheenConfiguration"
  114253. */
  114254. getClassName(): string;
  114255. /**
  114256. * Add fallbacks to the effect fallbacks list.
  114257. * @param defines defines the Base texture to use.
  114258. * @param fallbacks defines the current fallback list.
  114259. * @param currentRank defines the current fallback rank.
  114260. * @returns the new fallback rank.
  114261. */
  114262. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114263. /**
  114264. * Add the required uniforms to the current list.
  114265. * @param uniforms defines the current uniform list.
  114266. */
  114267. static AddUniforms(uniforms: string[]): void;
  114268. /**
  114269. * Add the required uniforms to the current buffer.
  114270. * @param uniformBuffer defines the current uniform buffer.
  114271. */
  114272. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114273. /**
  114274. * Add the required samplers to the current list.
  114275. * @param samplers defines the current sampler list.
  114276. */
  114277. static AddSamplers(samplers: string[]): void;
  114278. /**
  114279. * Makes a duplicate of the current configuration into another one.
  114280. * @param sheenConfiguration define the config where to copy the info
  114281. */
  114282. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114283. /**
  114284. * Serializes this BRDF configuration.
  114285. * @returns - An object with the serialized config.
  114286. */
  114287. serialize(): any;
  114288. /**
  114289. * Parses a anisotropy Configuration from a serialized object.
  114290. * @param source - Serialized object.
  114291. * @param scene Defines the scene we are parsing for
  114292. * @param rootUrl Defines the rootUrl to load from
  114293. */
  114294. parse(source: any, scene: Scene, rootUrl: string): void;
  114295. }
  114296. }
  114297. declare module BABYLON {
  114298. /**
  114299. * @hidden
  114300. */
  114301. export interface IMaterialSubSurfaceDefines {
  114302. SUBSURFACE: boolean;
  114303. SS_REFRACTION: boolean;
  114304. SS_TRANSLUCENCY: boolean;
  114305. SS_SCATERRING: boolean;
  114306. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114307. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114308. SS_REFRACTIONMAP_3D: boolean;
  114309. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114310. SS_LODINREFRACTIONALPHA: boolean;
  114311. SS_GAMMAREFRACTION: boolean;
  114312. SS_RGBDREFRACTION: boolean;
  114313. SS_LINEARSPECULARREFRACTION: boolean;
  114314. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114315. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114316. /** @hidden */
  114317. _areTexturesDirty: boolean;
  114318. }
  114319. /**
  114320. * Define the code related to the sub surface parameters of the pbr material.
  114321. */
  114322. export class PBRSubSurfaceConfiguration {
  114323. private _isRefractionEnabled;
  114324. /**
  114325. * Defines if the refraction is enabled in the material.
  114326. */
  114327. isRefractionEnabled: boolean;
  114328. private _isTranslucencyEnabled;
  114329. /**
  114330. * Defines if the translucency is enabled in the material.
  114331. */
  114332. isTranslucencyEnabled: boolean;
  114333. private _isScatteringEnabled;
  114334. /**
  114335. * Defines the refraction intensity of the material.
  114336. * The refraction when enabled replaces the Diffuse part of the material.
  114337. * The intensity helps transitionning between diffuse and refraction.
  114338. */
  114339. refractionIntensity: number;
  114340. /**
  114341. * Defines the translucency intensity of the material.
  114342. * When translucency has been enabled, this defines how much of the "translucency"
  114343. * is addded to the diffuse part of the material.
  114344. */
  114345. translucencyIntensity: number;
  114346. /**
  114347. * Defines the scattering intensity of the material.
  114348. * When scattering has been enabled, this defines how much of the "scattered light"
  114349. * is addded to the diffuse part of the material.
  114350. */
  114351. scatteringIntensity: number;
  114352. private _thicknessTexture;
  114353. /**
  114354. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114355. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114356. * 0 would mean minimumThickness
  114357. * 1 would mean maximumThickness
  114358. * The other channels might be use as a mask to vary the different effects intensity.
  114359. */
  114360. thicknessTexture: Nullable<BaseTexture>;
  114361. private _refractionTexture;
  114362. /**
  114363. * Defines the texture to use for refraction.
  114364. */
  114365. refractionTexture: Nullable<BaseTexture>;
  114366. private _indexOfRefraction;
  114367. /**
  114368. * Defines the index of refraction used in the material.
  114369. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114370. */
  114371. indexOfRefraction: number;
  114372. private _invertRefractionY;
  114373. /**
  114374. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114375. */
  114376. invertRefractionY: boolean;
  114377. private _linkRefractionWithTransparency;
  114378. /**
  114379. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114380. * Materials half opaque for instance using refraction could benefit from this control.
  114381. */
  114382. linkRefractionWithTransparency: boolean;
  114383. /**
  114384. * Defines the minimum thickness stored in the thickness map.
  114385. * If no thickness map is defined, this value will be used to simulate thickness.
  114386. */
  114387. minimumThickness: number;
  114388. /**
  114389. * Defines the maximum thickness stored in the thickness map.
  114390. */
  114391. maximumThickness: number;
  114392. /**
  114393. * Defines the volume tint of the material.
  114394. * This is used for both translucency and scattering.
  114395. */
  114396. tintColor: Color3;
  114397. /**
  114398. * Defines the distance at which the tint color should be found in the media.
  114399. * This is used for refraction only.
  114400. */
  114401. tintColorAtDistance: number;
  114402. /**
  114403. * Defines how far each channel transmit through the media.
  114404. * It is defined as a color to simplify it selection.
  114405. */
  114406. diffusionDistance: Color3;
  114407. private _useMaskFromThicknessTexture;
  114408. /**
  114409. * Stores the intensity of the different subsurface effects in the thickness texture.
  114410. * * the green channel is the translucency intensity.
  114411. * * the blue channel is the scattering intensity.
  114412. * * the alpha channel is the refraction intensity.
  114413. */
  114414. useMaskFromThicknessTexture: boolean;
  114415. /** @hidden */
  114416. private _internalMarkAllSubMeshesAsTexturesDirty;
  114417. /** @hidden */
  114418. _markAllSubMeshesAsTexturesDirty(): void;
  114419. /**
  114420. * Instantiate a new istance of sub surface configuration.
  114421. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114422. */
  114423. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114424. /**
  114425. * Gets wehter the submesh is ready to be used or not.
  114426. * @param defines the list of "defines" to update.
  114427. * @param scene defines the scene the material belongs to.
  114428. * @returns - boolean indicating that the submesh is ready or not.
  114429. */
  114430. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114431. /**
  114432. * Checks to see if a texture is used in the material.
  114433. * @param defines the list of "defines" to update.
  114434. * @param scene defines the scene to the material belongs to.
  114435. */
  114436. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114437. /**
  114438. * Binds the material data.
  114439. * @param uniformBuffer defines the Uniform buffer to fill in.
  114440. * @param scene defines the scene the material belongs to.
  114441. * @param engine defines the engine the material belongs to.
  114442. * @param isFrozen defines wether the material is frozen or not.
  114443. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114444. */
  114445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114446. /**
  114447. * Unbinds the material from the mesh.
  114448. * @param activeEffect defines the effect that should be unbound from.
  114449. * @returns true if unbound, otherwise false
  114450. */
  114451. unbind(activeEffect: Effect): boolean;
  114452. /**
  114453. * Returns the texture used for refraction or null if none is used.
  114454. * @param scene defines the scene the material belongs to.
  114455. * @returns - Refraction texture if present. If no refraction texture and refraction
  114456. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114457. */
  114458. private _getRefractionTexture;
  114459. /**
  114460. * Returns true if alpha blending should be disabled.
  114461. */
  114462. readonly disableAlphaBlending: boolean;
  114463. /**
  114464. * Fills the list of render target textures.
  114465. * @param renderTargets the list of render targets to update
  114466. */
  114467. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114468. /**
  114469. * Checks to see if a texture is used in the material.
  114470. * @param texture - Base texture to use.
  114471. * @returns - Boolean specifying if a texture is used in the material.
  114472. */
  114473. hasTexture(texture: BaseTexture): boolean;
  114474. /**
  114475. * Gets a boolean indicating that current material needs to register RTT
  114476. * @returns true if this uses a render target otherwise false.
  114477. */
  114478. hasRenderTargetTextures(): boolean;
  114479. /**
  114480. * Returns an array of the actively used textures.
  114481. * @param activeTextures Array of BaseTextures
  114482. */
  114483. getActiveTextures(activeTextures: BaseTexture[]): void;
  114484. /**
  114485. * Returns the animatable textures.
  114486. * @param animatables Array of animatable textures.
  114487. */
  114488. getAnimatables(animatables: IAnimatable[]): void;
  114489. /**
  114490. * Disposes the resources of the material.
  114491. * @param forceDisposeTextures - Forces the disposal of all textures.
  114492. */
  114493. dispose(forceDisposeTextures?: boolean): void;
  114494. /**
  114495. * Get the current class name of the texture useful for serialization or dynamic coding.
  114496. * @returns "PBRSubSurfaceConfiguration"
  114497. */
  114498. getClassName(): string;
  114499. /**
  114500. * Add fallbacks to the effect fallbacks list.
  114501. * @param defines defines the Base texture to use.
  114502. * @param fallbacks defines the current fallback list.
  114503. * @param currentRank defines the current fallback rank.
  114504. * @returns the new fallback rank.
  114505. */
  114506. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114507. /**
  114508. * Add the required uniforms to the current list.
  114509. * @param uniforms defines the current uniform list.
  114510. */
  114511. static AddUniforms(uniforms: string[]): void;
  114512. /**
  114513. * Add the required samplers to the current list.
  114514. * @param samplers defines the current sampler list.
  114515. */
  114516. static AddSamplers(samplers: string[]): void;
  114517. /**
  114518. * Add the required uniforms to the current buffer.
  114519. * @param uniformBuffer defines the current uniform buffer.
  114520. */
  114521. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114522. /**
  114523. * Makes a duplicate of the current configuration into another one.
  114524. * @param configuration define the config where to copy the info
  114525. */
  114526. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114527. /**
  114528. * Serializes this Sub Surface configuration.
  114529. * @returns - An object with the serialized config.
  114530. */
  114531. serialize(): any;
  114532. /**
  114533. * Parses a anisotropy Configuration from a serialized object.
  114534. * @param source - Serialized object.
  114535. * @param scene Defines the scene we are parsing for
  114536. * @param rootUrl Defines the rootUrl to load from
  114537. */
  114538. parse(source: any, scene: Scene, rootUrl: string): void;
  114539. }
  114540. }
  114541. declare module BABYLON {
  114542. /** @hidden */
  114543. export var pbrFragmentDeclaration: {
  114544. name: string;
  114545. shader: string;
  114546. };
  114547. }
  114548. declare module BABYLON {
  114549. /** @hidden */
  114550. export var pbrUboDeclaration: {
  114551. name: string;
  114552. shader: string;
  114553. };
  114554. }
  114555. declare module BABYLON {
  114556. /** @hidden */
  114557. export var pbrFragmentExtraDeclaration: {
  114558. name: string;
  114559. shader: string;
  114560. };
  114561. }
  114562. declare module BABYLON {
  114563. /** @hidden */
  114564. export var pbrFragmentSamplersDeclaration: {
  114565. name: string;
  114566. shader: string;
  114567. };
  114568. }
  114569. declare module BABYLON {
  114570. /** @hidden */
  114571. export var pbrHelperFunctions: {
  114572. name: string;
  114573. shader: string;
  114574. };
  114575. }
  114576. declare module BABYLON {
  114577. /** @hidden */
  114578. export var harmonicsFunctions: {
  114579. name: string;
  114580. shader: string;
  114581. };
  114582. }
  114583. declare module BABYLON {
  114584. /** @hidden */
  114585. export var pbrDirectLightingSetupFunctions: {
  114586. name: string;
  114587. shader: string;
  114588. };
  114589. }
  114590. declare module BABYLON {
  114591. /** @hidden */
  114592. export var pbrDirectLightingFalloffFunctions: {
  114593. name: string;
  114594. shader: string;
  114595. };
  114596. }
  114597. declare module BABYLON {
  114598. /** @hidden */
  114599. export var pbrBRDFFunctions: {
  114600. name: string;
  114601. shader: string;
  114602. };
  114603. }
  114604. declare module BABYLON {
  114605. /** @hidden */
  114606. export var pbrDirectLightingFunctions: {
  114607. name: string;
  114608. shader: string;
  114609. };
  114610. }
  114611. declare module BABYLON {
  114612. /** @hidden */
  114613. export var pbrIBLFunctions: {
  114614. name: string;
  114615. shader: string;
  114616. };
  114617. }
  114618. declare module BABYLON {
  114619. /** @hidden */
  114620. export var pbrDebug: {
  114621. name: string;
  114622. shader: string;
  114623. };
  114624. }
  114625. declare module BABYLON {
  114626. /** @hidden */
  114627. export var pbrPixelShader: {
  114628. name: string;
  114629. shader: string;
  114630. };
  114631. }
  114632. declare module BABYLON {
  114633. /** @hidden */
  114634. export var pbrVertexDeclaration: {
  114635. name: string;
  114636. shader: string;
  114637. };
  114638. }
  114639. declare module BABYLON {
  114640. /** @hidden */
  114641. export var pbrVertexShader: {
  114642. name: string;
  114643. shader: string;
  114644. };
  114645. }
  114646. declare module BABYLON {
  114647. /**
  114648. * Manages the defines for the PBR Material.
  114649. * @hidden
  114650. */
  114651. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114652. PBR: boolean;
  114653. MAINUV1: boolean;
  114654. MAINUV2: boolean;
  114655. UV1: boolean;
  114656. UV2: boolean;
  114657. ALBEDO: boolean;
  114658. ALBEDODIRECTUV: number;
  114659. VERTEXCOLOR: boolean;
  114660. AMBIENT: boolean;
  114661. AMBIENTDIRECTUV: number;
  114662. AMBIENTINGRAYSCALE: boolean;
  114663. OPACITY: boolean;
  114664. VERTEXALPHA: boolean;
  114665. OPACITYDIRECTUV: number;
  114666. OPACITYRGB: boolean;
  114667. ALPHATEST: boolean;
  114668. DEPTHPREPASS: boolean;
  114669. ALPHABLEND: boolean;
  114670. ALPHAFROMALBEDO: boolean;
  114671. ALPHATESTVALUE: string;
  114672. SPECULAROVERALPHA: boolean;
  114673. RADIANCEOVERALPHA: boolean;
  114674. ALPHAFRESNEL: boolean;
  114675. LINEARALPHAFRESNEL: boolean;
  114676. PREMULTIPLYALPHA: boolean;
  114677. EMISSIVE: boolean;
  114678. EMISSIVEDIRECTUV: number;
  114679. REFLECTIVITY: boolean;
  114680. REFLECTIVITYDIRECTUV: number;
  114681. SPECULARTERM: boolean;
  114682. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114683. MICROSURFACEAUTOMATIC: boolean;
  114684. LODBASEDMICROSFURACE: boolean;
  114685. MICROSURFACEMAP: boolean;
  114686. MICROSURFACEMAPDIRECTUV: number;
  114687. METALLICWORKFLOW: boolean;
  114688. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114689. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114690. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114691. AOSTOREINMETALMAPRED: boolean;
  114692. ENVIRONMENTBRDF: boolean;
  114693. ENVIRONMENTBRDF_RGBD: boolean;
  114694. NORMAL: boolean;
  114695. TANGENT: boolean;
  114696. BUMP: boolean;
  114697. BUMPDIRECTUV: number;
  114698. OBJECTSPACE_NORMALMAP: boolean;
  114699. PARALLAX: boolean;
  114700. PARALLAXOCCLUSION: boolean;
  114701. NORMALXYSCALE: boolean;
  114702. LIGHTMAP: boolean;
  114703. LIGHTMAPDIRECTUV: number;
  114704. USELIGHTMAPASSHADOWMAP: boolean;
  114705. GAMMALIGHTMAP: boolean;
  114706. RGBDLIGHTMAP: boolean;
  114707. REFLECTION: boolean;
  114708. REFLECTIONMAP_3D: boolean;
  114709. REFLECTIONMAP_SPHERICAL: boolean;
  114710. REFLECTIONMAP_PLANAR: boolean;
  114711. REFLECTIONMAP_CUBIC: boolean;
  114712. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114713. REFLECTIONMAP_PROJECTION: boolean;
  114714. REFLECTIONMAP_SKYBOX: boolean;
  114715. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114716. REFLECTIONMAP_EXPLICIT: boolean;
  114717. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114718. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114719. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114720. INVERTCUBICMAP: boolean;
  114721. USESPHERICALFROMREFLECTIONMAP: boolean;
  114722. USEIRRADIANCEMAP: boolean;
  114723. SPHERICAL_HARMONICS: boolean;
  114724. USESPHERICALINVERTEX: boolean;
  114725. REFLECTIONMAP_OPPOSITEZ: boolean;
  114726. LODINREFLECTIONALPHA: boolean;
  114727. GAMMAREFLECTION: boolean;
  114728. RGBDREFLECTION: boolean;
  114729. LINEARSPECULARREFLECTION: boolean;
  114730. RADIANCEOCCLUSION: boolean;
  114731. HORIZONOCCLUSION: boolean;
  114732. INSTANCES: boolean;
  114733. NUM_BONE_INFLUENCERS: number;
  114734. BonesPerMesh: number;
  114735. BONETEXTURE: boolean;
  114736. NONUNIFORMSCALING: boolean;
  114737. MORPHTARGETS: boolean;
  114738. MORPHTARGETS_NORMAL: boolean;
  114739. MORPHTARGETS_TANGENT: boolean;
  114740. MORPHTARGETS_UV: boolean;
  114741. NUM_MORPH_INFLUENCERS: number;
  114742. IMAGEPROCESSING: boolean;
  114743. VIGNETTE: boolean;
  114744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114745. VIGNETTEBLENDMODEOPAQUE: boolean;
  114746. TONEMAPPING: boolean;
  114747. TONEMAPPING_ACES: boolean;
  114748. CONTRAST: boolean;
  114749. COLORCURVES: boolean;
  114750. COLORGRADING: boolean;
  114751. COLORGRADING3D: boolean;
  114752. SAMPLER3DGREENDEPTH: boolean;
  114753. SAMPLER3DBGRMAP: boolean;
  114754. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114755. EXPOSURE: boolean;
  114756. MULTIVIEW: boolean;
  114757. USEPHYSICALLIGHTFALLOFF: boolean;
  114758. USEGLTFLIGHTFALLOFF: boolean;
  114759. TWOSIDEDLIGHTING: boolean;
  114760. SHADOWFLOAT: boolean;
  114761. CLIPPLANE: boolean;
  114762. CLIPPLANE2: boolean;
  114763. CLIPPLANE3: boolean;
  114764. CLIPPLANE4: boolean;
  114765. POINTSIZE: boolean;
  114766. FOG: boolean;
  114767. LOGARITHMICDEPTH: boolean;
  114768. FORCENORMALFORWARD: boolean;
  114769. SPECULARAA: boolean;
  114770. CLEARCOAT: boolean;
  114771. CLEARCOAT_DEFAULTIOR: boolean;
  114772. CLEARCOAT_TEXTURE: boolean;
  114773. CLEARCOAT_TEXTUREDIRECTUV: number;
  114774. CLEARCOAT_BUMP: boolean;
  114775. CLEARCOAT_BUMPDIRECTUV: number;
  114776. CLEARCOAT_TINT: boolean;
  114777. CLEARCOAT_TINT_TEXTURE: boolean;
  114778. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114779. ANISOTROPIC: boolean;
  114780. ANISOTROPIC_TEXTURE: boolean;
  114781. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114782. BRDF_V_HEIGHT_CORRELATED: boolean;
  114783. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114784. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114785. SHEEN: boolean;
  114786. SHEEN_TEXTURE: boolean;
  114787. SHEEN_TEXTUREDIRECTUV: number;
  114788. SHEEN_LINKWITHALBEDO: boolean;
  114789. SUBSURFACE: boolean;
  114790. SS_REFRACTION: boolean;
  114791. SS_TRANSLUCENCY: boolean;
  114792. SS_SCATERRING: boolean;
  114793. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114794. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114795. SS_REFRACTIONMAP_3D: boolean;
  114796. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114797. SS_LODINREFRACTIONALPHA: boolean;
  114798. SS_GAMMAREFRACTION: boolean;
  114799. SS_RGBDREFRACTION: boolean;
  114800. SS_LINEARSPECULARREFRACTION: boolean;
  114801. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114802. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114803. UNLIT: boolean;
  114804. DEBUGMODE: number;
  114805. /**
  114806. * Initializes the PBR Material defines.
  114807. */
  114808. constructor();
  114809. /**
  114810. * Resets the PBR Material defines.
  114811. */
  114812. reset(): void;
  114813. }
  114814. /**
  114815. * The Physically based material base class of BJS.
  114816. *
  114817. * This offers the main features of a standard PBR material.
  114818. * For more information, please refer to the documentation :
  114819. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114820. */
  114821. export abstract class PBRBaseMaterial extends PushMaterial {
  114822. /**
  114823. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114824. */
  114825. static readonly PBRMATERIAL_OPAQUE: number;
  114826. /**
  114827. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114828. */
  114829. static readonly PBRMATERIAL_ALPHATEST: number;
  114830. /**
  114831. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114832. */
  114833. static readonly PBRMATERIAL_ALPHABLEND: number;
  114834. /**
  114835. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114836. * They are also discarded below the alpha cutoff threshold to improve performances.
  114837. */
  114838. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114839. /**
  114840. * Defines the default value of how much AO map is occluding the analytical lights
  114841. * (point spot...).
  114842. */
  114843. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114844. /**
  114845. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114846. */
  114847. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114848. /**
  114849. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114850. * to enhance interoperability with other engines.
  114851. */
  114852. static readonly LIGHTFALLOFF_GLTF: number;
  114853. /**
  114854. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114855. * to enhance interoperability with other materials.
  114856. */
  114857. static readonly LIGHTFALLOFF_STANDARD: number;
  114858. /**
  114859. * Intensity of the direct lights e.g. the four lights available in your scene.
  114860. * This impacts both the direct diffuse and specular highlights.
  114861. */
  114862. protected _directIntensity: number;
  114863. /**
  114864. * Intensity of the emissive part of the material.
  114865. * This helps controlling the emissive effect without modifying the emissive color.
  114866. */
  114867. protected _emissiveIntensity: number;
  114868. /**
  114869. * Intensity of the environment e.g. how much the environment will light the object
  114870. * either through harmonics for rough material or through the refelction for shiny ones.
  114871. */
  114872. protected _environmentIntensity: number;
  114873. /**
  114874. * This is a special control allowing the reduction of the specular highlights coming from the
  114875. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114876. */
  114877. protected _specularIntensity: number;
  114878. /**
  114879. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114880. */
  114881. private _lightingInfos;
  114882. /**
  114883. * Debug Control allowing disabling the bump map on this material.
  114884. */
  114885. protected _disableBumpMap: boolean;
  114886. /**
  114887. * AKA Diffuse Texture in standard nomenclature.
  114888. */
  114889. protected _albedoTexture: Nullable<BaseTexture>;
  114890. /**
  114891. * AKA Occlusion Texture in other nomenclature.
  114892. */
  114893. protected _ambientTexture: Nullable<BaseTexture>;
  114894. /**
  114895. * AKA Occlusion Texture Intensity in other nomenclature.
  114896. */
  114897. protected _ambientTextureStrength: number;
  114898. /**
  114899. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114900. * 1 means it completely occludes it
  114901. * 0 mean it has no impact
  114902. */
  114903. protected _ambientTextureImpactOnAnalyticalLights: number;
  114904. /**
  114905. * Stores the alpha values in a texture.
  114906. */
  114907. protected _opacityTexture: Nullable<BaseTexture>;
  114908. /**
  114909. * Stores the reflection values in a texture.
  114910. */
  114911. protected _reflectionTexture: Nullable<BaseTexture>;
  114912. /**
  114913. * Stores the emissive values in a texture.
  114914. */
  114915. protected _emissiveTexture: Nullable<BaseTexture>;
  114916. /**
  114917. * AKA Specular texture in other nomenclature.
  114918. */
  114919. protected _reflectivityTexture: Nullable<BaseTexture>;
  114920. /**
  114921. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114922. */
  114923. protected _metallicTexture: Nullable<BaseTexture>;
  114924. /**
  114925. * Specifies the metallic scalar of the metallic/roughness workflow.
  114926. * Can also be used to scale the metalness values of the metallic texture.
  114927. */
  114928. protected _metallic: Nullable<number>;
  114929. /**
  114930. * Specifies the roughness scalar of the metallic/roughness workflow.
  114931. * Can also be used to scale the roughness values of the metallic texture.
  114932. */
  114933. protected _roughness: Nullable<number>;
  114934. /**
  114935. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114936. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114937. */
  114938. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114939. /**
  114940. * Stores surface normal data used to displace a mesh in a texture.
  114941. */
  114942. protected _bumpTexture: Nullable<BaseTexture>;
  114943. /**
  114944. * Stores the pre-calculated light information of a mesh in a texture.
  114945. */
  114946. protected _lightmapTexture: Nullable<BaseTexture>;
  114947. /**
  114948. * The color of a material in ambient lighting.
  114949. */
  114950. protected _ambientColor: Color3;
  114951. /**
  114952. * AKA Diffuse Color in other nomenclature.
  114953. */
  114954. protected _albedoColor: Color3;
  114955. /**
  114956. * AKA Specular Color in other nomenclature.
  114957. */
  114958. protected _reflectivityColor: Color3;
  114959. /**
  114960. * The color applied when light is reflected from a material.
  114961. */
  114962. protected _reflectionColor: Color3;
  114963. /**
  114964. * The color applied when light is emitted from a material.
  114965. */
  114966. protected _emissiveColor: Color3;
  114967. /**
  114968. * AKA Glossiness in other nomenclature.
  114969. */
  114970. protected _microSurface: number;
  114971. /**
  114972. * Specifies that the material will use the light map as a show map.
  114973. */
  114974. protected _useLightmapAsShadowmap: boolean;
  114975. /**
  114976. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114977. * makes the reflect vector face the model (under horizon).
  114978. */
  114979. protected _useHorizonOcclusion: boolean;
  114980. /**
  114981. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114982. * too much the area relying on ambient texture to define their ambient occlusion.
  114983. */
  114984. protected _useRadianceOcclusion: boolean;
  114985. /**
  114986. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114987. */
  114988. protected _useAlphaFromAlbedoTexture: boolean;
  114989. /**
  114990. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114991. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114992. */
  114993. protected _useSpecularOverAlpha: boolean;
  114994. /**
  114995. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114996. */
  114997. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114998. /**
  114999. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115000. */
  115001. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115002. /**
  115003. * Specifies if the metallic texture contains the roughness information in its green channel.
  115004. */
  115005. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115006. /**
  115007. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115008. */
  115009. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115010. /**
  115011. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115012. */
  115013. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115014. /**
  115015. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115016. */
  115017. protected _useAmbientInGrayScale: boolean;
  115018. /**
  115019. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115020. * The material will try to infer what glossiness each pixel should be.
  115021. */
  115022. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115023. /**
  115024. * Defines the falloff type used in this material.
  115025. * It by default is Physical.
  115026. */
  115027. protected _lightFalloff: number;
  115028. /**
  115029. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115030. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115031. */
  115032. protected _useRadianceOverAlpha: boolean;
  115033. /**
  115034. * Allows using an object space normal map (instead of tangent space).
  115035. */
  115036. protected _useObjectSpaceNormalMap: boolean;
  115037. /**
  115038. * Allows using the bump map in parallax mode.
  115039. */
  115040. protected _useParallax: boolean;
  115041. /**
  115042. * Allows using the bump map in parallax occlusion mode.
  115043. */
  115044. protected _useParallaxOcclusion: boolean;
  115045. /**
  115046. * Controls the scale bias of the parallax mode.
  115047. */
  115048. protected _parallaxScaleBias: number;
  115049. /**
  115050. * If sets to true, disables all the lights affecting the material.
  115051. */
  115052. protected _disableLighting: boolean;
  115053. /**
  115054. * Number of Simultaneous lights allowed on the material.
  115055. */
  115056. protected _maxSimultaneousLights: number;
  115057. /**
  115058. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115059. */
  115060. protected _invertNormalMapX: boolean;
  115061. /**
  115062. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115063. */
  115064. protected _invertNormalMapY: boolean;
  115065. /**
  115066. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115067. */
  115068. protected _twoSidedLighting: boolean;
  115069. /**
  115070. * Defines the alpha limits in alpha test mode.
  115071. */
  115072. protected _alphaCutOff: number;
  115073. /**
  115074. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115075. */
  115076. protected _forceAlphaTest: boolean;
  115077. /**
  115078. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115079. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115080. */
  115081. protected _useAlphaFresnel: boolean;
  115082. /**
  115083. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115084. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115085. */
  115086. protected _useLinearAlphaFresnel: boolean;
  115087. /**
  115088. * The transparency mode of the material.
  115089. */
  115090. protected _transparencyMode: Nullable<number>;
  115091. /**
  115092. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115093. * from cos thetav and roughness:
  115094. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115095. */
  115096. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115097. /**
  115098. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115099. */
  115100. protected _forceIrradianceInFragment: boolean;
  115101. /**
  115102. * Force normal to face away from face.
  115103. */
  115104. protected _forceNormalForward: boolean;
  115105. /**
  115106. * Enables specular anti aliasing in the PBR shader.
  115107. * It will both interacts on the Geometry for analytical and IBL lighting.
  115108. * It also prefilter the roughness map based on the bump values.
  115109. */
  115110. protected _enableSpecularAntiAliasing: boolean;
  115111. /**
  115112. * Default configuration related to image processing available in the PBR Material.
  115113. */
  115114. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115115. /**
  115116. * Keep track of the image processing observer to allow dispose and replace.
  115117. */
  115118. private _imageProcessingObserver;
  115119. /**
  115120. * Attaches a new image processing configuration to the PBR Material.
  115121. * @param configuration
  115122. */
  115123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115124. /**
  115125. * Stores the available render targets.
  115126. */
  115127. private _renderTargets;
  115128. /**
  115129. * Sets the global ambient color for the material used in lighting calculations.
  115130. */
  115131. private _globalAmbientColor;
  115132. /**
  115133. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115134. */
  115135. private _useLogarithmicDepth;
  115136. /**
  115137. * If set to true, no lighting calculations will be applied.
  115138. */
  115139. private _unlit;
  115140. private _debugMode;
  115141. /**
  115142. * @hidden
  115143. * This is reserved for the inspector.
  115144. * Defines the material debug mode.
  115145. * It helps seeing only some components of the material while troubleshooting.
  115146. */
  115147. debugMode: number;
  115148. /**
  115149. * @hidden
  115150. * This is reserved for the inspector.
  115151. * Specify from where on screen the debug mode should start.
  115152. * The value goes from -1 (full screen) to 1 (not visible)
  115153. * It helps with side by side comparison against the final render
  115154. * This defaults to -1
  115155. */
  115156. private debugLimit;
  115157. /**
  115158. * @hidden
  115159. * This is reserved for the inspector.
  115160. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115161. * You can use the factor to better multiply the final value.
  115162. */
  115163. private debugFactor;
  115164. /**
  115165. * Defines the clear coat layer parameters for the material.
  115166. */
  115167. readonly clearCoat: PBRClearCoatConfiguration;
  115168. /**
  115169. * Defines the anisotropic parameters for the material.
  115170. */
  115171. readonly anisotropy: PBRAnisotropicConfiguration;
  115172. /**
  115173. * Defines the BRDF parameters for the material.
  115174. */
  115175. readonly brdf: PBRBRDFConfiguration;
  115176. /**
  115177. * Defines the Sheen parameters for the material.
  115178. */
  115179. readonly sheen: PBRSheenConfiguration;
  115180. /**
  115181. * Defines the SubSurface parameters for the material.
  115182. */
  115183. readonly subSurface: PBRSubSurfaceConfiguration;
  115184. /**
  115185. * Custom callback helping to override the default shader used in the material.
  115186. */
  115187. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115188. protected _rebuildInParallel: boolean;
  115189. /**
  115190. * Instantiates a new PBRMaterial instance.
  115191. *
  115192. * @param name The material name
  115193. * @param scene The scene the material will be use in.
  115194. */
  115195. constructor(name: string, scene: Scene);
  115196. /**
  115197. * Gets a boolean indicating that current material needs to register RTT
  115198. */
  115199. readonly hasRenderTargetTextures: boolean;
  115200. /**
  115201. * Gets the name of the material class.
  115202. */
  115203. getClassName(): string;
  115204. /**
  115205. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115206. */
  115207. /**
  115208. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115209. */
  115210. useLogarithmicDepth: boolean;
  115211. /**
  115212. * Gets the current transparency mode.
  115213. */
  115214. /**
  115215. * Sets the transparency mode of the material.
  115216. *
  115217. * | Value | Type | Description |
  115218. * | ----- | ----------------------------------- | ----------- |
  115219. * | 0 | OPAQUE | |
  115220. * | 1 | ALPHATEST | |
  115221. * | 2 | ALPHABLEND | |
  115222. * | 3 | ALPHATESTANDBLEND | |
  115223. *
  115224. */
  115225. transparencyMode: Nullable<number>;
  115226. /**
  115227. * Returns true if alpha blending should be disabled.
  115228. */
  115229. private readonly _disableAlphaBlending;
  115230. /**
  115231. * Specifies whether or not this material should be rendered in alpha blend mode.
  115232. */
  115233. needAlphaBlending(): boolean;
  115234. /**
  115235. * Specifies if the mesh will require alpha blending.
  115236. * @param mesh - BJS mesh.
  115237. */
  115238. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115239. /**
  115240. * Specifies whether or not this material should be rendered in alpha test mode.
  115241. */
  115242. needAlphaTesting(): boolean;
  115243. /**
  115244. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115245. */
  115246. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115247. /**
  115248. * Gets the texture used for the alpha test.
  115249. */
  115250. getAlphaTestTexture(): Nullable<BaseTexture>;
  115251. /**
  115252. * Specifies that the submesh is ready to be used.
  115253. * @param mesh - BJS mesh.
  115254. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115255. * @param useInstances - Specifies that instances should be used.
  115256. * @returns - boolean indicating that the submesh is ready or not.
  115257. */
  115258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115259. /**
  115260. * Specifies if the material uses metallic roughness workflow.
  115261. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115262. */
  115263. isMetallicWorkflow(): boolean;
  115264. private _prepareEffect;
  115265. private _prepareDefines;
  115266. /**
  115267. * Force shader compilation
  115268. */
  115269. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  115270. clipPlane: boolean;
  115271. }>): void;
  115272. /**
  115273. * Initializes the uniform buffer layout for the shader.
  115274. */
  115275. buildUniformLayout(): void;
  115276. /**
  115277. * Unbinds the material from the mesh
  115278. */
  115279. unbind(): void;
  115280. /**
  115281. * Binds the submesh data.
  115282. * @param world - The world matrix.
  115283. * @param mesh - The BJS mesh.
  115284. * @param subMesh - A submesh of the BJS mesh.
  115285. */
  115286. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115287. /**
  115288. * Returns the animatable textures.
  115289. * @returns - Array of animatable textures.
  115290. */
  115291. getAnimatables(): IAnimatable[];
  115292. /**
  115293. * Returns the texture used for reflections.
  115294. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115295. */
  115296. private _getReflectionTexture;
  115297. /**
  115298. * Returns an array of the actively used textures.
  115299. * @returns - Array of BaseTextures
  115300. */
  115301. getActiveTextures(): BaseTexture[];
  115302. /**
  115303. * Checks to see if a texture is used in the material.
  115304. * @param texture - Base texture to use.
  115305. * @returns - Boolean specifying if a texture is used in the material.
  115306. */
  115307. hasTexture(texture: BaseTexture): boolean;
  115308. /**
  115309. * Disposes the resources of the material.
  115310. * @param forceDisposeEffect - Forces the disposal of effects.
  115311. * @param forceDisposeTextures - Forces the disposal of all textures.
  115312. */
  115313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115314. }
  115315. }
  115316. declare module BABYLON {
  115317. /**
  115318. * The Physically based material of BJS.
  115319. *
  115320. * This offers the main features of a standard PBR material.
  115321. * For more information, please refer to the documentation :
  115322. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115323. */
  115324. export class PBRMaterial extends PBRBaseMaterial {
  115325. /**
  115326. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115327. */
  115328. static readonly PBRMATERIAL_OPAQUE: number;
  115329. /**
  115330. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115331. */
  115332. static readonly PBRMATERIAL_ALPHATEST: number;
  115333. /**
  115334. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115335. */
  115336. static readonly PBRMATERIAL_ALPHABLEND: number;
  115337. /**
  115338. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115339. * They are also discarded below the alpha cutoff threshold to improve performances.
  115340. */
  115341. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115342. /**
  115343. * Defines the default value of how much AO map is occluding the analytical lights
  115344. * (point spot...).
  115345. */
  115346. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115347. /**
  115348. * Intensity of the direct lights e.g. the four lights available in your scene.
  115349. * This impacts both the direct diffuse and specular highlights.
  115350. */
  115351. directIntensity: number;
  115352. /**
  115353. * Intensity of the emissive part of the material.
  115354. * This helps controlling the emissive effect without modifying the emissive color.
  115355. */
  115356. emissiveIntensity: number;
  115357. /**
  115358. * Intensity of the environment e.g. how much the environment will light the object
  115359. * either through harmonics for rough material or through the refelction for shiny ones.
  115360. */
  115361. environmentIntensity: number;
  115362. /**
  115363. * This is a special control allowing the reduction of the specular highlights coming from the
  115364. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115365. */
  115366. specularIntensity: number;
  115367. /**
  115368. * Debug Control allowing disabling the bump map on this material.
  115369. */
  115370. disableBumpMap: boolean;
  115371. /**
  115372. * AKA Diffuse Texture in standard nomenclature.
  115373. */
  115374. albedoTexture: BaseTexture;
  115375. /**
  115376. * AKA Occlusion Texture in other nomenclature.
  115377. */
  115378. ambientTexture: BaseTexture;
  115379. /**
  115380. * AKA Occlusion Texture Intensity in other nomenclature.
  115381. */
  115382. ambientTextureStrength: number;
  115383. /**
  115384. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115385. * 1 means it completely occludes it
  115386. * 0 mean it has no impact
  115387. */
  115388. ambientTextureImpactOnAnalyticalLights: number;
  115389. /**
  115390. * Stores the alpha values in a texture.
  115391. */
  115392. opacityTexture: BaseTexture;
  115393. /**
  115394. * Stores the reflection values in a texture.
  115395. */
  115396. reflectionTexture: Nullable<BaseTexture>;
  115397. /**
  115398. * Stores the emissive values in a texture.
  115399. */
  115400. emissiveTexture: BaseTexture;
  115401. /**
  115402. * AKA Specular texture in other nomenclature.
  115403. */
  115404. reflectivityTexture: BaseTexture;
  115405. /**
  115406. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115407. */
  115408. metallicTexture: BaseTexture;
  115409. /**
  115410. * Specifies the metallic scalar of the metallic/roughness workflow.
  115411. * Can also be used to scale the metalness values of the metallic texture.
  115412. */
  115413. metallic: Nullable<number>;
  115414. /**
  115415. * Specifies the roughness scalar of the metallic/roughness workflow.
  115416. * Can also be used to scale the roughness values of the metallic texture.
  115417. */
  115418. roughness: Nullable<number>;
  115419. /**
  115420. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115421. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115422. */
  115423. microSurfaceTexture: BaseTexture;
  115424. /**
  115425. * Stores surface normal data used to displace a mesh in a texture.
  115426. */
  115427. bumpTexture: BaseTexture;
  115428. /**
  115429. * Stores the pre-calculated light information of a mesh in a texture.
  115430. */
  115431. lightmapTexture: BaseTexture;
  115432. /**
  115433. * Stores the refracted light information in a texture.
  115434. */
  115435. refractionTexture: Nullable<BaseTexture>;
  115436. /**
  115437. * The color of a material in ambient lighting.
  115438. */
  115439. ambientColor: Color3;
  115440. /**
  115441. * AKA Diffuse Color in other nomenclature.
  115442. */
  115443. albedoColor: Color3;
  115444. /**
  115445. * AKA Specular Color in other nomenclature.
  115446. */
  115447. reflectivityColor: Color3;
  115448. /**
  115449. * The color reflected from the material.
  115450. */
  115451. reflectionColor: Color3;
  115452. /**
  115453. * The color emitted from the material.
  115454. */
  115455. emissiveColor: Color3;
  115456. /**
  115457. * AKA Glossiness in other nomenclature.
  115458. */
  115459. microSurface: number;
  115460. /**
  115461. * source material index of refraction (IOR)' / 'destination material IOR.
  115462. */
  115463. indexOfRefraction: number;
  115464. /**
  115465. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115466. */
  115467. invertRefractionY: boolean;
  115468. /**
  115469. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115470. * Materials half opaque for instance using refraction could benefit from this control.
  115471. */
  115472. linkRefractionWithTransparency: boolean;
  115473. /**
  115474. * If true, the light map contains occlusion information instead of lighting info.
  115475. */
  115476. useLightmapAsShadowmap: boolean;
  115477. /**
  115478. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115479. */
  115480. useAlphaFromAlbedoTexture: boolean;
  115481. /**
  115482. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115483. */
  115484. forceAlphaTest: boolean;
  115485. /**
  115486. * Defines the alpha limits in alpha test mode.
  115487. */
  115488. alphaCutOff: number;
  115489. /**
  115490. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115491. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115492. */
  115493. useSpecularOverAlpha: boolean;
  115494. /**
  115495. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115496. */
  115497. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115498. /**
  115499. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115500. */
  115501. useRoughnessFromMetallicTextureAlpha: boolean;
  115502. /**
  115503. * Specifies if the metallic texture contains the roughness information in its green channel.
  115504. */
  115505. useRoughnessFromMetallicTextureGreen: boolean;
  115506. /**
  115507. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115508. */
  115509. useMetallnessFromMetallicTextureBlue: boolean;
  115510. /**
  115511. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115512. */
  115513. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115514. /**
  115515. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115516. */
  115517. useAmbientInGrayScale: boolean;
  115518. /**
  115519. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115520. * The material will try to infer what glossiness each pixel should be.
  115521. */
  115522. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115523. /**
  115524. * BJS is using an harcoded light falloff based on a manually sets up range.
  115525. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115526. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115527. */
  115528. /**
  115529. * BJS is using an harcoded light falloff based on a manually sets up range.
  115530. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115531. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115532. */
  115533. usePhysicalLightFalloff: boolean;
  115534. /**
  115535. * In order to support the falloff compatibility with gltf, a special mode has been added
  115536. * to reproduce the gltf light falloff.
  115537. */
  115538. /**
  115539. * In order to support the falloff compatibility with gltf, a special mode has been added
  115540. * to reproduce the gltf light falloff.
  115541. */
  115542. useGLTFLightFalloff: boolean;
  115543. /**
  115544. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115545. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115546. */
  115547. useRadianceOverAlpha: boolean;
  115548. /**
  115549. * Allows using an object space normal map (instead of tangent space).
  115550. */
  115551. useObjectSpaceNormalMap: boolean;
  115552. /**
  115553. * Allows using the bump map in parallax mode.
  115554. */
  115555. useParallax: boolean;
  115556. /**
  115557. * Allows using the bump map in parallax occlusion mode.
  115558. */
  115559. useParallaxOcclusion: boolean;
  115560. /**
  115561. * Controls the scale bias of the parallax mode.
  115562. */
  115563. parallaxScaleBias: number;
  115564. /**
  115565. * If sets to true, disables all the lights affecting the material.
  115566. */
  115567. disableLighting: boolean;
  115568. /**
  115569. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115570. */
  115571. forceIrradianceInFragment: boolean;
  115572. /**
  115573. * Number of Simultaneous lights allowed on the material.
  115574. */
  115575. maxSimultaneousLights: number;
  115576. /**
  115577. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115578. */
  115579. invertNormalMapX: boolean;
  115580. /**
  115581. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115582. */
  115583. invertNormalMapY: boolean;
  115584. /**
  115585. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115586. */
  115587. twoSidedLighting: boolean;
  115588. /**
  115589. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115590. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115591. */
  115592. useAlphaFresnel: boolean;
  115593. /**
  115594. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115595. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115596. */
  115597. useLinearAlphaFresnel: boolean;
  115598. /**
  115599. * Let user defines the brdf lookup texture used for IBL.
  115600. * A default 8bit version is embedded but you could point at :
  115601. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115602. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115603. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115604. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115605. */
  115606. environmentBRDFTexture: Nullable<BaseTexture>;
  115607. /**
  115608. * Force normal to face away from face.
  115609. */
  115610. forceNormalForward: boolean;
  115611. /**
  115612. * Enables specular anti aliasing in the PBR shader.
  115613. * It will both interacts on the Geometry for analytical and IBL lighting.
  115614. * It also prefilter the roughness map based on the bump values.
  115615. */
  115616. enableSpecularAntiAliasing: boolean;
  115617. /**
  115618. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115619. * makes the reflect vector face the model (under horizon).
  115620. */
  115621. useHorizonOcclusion: boolean;
  115622. /**
  115623. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115624. * too much the area relying on ambient texture to define their ambient occlusion.
  115625. */
  115626. useRadianceOcclusion: boolean;
  115627. /**
  115628. * If set to true, no lighting calculations will be applied.
  115629. */
  115630. unlit: boolean;
  115631. /**
  115632. * Gets the image processing configuration used either in this material.
  115633. */
  115634. /**
  115635. * Sets the Default image processing configuration used either in the this material.
  115636. *
  115637. * If sets to null, the scene one is in use.
  115638. */
  115639. imageProcessingConfiguration: ImageProcessingConfiguration;
  115640. /**
  115641. * Gets wether the color curves effect is enabled.
  115642. */
  115643. /**
  115644. * Sets wether the color curves effect is enabled.
  115645. */
  115646. cameraColorCurvesEnabled: boolean;
  115647. /**
  115648. * Gets wether the color grading effect is enabled.
  115649. */
  115650. /**
  115651. * Gets wether the color grading effect is enabled.
  115652. */
  115653. cameraColorGradingEnabled: boolean;
  115654. /**
  115655. * Gets wether tonemapping is enabled or not.
  115656. */
  115657. /**
  115658. * Sets wether tonemapping is enabled or not
  115659. */
  115660. cameraToneMappingEnabled: boolean;
  115661. /**
  115662. * The camera exposure used on this material.
  115663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115664. * This corresponds to a photographic exposure.
  115665. */
  115666. /**
  115667. * The camera exposure used on this material.
  115668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115669. * This corresponds to a photographic exposure.
  115670. */
  115671. cameraExposure: number;
  115672. /**
  115673. * Gets The camera contrast used on this material.
  115674. */
  115675. /**
  115676. * Sets The camera contrast used on this material.
  115677. */
  115678. cameraContrast: number;
  115679. /**
  115680. * Gets the Color Grading 2D Lookup Texture.
  115681. */
  115682. /**
  115683. * Sets the Color Grading 2D Lookup Texture.
  115684. */
  115685. cameraColorGradingTexture: Nullable<BaseTexture>;
  115686. /**
  115687. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115688. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115689. * 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;
  115690. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115691. */
  115692. /**
  115693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115695. * 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;
  115696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115697. */
  115698. cameraColorCurves: Nullable<ColorCurves>;
  115699. /**
  115700. * Instantiates a new PBRMaterial instance.
  115701. *
  115702. * @param name The material name
  115703. * @param scene The scene the material will be use in.
  115704. */
  115705. constructor(name: string, scene: Scene);
  115706. /**
  115707. * Returns the name of this material class.
  115708. */
  115709. getClassName(): string;
  115710. /**
  115711. * Makes a duplicate of the current material.
  115712. * @param name - name to use for the new material.
  115713. */
  115714. clone(name: string): PBRMaterial;
  115715. /**
  115716. * Serializes this PBR Material.
  115717. * @returns - An object with the serialized material.
  115718. */
  115719. serialize(): any;
  115720. /**
  115721. * Parses a PBR Material from a serialized object.
  115722. * @param source - Serialized object.
  115723. * @param scene - BJS scene instance.
  115724. * @param rootUrl - url for the scene object
  115725. * @returns - PBRMaterial
  115726. */
  115727. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115728. }
  115729. }
  115730. declare module BABYLON {
  115731. /**
  115732. * Direct draw surface info
  115733. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115734. */
  115735. export interface DDSInfo {
  115736. /**
  115737. * Width of the texture
  115738. */
  115739. width: number;
  115740. /**
  115741. * Width of the texture
  115742. */
  115743. height: number;
  115744. /**
  115745. * Number of Mipmaps for the texture
  115746. * @see https://en.wikipedia.org/wiki/Mipmap
  115747. */
  115748. mipmapCount: number;
  115749. /**
  115750. * If the textures format is a known fourCC format
  115751. * @see https://www.fourcc.org/
  115752. */
  115753. isFourCC: boolean;
  115754. /**
  115755. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115756. */
  115757. isRGB: boolean;
  115758. /**
  115759. * If the texture is a lumincance format
  115760. */
  115761. isLuminance: boolean;
  115762. /**
  115763. * If this is a cube texture
  115764. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115765. */
  115766. isCube: boolean;
  115767. /**
  115768. * If the texture is a compressed format eg. FOURCC_DXT1
  115769. */
  115770. isCompressed: boolean;
  115771. /**
  115772. * The dxgiFormat of the texture
  115773. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115774. */
  115775. dxgiFormat: number;
  115776. /**
  115777. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115778. */
  115779. textureType: number;
  115780. /**
  115781. * Sphericle polynomial created for the dds texture
  115782. */
  115783. sphericalPolynomial?: SphericalPolynomial;
  115784. }
  115785. /**
  115786. * Class used to provide DDS decompression tools
  115787. */
  115788. export class DDSTools {
  115789. /**
  115790. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115791. */
  115792. static StoreLODInAlphaChannel: boolean;
  115793. /**
  115794. * Gets DDS information from an array buffer
  115795. * @param arrayBuffer defines the array buffer to read data from
  115796. * @returns the DDS information
  115797. */
  115798. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115799. private static _FloatView;
  115800. private static _Int32View;
  115801. private static _ToHalfFloat;
  115802. private static _FromHalfFloat;
  115803. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115804. private static _GetHalfFloatRGBAArrayBuffer;
  115805. private static _GetFloatRGBAArrayBuffer;
  115806. private static _GetFloatAsUIntRGBAArrayBuffer;
  115807. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115808. private static _GetRGBAArrayBuffer;
  115809. private static _ExtractLongWordOrder;
  115810. private static _GetRGBArrayBuffer;
  115811. private static _GetLuminanceArrayBuffer;
  115812. /**
  115813. * Uploads DDS Levels to a Babylon Texture
  115814. * @hidden
  115815. */
  115816. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115817. }
  115818. interface ThinEngine {
  115819. /**
  115820. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115821. * @param rootUrl defines the url where the file to load is located
  115822. * @param scene defines the current scene
  115823. * @param lodScale defines scale to apply to the mip map selection
  115824. * @param lodOffset defines offset to apply to the mip map selection
  115825. * @param onLoad defines an optional callback raised when the texture is loaded
  115826. * @param onError defines an optional callback raised if there is an issue to load the texture
  115827. * @param format defines the format of the data
  115828. * @param forcedExtension defines the extension to use to pick the right loader
  115829. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115830. * @returns the cube texture as an InternalTexture
  115831. */
  115832. 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;
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * Implementation of the DDS Texture Loader.
  115838. * @hidden
  115839. */
  115840. export class _DDSTextureLoader implements IInternalTextureLoader {
  115841. /**
  115842. * Defines wether the loader supports cascade loading the different faces.
  115843. */
  115844. readonly supportCascades: boolean;
  115845. /**
  115846. * This returns if the loader support the current file information.
  115847. * @param extension defines the file extension of the file being loaded
  115848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115849. * @param fallback defines the fallback internal texture if any
  115850. * @param isBase64 defines whether the texture is encoded as a base64
  115851. * @param isBuffer defines whether the texture data are stored as a buffer
  115852. * @returns true if the loader can load the specified file
  115853. */
  115854. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115855. /**
  115856. * Transform the url before loading if required.
  115857. * @param rootUrl the url of the texture
  115858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115859. * @returns the transformed texture
  115860. */
  115861. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115862. /**
  115863. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115864. * @param rootUrl the url of the texture
  115865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115866. * @returns the fallback texture
  115867. */
  115868. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115869. /**
  115870. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115871. * @param data contains the texture data
  115872. * @param texture defines the BabylonJS internal texture
  115873. * @param createPolynomials will be true if polynomials have been requested
  115874. * @param onLoad defines the callback to trigger once the texture is ready
  115875. * @param onError defines the callback to trigger in case of error
  115876. */
  115877. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115878. /**
  115879. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115880. * @param data contains the texture data
  115881. * @param texture defines the BabylonJS internal texture
  115882. * @param callback defines the method to call once ready to upload
  115883. */
  115884. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115885. }
  115886. }
  115887. declare module BABYLON {
  115888. /**
  115889. * Implementation of the ENV Texture Loader.
  115890. * @hidden
  115891. */
  115892. export class _ENVTextureLoader implements IInternalTextureLoader {
  115893. /**
  115894. * Defines wether the loader supports cascade loading the different faces.
  115895. */
  115896. readonly supportCascades: boolean;
  115897. /**
  115898. * This returns if the loader support the current file information.
  115899. * @param extension defines the file extension of the file being loaded
  115900. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115901. * @param fallback defines the fallback internal texture if any
  115902. * @param isBase64 defines whether the texture is encoded as a base64
  115903. * @param isBuffer defines whether the texture data are stored as a buffer
  115904. * @returns true if the loader can load the specified file
  115905. */
  115906. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115907. /**
  115908. * Transform the url before loading if required.
  115909. * @param rootUrl the url of the texture
  115910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115911. * @returns the transformed texture
  115912. */
  115913. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115914. /**
  115915. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115916. * @param rootUrl the url of the texture
  115917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115918. * @returns the fallback texture
  115919. */
  115920. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115921. /**
  115922. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115923. * @param data contains the texture data
  115924. * @param texture defines the BabylonJS internal texture
  115925. * @param createPolynomials will be true if polynomials have been requested
  115926. * @param onLoad defines the callback to trigger once the texture is ready
  115927. * @param onError defines the callback to trigger in case of error
  115928. */
  115929. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115930. /**
  115931. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115932. * @param data contains the texture data
  115933. * @param texture defines the BabylonJS internal texture
  115934. * @param callback defines the method to call once ready to upload
  115935. */
  115936. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115937. }
  115938. }
  115939. declare module BABYLON {
  115940. /**
  115941. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115942. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115943. */
  115944. export class KhronosTextureContainer {
  115945. /** contents of the KTX container file */
  115946. arrayBuffer: any;
  115947. private static HEADER_LEN;
  115948. private static COMPRESSED_2D;
  115949. private static COMPRESSED_3D;
  115950. private static TEX_2D;
  115951. private static TEX_3D;
  115952. /**
  115953. * Gets the openGL type
  115954. */
  115955. glType: number;
  115956. /**
  115957. * Gets the openGL type size
  115958. */
  115959. glTypeSize: number;
  115960. /**
  115961. * Gets the openGL format
  115962. */
  115963. glFormat: number;
  115964. /**
  115965. * Gets the openGL internal format
  115966. */
  115967. glInternalFormat: number;
  115968. /**
  115969. * Gets the base internal format
  115970. */
  115971. glBaseInternalFormat: number;
  115972. /**
  115973. * Gets image width in pixel
  115974. */
  115975. pixelWidth: number;
  115976. /**
  115977. * Gets image height in pixel
  115978. */
  115979. pixelHeight: number;
  115980. /**
  115981. * Gets image depth in pixels
  115982. */
  115983. pixelDepth: number;
  115984. /**
  115985. * Gets the number of array elements
  115986. */
  115987. numberOfArrayElements: number;
  115988. /**
  115989. * Gets the number of faces
  115990. */
  115991. numberOfFaces: number;
  115992. /**
  115993. * Gets the number of mipmap levels
  115994. */
  115995. numberOfMipmapLevels: number;
  115996. /**
  115997. * Gets the bytes of key value data
  115998. */
  115999. bytesOfKeyValueData: number;
  116000. /**
  116001. * Gets the load type
  116002. */
  116003. loadType: number;
  116004. /**
  116005. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116006. */
  116007. isInvalid: boolean;
  116008. /**
  116009. * Creates a new KhronosTextureContainer
  116010. * @param arrayBuffer contents of the KTX container file
  116011. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116012. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116013. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116014. */
  116015. constructor(
  116016. /** contents of the KTX container file */
  116017. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116018. /**
  116019. * Uploads KTX content to a Babylon Texture.
  116020. * It is assumed that the texture has already been created & is currently bound
  116021. * @hidden
  116022. */
  116023. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116024. private _upload2DCompressedLevels;
  116025. }
  116026. }
  116027. declare module BABYLON {
  116028. /**
  116029. * Implementation of the KTX Texture Loader.
  116030. * @hidden
  116031. */
  116032. export class _KTXTextureLoader implements IInternalTextureLoader {
  116033. /**
  116034. * Defines wether the loader supports cascade loading the different faces.
  116035. */
  116036. readonly supportCascades: boolean;
  116037. /**
  116038. * This returns if the loader support the current file information.
  116039. * @param extension defines the file extension of the file being loaded
  116040. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116041. * @param fallback defines the fallback internal texture if any
  116042. * @param isBase64 defines whether the texture is encoded as a base64
  116043. * @param isBuffer defines whether the texture data are stored as a buffer
  116044. * @returns true if the loader can load the specified file
  116045. */
  116046. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116047. /**
  116048. * Transform the url before loading if required.
  116049. * @param rootUrl the url of the texture
  116050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116051. * @returns the transformed texture
  116052. */
  116053. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116054. /**
  116055. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116056. * @param rootUrl the url of the texture
  116057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116058. * @returns the fallback texture
  116059. */
  116060. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116061. /**
  116062. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116063. * @param data contains the texture data
  116064. * @param texture defines the BabylonJS internal texture
  116065. * @param createPolynomials will be true if polynomials have been requested
  116066. * @param onLoad defines the callback to trigger once the texture is ready
  116067. * @param onError defines the callback to trigger in case of error
  116068. */
  116069. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116070. /**
  116071. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116072. * @param data contains the texture data
  116073. * @param texture defines the BabylonJS internal texture
  116074. * @param callback defines the method to call once ready to upload
  116075. */
  116076. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116077. }
  116078. }
  116079. declare module BABYLON {
  116080. /**
  116081. * Options for the default xr helper
  116082. */
  116083. export class WebXRDefaultExperienceOptions {
  116084. /**
  116085. * Floor meshes that should be used for teleporting
  116086. */
  116087. floorMeshes: Array<AbstractMesh>;
  116088. }
  116089. /**
  116090. * Default experience which provides a similar setup to the previous webVRExperience
  116091. */
  116092. export class WebXRDefaultExperience {
  116093. /**
  116094. * Base experience
  116095. */
  116096. baseExperience: WebXRExperienceHelper;
  116097. /**
  116098. * Input experience extension
  116099. */
  116100. input: WebXRInput;
  116101. /**
  116102. * Loads the controller models
  116103. */
  116104. controllerModelLoader: WebXRControllerModelLoader;
  116105. /**
  116106. * Enables laser pointer and selection
  116107. */
  116108. pointerSelection: WebXRControllerPointerSelection;
  116109. /**
  116110. * Enables teleportation
  116111. */
  116112. teleportation: WebXRControllerTeleportation;
  116113. /**
  116114. * Enables ui for enetering/exiting xr
  116115. */
  116116. enterExitUI: WebXREnterExitUI;
  116117. /**
  116118. * Default output canvas xr should render to
  116119. */
  116120. outputCanvas: WebXRManagedOutputCanvas;
  116121. /**
  116122. * Creates the default xr experience
  116123. * @param scene scene
  116124. * @param options options for basic configuration
  116125. * @returns resulting WebXRDefaultExperience
  116126. */
  116127. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116128. private constructor();
  116129. /**
  116130. * DIsposes of the experience helper
  116131. */
  116132. dispose(): void;
  116133. }
  116134. }
  116135. declare module BABYLON {
  116136. /** @hidden */
  116137. export var _forceSceneHelpersToBundle: boolean;
  116138. interface Scene {
  116139. /**
  116140. * Creates a default light for the scene.
  116141. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116142. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116143. */
  116144. createDefaultLight(replace?: boolean): void;
  116145. /**
  116146. * Creates a default camera for the scene.
  116147. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116148. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116149. * @param replace has default false, when true replaces the active camera in the scene
  116150. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116151. */
  116152. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116153. /**
  116154. * Creates a default camera and a default light.
  116155. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116156. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116157. * @param replace has the default false, when true replaces the active camera/light in the scene
  116158. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116159. */
  116160. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116161. /**
  116162. * Creates a new sky box
  116163. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116164. * @param environmentTexture defines the texture to use as environment texture
  116165. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116166. * @param scale defines the overall scale of the skybox
  116167. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116168. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116169. * @returns a new mesh holding the sky box
  116170. */
  116171. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116172. /**
  116173. * Creates a new environment
  116174. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116175. * @param options defines the options you can use to configure the environment
  116176. * @returns the new EnvironmentHelper
  116177. */
  116178. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116179. /**
  116180. * Creates a new VREXperienceHelper
  116181. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116182. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116183. * @returns a new VREXperienceHelper
  116184. */
  116185. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116186. /**
  116187. * Creates a new WebXRDefaultExperience
  116188. * @see http://doc.babylonjs.com/how_to/webxr
  116189. * @param options experience options
  116190. * @returns a promise for a new WebXRDefaultExperience
  116191. */
  116192. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116193. }
  116194. }
  116195. declare module BABYLON {
  116196. /**
  116197. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116198. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116199. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116201. */
  116202. export class VideoDome extends TransformNode {
  116203. /**
  116204. * Define the video source as a Monoscopic panoramic 360 video.
  116205. */
  116206. static readonly MODE_MONOSCOPIC: number;
  116207. /**
  116208. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116209. */
  116210. static readonly MODE_TOPBOTTOM: number;
  116211. /**
  116212. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116213. */
  116214. static readonly MODE_SIDEBYSIDE: number;
  116215. private _halfDome;
  116216. private _useDirectMapping;
  116217. /**
  116218. * The video texture being displayed on the sphere
  116219. */
  116220. protected _videoTexture: VideoTexture;
  116221. /**
  116222. * Gets the video texture being displayed on the sphere
  116223. */
  116224. readonly videoTexture: VideoTexture;
  116225. /**
  116226. * The skybox material
  116227. */
  116228. protected _material: BackgroundMaterial;
  116229. /**
  116230. * The surface used for the skybox
  116231. */
  116232. protected _mesh: Mesh;
  116233. /**
  116234. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116235. */
  116236. private _halfDomeMask;
  116237. /**
  116238. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116239. * Also see the options.resolution property.
  116240. */
  116241. fovMultiplier: number;
  116242. private _videoMode;
  116243. /**
  116244. * Gets or set the current video mode for the video. It can be:
  116245. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116246. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116247. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116248. */
  116249. videoMode: number;
  116250. /**
  116251. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116252. *
  116253. */
  116254. /**
  116255. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116256. */
  116257. halfDome: boolean;
  116258. /**
  116259. * Oberserver used in Stereoscopic VR Mode.
  116260. */
  116261. private _onBeforeCameraRenderObserver;
  116262. /**
  116263. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116264. * @param name Element's name, child elements will append suffixes for their own names.
  116265. * @param urlsOrVideo defines the url(s) or the video element to use
  116266. * @param options An object containing optional or exposed sub element properties
  116267. */
  116268. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116269. resolution?: number;
  116270. clickToPlay?: boolean;
  116271. autoPlay?: boolean;
  116272. loop?: boolean;
  116273. size?: number;
  116274. poster?: string;
  116275. faceForward?: boolean;
  116276. useDirectMapping?: boolean;
  116277. halfDomeMode?: boolean;
  116278. }, scene: Scene);
  116279. private _changeVideoMode;
  116280. /**
  116281. * Releases resources associated with this node.
  116282. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116283. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116284. */
  116285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116286. }
  116287. }
  116288. declare module BABYLON {
  116289. /**
  116290. * This class can be used to get instrumentation data from a Babylon engine
  116291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116292. */
  116293. export class EngineInstrumentation implements IDisposable {
  116294. /**
  116295. * Define the instrumented engine.
  116296. */
  116297. engine: Engine;
  116298. private _captureGPUFrameTime;
  116299. private _gpuFrameTimeToken;
  116300. private _gpuFrameTime;
  116301. private _captureShaderCompilationTime;
  116302. private _shaderCompilationTime;
  116303. private _onBeginFrameObserver;
  116304. private _onEndFrameObserver;
  116305. private _onBeforeShaderCompilationObserver;
  116306. private _onAfterShaderCompilationObserver;
  116307. /**
  116308. * Gets the perf counter used for GPU frame time
  116309. */
  116310. readonly gpuFrameTimeCounter: PerfCounter;
  116311. /**
  116312. * Gets the GPU frame time capture status
  116313. */
  116314. /**
  116315. * Enable or disable the GPU frame time capture
  116316. */
  116317. captureGPUFrameTime: boolean;
  116318. /**
  116319. * Gets the perf counter used for shader compilation time
  116320. */
  116321. readonly shaderCompilationTimeCounter: PerfCounter;
  116322. /**
  116323. * Gets the shader compilation time capture status
  116324. */
  116325. /**
  116326. * Enable or disable the shader compilation time capture
  116327. */
  116328. captureShaderCompilationTime: boolean;
  116329. /**
  116330. * Instantiates a new engine instrumentation.
  116331. * This class can be used to get instrumentation data from a Babylon engine
  116332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116333. * @param engine Defines the engine to instrument
  116334. */
  116335. constructor(
  116336. /**
  116337. * Define the instrumented engine.
  116338. */
  116339. engine: Engine);
  116340. /**
  116341. * Dispose and release associated resources.
  116342. */
  116343. dispose(): void;
  116344. }
  116345. }
  116346. declare module BABYLON {
  116347. /**
  116348. * This class can be used to get instrumentation data from a Babylon engine
  116349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116350. */
  116351. export class SceneInstrumentation implements IDisposable {
  116352. /**
  116353. * Defines the scene to instrument
  116354. */
  116355. scene: Scene;
  116356. private _captureActiveMeshesEvaluationTime;
  116357. private _activeMeshesEvaluationTime;
  116358. private _captureRenderTargetsRenderTime;
  116359. private _renderTargetsRenderTime;
  116360. private _captureFrameTime;
  116361. private _frameTime;
  116362. private _captureRenderTime;
  116363. private _renderTime;
  116364. private _captureInterFrameTime;
  116365. private _interFrameTime;
  116366. private _captureParticlesRenderTime;
  116367. private _particlesRenderTime;
  116368. private _captureSpritesRenderTime;
  116369. private _spritesRenderTime;
  116370. private _capturePhysicsTime;
  116371. private _physicsTime;
  116372. private _captureAnimationsTime;
  116373. private _animationsTime;
  116374. private _captureCameraRenderTime;
  116375. private _cameraRenderTime;
  116376. private _onBeforeActiveMeshesEvaluationObserver;
  116377. private _onAfterActiveMeshesEvaluationObserver;
  116378. private _onBeforeRenderTargetsRenderObserver;
  116379. private _onAfterRenderTargetsRenderObserver;
  116380. private _onAfterRenderObserver;
  116381. private _onBeforeDrawPhaseObserver;
  116382. private _onAfterDrawPhaseObserver;
  116383. private _onBeforeAnimationsObserver;
  116384. private _onBeforeParticlesRenderingObserver;
  116385. private _onAfterParticlesRenderingObserver;
  116386. private _onBeforeSpritesRenderingObserver;
  116387. private _onAfterSpritesRenderingObserver;
  116388. private _onBeforePhysicsObserver;
  116389. private _onAfterPhysicsObserver;
  116390. private _onAfterAnimationsObserver;
  116391. private _onBeforeCameraRenderObserver;
  116392. private _onAfterCameraRenderObserver;
  116393. /**
  116394. * Gets the perf counter used for active meshes evaluation time
  116395. */
  116396. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116397. /**
  116398. * Gets the active meshes evaluation time capture status
  116399. */
  116400. /**
  116401. * Enable or disable the active meshes evaluation time capture
  116402. */
  116403. captureActiveMeshesEvaluationTime: boolean;
  116404. /**
  116405. * Gets the perf counter used for render targets render time
  116406. */
  116407. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116408. /**
  116409. * Gets the render targets render time capture status
  116410. */
  116411. /**
  116412. * Enable or disable the render targets render time capture
  116413. */
  116414. captureRenderTargetsRenderTime: boolean;
  116415. /**
  116416. * Gets the perf counter used for particles render time
  116417. */
  116418. readonly particlesRenderTimeCounter: PerfCounter;
  116419. /**
  116420. * Gets the particles render time capture status
  116421. */
  116422. /**
  116423. * Enable or disable the particles render time capture
  116424. */
  116425. captureParticlesRenderTime: boolean;
  116426. /**
  116427. * Gets the perf counter used for sprites render time
  116428. */
  116429. readonly spritesRenderTimeCounter: PerfCounter;
  116430. /**
  116431. * Gets the sprites render time capture status
  116432. */
  116433. /**
  116434. * Enable or disable the sprites render time capture
  116435. */
  116436. captureSpritesRenderTime: boolean;
  116437. /**
  116438. * Gets the perf counter used for physics time
  116439. */
  116440. readonly physicsTimeCounter: PerfCounter;
  116441. /**
  116442. * Gets the physics time capture status
  116443. */
  116444. /**
  116445. * Enable or disable the physics time capture
  116446. */
  116447. capturePhysicsTime: boolean;
  116448. /**
  116449. * Gets the perf counter used for animations time
  116450. */
  116451. readonly animationsTimeCounter: PerfCounter;
  116452. /**
  116453. * Gets the animations time capture status
  116454. */
  116455. /**
  116456. * Enable or disable the animations time capture
  116457. */
  116458. captureAnimationsTime: boolean;
  116459. /**
  116460. * Gets the perf counter used for frame time capture
  116461. */
  116462. readonly frameTimeCounter: PerfCounter;
  116463. /**
  116464. * Gets the frame time capture status
  116465. */
  116466. /**
  116467. * Enable or disable the frame time capture
  116468. */
  116469. captureFrameTime: boolean;
  116470. /**
  116471. * Gets the perf counter used for inter-frames time capture
  116472. */
  116473. readonly interFrameTimeCounter: PerfCounter;
  116474. /**
  116475. * Gets the inter-frames time capture status
  116476. */
  116477. /**
  116478. * Enable or disable the inter-frames time capture
  116479. */
  116480. captureInterFrameTime: boolean;
  116481. /**
  116482. * Gets the perf counter used for render time capture
  116483. */
  116484. readonly renderTimeCounter: PerfCounter;
  116485. /**
  116486. * Gets the render time capture status
  116487. */
  116488. /**
  116489. * Enable or disable the render time capture
  116490. */
  116491. captureRenderTime: boolean;
  116492. /**
  116493. * Gets the perf counter used for camera render time capture
  116494. */
  116495. readonly cameraRenderTimeCounter: PerfCounter;
  116496. /**
  116497. * Gets the camera render time capture status
  116498. */
  116499. /**
  116500. * Enable or disable the camera render time capture
  116501. */
  116502. captureCameraRenderTime: boolean;
  116503. /**
  116504. * Gets the perf counter used for draw calls
  116505. */
  116506. readonly drawCallsCounter: PerfCounter;
  116507. /**
  116508. * Instantiates a new scene instrumentation.
  116509. * This class can be used to get instrumentation data from a Babylon engine
  116510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116511. * @param scene Defines the scene to instrument
  116512. */
  116513. constructor(
  116514. /**
  116515. * Defines the scene to instrument
  116516. */
  116517. scene: Scene);
  116518. /**
  116519. * Dispose and release associated resources.
  116520. */
  116521. dispose(): void;
  116522. }
  116523. }
  116524. declare module BABYLON {
  116525. /** @hidden */
  116526. export var glowMapGenerationPixelShader: {
  116527. name: string;
  116528. shader: string;
  116529. };
  116530. }
  116531. declare module BABYLON {
  116532. /** @hidden */
  116533. export var glowMapGenerationVertexShader: {
  116534. name: string;
  116535. shader: string;
  116536. };
  116537. }
  116538. declare module BABYLON {
  116539. /**
  116540. * Effect layer options. This helps customizing the behaviour
  116541. * of the effect layer.
  116542. */
  116543. export interface IEffectLayerOptions {
  116544. /**
  116545. * Multiplication factor apply to the canvas size to compute the render target size
  116546. * used to generated the objects (the smaller the faster).
  116547. */
  116548. mainTextureRatio: number;
  116549. /**
  116550. * Enforces a fixed size texture to ensure effect stability across devices.
  116551. */
  116552. mainTextureFixedSize?: number;
  116553. /**
  116554. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116555. */
  116556. alphaBlendingMode: number;
  116557. /**
  116558. * The camera attached to the layer.
  116559. */
  116560. camera: Nullable<Camera>;
  116561. /**
  116562. * The rendering group to draw the layer in.
  116563. */
  116564. renderingGroupId: number;
  116565. }
  116566. /**
  116567. * The effect layer Helps adding post process effect blended with the main pass.
  116568. *
  116569. * This can be for instance use to generate glow or higlight effects on the scene.
  116570. *
  116571. * The effect layer class can not be used directly and is intented to inherited from to be
  116572. * customized per effects.
  116573. */
  116574. export abstract class EffectLayer {
  116575. private _vertexBuffers;
  116576. private _indexBuffer;
  116577. private _cachedDefines;
  116578. private _effectLayerMapGenerationEffect;
  116579. private _effectLayerOptions;
  116580. private _mergeEffect;
  116581. protected _scene: Scene;
  116582. protected _engine: Engine;
  116583. protected _maxSize: number;
  116584. protected _mainTextureDesiredSize: ISize;
  116585. protected _mainTexture: RenderTargetTexture;
  116586. protected _shouldRender: boolean;
  116587. protected _postProcesses: PostProcess[];
  116588. protected _textures: BaseTexture[];
  116589. protected _emissiveTextureAndColor: {
  116590. texture: Nullable<BaseTexture>;
  116591. color: Color4;
  116592. };
  116593. /**
  116594. * The name of the layer
  116595. */
  116596. name: string;
  116597. /**
  116598. * The clear color of the texture used to generate the glow map.
  116599. */
  116600. neutralColor: Color4;
  116601. /**
  116602. * Specifies wether the highlight layer is enabled or not.
  116603. */
  116604. isEnabled: boolean;
  116605. /**
  116606. * Gets the camera attached to the layer.
  116607. */
  116608. readonly camera: Nullable<Camera>;
  116609. /**
  116610. * Gets the rendering group id the layer should render in.
  116611. */
  116612. renderingGroupId: number;
  116613. /**
  116614. * An event triggered when the effect layer has been disposed.
  116615. */
  116616. onDisposeObservable: Observable<EffectLayer>;
  116617. /**
  116618. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116619. */
  116620. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116621. /**
  116622. * An event triggered when the generated texture is being merged in the scene.
  116623. */
  116624. onBeforeComposeObservable: Observable<EffectLayer>;
  116625. /**
  116626. * An event triggered when the generated texture has been merged in the scene.
  116627. */
  116628. onAfterComposeObservable: Observable<EffectLayer>;
  116629. /**
  116630. * An event triggered when the efffect layer changes its size.
  116631. */
  116632. onSizeChangedObservable: Observable<EffectLayer>;
  116633. /** @hidden */
  116634. static _SceneComponentInitialization: (scene: Scene) => void;
  116635. /**
  116636. * Instantiates a new effect Layer and references it in the scene.
  116637. * @param name The name of the layer
  116638. * @param scene The scene to use the layer in
  116639. */
  116640. constructor(
  116641. /** The Friendly of the effect in the scene */
  116642. name: string, scene: Scene);
  116643. /**
  116644. * Get the effect name of the layer.
  116645. * @return The effect name
  116646. */
  116647. abstract getEffectName(): string;
  116648. /**
  116649. * Checks for the readiness of the element composing the layer.
  116650. * @param subMesh the mesh to check for
  116651. * @param useInstances specify wether or not to use instances to render the mesh
  116652. * @return true if ready otherwise, false
  116653. */
  116654. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116655. /**
  116656. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116657. * @returns true if the effect requires stencil during the main canvas render pass.
  116658. */
  116659. abstract needStencil(): boolean;
  116660. /**
  116661. * Create the merge effect. This is the shader use to blit the information back
  116662. * to the main canvas at the end of the scene rendering.
  116663. * @returns The effect containing the shader used to merge the effect on the main canvas
  116664. */
  116665. protected abstract _createMergeEffect(): Effect;
  116666. /**
  116667. * Creates the render target textures and post processes used in the effect layer.
  116668. */
  116669. protected abstract _createTextureAndPostProcesses(): void;
  116670. /**
  116671. * Implementation specific of rendering the generating effect on the main canvas.
  116672. * @param effect The effect used to render through
  116673. */
  116674. protected abstract _internalRender(effect: Effect): void;
  116675. /**
  116676. * Sets the required values for both the emissive texture and and the main color.
  116677. */
  116678. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116679. /**
  116680. * Free any resources and references associated to a mesh.
  116681. * Internal use
  116682. * @param mesh The mesh to free.
  116683. */
  116684. abstract _disposeMesh(mesh: Mesh): void;
  116685. /**
  116686. * Serializes this layer (Glow or Highlight for example)
  116687. * @returns a serialized layer object
  116688. */
  116689. abstract serialize?(): any;
  116690. /**
  116691. * Initializes the effect layer with the required options.
  116692. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116693. */
  116694. protected _init(options: Partial<IEffectLayerOptions>): void;
  116695. /**
  116696. * Generates the index buffer of the full screen quad blending to the main canvas.
  116697. */
  116698. private _generateIndexBuffer;
  116699. /**
  116700. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116701. */
  116702. private _generateVertexBuffer;
  116703. /**
  116704. * Sets the main texture desired size which is the closest power of two
  116705. * of the engine canvas size.
  116706. */
  116707. private _setMainTextureSize;
  116708. /**
  116709. * Creates the main texture for the effect layer.
  116710. */
  116711. protected _createMainTexture(): void;
  116712. /**
  116713. * Adds specific effects defines.
  116714. * @param defines The defines to add specifics to.
  116715. */
  116716. protected _addCustomEffectDefines(defines: string[]): void;
  116717. /**
  116718. * Checks for the readiness of the element composing the layer.
  116719. * @param subMesh the mesh to check for
  116720. * @param useInstances specify wether or not to use instances to render the mesh
  116721. * @param emissiveTexture the associated emissive texture used to generate the glow
  116722. * @return true if ready otherwise, false
  116723. */
  116724. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116725. /**
  116726. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116727. */
  116728. render(): void;
  116729. /**
  116730. * Determine if a given mesh will be used in the current effect.
  116731. * @param mesh mesh to test
  116732. * @returns true if the mesh will be used
  116733. */
  116734. hasMesh(mesh: AbstractMesh): boolean;
  116735. /**
  116736. * Returns true if the layer contains information to display, otherwise false.
  116737. * @returns true if the glow layer should be rendered
  116738. */
  116739. shouldRender(): boolean;
  116740. /**
  116741. * Returns true if the mesh should render, otherwise false.
  116742. * @param mesh The mesh to render
  116743. * @returns true if it should render otherwise false
  116744. */
  116745. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116746. /**
  116747. * Returns true if the mesh can be rendered, otherwise false.
  116748. * @param mesh The mesh to render
  116749. * @param material The material used on the mesh
  116750. * @returns true if it can be rendered otherwise false
  116751. */
  116752. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116753. /**
  116754. * Returns true if the mesh should render, otherwise false.
  116755. * @param mesh The mesh to render
  116756. * @returns true if it should render otherwise false
  116757. */
  116758. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116759. /**
  116760. * Renders the submesh passed in parameter to the generation map.
  116761. */
  116762. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116763. /**
  116764. * Rebuild the required buffers.
  116765. * @hidden Internal use only.
  116766. */
  116767. _rebuild(): void;
  116768. /**
  116769. * Dispose only the render target textures and post process.
  116770. */
  116771. private _disposeTextureAndPostProcesses;
  116772. /**
  116773. * Dispose the highlight layer and free resources.
  116774. */
  116775. dispose(): void;
  116776. /**
  116777. * Gets the class name of the effect layer
  116778. * @returns the string with the class name of the effect layer
  116779. */
  116780. getClassName(): string;
  116781. /**
  116782. * Creates an effect layer from parsed effect layer data
  116783. * @param parsedEffectLayer defines effect layer data
  116784. * @param scene defines the current scene
  116785. * @param rootUrl defines the root URL containing the effect layer information
  116786. * @returns a parsed effect Layer
  116787. */
  116788. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116789. }
  116790. }
  116791. declare module BABYLON {
  116792. interface AbstractScene {
  116793. /**
  116794. * The list of effect layers (highlights/glow) added to the scene
  116795. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116796. * @see http://doc.babylonjs.com/how_to/glow_layer
  116797. */
  116798. effectLayers: Array<EffectLayer>;
  116799. /**
  116800. * Removes the given effect layer from this scene.
  116801. * @param toRemove defines the effect layer to remove
  116802. * @returns the index of the removed effect layer
  116803. */
  116804. removeEffectLayer(toRemove: EffectLayer): number;
  116805. /**
  116806. * Adds the given effect layer to this scene
  116807. * @param newEffectLayer defines the effect layer to add
  116808. */
  116809. addEffectLayer(newEffectLayer: EffectLayer): void;
  116810. }
  116811. /**
  116812. * Defines the layer scene component responsible to manage any effect layers
  116813. * in a given scene.
  116814. */
  116815. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116816. /**
  116817. * The component name helpfull to identify the component in the list of scene components.
  116818. */
  116819. readonly name: string;
  116820. /**
  116821. * The scene the component belongs to.
  116822. */
  116823. scene: Scene;
  116824. private _engine;
  116825. private _renderEffects;
  116826. private _needStencil;
  116827. private _previousStencilState;
  116828. /**
  116829. * Creates a new instance of the component for the given scene
  116830. * @param scene Defines the scene to register the component in
  116831. */
  116832. constructor(scene: Scene);
  116833. /**
  116834. * Registers the component in a given scene
  116835. */
  116836. register(): void;
  116837. /**
  116838. * Rebuilds the elements related to this component in case of
  116839. * context lost for instance.
  116840. */
  116841. rebuild(): void;
  116842. /**
  116843. * Serializes the component data to the specified json object
  116844. * @param serializationObject The object to serialize to
  116845. */
  116846. serialize(serializationObject: any): void;
  116847. /**
  116848. * Adds all the elements from the container to the scene
  116849. * @param container the container holding the elements
  116850. */
  116851. addFromContainer(container: AbstractScene): void;
  116852. /**
  116853. * Removes all the elements in the container from the scene
  116854. * @param container contains the elements to remove
  116855. * @param dispose if the removed element should be disposed (default: false)
  116856. */
  116857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116858. /**
  116859. * Disposes the component and the associated ressources.
  116860. */
  116861. dispose(): void;
  116862. private _isReadyForMesh;
  116863. private _renderMainTexture;
  116864. private _setStencil;
  116865. private _setStencilBack;
  116866. private _draw;
  116867. private _drawCamera;
  116868. private _drawRenderingGroup;
  116869. }
  116870. }
  116871. declare module BABYLON {
  116872. /** @hidden */
  116873. export var glowMapMergePixelShader: {
  116874. name: string;
  116875. shader: string;
  116876. };
  116877. }
  116878. declare module BABYLON {
  116879. /** @hidden */
  116880. export var glowMapMergeVertexShader: {
  116881. name: string;
  116882. shader: string;
  116883. };
  116884. }
  116885. declare module BABYLON {
  116886. interface AbstractScene {
  116887. /**
  116888. * Return a the first highlight layer of the scene with a given name.
  116889. * @param name The name of the highlight layer to look for.
  116890. * @return The highlight layer if found otherwise null.
  116891. */
  116892. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116893. }
  116894. /**
  116895. * Glow layer options. This helps customizing the behaviour
  116896. * of the glow layer.
  116897. */
  116898. export interface IGlowLayerOptions {
  116899. /**
  116900. * Multiplication factor apply to the canvas size to compute the render target size
  116901. * used to generated the glowing objects (the smaller the faster).
  116902. */
  116903. mainTextureRatio: number;
  116904. /**
  116905. * Enforces a fixed size texture to ensure resize independant blur.
  116906. */
  116907. mainTextureFixedSize?: number;
  116908. /**
  116909. * How big is the kernel of the blur texture.
  116910. */
  116911. blurKernelSize: number;
  116912. /**
  116913. * The camera attached to the layer.
  116914. */
  116915. camera: Nullable<Camera>;
  116916. /**
  116917. * Enable MSAA by chosing the number of samples.
  116918. */
  116919. mainTextureSamples?: number;
  116920. /**
  116921. * The rendering group to draw the layer in.
  116922. */
  116923. renderingGroupId: number;
  116924. }
  116925. /**
  116926. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116927. *
  116928. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116929. * glowy meshes to your scene.
  116930. *
  116931. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116932. */
  116933. export class GlowLayer extends EffectLayer {
  116934. /**
  116935. * Effect Name of the layer.
  116936. */
  116937. static readonly EffectName: string;
  116938. /**
  116939. * The default blur kernel size used for the glow.
  116940. */
  116941. static DefaultBlurKernelSize: number;
  116942. /**
  116943. * The default texture size ratio used for the glow.
  116944. */
  116945. static DefaultTextureRatio: number;
  116946. /**
  116947. * Sets the kernel size of the blur.
  116948. */
  116949. /**
  116950. * Gets the kernel size of the blur.
  116951. */
  116952. blurKernelSize: number;
  116953. /**
  116954. * Sets the glow intensity.
  116955. */
  116956. /**
  116957. * Gets the glow intensity.
  116958. */
  116959. intensity: number;
  116960. private _options;
  116961. private _intensity;
  116962. private _horizontalBlurPostprocess1;
  116963. private _verticalBlurPostprocess1;
  116964. private _horizontalBlurPostprocess2;
  116965. private _verticalBlurPostprocess2;
  116966. private _blurTexture1;
  116967. private _blurTexture2;
  116968. private _postProcesses1;
  116969. private _postProcesses2;
  116970. private _includedOnlyMeshes;
  116971. private _excludedMeshes;
  116972. /**
  116973. * Callback used to let the user override the color selection on a per mesh basis
  116974. */
  116975. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116976. /**
  116977. * Callback used to let the user override the texture selection on a per mesh basis
  116978. */
  116979. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116980. /**
  116981. * Instantiates a new glow Layer and references it to the scene.
  116982. * @param name The name of the layer
  116983. * @param scene The scene to use the layer in
  116984. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116985. */
  116986. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116987. /**
  116988. * Get the effect name of the layer.
  116989. * @return The effect name
  116990. */
  116991. getEffectName(): string;
  116992. /**
  116993. * Create the merge effect. This is the shader use to blit the information back
  116994. * to the main canvas at the end of the scene rendering.
  116995. */
  116996. protected _createMergeEffect(): Effect;
  116997. /**
  116998. * Creates the render target textures and post processes used in the glow layer.
  116999. */
  117000. protected _createTextureAndPostProcesses(): void;
  117001. /**
  117002. * Checks for the readiness of the element composing the layer.
  117003. * @param subMesh the mesh to check for
  117004. * @param useInstances specify wether or not to use instances to render the mesh
  117005. * @param emissiveTexture the associated emissive texture used to generate the glow
  117006. * @return true if ready otherwise, false
  117007. */
  117008. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117009. /**
  117010. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117011. */
  117012. needStencil(): boolean;
  117013. /**
  117014. * Returns true if the mesh can be rendered, otherwise false.
  117015. * @param mesh The mesh to render
  117016. * @param material The material used on the mesh
  117017. * @returns true if it can be rendered otherwise false
  117018. */
  117019. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117020. /**
  117021. * Implementation specific of rendering the generating effect on the main canvas.
  117022. * @param effect The effect used to render through
  117023. */
  117024. protected _internalRender(effect: Effect): void;
  117025. /**
  117026. * Sets the required values for both the emissive texture and and the main color.
  117027. */
  117028. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117029. /**
  117030. * Returns true if the mesh should render, otherwise false.
  117031. * @param mesh The mesh to render
  117032. * @returns true if it should render otherwise false
  117033. */
  117034. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117035. /**
  117036. * Adds specific effects defines.
  117037. * @param defines The defines to add specifics to.
  117038. */
  117039. protected _addCustomEffectDefines(defines: string[]): void;
  117040. /**
  117041. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117042. * @param mesh The mesh to exclude from the glow layer
  117043. */
  117044. addExcludedMesh(mesh: Mesh): void;
  117045. /**
  117046. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117047. * @param mesh The mesh to remove
  117048. */
  117049. removeExcludedMesh(mesh: Mesh): void;
  117050. /**
  117051. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117052. * @param mesh The mesh to include in the glow layer
  117053. */
  117054. addIncludedOnlyMesh(mesh: Mesh): void;
  117055. /**
  117056. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117057. * @param mesh The mesh to remove
  117058. */
  117059. removeIncludedOnlyMesh(mesh: Mesh): void;
  117060. /**
  117061. * Determine if a given mesh will be used in the glow layer
  117062. * @param mesh The mesh to test
  117063. * @returns true if the mesh will be highlighted by the current glow layer
  117064. */
  117065. hasMesh(mesh: AbstractMesh): boolean;
  117066. /**
  117067. * Free any resources and references associated to a mesh.
  117068. * Internal use
  117069. * @param mesh The mesh to free.
  117070. * @hidden
  117071. */
  117072. _disposeMesh(mesh: Mesh): void;
  117073. /**
  117074. * Gets the class name of the effect layer
  117075. * @returns the string with the class name of the effect layer
  117076. */
  117077. getClassName(): string;
  117078. /**
  117079. * Serializes this glow layer
  117080. * @returns a serialized glow layer object
  117081. */
  117082. serialize(): any;
  117083. /**
  117084. * Creates a Glow Layer from parsed glow layer data
  117085. * @param parsedGlowLayer defines glow layer data
  117086. * @param scene defines the current scene
  117087. * @param rootUrl defines the root URL containing the glow layer information
  117088. * @returns a parsed Glow Layer
  117089. */
  117090. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117091. }
  117092. }
  117093. declare module BABYLON {
  117094. /** @hidden */
  117095. export var glowBlurPostProcessPixelShader: {
  117096. name: string;
  117097. shader: string;
  117098. };
  117099. }
  117100. declare module BABYLON {
  117101. interface AbstractScene {
  117102. /**
  117103. * Return a the first highlight layer of the scene with a given name.
  117104. * @param name The name of the highlight layer to look for.
  117105. * @return The highlight layer if found otherwise null.
  117106. */
  117107. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117108. }
  117109. /**
  117110. * Highlight layer options. This helps customizing the behaviour
  117111. * of the highlight layer.
  117112. */
  117113. export interface IHighlightLayerOptions {
  117114. /**
  117115. * Multiplication factor apply to the canvas size to compute the render target size
  117116. * used to generated the glowing objects (the smaller the faster).
  117117. */
  117118. mainTextureRatio: number;
  117119. /**
  117120. * Enforces a fixed size texture to ensure resize independant blur.
  117121. */
  117122. mainTextureFixedSize?: number;
  117123. /**
  117124. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117125. * of the picture to blur (the smaller the faster).
  117126. */
  117127. blurTextureSizeRatio: number;
  117128. /**
  117129. * How big in texel of the blur texture is the vertical blur.
  117130. */
  117131. blurVerticalSize: number;
  117132. /**
  117133. * How big in texel of the blur texture is the horizontal blur.
  117134. */
  117135. blurHorizontalSize: number;
  117136. /**
  117137. * Alpha blending mode used to apply the blur. Default is combine.
  117138. */
  117139. alphaBlendingMode: number;
  117140. /**
  117141. * The camera attached to the layer.
  117142. */
  117143. camera: Nullable<Camera>;
  117144. /**
  117145. * Should we display highlight as a solid stroke?
  117146. */
  117147. isStroke?: boolean;
  117148. /**
  117149. * The rendering group to draw the layer in.
  117150. */
  117151. renderingGroupId: number;
  117152. }
  117153. /**
  117154. * The highlight layer Helps adding a glow effect around a mesh.
  117155. *
  117156. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  117157. * glowy meshes to your scene.
  117158. *
  117159. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117160. */
  117161. export class HighlightLayer extends EffectLayer {
  117162. name: string;
  117163. /**
  117164. * Effect Name of the highlight layer.
  117165. */
  117166. static readonly EffectName: string;
  117167. /**
  117168. * The neutral color used during the preparation of the glow effect.
  117169. * This is black by default as the blend operation is a blend operation.
  117170. */
  117171. static NeutralColor: Color4;
  117172. /**
  117173. * Stencil value used for glowing meshes.
  117174. */
  117175. static GlowingMeshStencilReference: number;
  117176. /**
  117177. * Stencil value used for the other meshes in the scene.
  117178. */
  117179. static NormalMeshStencilReference: number;
  117180. /**
  117181. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117182. */
  117183. innerGlow: boolean;
  117184. /**
  117185. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117186. */
  117187. outerGlow: boolean;
  117188. /**
  117189. * Specifies the horizontal size of the blur.
  117190. */
  117191. /**
  117192. * Gets the horizontal size of the blur.
  117193. */
  117194. blurHorizontalSize: number;
  117195. /**
  117196. * Specifies the vertical size of the blur.
  117197. */
  117198. /**
  117199. * Gets the vertical size of the blur.
  117200. */
  117201. blurVerticalSize: number;
  117202. /**
  117203. * An event triggered when the highlight layer is being blurred.
  117204. */
  117205. onBeforeBlurObservable: Observable<HighlightLayer>;
  117206. /**
  117207. * An event triggered when the highlight layer has been blurred.
  117208. */
  117209. onAfterBlurObservable: Observable<HighlightLayer>;
  117210. private _instanceGlowingMeshStencilReference;
  117211. private _options;
  117212. private _downSamplePostprocess;
  117213. private _horizontalBlurPostprocess;
  117214. private _verticalBlurPostprocess;
  117215. private _blurTexture;
  117216. private _meshes;
  117217. private _excludedMeshes;
  117218. /**
  117219. * Instantiates a new highlight Layer and references it to the scene..
  117220. * @param name The name of the layer
  117221. * @param scene The scene to use the layer in
  117222. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117223. */
  117224. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117225. /**
  117226. * Get the effect name of the layer.
  117227. * @return The effect name
  117228. */
  117229. getEffectName(): string;
  117230. /**
  117231. * Create the merge effect. This is the shader use to blit the information back
  117232. * to the main canvas at the end of the scene rendering.
  117233. */
  117234. protected _createMergeEffect(): Effect;
  117235. /**
  117236. * Creates the render target textures and post processes used in the highlight layer.
  117237. */
  117238. protected _createTextureAndPostProcesses(): void;
  117239. /**
  117240. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117241. */
  117242. needStencil(): boolean;
  117243. /**
  117244. * Checks for the readiness of the element composing the layer.
  117245. * @param subMesh the mesh to check for
  117246. * @param useInstances specify wether or not to use instances to render the mesh
  117247. * @param emissiveTexture the associated emissive texture used to generate the glow
  117248. * @return true if ready otherwise, false
  117249. */
  117250. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117251. /**
  117252. * Implementation specific of rendering the generating effect on the main canvas.
  117253. * @param effect The effect used to render through
  117254. */
  117255. protected _internalRender(effect: Effect): void;
  117256. /**
  117257. * Returns true if the layer contains information to display, otherwise false.
  117258. */
  117259. shouldRender(): boolean;
  117260. /**
  117261. * Returns true if the mesh should render, otherwise false.
  117262. * @param mesh The mesh to render
  117263. * @returns true if it should render otherwise false
  117264. */
  117265. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117266. /**
  117267. * Sets the required values for both the emissive texture and and the main color.
  117268. */
  117269. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117270. /**
  117271. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117272. * @param mesh The mesh to exclude from the highlight layer
  117273. */
  117274. addExcludedMesh(mesh: Mesh): void;
  117275. /**
  117276. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117277. * @param mesh The mesh to highlight
  117278. */
  117279. removeExcludedMesh(mesh: Mesh): void;
  117280. /**
  117281. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117282. * @param mesh mesh to test
  117283. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117284. */
  117285. hasMesh(mesh: AbstractMesh): boolean;
  117286. /**
  117287. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117288. * @param mesh The mesh to highlight
  117289. * @param color The color of the highlight
  117290. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117291. */
  117292. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117293. /**
  117294. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117295. * @param mesh The mesh to highlight
  117296. */
  117297. removeMesh(mesh: Mesh): void;
  117298. /**
  117299. * Force the stencil to the normal expected value for none glowing parts
  117300. */
  117301. private _defaultStencilReference;
  117302. /**
  117303. * Free any resources and references associated to a mesh.
  117304. * Internal use
  117305. * @param mesh The mesh to free.
  117306. * @hidden
  117307. */
  117308. _disposeMesh(mesh: Mesh): void;
  117309. /**
  117310. * Dispose the highlight layer and free resources.
  117311. */
  117312. dispose(): void;
  117313. /**
  117314. * Gets the class name of the effect layer
  117315. * @returns the string with the class name of the effect layer
  117316. */
  117317. getClassName(): string;
  117318. /**
  117319. * Serializes this Highlight layer
  117320. * @returns a serialized Highlight layer object
  117321. */
  117322. serialize(): any;
  117323. /**
  117324. * Creates a Highlight layer from parsed Highlight layer data
  117325. * @param parsedHightlightLayer defines the Highlight layer data
  117326. * @param scene defines the current scene
  117327. * @param rootUrl defines the root URL containing the Highlight layer information
  117328. * @returns a parsed Highlight layer
  117329. */
  117330. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117331. }
  117332. }
  117333. declare module BABYLON {
  117334. interface AbstractScene {
  117335. /**
  117336. * The list of layers (background and foreground) of the scene
  117337. */
  117338. layers: Array<Layer>;
  117339. }
  117340. /**
  117341. * Defines the layer scene component responsible to manage any layers
  117342. * in a given scene.
  117343. */
  117344. export class LayerSceneComponent implements ISceneComponent {
  117345. /**
  117346. * The component name helpfull to identify the component in the list of scene components.
  117347. */
  117348. readonly name: string;
  117349. /**
  117350. * The scene the component belongs to.
  117351. */
  117352. scene: Scene;
  117353. private _engine;
  117354. /**
  117355. * Creates a new instance of the component for the given scene
  117356. * @param scene Defines the scene to register the component in
  117357. */
  117358. constructor(scene: Scene);
  117359. /**
  117360. * Registers the component in a given scene
  117361. */
  117362. register(): void;
  117363. /**
  117364. * Rebuilds the elements related to this component in case of
  117365. * context lost for instance.
  117366. */
  117367. rebuild(): void;
  117368. /**
  117369. * Disposes the component and the associated ressources.
  117370. */
  117371. dispose(): void;
  117372. private _draw;
  117373. private _drawCameraPredicate;
  117374. private _drawCameraBackground;
  117375. private _drawCameraForeground;
  117376. private _drawRenderTargetPredicate;
  117377. private _drawRenderTargetBackground;
  117378. private _drawRenderTargetForeground;
  117379. /**
  117380. * Adds all the elements from the container to the scene
  117381. * @param container the container holding the elements
  117382. */
  117383. addFromContainer(container: AbstractScene): void;
  117384. /**
  117385. * Removes all the elements in the container from the scene
  117386. * @param container contains the elements to remove
  117387. * @param dispose if the removed element should be disposed (default: false)
  117388. */
  117389. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117390. }
  117391. }
  117392. declare module BABYLON {
  117393. /** @hidden */
  117394. export var layerPixelShader: {
  117395. name: string;
  117396. shader: string;
  117397. };
  117398. }
  117399. declare module BABYLON {
  117400. /** @hidden */
  117401. export var layerVertexShader: {
  117402. name: string;
  117403. shader: string;
  117404. };
  117405. }
  117406. declare module BABYLON {
  117407. /**
  117408. * This represents a full screen 2d layer.
  117409. * This can be useful to display a picture in the background of your scene for instance.
  117410. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117411. */
  117412. export class Layer {
  117413. /**
  117414. * Define the name of the layer.
  117415. */
  117416. name: string;
  117417. /**
  117418. * Define the texture the layer should display.
  117419. */
  117420. texture: Nullable<Texture>;
  117421. /**
  117422. * Is the layer in background or foreground.
  117423. */
  117424. isBackground: boolean;
  117425. /**
  117426. * Define the color of the layer (instead of texture).
  117427. */
  117428. color: Color4;
  117429. /**
  117430. * Define the scale of the layer in order to zoom in out of the texture.
  117431. */
  117432. scale: Vector2;
  117433. /**
  117434. * Define an offset for the layer in order to shift the texture.
  117435. */
  117436. offset: Vector2;
  117437. /**
  117438. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117439. */
  117440. alphaBlendingMode: number;
  117441. /**
  117442. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117443. * Alpha test will not mix with the background color in case of transparency.
  117444. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117445. */
  117446. alphaTest: boolean;
  117447. /**
  117448. * Define a mask to restrict the layer to only some of the scene cameras.
  117449. */
  117450. layerMask: number;
  117451. /**
  117452. * Define the list of render target the layer is visible into.
  117453. */
  117454. renderTargetTextures: RenderTargetTexture[];
  117455. /**
  117456. * Define if the layer is only used in renderTarget or if it also
  117457. * renders in the main frame buffer of the canvas.
  117458. */
  117459. renderOnlyInRenderTargetTextures: boolean;
  117460. private _scene;
  117461. private _vertexBuffers;
  117462. private _indexBuffer;
  117463. private _effect;
  117464. private _alphaTestEffect;
  117465. /**
  117466. * An event triggered when the layer is disposed.
  117467. */
  117468. onDisposeObservable: Observable<Layer>;
  117469. private _onDisposeObserver;
  117470. /**
  117471. * Back compatibility with callback before the onDisposeObservable existed.
  117472. * The set callback will be triggered when the layer has been disposed.
  117473. */
  117474. onDispose: () => void;
  117475. /**
  117476. * An event triggered before rendering the scene
  117477. */
  117478. onBeforeRenderObservable: Observable<Layer>;
  117479. private _onBeforeRenderObserver;
  117480. /**
  117481. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117482. * The set callback will be triggered just before rendering the layer.
  117483. */
  117484. onBeforeRender: () => void;
  117485. /**
  117486. * An event triggered after rendering the scene
  117487. */
  117488. onAfterRenderObservable: Observable<Layer>;
  117489. private _onAfterRenderObserver;
  117490. /**
  117491. * Back compatibility with callback before the onAfterRenderObservable existed.
  117492. * The set callback will be triggered just after rendering the layer.
  117493. */
  117494. onAfterRender: () => void;
  117495. /**
  117496. * Instantiates a new layer.
  117497. * This represents a full screen 2d layer.
  117498. * This can be useful to display a picture in the background of your scene for instance.
  117499. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117500. * @param name Define the name of the layer in the scene
  117501. * @param imgUrl Define the url of the texture to display in the layer
  117502. * @param scene Define the scene the layer belongs to
  117503. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117504. * @param color Defines a color for the layer
  117505. */
  117506. constructor(
  117507. /**
  117508. * Define the name of the layer.
  117509. */
  117510. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117511. private _createIndexBuffer;
  117512. /** @hidden */
  117513. _rebuild(): void;
  117514. /**
  117515. * Renders the layer in the scene.
  117516. */
  117517. render(): void;
  117518. /**
  117519. * Disposes and releases the associated ressources.
  117520. */
  117521. dispose(): void;
  117522. }
  117523. }
  117524. declare module BABYLON {
  117525. /** @hidden */
  117526. export var lensFlarePixelShader: {
  117527. name: string;
  117528. shader: string;
  117529. };
  117530. }
  117531. declare module BABYLON {
  117532. /** @hidden */
  117533. export var lensFlareVertexShader: {
  117534. name: string;
  117535. shader: string;
  117536. };
  117537. }
  117538. declare module BABYLON {
  117539. /**
  117540. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117541. * It is usually composed of several `lensFlare`.
  117542. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117543. */
  117544. export class LensFlareSystem {
  117545. /**
  117546. * Define the name of the lens flare system
  117547. */
  117548. name: string;
  117549. /**
  117550. * List of lens flares used in this system.
  117551. */
  117552. lensFlares: LensFlare[];
  117553. /**
  117554. * Define a limit from the border the lens flare can be visible.
  117555. */
  117556. borderLimit: number;
  117557. /**
  117558. * Define a viewport border we do not want to see the lens flare in.
  117559. */
  117560. viewportBorder: number;
  117561. /**
  117562. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117563. */
  117564. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117565. /**
  117566. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117567. */
  117568. layerMask: number;
  117569. /**
  117570. * Define the id of the lens flare system in the scene.
  117571. * (equal to name by default)
  117572. */
  117573. id: string;
  117574. private _scene;
  117575. private _emitter;
  117576. private _vertexBuffers;
  117577. private _indexBuffer;
  117578. private _effect;
  117579. private _positionX;
  117580. private _positionY;
  117581. private _isEnabled;
  117582. /** @hidden */
  117583. static _SceneComponentInitialization: (scene: Scene) => void;
  117584. /**
  117585. * Instantiates a lens flare system.
  117586. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117587. * It is usually composed of several `lensFlare`.
  117588. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117589. * @param name Define the name of the lens flare system in the scene
  117590. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117591. * @param scene Define the scene the lens flare system belongs to
  117592. */
  117593. constructor(
  117594. /**
  117595. * Define the name of the lens flare system
  117596. */
  117597. name: string, emitter: any, scene: Scene);
  117598. /**
  117599. * Define if the lens flare system is enabled.
  117600. */
  117601. isEnabled: boolean;
  117602. /**
  117603. * Get the scene the effects belongs to.
  117604. * @returns the scene holding the lens flare system
  117605. */
  117606. getScene(): Scene;
  117607. /**
  117608. * Get the emitter of the lens flare system.
  117609. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117610. * @returns the emitter of the lens flare system
  117611. */
  117612. getEmitter(): any;
  117613. /**
  117614. * Set the emitter of the lens flare system.
  117615. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117616. * @param newEmitter Define the new emitter of the system
  117617. */
  117618. setEmitter(newEmitter: any): void;
  117619. /**
  117620. * Get the lens flare system emitter position.
  117621. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117622. * @returns the position
  117623. */
  117624. getEmitterPosition(): Vector3;
  117625. /**
  117626. * @hidden
  117627. */
  117628. computeEffectivePosition(globalViewport: Viewport): boolean;
  117629. /** @hidden */
  117630. _isVisible(): boolean;
  117631. /**
  117632. * @hidden
  117633. */
  117634. render(): boolean;
  117635. /**
  117636. * Dispose and release the lens flare with its associated resources.
  117637. */
  117638. dispose(): void;
  117639. /**
  117640. * Parse a lens flare system from a JSON repressentation
  117641. * @param parsedLensFlareSystem Define the JSON to parse
  117642. * @param scene Define the scene the parsed system should be instantiated in
  117643. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117644. * @returns the parsed system
  117645. */
  117646. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117647. /**
  117648. * Serialize the current Lens Flare System into a JSON representation.
  117649. * @returns the serialized JSON
  117650. */
  117651. serialize(): any;
  117652. }
  117653. }
  117654. declare module BABYLON {
  117655. /**
  117656. * This represents one of the lens effect in a `lensFlareSystem`.
  117657. * It controls one of the indiviual texture used in the effect.
  117658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117659. */
  117660. export class LensFlare {
  117661. /**
  117662. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117663. */
  117664. size: number;
  117665. /**
  117666. * 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.
  117667. */
  117668. position: number;
  117669. /**
  117670. * Define the lens color.
  117671. */
  117672. color: Color3;
  117673. /**
  117674. * Define the lens texture.
  117675. */
  117676. texture: Nullable<Texture>;
  117677. /**
  117678. * Define the alpha mode to render this particular lens.
  117679. */
  117680. alphaMode: number;
  117681. private _system;
  117682. /**
  117683. * Creates a new Lens Flare.
  117684. * This represents one of the lens effect in a `lensFlareSystem`.
  117685. * It controls one of the indiviual texture used in the effect.
  117686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117687. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117688. * @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.
  117689. * @param color Define the lens color
  117690. * @param imgUrl Define the lens texture url
  117691. * @param system Define the `lensFlareSystem` this flare is part of
  117692. * @returns The newly created Lens Flare
  117693. */
  117694. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117695. /**
  117696. * Instantiates a new Lens Flare.
  117697. * This represents one of the lens effect in a `lensFlareSystem`.
  117698. * It controls one of the indiviual texture used in the effect.
  117699. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117700. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117701. * @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.
  117702. * @param color Define the lens color
  117703. * @param imgUrl Define the lens texture url
  117704. * @param system Define the `lensFlareSystem` this flare is part of
  117705. */
  117706. constructor(
  117707. /**
  117708. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117709. */
  117710. size: number,
  117711. /**
  117712. * 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.
  117713. */
  117714. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117715. /**
  117716. * Dispose and release the lens flare with its associated resources.
  117717. */
  117718. dispose(): void;
  117719. }
  117720. }
  117721. declare module BABYLON {
  117722. interface AbstractScene {
  117723. /**
  117724. * The list of lens flare system added to the scene
  117725. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117726. */
  117727. lensFlareSystems: Array<LensFlareSystem>;
  117728. /**
  117729. * Removes the given lens flare system from this scene.
  117730. * @param toRemove The lens flare system to remove
  117731. * @returns The index of the removed lens flare system
  117732. */
  117733. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117734. /**
  117735. * Adds the given lens flare system to this scene
  117736. * @param newLensFlareSystem The lens flare system to add
  117737. */
  117738. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117739. /**
  117740. * Gets a lens flare system using its name
  117741. * @param name defines the name to look for
  117742. * @returns the lens flare system or null if not found
  117743. */
  117744. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117745. /**
  117746. * Gets a lens flare system using its id
  117747. * @param id defines the id to look for
  117748. * @returns the lens flare system or null if not found
  117749. */
  117750. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117751. }
  117752. /**
  117753. * Defines the lens flare scene component responsible to manage any lens flares
  117754. * in a given scene.
  117755. */
  117756. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117757. /**
  117758. * The component name helpfull to identify the component in the list of scene components.
  117759. */
  117760. readonly name: string;
  117761. /**
  117762. * The scene the component belongs to.
  117763. */
  117764. scene: Scene;
  117765. /**
  117766. * Creates a new instance of the component for the given scene
  117767. * @param scene Defines the scene to register the component in
  117768. */
  117769. constructor(scene: Scene);
  117770. /**
  117771. * Registers the component in a given scene
  117772. */
  117773. register(): void;
  117774. /**
  117775. * Rebuilds the elements related to this component in case of
  117776. * context lost for instance.
  117777. */
  117778. rebuild(): void;
  117779. /**
  117780. * Adds all the elements from the container to the scene
  117781. * @param container the container holding the elements
  117782. */
  117783. addFromContainer(container: AbstractScene): void;
  117784. /**
  117785. * Removes all the elements in the container from the scene
  117786. * @param container contains the elements to remove
  117787. * @param dispose if the removed element should be disposed (default: false)
  117788. */
  117789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117790. /**
  117791. * Serializes the component data to the specified json object
  117792. * @param serializationObject The object to serialize to
  117793. */
  117794. serialize(serializationObject: any): void;
  117795. /**
  117796. * Disposes the component and the associated ressources.
  117797. */
  117798. dispose(): void;
  117799. private _draw;
  117800. }
  117801. }
  117802. declare module BABYLON {
  117803. /**
  117804. * Defines the shadow generator component responsible to manage any shadow generators
  117805. * in a given scene.
  117806. */
  117807. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117808. /**
  117809. * The component name helpfull to identify the component in the list of scene components.
  117810. */
  117811. readonly name: string;
  117812. /**
  117813. * The scene the component belongs to.
  117814. */
  117815. scene: Scene;
  117816. /**
  117817. * Creates a new instance of the component for the given scene
  117818. * @param scene Defines the scene to register the component in
  117819. */
  117820. constructor(scene: Scene);
  117821. /**
  117822. * Registers the component in a given scene
  117823. */
  117824. register(): void;
  117825. /**
  117826. * Rebuilds the elements related to this component in case of
  117827. * context lost for instance.
  117828. */
  117829. rebuild(): void;
  117830. /**
  117831. * Serializes the component data to the specified json object
  117832. * @param serializationObject The object to serialize to
  117833. */
  117834. serialize(serializationObject: any): void;
  117835. /**
  117836. * Adds all the elements from the container to the scene
  117837. * @param container the container holding the elements
  117838. */
  117839. addFromContainer(container: AbstractScene): void;
  117840. /**
  117841. * Removes all the elements in the container from the scene
  117842. * @param container contains the elements to remove
  117843. * @param dispose if the removed element should be disposed (default: false)
  117844. */
  117845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117846. /**
  117847. * Rebuilds the elements related to this component in case of
  117848. * context lost for instance.
  117849. */
  117850. dispose(): void;
  117851. private _gatherRenderTargets;
  117852. }
  117853. }
  117854. declare module BABYLON {
  117855. /**
  117856. * A point light is a light defined by an unique point in world space.
  117857. * The light is emitted in every direction from this point.
  117858. * A good example of a point light is a standard light bulb.
  117859. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117860. */
  117861. export class PointLight extends ShadowLight {
  117862. private _shadowAngle;
  117863. /**
  117864. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117865. * This specifies what angle the shadow will use to be created.
  117866. *
  117867. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117868. */
  117869. /**
  117870. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117871. * This specifies what angle the shadow will use to be created.
  117872. *
  117873. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117874. */
  117875. shadowAngle: number;
  117876. /**
  117877. * Gets the direction if it has been set.
  117878. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117879. */
  117880. /**
  117881. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117882. */
  117883. direction: Vector3;
  117884. /**
  117885. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117886. * A PointLight emits the light in every direction.
  117887. * It can cast shadows.
  117888. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117889. * ```javascript
  117890. * var pointLight = new PointLight("pl", camera.position, scene);
  117891. * ```
  117892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117893. * @param name The light friendly name
  117894. * @param position The position of the point light in the scene
  117895. * @param scene The scene the lights belongs to
  117896. */
  117897. constructor(name: string, position: Vector3, scene: Scene);
  117898. /**
  117899. * Returns the string "PointLight"
  117900. * @returns the class name
  117901. */
  117902. getClassName(): string;
  117903. /**
  117904. * Returns the integer 0.
  117905. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117906. */
  117907. getTypeID(): number;
  117908. /**
  117909. * Specifies wether or not the shadowmap should be a cube texture.
  117910. * @returns true if the shadowmap needs to be a cube texture.
  117911. */
  117912. needCube(): boolean;
  117913. /**
  117914. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117915. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117916. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117917. */
  117918. getShadowDirection(faceIndex?: number): Vector3;
  117919. /**
  117920. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117921. * - fov = PI / 2
  117922. * - aspect ratio : 1.0
  117923. * - z-near and far equal to the active camera minZ and maxZ.
  117924. * Returns the PointLight.
  117925. */
  117926. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117927. protected _buildUniformLayout(): void;
  117928. /**
  117929. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117930. * @param effect The effect to update
  117931. * @param lightIndex The index of the light in the effect to update
  117932. * @returns The point light
  117933. */
  117934. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117935. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117936. /**
  117937. * Prepares the list of defines specific to the light type.
  117938. * @param defines the list of defines
  117939. * @param lightIndex defines the index of the light for the effect
  117940. */
  117941. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117942. }
  117943. }
  117944. declare module BABYLON {
  117945. /**
  117946. * Header information of HDR texture files.
  117947. */
  117948. export interface HDRInfo {
  117949. /**
  117950. * The height of the texture in pixels.
  117951. */
  117952. height: number;
  117953. /**
  117954. * The width of the texture in pixels.
  117955. */
  117956. width: number;
  117957. /**
  117958. * The index of the beginning of the data in the binary file.
  117959. */
  117960. dataPosition: number;
  117961. }
  117962. /**
  117963. * This groups tools to convert HDR texture to native colors array.
  117964. */
  117965. export class HDRTools {
  117966. private static Ldexp;
  117967. private static Rgbe2float;
  117968. private static readStringLine;
  117969. /**
  117970. * Reads header information from an RGBE texture stored in a native array.
  117971. * More information on this format are available here:
  117972. * https://en.wikipedia.org/wiki/RGBE_image_format
  117973. *
  117974. * @param uint8array The binary file stored in native array.
  117975. * @return The header information.
  117976. */
  117977. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117978. /**
  117979. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117980. * This RGBE texture needs to store the information as a panorama.
  117981. *
  117982. * More information on this format are available here:
  117983. * https://en.wikipedia.org/wiki/RGBE_image_format
  117984. *
  117985. * @param buffer The binary file stored in an array buffer.
  117986. * @param size The expected size of the extracted cubemap.
  117987. * @return The Cube Map information.
  117988. */
  117989. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117990. /**
  117991. * Returns the pixels data extracted from an RGBE texture.
  117992. * This pixels will be stored left to right up to down in the R G B order in one array.
  117993. *
  117994. * More information on this format are available here:
  117995. * https://en.wikipedia.org/wiki/RGBE_image_format
  117996. *
  117997. * @param uint8array The binary file stored in an array buffer.
  117998. * @param hdrInfo The header information of the file.
  117999. * @return The pixels data in RGB right to left up to down order.
  118000. */
  118001. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118002. private static RGBE_ReadPixels_RLE;
  118003. }
  118004. }
  118005. declare module BABYLON {
  118006. /**
  118007. * This represents a texture coming from an HDR input.
  118008. *
  118009. * The only supported format is currently panorama picture stored in RGBE format.
  118010. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118011. */
  118012. export class HDRCubeTexture extends BaseTexture {
  118013. private static _facesMapping;
  118014. private _generateHarmonics;
  118015. private _noMipmap;
  118016. private _textureMatrix;
  118017. private _size;
  118018. private _onLoad;
  118019. private _onError;
  118020. /**
  118021. * The texture URL.
  118022. */
  118023. url: string;
  118024. /**
  118025. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118026. */
  118027. coordinatesMode: number;
  118028. protected _isBlocking: boolean;
  118029. /**
  118030. * Sets wether or not the texture is blocking during loading.
  118031. */
  118032. /**
  118033. * Gets wether or not the texture is blocking during loading.
  118034. */
  118035. isBlocking: boolean;
  118036. protected _rotationY: number;
  118037. /**
  118038. * Sets texture matrix rotation angle around Y axis in radians.
  118039. */
  118040. /**
  118041. * Gets texture matrix rotation angle around Y axis radians.
  118042. */
  118043. rotationY: number;
  118044. /**
  118045. * Gets or sets the center of the bounding box associated with the cube texture
  118046. * It must define where the camera used to render the texture was set
  118047. */
  118048. boundingBoxPosition: Vector3;
  118049. private _boundingBoxSize;
  118050. /**
  118051. * Gets or sets the size of the bounding box associated with the cube texture
  118052. * When defined, the cubemap will switch to local mode
  118053. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118054. * @example https://www.babylonjs-playground.com/#RNASML
  118055. */
  118056. boundingBoxSize: Vector3;
  118057. /**
  118058. * Instantiates an HDRTexture from the following parameters.
  118059. *
  118060. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118061. * @param scene The scene the texture will be used in
  118062. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118063. * @param noMipmap Forces to not generate the mipmap if true
  118064. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118065. * @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)
  118066. * @param reserved Reserved flag for internal use.
  118067. */
  118068. 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>);
  118069. /**
  118070. * Get the current class name of the texture useful for serialization or dynamic coding.
  118071. * @returns "HDRCubeTexture"
  118072. */
  118073. getClassName(): string;
  118074. /**
  118075. * Occurs when the file is raw .hdr file.
  118076. */
  118077. private loadTexture;
  118078. clone(): HDRCubeTexture;
  118079. delayLoad(): void;
  118080. /**
  118081. * Get the texture reflection matrix used to rotate/transform the reflection.
  118082. * @returns the reflection matrix
  118083. */
  118084. getReflectionTextureMatrix(): Matrix;
  118085. /**
  118086. * Set the texture reflection matrix used to rotate/transform the reflection.
  118087. * @param value Define the reflection matrix to set
  118088. */
  118089. setReflectionTextureMatrix(value: Matrix): void;
  118090. /**
  118091. * Parses a JSON representation of an HDR Texture in order to create the texture
  118092. * @param parsedTexture Define the JSON representation
  118093. * @param scene Define the scene the texture should be created in
  118094. * @param rootUrl Define the root url in case we need to load relative dependencies
  118095. * @returns the newly created texture after parsing
  118096. */
  118097. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118098. serialize(): any;
  118099. }
  118100. }
  118101. declare module BABYLON {
  118102. /**
  118103. * Class used to control physics engine
  118104. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118105. */
  118106. export class PhysicsEngine implements IPhysicsEngine {
  118107. private _physicsPlugin;
  118108. /**
  118109. * Global value used to control the smallest number supported by the simulation
  118110. */
  118111. static Epsilon: number;
  118112. private _impostors;
  118113. private _joints;
  118114. /**
  118115. * Gets the gravity vector used by the simulation
  118116. */
  118117. gravity: Vector3;
  118118. /**
  118119. * Factory used to create the default physics plugin.
  118120. * @returns The default physics plugin
  118121. */
  118122. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118123. /**
  118124. * Creates a new Physics Engine
  118125. * @param gravity defines the gravity vector used by the simulation
  118126. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118127. */
  118128. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118129. /**
  118130. * Sets the gravity vector used by the simulation
  118131. * @param gravity defines the gravity vector to use
  118132. */
  118133. setGravity(gravity: Vector3): void;
  118134. /**
  118135. * Set the time step of the physics engine.
  118136. * Default is 1/60.
  118137. * To slow it down, enter 1/600 for example.
  118138. * To speed it up, 1/30
  118139. * @param newTimeStep defines the new timestep to apply to this world.
  118140. */
  118141. setTimeStep(newTimeStep?: number): void;
  118142. /**
  118143. * Get the time step of the physics engine.
  118144. * @returns the current time step
  118145. */
  118146. getTimeStep(): number;
  118147. /**
  118148. * Release all resources
  118149. */
  118150. dispose(): void;
  118151. /**
  118152. * Gets the name of the current physics plugin
  118153. * @returns the name of the plugin
  118154. */
  118155. getPhysicsPluginName(): string;
  118156. /**
  118157. * Adding a new impostor for the impostor tracking.
  118158. * This will be done by the impostor itself.
  118159. * @param impostor the impostor to add
  118160. */
  118161. addImpostor(impostor: PhysicsImpostor): void;
  118162. /**
  118163. * Remove an impostor from the engine.
  118164. * This impostor and its mesh will not longer be updated by the physics engine.
  118165. * @param impostor the impostor to remove
  118166. */
  118167. removeImpostor(impostor: PhysicsImpostor): void;
  118168. /**
  118169. * Add a joint to the physics engine
  118170. * @param mainImpostor defines the main impostor to which the joint is added.
  118171. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118172. * @param joint defines the joint that will connect both impostors.
  118173. */
  118174. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118175. /**
  118176. * Removes a joint from the simulation
  118177. * @param mainImpostor defines the impostor used with the joint
  118178. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118179. * @param joint defines the joint to remove
  118180. */
  118181. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118182. /**
  118183. * Called by the scene. No need to call it.
  118184. * @param delta defines the timespam between frames
  118185. */
  118186. _step(delta: number): void;
  118187. /**
  118188. * Gets the current plugin used to run the simulation
  118189. * @returns current plugin
  118190. */
  118191. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118192. /**
  118193. * Gets the list of physic impostors
  118194. * @returns an array of PhysicsImpostor
  118195. */
  118196. getImpostors(): Array<PhysicsImpostor>;
  118197. /**
  118198. * Gets the impostor for a physics enabled object
  118199. * @param object defines the object impersonated by the impostor
  118200. * @returns the PhysicsImpostor or null if not found
  118201. */
  118202. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118203. /**
  118204. * Gets the impostor for a physics body object
  118205. * @param body defines physics body used by the impostor
  118206. * @returns the PhysicsImpostor or null if not found
  118207. */
  118208. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118209. /**
  118210. * Does a raycast in the physics world
  118211. * @param from when should the ray start?
  118212. * @param to when should the ray end?
  118213. * @returns PhysicsRaycastResult
  118214. */
  118215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118216. }
  118217. }
  118218. declare module BABYLON {
  118219. /** @hidden */
  118220. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118221. private _useDeltaForWorldStep;
  118222. world: any;
  118223. name: string;
  118224. private _physicsMaterials;
  118225. private _fixedTimeStep;
  118226. private _cannonRaycastResult;
  118227. private _raycastResult;
  118228. private _physicsBodysToRemoveAfterStep;
  118229. BJSCANNON: any;
  118230. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118231. setGravity(gravity: Vector3): void;
  118232. setTimeStep(timeStep: number): void;
  118233. getTimeStep(): number;
  118234. executeStep(delta: number): void;
  118235. private _removeMarkedPhysicsBodiesFromWorld;
  118236. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118237. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118239. private _processChildMeshes;
  118240. removePhysicsBody(impostor: PhysicsImpostor): void;
  118241. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118242. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118243. private _addMaterial;
  118244. private _checkWithEpsilon;
  118245. private _createShape;
  118246. private _createHeightmap;
  118247. private _minus90X;
  118248. private _plus90X;
  118249. private _tmpPosition;
  118250. private _tmpDeltaPosition;
  118251. private _tmpUnityRotation;
  118252. private _updatePhysicsBodyTransformation;
  118253. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118254. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118255. isSupported(): boolean;
  118256. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118257. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118258. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118259. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118260. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118261. getBodyMass(impostor: PhysicsImpostor): number;
  118262. getBodyFriction(impostor: PhysicsImpostor): number;
  118263. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118264. getBodyRestitution(impostor: PhysicsImpostor): number;
  118265. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118266. sleepBody(impostor: PhysicsImpostor): void;
  118267. wakeUpBody(impostor: PhysicsImpostor): void;
  118268. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118269. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118270. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118271. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118272. getRadius(impostor: PhysicsImpostor): number;
  118273. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118274. dispose(): void;
  118275. private _extendNamespace;
  118276. /**
  118277. * Does a raycast in the physics world
  118278. * @param from when should the ray start?
  118279. * @param to when should the ray end?
  118280. * @returns PhysicsRaycastResult
  118281. */
  118282. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118283. }
  118284. }
  118285. declare module BABYLON {
  118286. /** @hidden */
  118287. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118288. world: any;
  118289. name: string;
  118290. BJSOIMO: any;
  118291. private _raycastResult;
  118292. constructor(iterations?: number, oimoInjection?: any);
  118293. setGravity(gravity: Vector3): void;
  118294. setTimeStep(timeStep: number): void;
  118295. getTimeStep(): number;
  118296. private _tmpImpostorsArray;
  118297. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118298. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118299. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118300. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118301. private _tmpPositionVector;
  118302. removePhysicsBody(impostor: PhysicsImpostor): void;
  118303. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118304. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118305. isSupported(): boolean;
  118306. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118307. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118308. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118310. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118311. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118312. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118313. getBodyMass(impostor: PhysicsImpostor): number;
  118314. getBodyFriction(impostor: PhysicsImpostor): number;
  118315. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118316. getBodyRestitution(impostor: PhysicsImpostor): number;
  118317. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118318. sleepBody(impostor: PhysicsImpostor): void;
  118319. wakeUpBody(impostor: PhysicsImpostor): void;
  118320. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118321. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118324. getRadius(impostor: PhysicsImpostor): number;
  118325. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118326. dispose(): void;
  118327. /**
  118328. * Does a raycast in the physics world
  118329. * @param from when should the ray start?
  118330. * @param to when should the ray end?
  118331. * @returns PhysicsRaycastResult
  118332. */
  118333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118334. }
  118335. }
  118336. declare module BABYLON {
  118337. /**
  118338. * Class containing static functions to help procedurally build meshes
  118339. */
  118340. export class RibbonBuilder {
  118341. /**
  118342. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118343. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118344. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118345. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118346. * * 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
  118347. * * 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
  118348. * * 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
  118349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118352. * * 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
  118353. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118354. * * 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
  118355. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118357. * @param name defines the name of the mesh
  118358. * @param options defines the options used to create the mesh
  118359. * @param scene defines the hosting scene
  118360. * @returns the ribbon mesh
  118361. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118362. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118363. */
  118364. static CreateRibbon(name: string, options: {
  118365. pathArray: Vector3[][];
  118366. closeArray?: boolean;
  118367. closePath?: boolean;
  118368. offset?: number;
  118369. updatable?: boolean;
  118370. sideOrientation?: number;
  118371. frontUVs?: Vector4;
  118372. backUVs?: Vector4;
  118373. instance?: Mesh;
  118374. invertUV?: boolean;
  118375. uvs?: Vector2[];
  118376. colors?: Color4[];
  118377. }, scene?: Nullable<Scene>): Mesh;
  118378. }
  118379. }
  118380. declare module BABYLON {
  118381. /**
  118382. * Class containing static functions to help procedurally build meshes
  118383. */
  118384. export class ShapeBuilder {
  118385. /**
  118386. * 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.
  118387. * * 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.
  118388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118389. * * 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.
  118390. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118391. * * 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
  118392. * * 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
  118393. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118398. * @param name defines the name of the mesh
  118399. * @param options defines the options used to create the mesh
  118400. * @param scene defines the hosting scene
  118401. * @returns the extruded shape mesh
  118402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118404. */
  118405. static ExtrudeShape(name: string, options: {
  118406. shape: Vector3[];
  118407. path: Vector3[];
  118408. scale?: number;
  118409. rotation?: number;
  118410. cap?: number;
  118411. updatable?: boolean;
  118412. sideOrientation?: number;
  118413. frontUVs?: Vector4;
  118414. backUVs?: Vector4;
  118415. instance?: Mesh;
  118416. invertUV?: boolean;
  118417. }, scene?: Nullable<Scene>): Mesh;
  118418. /**
  118419. * Creates an custom extruded shape mesh.
  118420. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118421. * * 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.
  118422. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118423. * * 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
  118424. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118425. * * 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
  118426. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118427. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118428. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118429. * * 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
  118430. * * 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
  118431. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118436. * @param name defines the name of the mesh
  118437. * @param options defines the options used to create the mesh
  118438. * @param scene defines the hosting scene
  118439. * @returns the custom extruded shape mesh
  118440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118441. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118443. */
  118444. static ExtrudeShapeCustom(name: string, options: {
  118445. shape: Vector3[];
  118446. path: Vector3[];
  118447. scaleFunction?: any;
  118448. rotationFunction?: any;
  118449. ribbonCloseArray?: boolean;
  118450. ribbonClosePath?: boolean;
  118451. cap?: number;
  118452. updatable?: boolean;
  118453. sideOrientation?: number;
  118454. frontUVs?: Vector4;
  118455. backUVs?: Vector4;
  118456. instance?: Mesh;
  118457. invertUV?: boolean;
  118458. }, scene?: Nullable<Scene>): Mesh;
  118459. private static _ExtrudeShapeGeneric;
  118460. }
  118461. }
  118462. declare module BABYLON {
  118463. /**
  118464. * AmmoJS Physics plugin
  118465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118466. * @see https://github.com/kripken/ammo.js/
  118467. */
  118468. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118469. private _useDeltaForWorldStep;
  118470. /**
  118471. * Reference to the Ammo library
  118472. */
  118473. bjsAMMO: any;
  118474. /**
  118475. * Created ammoJS world which physics bodies are added to
  118476. */
  118477. world: any;
  118478. /**
  118479. * Name of the plugin
  118480. */
  118481. name: string;
  118482. private _timeStep;
  118483. private _fixedTimeStep;
  118484. private _maxSteps;
  118485. private _tmpQuaternion;
  118486. private _tmpAmmoTransform;
  118487. private _tmpAmmoQuaternion;
  118488. private _tmpAmmoConcreteContactResultCallback;
  118489. private _collisionConfiguration;
  118490. private _dispatcher;
  118491. private _overlappingPairCache;
  118492. private _solver;
  118493. private _softBodySolver;
  118494. private _tmpAmmoVectorA;
  118495. private _tmpAmmoVectorB;
  118496. private _tmpAmmoVectorC;
  118497. private _tmpAmmoVectorD;
  118498. private _tmpContactCallbackResult;
  118499. private _tmpAmmoVectorRCA;
  118500. private _tmpAmmoVectorRCB;
  118501. private _raycastResult;
  118502. private static readonly DISABLE_COLLISION_FLAG;
  118503. private static readonly KINEMATIC_FLAG;
  118504. private static readonly DISABLE_DEACTIVATION_FLAG;
  118505. /**
  118506. * Initializes the ammoJS plugin
  118507. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118508. * @param ammoInjection can be used to inject your own ammo reference
  118509. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118510. */
  118511. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118512. /**
  118513. * Sets the gravity of the physics world (m/(s^2))
  118514. * @param gravity Gravity to set
  118515. */
  118516. setGravity(gravity: Vector3): void;
  118517. /**
  118518. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118519. * @param timeStep timestep to use in seconds
  118520. */
  118521. setTimeStep(timeStep: number): void;
  118522. /**
  118523. * 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)
  118524. * @param fixedTimeStep fixedTimeStep to use in seconds
  118525. */
  118526. setFixedTimeStep(fixedTimeStep: number): void;
  118527. /**
  118528. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118529. * @param maxSteps the maximum number of steps by the physics engine per frame
  118530. */
  118531. setMaxSteps(maxSteps: number): void;
  118532. /**
  118533. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118534. * @returns the current timestep in seconds
  118535. */
  118536. getTimeStep(): number;
  118537. private _isImpostorInContact;
  118538. private _isImpostorPairInContact;
  118539. private _stepSimulation;
  118540. /**
  118541. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118542. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118543. * After the step the babylon meshes are set to the position of the physics imposters
  118544. * @param delta amount of time to step forward
  118545. * @param impostors array of imposters to update before/after the step
  118546. */
  118547. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118548. /**
  118549. * Update babylon mesh to match physics world object
  118550. * @param impostor imposter to match
  118551. */
  118552. private _afterSoftStep;
  118553. /**
  118554. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118555. * @param impostor imposter to match
  118556. */
  118557. private _ropeStep;
  118558. /**
  118559. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118560. * @param impostor imposter to match
  118561. */
  118562. private _softbodyOrClothStep;
  118563. private _tmpVector;
  118564. private _tmpMatrix;
  118565. /**
  118566. * Applies an impulse on the imposter
  118567. * @param impostor imposter to apply impulse to
  118568. * @param force amount of force to be applied to the imposter
  118569. * @param contactPoint the location to apply the impulse on the imposter
  118570. */
  118571. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118572. /**
  118573. * Applies a force on the imposter
  118574. * @param impostor imposter to apply force
  118575. * @param force amount of force to be applied to the imposter
  118576. * @param contactPoint the location to apply the force on the imposter
  118577. */
  118578. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118579. /**
  118580. * Creates a physics body using the plugin
  118581. * @param impostor the imposter to create the physics body on
  118582. */
  118583. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118584. /**
  118585. * Removes the physics body from the imposter and disposes of the body's memory
  118586. * @param impostor imposter to remove the physics body from
  118587. */
  118588. removePhysicsBody(impostor: PhysicsImpostor): void;
  118589. /**
  118590. * Generates a joint
  118591. * @param impostorJoint the imposter joint to create the joint with
  118592. */
  118593. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118594. /**
  118595. * Removes a joint
  118596. * @param impostorJoint the imposter joint to remove the joint from
  118597. */
  118598. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118599. private _addMeshVerts;
  118600. /**
  118601. * Initialise the soft body vertices to match its object's (mesh) vertices
  118602. * Softbody vertices (nodes) are in world space and to match this
  118603. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118604. * @param impostor to create the softbody for
  118605. */
  118606. private _softVertexData;
  118607. /**
  118608. * Create an impostor's soft body
  118609. * @param impostor to create the softbody for
  118610. */
  118611. private _createSoftbody;
  118612. /**
  118613. * Create cloth for an impostor
  118614. * @param impostor to create the softbody for
  118615. */
  118616. private _createCloth;
  118617. /**
  118618. * Create rope for an impostor
  118619. * @param impostor to create the softbody for
  118620. */
  118621. private _createRope;
  118622. private _addHullVerts;
  118623. private _createShape;
  118624. /**
  118625. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118626. * @param impostor imposter containing the physics body and babylon object
  118627. */
  118628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118629. /**
  118630. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118631. * @param impostor imposter containing the physics body and babylon object
  118632. * @param newPosition new position
  118633. * @param newRotation new rotation
  118634. */
  118635. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118636. /**
  118637. * If this plugin is supported
  118638. * @returns true if its supported
  118639. */
  118640. isSupported(): boolean;
  118641. /**
  118642. * Sets the linear velocity of the physics body
  118643. * @param impostor imposter to set the velocity on
  118644. * @param velocity velocity to set
  118645. */
  118646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118647. /**
  118648. * Sets the angular velocity of the physics body
  118649. * @param impostor imposter to set the velocity on
  118650. * @param velocity velocity to set
  118651. */
  118652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118653. /**
  118654. * gets the linear velocity
  118655. * @param impostor imposter to get linear velocity from
  118656. * @returns linear velocity
  118657. */
  118658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118659. /**
  118660. * gets the angular velocity
  118661. * @param impostor imposter to get angular velocity from
  118662. * @returns angular velocity
  118663. */
  118664. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118665. /**
  118666. * Sets the mass of physics body
  118667. * @param impostor imposter to set the mass on
  118668. * @param mass mass to set
  118669. */
  118670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118671. /**
  118672. * Gets the mass of the physics body
  118673. * @param impostor imposter to get the mass from
  118674. * @returns mass
  118675. */
  118676. getBodyMass(impostor: PhysicsImpostor): number;
  118677. /**
  118678. * Gets friction of the impostor
  118679. * @param impostor impostor to get friction from
  118680. * @returns friction value
  118681. */
  118682. getBodyFriction(impostor: PhysicsImpostor): number;
  118683. /**
  118684. * Sets friction of the impostor
  118685. * @param impostor impostor to set friction on
  118686. * @param friction friction value
  118687. */
  118688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118689. /**
  118690. * Gets restitution of the impostor
  118691. * @param impostor impostor to get restitution from
  118692. * @returns restitution value
  118693. */
  118694. getBodyRestitution(impostor: PhysicsImpostor): number;
  118695. /**
  118696. * Sets resitution of the impostor
  118697. * @param impostor impostor to set resitution on
  118698. * @param restitution resitution value
  118699. */
  118700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118701. /**
  118702. * Gets pressure inside the impostor
  118703. * @param impostor impostor to get pressure from
  118704. * @returns pressure value
  118705. */
  118706. getBodyPressure(impostor: PhysicsImpostor): number;
  118707. /**
  118708. * Sets pressure inside a soft body impostor
  118709. * Cloth and rope must remain 0 pressure
  118710. * @param impostor impostor to set pressure on
  118711. * @param pressure pressure value
  118712. */
  118713. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118714. /**
  118715. * Gets stiffness of the impostor
  118716. * @param impostor impostor to get stiffness from
  118717. * @returns pressure value
  118718. */
  118719. getBodyStiffness(impostor: PhysicsImpostor): number;
  118720. /**
  118721. * Sets stiffness of the impostor
  118722. * @param impostor impostor to set stiffness on
  118723. * @param stiffness stiffness value from 0 to 1
  118724. */
  118725. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118726. /**
  118727. * Gets velocityIterations of the impostor
  118728. * @param impostor impostor to get velocity iterations from
  118729. * @returns velocityIterations value
  118730. */
  118731. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118732. /**
  118733. * Sets velocityIterations of the impostor
  118734. * @param impostor impostor to set velocity iterations on
  118735. * @param velocityIterations velocityIterations value
  118736. */
  118737. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118738. /**
  118739. * Gets positionIterations of the impostor
  118740. * @param impostor impostor to get position iterations from
  118741. * @returns positionIterations value
  118742. */
  118743. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118744. /**
  118745. * Sets positionIterations of the impostor
  118746. * @param impostor impostor to set position on
  118747. * @param positionIterations positionIterations value
  118748. */
  118749. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118750. /**
  118751. * Append an anchor to a cloth object
  118752. * @param impostor is the cloth impostor to add anchor to
  118753. * @param otherImpostor is the rigid impostor to anchor to
  118754. * @param width ratio across width from 0 to 1
  118755. * @param height ratio up height from 0 to 1
  118756. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118757. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118758. */
  118759. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118760. /**
  118761. * Append an hook to a rope object
  118762. * @param impostor is the rope impostor to add hook to
  118763. * @param otherImpostor is the rigid impostor to hook to
  118764. * @param length ratio along the rope from 0 to 1
  118765. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118766. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118767. */
  118768. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118769. /**
  118770. * Sleeps the physics body and stops it from being active
  118771. * @param impostor impostor to sleep
  118772. */
  118773. sleepBody(impostor: PhysicsImpostor): void;
  118774. /**
  118775. * Activates the physics body
  118776. * @param impostor impostor to activate
  118777. */
  118778. wakeUpBody(impostor: PhysicsImpostor): void;
  118779. /**
  118780. * Updates the distance parameters of the joint
  118781. * @param joint joint to update
  118782. * @param maxDistance maximum distance of the joint
  118783. * @param minDistance minimum distance of the joint
  118784. */
  118785. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118786. /**
  118787. * Sets a motor on the joint
  118788. * @param joint joint to set motor on
  118789. * @param speed speed of the motor
  118790. * @param maxForce maximum force of the motor
  118791. * @param motorIndex index of the motor
  118792. */
  118793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118794. /**
  118795. * Sets the motors limit
  118796. * @param joint joint to set limit on
  118797. * @param upperLimit upper limit
  118798. * @param lowerLimit lower limit
  118799. */
  118800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118801. /**
  118802. * Syncs the position and rotation of a mesh with the impostor
  118803. * @param mesh mesh to sync
  118804. * @param impostor impostor to update the mesh with
  118805. */
  118806. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118807. /**
  118808. * Gets the radius of the impostor
  118809. * @param impostor impostor to get radius from
  118810. * @returns the radius
  118811. */
  118812. getRadius(impostor: PhysicsImpostor): number;
  118813. /**
  118814. * Gets the box size of the impostor
  118815. * @param impostor impostor to get box size from
  118816. * @param result the resulting box size
  118817. */
  118818. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118819. /**
  118820. * Disposes of the impostor
  118821. */
  118822. dispose(): void;
  118823. /**
  118824. * Does a raycast in the physics world
  118825. * @param from when should the ray start?
  118826. * @param to when should the ray end?
  118827. * @returns PhysicsRaycastResult
  118828. */
  118829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118830. }
  118831. }
  118832. declare module BABYLON {
  118833. interface AbstractScene {
  118834. /**
  118835. * The list of reflection probes added to the scene
  118836. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118837. */
  118838. reflectionProbes: Array<ReflectionProbe>;
  118839. /**
  118840. * Removes the given reflection probe from this scene.
  118841. * @param toRemove The reflection probe to remove
  118842. * @returns The index of the removed reflection probe
  118843. */
  118844. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118845. /**
  118846. * Adds the given reflection probe to this scene.
  118847. * @param newReflectionProbe The reflection probe to add
  118848. */
  118849. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118850. }
  118851. /**
  118852. * Class used to generate realtime reflection / refraction cube textures
  118853. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118854. */
  118855. export class ReflectionProbe {
  118856. /** defines the name of the probe */
  118857. name: string;
  118858. private _scene;
  118859. private _renderTargetTexture;
  118860. private _projectionMatrix;
  118861. private _viewMatrix;
  118862. private _target;
  118863. private _add;
  118864. private _attachedMesh;
  118865. private _invertYAxis;
  118866. /** Gets or sets probe position (center of the cube map) */
  118867. position: Vector3;
  118868. /**
  118869. * Creates a new reflection probe
  118870. * @param name defines the name of the probe
  118871. * @param size defines the texture resolution (for each face)
  118872. * @param scene defines the hosting scene
  118873. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118874. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118875. */
  118876. constructor(
  118877. /** defines the name of the probe */
  118878. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118879. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118880. samples: number;
  118881. /** Gets or sets the refresh rate to use (on every frame by default) */
  118882. refreshRate: number;
  118883. /**
  118884. * Gets the hosting scene
  118885. * @returns a Scene
  118886. */
  118887. getScene(): Scene;
  118888. /** Gets the internal CubeTexture used to render to */
  118889. readonly cubeTexture: RenderTargetTexture;
  118890. /** Gets the list of meshes to render */
  118891. readonly renderList: Nullable<AbstractMesh[]>;
  118892. /**
  118893. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118894. * @param mesh defines the mesh to attach to
  118895. */
  118896. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118897. /**
  118898. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118899. * @param renderingGroupId The rendering group id corresponding to its index
  118900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118901. */
  118902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118903. /**
  118904. * Clean all associated resources
  118905. */
  118906. dispose(): void;
  118907. /**
  118908. * Converts the reflection probe information to a readable string for debug purpose.
  118909. * @param fullDetails Supports for multiple levels of logging within scene loading
  118910. * @returns the human readable reflection probe info
  118911. */
  118912. toString(fullDetails?: boolean): string;
  118913. /**
  118914. * Get the class name of the relfection probe.
  118915. * @returns "ReflectionProbe"
  118916. */
  118917. getClassName(): string;
  118918. /**
  118919. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118920. * @returns The JSON representation of the texture
  118921. */
  118922. serialize(): any;
  118923. /**
  118924. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118925. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118926. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118927. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118928. * @returns The parsed reflection probe if successful
  118929. */
  118930. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118931. }
  118932. }
  118933. declare module BABYLON {
  118934. /** @hidden */
  118935. export var _BabylonLoaderRegistered: boolean;
  118936. }
  118937. declare module BABYLON {
  118938. /**
  118939. * The Physically based simple base material of BJS.
  118940. *
  118941. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118942. * It is used as the base class for both the specGloss and metalRough conventions.
  118943. */
  118944. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118945. /**
  118946. * Number of Simultaneous lights allowed on the material.
  118947. */
  118948. maxSimultaneousLights: number;
  118949. /**
  118950. * If sets to true, disables all the lights affecting the material.
  118951. */
  118952. disableLighting: boolean;
  118953. /**
  118954. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118955. */
  118956. environmentTexture: BaseTexture;
  118957. /**
  118958. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118959. */
  118960. invertNormalMapX: boolean;
  118961. /**
  118962. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118963. */
  118964. invertNormalMapY: boolean;
  118965. /**
  118966. * Normal map used in the model.
  118967. */
  118968. normalTexture: BaseTexture;
  118969. /**
  118970. * Emissivie color used to self-illuminate the model.
  118971. */
  118972. emissiveColor: Color3;
  118973. /**
  118974. * Emissivie texture used to self-illuminate the model.
  118975. */
  118976. emissiveTexture: BaseTexture;
  118977. /**
  118978. * Occlusion Channel Strenght.
  118979. */
  118980. occlusionStrength: number;
  118981. /**
  118982. * Occlusion Texture of the material (adding extra occlusion effects).
  118983. */
  118984. occlusionTexture: BaseTexture;
  118985. /**
  118986. * Defines the alpha limits in alpha test mode.
  118987. */
  118988. alphaCutOff: number;
  118989. /**
  118990. * Gets the current double sided mode.
  118991. */
  118992. /**
  118993. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118994. */
  118995. doubleSided: boolean;
  118996. /**
  118997. * Stores the pre-calculated light information of a mesh in a texture.
  118998. */
  118999. lightmapTexture: BaseTexture;
  119000. /**
  119001. * If true, the light map contains occlusion information instead of lighting info.
  119002. */
  119003. useLightmapAsShadowmap: boolean;
  119004. /**
  119005. * Instantiates a new PBRMaterial instance.
  119006. *
  119007. * @param name The material name
  119008. * @param scene The scene the material will be use in.
  119009. */
  119010. constructor(name: string, scene: Scene);
  119011. getClassName(): string;
  119012. }
  119013. }
  119014. declare module BABYLON {
  119015. /**
  119016. * The PBR material of BJS following the metal roughness convention.
  119017. *
  119018. * This fits to the PBR convention in the GLTF definition:
  119019. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119020. */
  119021. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119022. /**
  119023. * The base color has two different interpretations depending on the value of metalness.
  119024. * When the material is a metal, the base color is the specific measured reflectance value
  119025. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119026. * of the material.
  119027. */
  119028. baseColor: Color3;
  119029. /**
  119030. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119031. * well as opacity information in the alpha channel.
  119032. */
  119033. baseTexture: BaseTexture;
  119034. /**
  119035. * Specifies the metallic scalar value of the material.
  119036. * Can also be used to scale the metalness values of the metallic texture.
  119037. */
  119038. metallic: number;
  119039. /**
  119040. * Specifies the roughness scalar value of the material.
  119041. * Can also be used to scale the roughness values of the metallic texture.
  119042. */
  119043. roughness: number;
  119044. /**
  119045. * Texture containing both the metallic value in the B channel and the
  119046. * roughness value in the G channel to keep better precision.
  119047. */
  119048. metallicRoughnessTexture: BaseTexture;
  119049. /**
  119050. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119051. *
  119052. * @param name The material name
  119053. * @param scene The scene the material will be use in.
  119054. */
  119055. constructor(name: string, scene: Scene);
  119056. /**
  119057. * Return the currrent class name of the material.
  119058. */
  119059. getClassName(): string;
  119060. /**
  119061. * Makes a duplicate of the current material.
  119062. * @param name - name to use for the new material.
  119063. */
  119064. clone(name: string): PBRMetallicRoughnessMaterial;
  119065. /**
  119066. * Serialize the material to a parsable JSON object.
  119067. */
  119068. serialize(): any;
  119069. /**
  119070. * Parses a JSON object correponding to the serialize function.
  119071. */
  119072. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119073. }
  119074. }
  119075. declare module BABYLON {
  119076. /**
  119077. * The PBR material of BJS following the specular glossiness convention.
  119078. *
  119079. * This fits to the PBR convention in the GLTF definition:
  119080. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119081. */
  119082. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119083. /**
  119084. * Specifies the diffuse color of the material.
  119085. */
  119086. diffuseColor: Color3;
  119087. /**
  119088. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119089. * channel.
  119090. */
  119091. diffuseTexture: BaseTexture;
  119092. /**
  119093. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119094. */
  119095. specularColor: Color3;
  119096. /**
  119097. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119098. */
  119099. glossiness: number;
  119100. /**
  119101. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119102. */
  119103. specularGlossinessTexture: BaseTexture;
  119104. /**
  119105. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119106. *
  119107. * @param name The material name
  119108. * @param scene The scene the material will be use in.
  119109. */
  119110. constructor(name: string, scene: Scene);
  119111. /**
  119112. * Return the currrent class name of the material.
  119113. */
  119114. getClassName(): string;
  119115. /**
  119116. * Makes a duplicate of the current material.
  119117. * @param name - name to use for the new material.
  119118. */
  119119. clone(name: string): PBRSpecularGlossinessMaterial;
  119120. /**
  119121. * Serialize the material to a parsable JSON object.
  119122. */
  119123. serialize(): any;
  119124. /**
  119125. * Parses a JSON object correponding to the serialize function.
  119126. */
  119127. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119128. }
  119129. }
  119130. declare module BABYLON {
  119131. /**
  119132. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119133. * It can help converting any input color in a desired output one. This can then be used to create effects
  119134. * from sepia, black and white to sixties or futuristic rendering...
  119135. *
  119136. * The only supported format is currently 3dl.
  119137. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119138. */
  119139. export class ColorGradingTexture extends BaseTexture {
  119140. /**
  119141. * The current texture matrix. (will always be identity in color grading texture)
  119142. */
  119143. private _textureMatrix;
  119144. /**
  119145. * The texture URL.
  119146. */
  119147. url: string;
  119148. /**
  119149. * Empty line regex stored for GC.
  119150. */
  119151. private static _noneEmptyLineRegex;
  119152. private _engine;
  119153. /**
  119154. * Instantiates a ColorGradingTexture from the following parameters.
  119155. *
  119156. * @param url The location of the color gradind data (currently only supporting 3dl)
  119157. * @param scene The scene the texture will be used in
  119158. */
  119159. constructor(url: string, scene: Scene);
  119160. /**
  119161. * Returns the texture matrix used in most of the material.
  119162. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119163. */
  119164. getTextureMatrix(): Matrix;
  119165. /**
  119166. * Occurs when the file being loaded is a .3dl LUT file.
  119167. */
  119168. private load3dlTexture;
  119169. /**
  119170. * Starts the loading process of the texture.
  119171. */
  119172. private loadTexture;
  119173. /**
  119174. * Clones the color gradind texture.
  119175. */
  119176. clone(): ColorGradingTexture;
  119177. /**
  119178. * Called during delayed load for textures.
  119179. */
  119180. delayLoad(): void;
  119181. /**
  119182. * Parses a color grading texture serialized by Babylon.
  119183. * @param parsedTexture The texture information being parsedTexture
  119184. * @param scene The scene to load the texture in
  119185. * @param rootUrl The root url of the data assets to load
  119186. * @return A color gradind texture
  119187. */
  119188. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119189. /**
  119190. * Serializes the LUT texture to json format.
  119191. */
  119192. serialize(): any;
  119193. }
  119194. }
  119195. declare module BABYLON {
  119196. /**
  119197. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119198. */
  119199. export class EquiRectangularCubeTexture extends BaseTexture {
  119200. /** The six faces of the cube. */
  119201. private static _FacesMapping;
  119202. private _noMipmap;
  119203. private _onLoad;
  119204. private _onError;
  119205. /** The size of the cubemap. */
  119206. private _size;
  119207. /** The buffer of the image. */
  119208. private _buffer;
  119209. /** The width of the input image. */
  119210. private _width;
  119211. /** The height of the input image. */
  119212. private _height;
  119213. /** The URL to the image. */
  119214. url: string;
  119215. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119216. coordinatesMode: number;
  119217. /**
  119218. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119219. * @param url The location of the image
  119220. * @param scene The scene the texture will be used in
  119221. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119222. * @param noMipmap Forces to not generate the mipmap if true
  119223. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119224. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119225. * @param onLoad — defines a callback called when texture is loaded
  119226. * @param onError — defines a callback called if there is an error
  119227. */
  119228. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119229. /**
  119230. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119231. */
  119232. private loadImage;
  119233. /**
  119234. * Convert the image buffer into a cubemap and create a CubeTexture.
  119235. */
  119236. private loadTexture;
  119237. /**
  119238. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119239. * @param buffer The ArrayBuffer that should be converted.
  119240. * @returns The buffer as Float32Array.
  119241. */
  119242. private getFloat32ArrayFromArrayBuffer;
  119243. /**
  119244. * Get the current class name of the texture useful for serialization or dynamic coding.
  119245. * @returns "EquiRectangularCubeTexture"
  119246. */
  119247. getClassName(): string;
  119248. /**
  119249. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119250. * @returns A clone of the current EquiRectangularCubeTexture.
  119251. */
  119252. clone(): EquiRectangularCubeTexture;
  119253. }
  119254. }
  119255. declare module BABYLON {
  119256. /**
  119257. * Based on jsTGALoader - Javascript loader for TGA file
  119258. * By Vincent Thibault
  119259. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119260. */
  119261. export class TGATools {
  119262. private static _TYPE_INDEXED;
  119263. private static _TYPE_RGB;
  119264. private static _TYPE_GREY;
  119265. private static _TYPE_RLE_INDEXED;
  119266. private static _TYPE_RLE_RGB;
  119267. private static _TYPE_RLE_GREY;
  119268. private static _ORIGIN_MASK;
  119269. private static _ORIGIN_SHIFT;
  119270. private static _ORIGIN_BL;
  119271. private static _ORIGIN_BR;
  119272. private static _ORIGIN_UL;
  119273. private static _ORIGIN_UR;
  119274. /**
  119275. * Gets the header of a TGA file
  119276. * @param data defines the TGA data
  119277. * @returns the header
  119278. */
  119279. static GetTGAHeader(data: Uint8Array): any;
  119280. /**
  119281. * Uploads TGA content to a Babylon Texture
  119282. * @hidden
  119283. */
  119284. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119285. /** @hidden */
  119286. 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;
  119287. /** @hidden */
  119288. 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;
  119289. /** @hidden */
  119290. 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;
  119291. /** @hidden */
  119292. 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;
  119293. /** @hidden */
  119294. 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;
  119295. /** @hidden */
  119296. 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;
  119297. }
  119298. }
  119299. declare module BABYLON {
  119300. /**
  119301. * Implementation of the TGA Texture Loader.
  119302. * @hidden
  119303. */
  119304. export class _TGATextureLoader implements IInternalTextureLoader {
  119305. /**
  119306. * Defines wether the loader supports cascade loading the different faces.
  119307. */
  119308. readonly supportCascades: boolean;
  119309. /**
  119310. * This returns if the loader support the current file information.
  119311. * @param extension defines the file extension of the file being loaded
  119312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119313. * @param fallback defines the fallback internal texture if any
  119314. * @param isBase64 defines whether the texture is encoded as a base64
  119315. * @param isBuffer defines whether the texture data are stored as a buffer
  119316. * @returns true if the loader can load the specified file
  119317. */
  119318. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119319. /**
  119320. * Transform the url before loading if required.
  119321. * @param rootUrl the url of the texture
  119322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119323. * @returns the transformed texture
  119324. */
  119325. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119326. /**
  119327. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119328. * @param rootUrl the url of the texture
  119329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119330. * @returns the fallback texture
  119331. */
  119332. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119333. /**
  119334. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119335. * @param data contains the texture data
  119336. * @param texture defines the BabylonJS internal texture
  119337. * @param createPolynomials will be true if polynomials have been requested
  119338. * @param onLoad defines the callback to trigger once the texture is ready
  119339. * @param onError defines the callback to trigger in case of error
  119340. */
  119341. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119342. /**
  119343. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119344. * @param data contains the texture data
  119345. * @param texture defines the BabylonJS internal texture
  119346. * @param callback defines the method to call once ready to upload
  119347. */
  119348. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119349. }
  119350. }
  119351. declare module BABYLON {
  119352. /**
  119353. * Info about the .basis files
  119354. */
  119355. class BasisFileInfo {
  119356. /**
  119357. * If the file has alpha
  119358. */
  119359. hasAlpha: boolean;
  119360. /**
  119361. * Info about each image of the basis file
  119362. */
  119363. images: Array<{
  119364. levels: Array<{
  119365. width: number;
  119366. height: number;
  119367. transcodedPixels: ArrayBufferView;
  119368. }>;
  119369. }>;
  119370. }
  119371. /**
  119372. * Result of transcoding a basis file
  119373. */
  119374. class TranscodeResult {
  119375. /**
  119376. * Info about the .basis file
  119377. */
  119378. fileInfo: BasisFileInfo;
  119379. /**
  119380. * Format to use when loading the file
  119381. */
  119382. format: number;
  119383. }
  119384. /**
  119385. * Configuration options for the Basis transcoder
  119386. */
  119387. export class BasisTranscodeConfiguration {
  119388. /**
  119389. * Supported compression formats used to determine the supported output format of the transcoder
  119390. */
  119391. supportedCompressionFormats?: {
  119392. /**
  119393. * etc1 compression format
  119394. */
  119395. etc1?: boolean;
  119396. /**
  119397. * s3tc compression format
  119398. */
  119399. s3tc?: boolean;
  119400. /**
  119401. * pvrtc compression format
  119402. */
  119403. pvrtc?: boolean;
  119404. /**
  119405. * etc2 compression format
  119406. */
  119407. etc2?: boolean;
  119408. };
  119409. /**
  119410. * If mipmap levels should be loaded for transcoded images (Default: true)
  119411. */
  119412. loadMipmapLevels?: boolean;
  119413. /**
  119414. * Index of a single image to load (Default: all images)
  119415. */
  119416. loadSingleImage?: number;
  119417. }
  119418. /**
  119419. * Used to load .Basis files
  119420. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119421. */
  119422. export class BasisTools {
  119423. private static _IgnoreSupportedFormats;
  119424. /**
  119425. * URL to use when loading the basis transcoder
  119426. */
  119427. static JSModuleURL: string;
  119428. /**
  119429. * URL to use when loading the wasm module for the transcoder
  119430. */
  119431. static WasmModuleURL: string;
  119432. /**
  119433. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119434. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119435. * @returns internal format corresponding to the Basis format
  119436. */
  119437. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119438. private static _WorkerPromise;
  119439. private static _Worker;
  119440. private static _actionId;
  119441. private static _CreateWorkerAsync;
  119442. /**
  119443. * Transcodes a loaded image file to compressed pixel data
  119444. * @param imageData image data to transcode
  119445. * @param config configuration options for the transcoding
  119446. * @returns a promise resulting in the transcoded image
  119447. */
  119448. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119449. /**
  119450. * Loads a texture from the transcode result
  119451. * @param texture texture load to
  119452. * @param transcodeResult the result of transcoding the basis file to load from
  119453. */
  119454. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119455. }
  119456. }
  119457. declare module BABYLON {
  119458. /**
  119459. * Loader for .basis file format
  119460. */
  119461. export class _BasisTextureLoader implements IInternalTextureLoader {
  119462. /**
  119463. * Defines whether the loader supports cascade loading the different faces.
  119464. */
  119465. readonly supportCascades: boolean;
  119466. /**
  119467. * This returns if the loader support the current file information.
  119468. * @param extension defines the file extension of the file being loaded
  119469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119470. * @param fallback defines the fallback internal texture if any
  119471. * @param isBase64 defines whether the texture is encoded as a base64
  119472. * @param isBuffer defines whether the texture data are stored as a buffer
  119473. * @returns true if the loader can load the specified file
  119474. */
  119475. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119476. /**
  119477. * Transform the url before loading if required.
  119478. * @param rootUrl the url of the texture
  119479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119480. * @returns the transformed texture
  119481. */
  119482. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119483. /**
  119484. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119485. * @param rootUrl the url of the texture
  119486. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119487. * @returns the fallback texture
  119488. */
  119489. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119490. /**
  119491. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119492. * @param data contains the texture data
  119493. * @param texture defines the BabylonJS internal texture
  119494. * @param createPolynomials will be true if polynomials have been requested
  119495. * @param onLoad defines the callback to trigger once the texture is ready
  119496. * @param onError defines the callback to trigger in case of error
  119497. */
  119498. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119499. /**
  119500. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119501. * @param data contains the texture data
  119502. * @param texture defines the BabylonJS internal texture
  119503. * @param callback defines the method to call once ready to upload
  119504. */
  119505. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /**
  119510. * 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.
  119511. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119512. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119513. */
  119514. export class CustomProceduralTexture extends ProceduralTexture {
  119515. private _animate;
  119516. private _time;
  119517. private _config;
  119518. private _texturePath;
  119519. /**
  119520. * Instantiates a new Custom Procedural Texture.
  119521. * 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.
  119522. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119523. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119524. * @param name Define the name of the texture
  119525. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119526. * @param size Define the size of the texture to create
  119527. * @param scene Define the scene the texture belongs to
  119528. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119529. * @param generateMipMaps Define if the texture should creates mip maps or not
  119530. */
  119531. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119532. private _loadJson;
  119533. /**
  119534. * Is the texture ready to be used ? (rendered at least once)
  119535. * @returns true if ready, otherwise, false.
  119536. */
  119537. isReady(): boolean;
  119538. /**
  119539. * Render the texture to its associated render target.
  119540. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119541. */
  119542. render(useCameraPostProcess?: boolean): void;
  119543. /**
  119544. * Update the list of dependant textures samplers in the shader.
  119545. */
  119546. updateTextures(): void;
  119547. /**
  119548. * Update the uniform values of the procedural texture in the shader.
  119549. */
  119550. updateShaderUniforms(): void;
  119551. /**
  119552. * Define if the texture animates or not.
  119553. */
  119554. animate: boolean;
  119555. }
  119556. }
  119557. declare module BABYLON {
  119558. /** @hidden */
  119559. export var noisePixelShader: {
  119560. name: string;
  119561. shader: string;
  119562. };
  119563. }
  119564. declare module BABYLON {
  119565. /**
  119566. * Class used to generate noise procedural textures
  119567. */
  119568. export class NoiseProceduralTexture extends ProceduralTexture {
  119569. private _time;
  119570. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119571. brightness: number;
  119572. /** Defines the number of octaves to process */
  119573. octaves: number;
  119574. /** Defines the level of persistence (0.8 by default) */
  119575. persistence: number;
  119576. /** Gets or sets animation speed factor (default is 1) */
  119577. animationSpeedFactor: number;
  119578. /**
  119579. * Creates a new NoiseProceduralTexture
  119580. * @param name defines the name fo the texture
  119581. * @param size defines the size of the texture (default is 256)
  119582. * @param scene defines the hosting scene
  119583. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119584. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119585. */
  119586. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119587. private _updateShaderUniforms;
  119588. protected _getDefines(): string;
  119589. /** Generate the current state of the procedural texture */
  119590. render(useCameraPostProcess?: boolean): void;
  119591. /**
  119592. * Serializes this noise procedural texture
  119593. * @returns a serialized noise procedural texture object
  119594. */
  119595. serialize(): any;
  119596. /**
  119597. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119598. * @param parsedTexture defines parsed texture data
  119599. * @param scene defines the current scene
  119600. * @param rootUrl defines the root URL containing noise procedural texture information
  119601. * @returns a parsed NoiseProceduralTexture
  119602. */
  119603. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119604. }
  119605. }
  119606. declare module BABYLON {
  119607. /**
  119608. * Raw cube texture where the raw buffers are passed in
  119609. */
  119610. export class RawCubeTexture extends CubeTexture {
  119611. /**
  119612. * Creates a cube texture where the raw buffers are passed in.
  119613. * @param scene defines the scene the texture is attached to
  119614. * @param data defines the array of data to use to create each face
  119615. * @param size defines the size of the textures
  119616. * @param format defines the format of the data
  119617. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119618. * @param generateMipMaps defines if the engine should generate the mip levels
  119619. * @param invertY defines if data must be stored with Y axis inverted
  119620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119621. * @param compression defines the compression used (null by default)
  119622. */
  119623. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119624. /**
  119625. * Updates the raw cube texture.
  119626. * @param data defines the data to store
  119627. * @param format defines the data format
  119628. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119629. * @param invertY defines if data must be stored with Y axis inverted
  119630. * @param compression defines the compression used (null by default)
  119631. * @param level defines which level of the texture to update
  119632. */
  119633. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119634. /**
  119635. * Updates a raw cube texture with RGBD encoded data.
  119636. * @param data defines the array of data [mipmap][face] to use to create each face
  119637. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119638. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119639. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119640. * @returns a promsie that resolves when the operation is complete
  119641. */
  119642. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119643. /**
  119644. * Clones the raw cube texture.
  119645. * @return a new cube texture
  119646. */
  119647. clone(): CubeTexture;
  119648. /** @hidden */
  119649. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119650. }
  119651. }
  119652. declare module BABYLON {
  119653. /**
  119654. * Class used to store 3D textures containing user data
  119655. */
  119656. export class RawTexture3D extends Texture {
  119657. /** Gets or sets the texture format to use */
  119658. format: number;
  119659. private _engine;
  119660. /**
  119661. * Create a new RawTexture3D
  119662. * @param data defines the data of the texture
  119663. * @param width defines the width of the texture
  119664. * @param height defines the height of the texture
  119665. * @param depth defines the depth of the texture
  119666. * @param format defines the texture format to use
  119667. * @param scene defines the hosting scene
  119668. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119669. * @param invertY defines if texture must be stored with Y axis inverted
  119670. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119671. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119672. */
  119673. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119674. /** Gets or sets the texture format to use */
  119675. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119676. /**
  119677. * Update the texture with new data
  119678. * @param data defines the data to store in the texture
  119679. */
  119680. update(data: ArrayBufferView): void;
  119681. }
  119682. }
  119683. declare module BABYLON {
  119684. /**
  119685. * Creates a refraction texture used by refraction channel of the standard material.
  119686. * It is like a mirror but to see through a material.
  119687. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119688. */
  119689. export class RefractionTexture extends RenderTargetTexture {
  119690. /**
  119691. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119692. * 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.
  119693. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119694. */
  119695. refractionPlane: Plane;
  119696. /**
  119697. * Define how deep under the surface we should see.
  119698. */
  119699. depth: number;
  119700. /**
  119701. * Creates a refraction texture used by refraction channel of the standard material.
  119702. * It is like a mirror but to see through a material.
  119703. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119704. * @param name Define the texture name
  119705. * @param size Define the size of the underlying texture
  119706. * @param scene Define the scene the refraction belongs to
  119707. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119708. */
  119709. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119710. /**
  119711. * Clone the refraction texture.
  119712. * @returns the cloned texture
  119713. */
  119714. clone(): RefractionTexture;
  119715. /**
  119716. * Serialize the texture to a JSON representation you could use in Parse later on
  119717. * @returns the serialized JSON representation
  119718. */
  119719. serialize(): any;
  119720. }
  119721. }
  119722. declare module BABYLON {
  119723. /**
  119724. * Defines the options related to the creation of an HtmlElementTexture
  119725. */
  119726. export interface IHtmlElementTextureOptions {
  119727. /**
  119728. * Defines wether mip maps should be created or not.
  119729. */
  119730. generateMipMaps?: boolean;
  119731. /**
  119732. * Defines the sampling mode of the texture.
  119733. */
  119734. samplingMode?: number;
  119735. /**
  119736. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119737. */
  119738. engine: Nullable<ThinEngine>;
  119739. /**
  119740. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119741. */
  119742. scene: Nullable<Scene>;
  119743. }
  119744. /**
  119745. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119746. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119747. * is automatically managed.
  119748. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119749. * in your application.
  119750. *
  119751. * As the update is not automatic, you need to call them manually.
  119752. */
  119753. export class HtmlElementTexture extends BaseTexture {
  119754. /**
  119755. * The texture URL.
  119756. */
  119757. element: HTMLVideoElement | HTMLCanvasElement;
  119758. private static readonly DefaultOptions;
  119759. private _textureMatrix;
  119760. private _engine;
  119761. private _isVideo;
  119762. private _generateMipMaps;
  119763. private _samplingMode;
  119764. /**
  119765. * Instantiates a HtmlElementTexture from the following parameters.
  119766. *
  119767. * @param name Defines the name of the texture
  119768. * @param element Defines the video or canvas the texture is filled with
  119769. * @param options Defines the other none mandatory texture creation options
  119770. */
  119771. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119772. private _createInternalTexture;
  119773. /**
  119774. * Returns the texture matrix used in most of the material.
  119775. */
  119776. getTextureMatrix(): Matrix;
  119777. /**
  119778. * Updates the content of the texture.
  119779. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119780. */
  119781. update(invertY?: Nullable<boolean>): void;
  119782. }
  119783. }
  119784. declare module BABYLON {
  119785. /**
  119786. * Enum used to define the target of a block
  119787. */
  119788. export enum NodeMaterialBlockTargets {
  119789. /** Vertex shader */
  119790. Vertex = 1,
  119791. /** Fragment shader */
  119792. Fragment = 2,
  119793. /** Neutral */
  119794. Neutral = 4,
  119795. /** Vertex and Fragment */
  119796. VertexAndFragment = 3
  119797. }
  119798. }
  119799. declare module BABYLON {
  119800. /**
  119801. * Defines the kind of connection point for node based material
  119802. */
  119803. export enum NodeMaterialBlockConnectionPointTypes {
  119804. /** Float */
  119805. Float = 1,
  119806. /** Int */
  119807. Int = 2,
  119808. /** Vector2 */
  119809. Vector2 = 4,
  119810. /** Vector3 */
  119811. Vector3 = 8,
  119812. /** Vector4 */
  119813. Vector4 = 16,
  119814. /** Color3 */
  119815. Color3 = 32,
  119816. /** Color4 */
  119817. Color4 = 64,
  119818. /** Matrix */
  119819. Matrix = 128,
  119820. /** Detect type based on connection */
  119821. AutoDetect = 1024,
  119822. /** Output type that will be defined by input type */
  119823. BasedOnInput = 2048
  119824. }
  119825. }
  119826. declare module BABYLON {
  119827. /**
  119828. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119829. */
  119830. export enum NodeMaterialBlockConnectionPointMode {
  119831. /** Value is an uniform */
  119832. Uniform = 0,
  119833. /** Value is a mesh attribute */
  119834. Attribute = 1,
  119835. /** Value is a varying between vertex and fragment shaders */
  119836. Varying = 2,
  119837. /** Mode is undefined */
  119838. Undefined = 3
  119839. }
  119840. }
  119841. declare module BABYLON {
  119842. /**
  119843. * Enum used to define system values e.g. values automatically provided by the system
  119844. */
  119845. export enum NodeMaterialSystemValues {
  119846. /** World */
  119847. World = 1,
  119848. /** View */
  119849. View = 2,
  119850. /** Projection */
  119851. Projection = 3,
  119852. /** ViewProjection */
  119853. ViewProjection = 4,
  119854. /** WorldView */
  119855. WorldView = 5,
  119856. /** WorldViewProjection */
  119857. WorldViewProjection = 6,
  119858. /** CameraPosition */
  119859. CameraPosition = 7,
  119860. /** Fog Color */
  119861. FogColor = 8,
  119862. /** Delta time */
  119863. DeltaTime = 9
  119864. }
  119865. }
  119866. declare module BABYLON {
  119867. /**
  119868. * Root class for all node material optimizers
  119869. */
  119870. export class NodeMaterialOptimizer {
  119871. /**
  119872. * Function used to optimize a NodeMaterial graph
  119873. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119874. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119875. */
  119876. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119877. }
  119878. }
  119879. declare module BABYLON {
  119880. /**
  119881. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119882. */
  119883. export class TransformBlock extends NodeMaterialBlock {
  119884. /**
  119885. * Defines the value to use to complement W value to transform it to a Vector4
  119886. */
  119887. complementW: number;
  119888. /**
  119889. * Defines the value to use to complement z value to transform it to a Vector4
  119890. */
  119891. complementZ: number;
  119892. /**
  119893. * Creates a new TransformBlock
  119894. * @param name defines the block name
  119895. */
  119896. constructor(name: string);
  119897. /**
  119898. * Gets the current class name
  119899. * @returns the class name
  119900. */
  119901. getClassName(): string;
  119902. /**
  119903. * Gets the vector input
  119904. */
  119905. readonly vector: NodeMaterialConnectionPoint;
  119906. /**
  119907. * Gets the output component
  119908. */
  119909. readonly output: NodeMaterialConnectionPoint;
  119910. /**
  119911. * Gets the matrix transform input
  119912. */
  119913. readonly transform: NodeMaterialConnectionPoint;
  119914. protected _buildBlock(state: NodeMaterialBuildState): this;
  119915. serialize(): any;
  119916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119917. protected _dumpPropertiesCode(): string;
  119918. }
  119919. }
  119920. declare module BABYLON {
  119921. /**
  119922. * Block used to output the vertex position
  119923. */
  119924. export class VertexOutputBlock extends NodeMaterialBlock {
  119925. /**
  119926. * Creates a new VertexOutputBlock
  119927. * @param name defines the block name
  119928. */
  119929. constructor(name: string);
  119930. /**
  119931. * Gets the current class name
  119932. * @returns the class name
  119933. */
  119934. getClassName(): string;
  119935. /**
  119936. * Gets the vector input component
  119937. */
  119938. readonly vector: NodeMaterialConnectionPoint;
  119939. protected _buildBlock(state: NodeMaterialBuildState): this;
  119940. }
  119941. }
  119942. declare module BABYLON {
  119943. /**
  119944. * Block used to output the final color
  119945. */
  119946. export class FragmentOutputBlock extends NodeMaterialBlock {
  119947. /**
  119948. * Create a new FragmentOutputBlock
  119949. * @param name defines the block name
  119950. */
  119951. constructor(name: string);
  119952. /**
  119953. * Gets the current class name
  119954. * @returns the class name
  119955. */
  119956. getClassName(): string;
  119957. /**
  119958. * Gets the rgba input component
  119959. */
  119960. readonly rgba: NodeMaterialConnectionPoint;
  119961. /**
  119962. * Gets the rgb input component
  119963. */
  119964. readonly rgb: NodeMaterialConnectionPoint;
  119965. /**
  119966. * Gets the a input component
  119967. */
  119968. readonly a: NodeMaterialConnectionPoint;
  119969. protected _buildBlock(state: NodeMaterialBuildState): this;
  119970. }
  119971. }
  119972. declare module BABYLON {
  119973. /**
  119974. * Block used to read a reflection texture from a sampler
  119975. */
  119976. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119977. private _define3DName;
  119978. private _defineCubicName;
  119979. private _defineExplicitName;
  119980. private _defineProjectionName;
  119981. private _defineLocalCubicName;
  119982. private _defineSphericalName;
  119983. private _definePlanarName;
  119984. private _defineEquirectangularName;
  119985. private _defineMirroredEquirectangularFixedName;
  119986. private _defineEquirectangularFixedName;
  119987. private _defineSkyboxName;
  119988. private _cubeSamplerName;
  119989. private _2DSamplerName;
  119990. private _positionUVWName;
  119991. private _directionWName;
  119992. private _reflectionCoordsName;
  119993. private _reflection2DCoordsName;
  119994. private _reflectionColorName;
  119995. private _reflectionMatrixName;
  119996. /**
  119997. * Gets or sets the texture associated with the node
  119998. */
  119999. texture: Nullable<BaseTexture>;
  120000. /**
  120001. * Create a new TextureBlock
  120002. * @param name defines the block name
  120003. */
  120004. constructor(name: string);
  120005. /**
  120006. * Gets the current class name
  120007. * @returns the class name
  120008. */
  120009. getClassName(): string;
  120010. /**
  120011. * Gets the world position input component
  120012. */
  120013. readonly position: NodeMaterialConnectionPoint;
  120014. /**
  120015. * Gets the world position input component
  120016. */
  120017. readonly worldPosition: NodeMaterialConnectionPoint;
  120018. /**
  120019. * Gets the world normal input component
  120020. */
  120021. readonly worldNormal: NodeMaterialConnectionPoint;
  120022. /**
  120023. * Gets the world input component
  120024. */
  120025. readonly world: NodeMaterialConnectionPoint;
  120026. /**
  120027. * Gets the camera (or eye) position component
  120028. */
  120029. readonly cameraPosition: NodeMaterialConnectionPoint;
  120030. /**
  120031. * Gets the view input component
  120032. */
  120033. readonly view: NodeMaterialConnectionPoint;
  120034. /**
  120035. * Gets the rgb output component
  120036. */
  120037. readonly rgb: NodeMaterialConnectionPoint;
  120038. /**
  120039. * Gets the r output component
  120040. */
  120041. readonly r: NodeMaterialConnectionPoint;
  120042. /**
  120043. * Gets the g output component
  120044. */
  120045. readonly g: NodeMaterialConnectionPoint;
  120046. /**
  120047. * Gets the b output component
  120048. */
  120049. readonly b: NodeMaterialConnectionPoint;
  120050. autoConfigure(material: NodeMaterial): void;
  120051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120052. isReady(): boolean;
  120053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120054. private _injectVertexCode;
  120055. private _writeOutput;
  120056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120057. serialize(): any;
  120058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120059. }
  120060. }
  120061. declare module BABYLON {
  120062. /**
  120063. * Interface used to configure the node material editor
  120064. */
  120065. export interface INodeMaterialEditorOptions {
  120066. /** Define the URl to load node editor script */
  120067. editorURL?: string;
  120068. }
  120069. /** @hidden */
  120070. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120071. /** BONES */
  120072. NUM_BONE_INFLUENCERS: number;
  120073. BonesPerMesh: number;
  120074. BONETEXTURE: boolean;
  120075. /** MORPH TARGETS */
  120076. MORPHTARGETS: boolean;
  120077. MORPHTARGETS_NORMAL: boolean;
  120078. MORPHTARGETS_TANGENT: boolean;
  120079. MORPHTARGETS_UV: boolean;
  120080. NUM_MORPH_INFLUENCERS: number;
  120081. /** IMAGE PROCESSING */
  120082. IMAGEPROCESSING: boolean;
  120083. VIGNETTE: boolean;
  120084. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120085. VIGNETTEBLENDMODEOPAQUE: boolean;
  120086. TONEMAPPING: boolean;
  120087. TONEMAPPING_ACES: boolean;
  120088. CONTRAST: boolean;
  120089. EXPOSURE: boolean;
  120090. COLORCURVES: boolean;
  120091. COLORGRADING: boolean;
  120092. COLORGRADING3D: boolean;
  120093. SAMPLER3DGREENDEPTH: boolean;
  120094. SAMPLER3DBGRMAP: boolean;
  120095. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120096. /** MISC. */
  120097. BUMPDIRECTUV: number;
  120098. constructor();
  120099. setValue(name: string, value: boolean): void;
  120100. }
  120101. /**
  120102. * Class used to configure NodeMaterial
  120103. */
  120104. export interface INodeMaterialOptions {
  120105. /**
  120106. * Defines if blocks should emit comments
  120107. */
  120108. emitComments: boolean;
  120109. }
  120110. /**
  120111. * Class used to create a node based material built by assembling shader blocks
  120112. */
  120113. export class NodeMaterial extends PushMaterial {
  120114. private static _BuildIdGenerator;
  120115. private _options;
  120116. private _vertexCompilationState;
  120117. private _fragmentCompilationState;
  120118. private _sharedData;
  120119. private _buildId;
  120120. private _buildWasSuccessful;
  120121. private _cachedWorldViewMatrix;
  120122. private _cachedWorldViewProjectionMatrix;
  120123. private _optimizers;
  120124. private _animationFrame;
  120125. /** Define the URl to load node editor script */
  120126. static EditorURL: string;
  120127. private BJSNODEMATERIALEDITOR;
  120128. /** Get the inspector from bundle or global */
  120129. private _getGlobalNodeMaterialEditor;
  120130. /**
  120131. * 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)
  120132. */
  120133. ignoreAlpha: boolean;
  120134. /**
  120135. * Defines the maximum number of lights that can be used in the material
  120136. */
  120137. maxSimultaneousLights: number;
  120138. /**
  120139. * Observable raised when the material is built
  120140. */
  120141. onBuildObservable: Observable<NodeMaterial>;
  120142. /**
  120143. * Gets or sets the root nodes of the material vertex shader
  120144. */
  120145. _vertexOutputNodes: NodeMaterialBlock[];
  120146. /**
  120147. * Gets or sets the root nodes of the material fragment (pixel) shader
  120148. */
  120149. _fragmentOutputNodes: NodeMaterialBlock[];
  120150. /** Gets or sets options to control the node material overall behavior */
  120151. options: INodeMaterialOptions;
  120152. /**
  120153. * Default configuration related to image processing available in the standard Material.
  120154. */
  120155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120156. /**
  120157. * Gets the image processing configuration used either in this material.
  120158. */
  120159. /**
  120160. * Sets the Default image processing configuration used either in the this material.
  120161. *
  120162. * If sets to null, the scene one is in use.
  120163. */
  120164. imageProcessingConfiguration: ImageProcessingConfiguration;
  120165. /**
  120166. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120167. */
  120168. attachedBlocks: NodeMaterialBlock[];
  120169. /**
  120170. * Create a new node based material
  120171. * @param name defines the material name
  120172. * @param scene defines the hosting scene
  120173. * @param options defines creation option
  120174. */
  120175. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120176. /**
  120177. * Gets the current class name of the material e.g. "NodeMaterial"
  120178. * @returns the class name
  120179. */
  120180. getClassName(): string;
  120181. /**
  120182. * Keep track of the image processing observer to allow dispose and replace.
  120183. */
  120184. private _imageProcessingObserver;
  120185. /**
  120186. * Attaches a new image processing configuration to the Standard Material.
  120187. * @param configuration
  120188. */
  120189. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120190. /**
  120191. * Get a block by its name
  120192. * @param name defines the name of the block to retrieve
  120193. * @returns the required block or null if not found
  120194. */
  120195. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120196. /**
  120197. * Get a block by its name
  120198. * @param predicate defines the predicate used to find the good candidate
  120199. * @returns the required block or null if not found
  120200. */
  120201. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120202. /**
  120203. * Get an input block by its name
  120204. * @param predicate defines the predicate used to find the good candidate
  120205. * @returns the required input block or null if not found
  120206. */
  120207. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120208. /**
  120209. * Gets the list of input blocks attached to this material
  120210. * @returns an array of InputBlocks
  120211. */
  120212. getInputBlocks(): InputBlock[];
  120213. /**
  120214. * Adds a new optimizer to the list of optimizers
  120215. * @param optimizer defines the optimizers to add
  120216. * @returns the current material
  120217. */
  120218. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120219. /**
  120220. * Remove an optimizer from the list of optimizers
  120221. * @param optimizer defines the optimizers to remove
  120222. * @returns the current material
  120223. */
  120224. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120225. /**
  120226. * Add a new block to the list of output nodes
  120227. * @param node defines the node to add
  120228. * @returns the current material
  120229. */
  120230. addOutputNode(node: NodeMaterialBlock): this;
  120231. /**
  120232. * Remove a block from the list of root nodes
  120233. * @param node defines the node to remove
  120234. * @returns the current material
  120235. */
  120236. removeOutputNode(node: NodeMaterialBlock): this;
  120237. private _addVertexOutputNode;
  120238. private _removeVertexOutputNode;
  120239. private _addFragmentOutputNode;
  120240. private _removeFragmentOutputNode;
  120241. /**
  120242. * Specifies if the material will require alpha blending
  120243. * @returns a boolean specifying if alpha blending is needed
  120244. */
  120245. needAlphaBlending(): boolean;
  120246. /**
  120247. * Specifies if this material should be rendered in alpha test mode
  120248. * @returns a boolean specifying if an alpha test is needed.
  120249. */
  120250. needAlphaTesting(): boolean;
  120251. private _initializeBlock;
  120252. private _resetDualBlocks;
  120253. /**
  120254. * Build the material and generates the inner effect
  120255. * @param verbose defines if the build should log activity
  120256. */
  120257. build(verbose?: boolean): void;
  120258. /**
  120259. * Runs an otpimization phase to try to improve the shader code
  120260. */
  120261. optimize(): void;
  120262. private _prepareDefinesForAttributes;
  120263. /**
  120264. * Get if the submesh is ready to be used and all its information available.
  120265. * Child classes can use it to update shaders
  120266. * @param mesh defines the mesh to check
  120267. * @param subMesh defines which submesh to check
  120268. * @param useInstances specifies that instances should be used
  120269. * @returns a boolean indicating that the submesh is ready or not
  120270. */
  120271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120272. /**
  120273. * Get a string representing the shaders built by the current node graph
  120274. */
  120275. readonly compiledShaders: string;
  120276. /**
  120277. * Binds the world matrix to the material
  120278. * @param world defines the world transformation matrix
  120279. */
  120280. bindOnlyWorldMatrix(world: Matrix): void;
  120281. /**
  120282. * Binds the submesh to this material by preparing the effect and shader to draw
  120283. * @param world defines the world transformation matrix
  120284. * @param mesh defines the mesh containing the submesh
  120285. * @param subMesh defines the submesh to bind the material to
  120286. */
  120287. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120288. /**
  120289. * Gets the active textures from the material
  120290. * @returns an array of textures
  120291. */
  120292. getActiveTextures(): BaseTexture[];
  120293. /**
  120294. * Gets the list of texture blocks
  120295. * @returns an array of texture blocks
  120296. */
  120297. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120298. /**
  120299. * Specifies if the material uses a texture
  120300. * @param texture defines the texture to check against the material
  120301. * @returns a boolean specifying if the material uses the texture
  120302. */
  120303. hasTexture(texture: BaseTexture): boolean;
  120304. /**
  120305. * Disposes the material
  120306. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120307. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120308. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120309. */
  120310. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120311. /** Creates the node editor window. */
  120312. private _createNodeEditor;
  120313. /**
  120314. * Launch the node material editor
  120315. * @param config Define the configuration of the editor
  120316. * @return a promise fulfilled when the node editor is visible
  120317. */
  120318. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120319. /**
  120320. * Clear the current material
  120321. */
  120322. clear(): void;
  120323. /**
  120324. * Clear the current material and set it to a default state
  120325. */
  120326. setToDefault(): void;
  120327. /**
  120328. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120329. * @param url defines the url to load from
  120330. * @returns a promise that will fullfil when the material is fully loaded
  120331. */
  120332. loadAsync(url: string): Promise<unknown>;
  120333. private _gatherBlocks;
  120334. /**
  120335. * Generate a string containing the code declaration required to create an equivalent of this material
  120336. * @returns a string
  120337. */
  120338. generateCode(): string;
  120339. /**
  120340. * Serializes this material in a JSON representation
  120341. * @returns the serialized material object
  120342. */
  120343. serialize(): any;
  120344. private _restoreConnections;
  120345. /**
  120346. * Clear the current graph and load a new one from a serialization object
  120347. * @param source defines the JSON representation of the material
  120348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120349. */
  120350. loadFromSerialization(source: any, rootUrl?: string): void;
  120351. /**
  120352. * Creates a node material from parsed material data
  120353. * @param source defines the JSON representation of the material
  120354. * @param scene defines the hosting scene
  120355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120356. * @returns a new node material
  120357. */
  120358. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120359. /**
  120360. * Creates a new node material set to default basic configuration
  120361. * @param name defines the name of the material
  120362. * @param scene defines the hosting scene
  120363. * @returns a new NodeMaterial
  120364. */
  120365. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120366. }
  120367. }
  120368. declare module BABYLON {
  120369. /**
  120370. * Block used to read a texture from a sampler
  120371. */
  120372. export class TextureBlock extends NodeMaterialBlock {
  120373. private _defineName;
  120374. private _linearDefineName;
  120375. private _samplerName;
  120376. private _transformedUVName;
  120377. private _textureTransformName;
  120378. private _textureInfoName;
  120379. private _mainUVName;
  120380. private _mainUVDefineName;
  120381. /**
  120382. * Gets or sets the texture associated with the node
  120383. */
  120384. texture: Nullable<Texture>;
  120385. /**
  120386. * Create a new TextureBlock
  120387. * @param name defines the block name
  120388. */
  120389. constructor(name: string);
  120390. /**
  120391. * Gets the current class name
  120392. * @returns the class name
  120393. */
  120394. getClassName(): string;
  120395. /**
  120396. * Gets the uv input component
  120397. */
  120398. readonly uv: NodeMaterialConnectionPoint;
  120399. /**
  120400. * Gets the rgba output component
  120401. */
  120402. readonly rgba: NodeMaterialConnectionPoint;
  120403. /**
  120404. * Gets the rgb output component
  120405. */
  120406. readonly rgb: NodeMaterialConnectionPoint;
  120407. /**
  120408. * Gets the r output component
  120409. */
  120410. readonly r: NodeMaterialConnectionPoint;
  120411. /**
  120412. * Gets the g output component
  120413. */
  120414. readonly g: NodeMaterialConnectionPoint;
  120415. /**
  120416. * Gets the b output component
  120417. */
  120418. readonly b: NodeMaterialConnectionPoint;
  120419. /**
  120420. * Gets the a output component
  120421. */
  120422. readonly a: NodeMaterialConnectionPoint;
  120423. readonly target: NodeMaterialBlockTargets;
  120424. autoConfigure(material: NodeMaterial): void;
  120425. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120427. isReady(): boolean;
  120428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120429. private readonly _isMixed;
  120430. private _injectVertexCode;
  120431. private _writeOutput;
  120432. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120433. protected _dumpPropertiesCode(): string;
  120434. serialize(): any;
  120435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120436. }
  120437. }
  120438. declare module BABYLON {
  120439. /**
  120440. * Class used to store shared data between 2 NodeMaterialBuildState
  120441. */
  120442. export class NodeMaterialBuildStateSharedData {
  120443. /**
  120444. * Gets the list of emitted varyings
  120445. */
  120446. temps: string[];
  120447. /**
  120448. * Gets the list of emitted varyings
  120449. */
  120450. varyings: string[];
  120451. /**
  120452. * Gets the varying declaration string
  120453. */
  120454. varyingDeclaration: string;
  120455. /**
  120456. * Input blocks
  120457. */
  120458. inputBlocks: InputBlock[];
  120459. /**
  120460. * Input blocks
  120461. */
  120462. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120463. /**
  120464. * Bindable blocks (Blocks that need to set data to the effect)
  120465. */
  120466. bindableBlocks: NodeMaterialBlock[];
  120467. /**
  120468. * List of blocks that can provide a compilation fallback
  120469. */
  120470. blocksWithFallbacks: NodeMaterialBlock[];
  120471. /**
  120472. * List of blocks that can provide a define update
  120473. */
  120474. blocksWithDefines: NodeMaterialBlock[];
  120475. /**
  120476. * List of blocks that can provide a repeatable content
  120477. */
  120478. repeatableContentBlocks: NodeMaterialBlock[];
  120479. /**
  120480. * List of blocks that can provide a dynamic list of uniforms
  120481. */
  120482. dynamicUniformBlocks: NodeMaterialBlock[];
  120483. /**
  120484. * List of blocks that can block the isReady function for the material
  120485. */
  120486. blockingBlocks: NodeMaterialBlock[];
  120487. /**
  120488. * Gets the list of animated inputs
  120489. */
  120490. animatedInputs: InputBlock[];
  120491. /**
  120492. * Build Id used to avoid multiple recompilations
  120493. */
  120494. buildId: number;
  120495. /** List of emitted variables */
  120496. variableNames: {
  120497. [key: string]: number;
  120498. };
  120499. /** List of emitted defines */
  120500. defineNames: {
  120501. [key: string]: number;
  120502. };
  120503. /** Should emit comments? */
  120504. emitComments: boolean;
  120505. /** Emit build activity */
  120506. verbose: boolean;
  120507. /** Gets or sets the hosting scene */
  120508. scene: Scene;
  120509. /**
  120510. * Gets the compilation hints emitted at compilation time
  120511. */
  120512. hints: {
  120513. needWorldViewMatrix: boolean;
  120514. needWorldViewProjectionMatrix: boolean;
  120515. needAlphaBlending: boolean;
  120516. needAlphaTesting: boolean;
  120517. };
  120518. /**
  120519. * List of compilation checks
  120520. */
  120521. checks: {
  120522. emitVertex: boolean;
  120523. emitFragment: boolean;
  120524. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120525. };
  120526. /** Creates a new shared data */
  120527. constructor();
  120528. /**
  120529. * Emits console errors and exceptions if there is a failing check
  120530. */
  120531. emitErrors(): void;
  120532. }
  120533. }
  120534. declare module BABYLON {
  120535. /**
  120536. * Class used to store node based material build state
  120537. */
  120538. export class NodeMaterialBuildState {
  120539. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120540. supportUniformBuffers: boolean;
  120541. /**
  120542. * Gets the list of emitted attributes
  120543. */
  120544. attributes: string[];
  120545. /**
  120546. * Gets the list of emitted uniforms
  120547. */
  120548. uniforms: string[];
  120549. /**
  120550. * Gets the list of emitted constants
  120551. */
  120552. constants: string[];
  120553. /**
  120554. * Gets the list of emitted samplers
  120555. */
  120556. samplers: string[];
  120557. /**
  120558. * Gets the list of emitted functions
  120559. */
  120560. functions: {
  120561. [key: string]: string;
  120562. };
  120563. /**
  120564. * Gets the list of emitted extensions
  120565. */
  120566. extensions: {
  120567. [key: string]: string;
  120568. };
  120569. /**
  120570. * Gets the target of the compilation state
  120571. */
  120572. target: NodeMaterialBlockTargets;
  120573. /**
  120574. * Gets the list of emitted counters
  120575. */
  120576. counters: {
  120577. [key: string]: number;
  120578. };
  120579. /**
  120580. * Shared data between multiple NodeMaterialBuildState instances
  120581. */
  120582. sharedData: NodeMaterialBuildStateSharedData;
  120583. /** @hidden */
  120584. _vertexState: NodeMaterialBuildState;
  120585. /** @hidden */
  120586. _attributeDeclaration: string;
  120587. /** @hidden */
  120588. _uniformDeclaration: string;
  120589. /** @hidden */
  120590. _constantDeclaration: string;
  120591. /** @hidden */
  120592. _samplerDeclaration: string;
  120593. /** @hidden */
  120594. _varyingTransfer: string;
  120595. private _repeatableContentAnchorIndex;
  120596. /** @hidden */
  120597. _builtCompilationString: string;
  120598. /**
  120599. * Gets the emitted compilation strings
  120600. */
  120601. compilationString: string;
  120602. /**
  120603. * Finalize the compilation strings
  120604. * @param state defines the current compilation state
  120605. */
  120606. finalize(state: NodeMaterialBuildState): void;
  120607. /** @hidden */
  120608. readonly _repeatableContentAnchor: string;
  120609. /** @hidden */
  120610. _getFreeVariableName(prefix: string): string;
  120611. /** @hidden */
  120612. _getFreeDefineName(prefix: string): string;
  120613. /** @hidden */
  120614. _excludeVariableName(name: string): void;
  120615. /** @hidden */
  120616. _emit2DSampler(name: string): void;
  120617. /** @hidden */
  120618. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120619. /** @hidden */
  120620. _emitExtension(name: string, extension: string): void;
  120621. /** @hidden */
  120622. _emitFunction(name: string, code: string, comments: string): void;
  120623. /** @hidden */
  120624. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120625. replaceStrings?: {
  120626. search: RegExp;
  120627. replace: string;
  120628. }[];
  120629. repeatKey?: string;
  120630. }): string;
  120631. /** @hidden */
  120632. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120633. repeatKey?: string;
  120634. removeAttributes?: boolean;
  120635. removeUniforms?: boolean;
  120636. removeVaryings?: boolean;
  120637. removeIfDef?: boolean;
  120638. replaceStrings?: {
  120639. search: RegExp;
  120640. replace: string;
  120641. }[];
  120642. }, storeKey?: string): void;
  120643. /** @hidden */
  120644. _registerTempVariable(name: string): boolean;
  120645. /** @hidden */
  120646. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120647. /** @hidden */
  120648. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120649. /** @hidden */
  120650. _emitFloat(value: number): string;
  120651. }
  120652. }
  120653. declare module BABYLON {
  120654. /**
  120655. * Defines a block that can be used inside a node based material
  120656. */
  120657. export class NodeMaterialBlock {
  120658. private _buildId;
  120659. private _buildTarget;
  120660. private _target;
  120661. private _isFinalMerger;
  120662. private _isInput;
  120663. /** @hidden */
  120664. _codeVariableName: string;
  120665. /** @hidden */
  120666. _inputs: NodeMaterialConnectionPoint[];
  120667. /** @hidden */
  120668. _outputs: NodeMaterialConnectionPoint[];
  120669. /** @hidden */
  120670. _preparationId: number;
  120671. /**
  120672. * Gets or sets the name of the block
  120673. */
  120674. name: string;
  120675. /**
  120676. * Gets or sets the unique id of the node
  120677. */
  120678. uniqueId: number;
  120679. /**
  120680. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120681. */
  120682. readonly isFinalMerger: boolean;
  120683. /**
  120684. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120685. */
  120686. readonly isInput: boolean;
  120687. /**
  120688. * Gets or sets the build Id
  120689. */
  120690. buildId: number;
  120691. /**
  120692. * Gets or sets the target of the block
  120693. */
  120694. target: NodeMaterialBlockTargets;
  120695. /**
  120696. * Gets the list of input points
  120697. */
  120698. readonly inputs: NodeMaterialConnectionPoint[];
  120699. /** Gets the list of output points */
  120700. readonly outputs: NodeMaterialConnectionPoint[];
  120701. /**
  120702. * Find an input by its name
  120703. * @param name defines the name of the input to look for
  120704. * @returns the input or null if not found
  120705. */
  120706. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120707. /**
  120708. * Find an output by its name
  120709. * @param name defines the name of the outputto look for
  120710. * @returns the output or null if not found
  120711. */
  120712. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120713. /**
  120714. * Creates a new NodeMaterialBlock
  120715. * @param name defines the block name
  120716. * @param target defines the target of that block (Vertex by default)
  120717. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120718. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120719. */
  120720. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120721. /**
  120722. * Initialize the block and prepare the context for build
  120723. * @param state defines the state that will be used for the build
  120724. */
  120725. initialize(state: NodeMaterialBuildState): void;
  120726. /**
  120727. * Bind data to effect. Will only be called for blocks with isBindable === true
  120728. * @param effect defines the effect to bind data to
  120729. * @param nodeMaterial defines the hosting NodeMaterial
  120730. * @param mesh defines the mesh that will be rendered
  120731. */
  120732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120733. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120734. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120735. protected _writeFloat(value: number): string;
  120736. /**
  120737. * Gets the current class name e.g. "NodeMaterialBlock"
  120738. * @returns the class name
  120739. */
  120740. getClassName(): string;
  120741. /**
  120742. * Register a new input. Must be called inside a block constructor
  120743. * @param name defines the connection point name
  120744. * @param type defines the connection point type
  120745. * @param isOptional defines a boolean indicating that this input can be omitted
  120746. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120747. * @returns the current block
  120748. */
  120749. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120750. /**
  120751. * Register a new output. Must be called inside a block constructor
  120752. * @param name defines the connection point name
  120753. * @param type defines the connection point type
  120754. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120755. * @returns the current block
  120756. */
  120757. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120758. /**
  120759. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120760. * @param forOutput defines an optional connection point to check compatibility with
  120761. * @returns the first available input or null
  120762. */
  120763. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120764. /**
  120765. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120766. * @param forBlock defines an optional block to check compatibility with
  120767. * @returns the first available input or null
  120768. */
  120769. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120770. /**
  120771. * Gets the sibling of the given output
  120772. * @param current defines the current output
  120773. * @returns the next output in the list or null
  120774. */
  120775. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120776. /**
  120777. * Connect current block with another block
  120778. * @param other defines the block to connect with
  120779. * @param options define the various options to help pick the right connections
  120780. * @returns the current block
  120781. */
  120782. connectTo(other: NodeMaterialBlock, options?: {
  120783. input?: string;
  120784. output?: string;
  120785. outputSwizzle?: string;
  120786. }): this | undefined;
  120787. protected _buildBlock(state: NodeMaterialBuildState): void;
  120788. /**
  120789. * Add uniforms, samplers and uniform buffers at compilation time
  120790. * @param state defines the state to update
  120791. * @param nodeMaterial defines the node material requesting the update
  120792. * @param defines defines the material defines to update
  120793. * @param uniformBuffers defines the list of uniform buffer names
  120794. */
  120795. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  120796. /**
  120797. * Add potential fallbacks if shader compilation fails
  120798. * @param mesh defines the mesh to be rendered
  120799. * @param fallbacks defines the current prioritized list of fallbacks
  120800. */
  120801. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120802. /**
  120803. * Initialize defines for shader compilation
  120804. * @param mesh defines the mesh to be rendered
  120805. * @param nodeMaterial defines the node material requesting the update
  120806. * @param defines defines the material defines to update
  120807. * @param useInstances specifies that instances should be used
  120808. */
  120809. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120810. /**
  120811. * Update defines for shader compilation
  120812. * @param mesh defines the mesh to be rendered
  120813. * @param nodeMaterial defines the node material requesting the update
  120814. * @param defines defines the material defines to update
  120815. * @param useInstances specifies that instances should be used
  120816. */
  120817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120818. /**
  120819. * Lets the block try to connect some inputs automatically
  120820. * @param material defines the hosting NodeMaterial
  120821. */
  120822. autoConfigure(material: NodeMaterial): void;
  120823. /**
  120824. * Function called when a block is declared as repeatable content generator
  120825. * @param vertexShaderState defines the current compilation state for the vertex shader
  120826. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120827. * @param mesh defines the mesh to be rendered
  120828. * @param defines defines the material defines to update
  120829. */
  120830. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120831. /**
  120832. * Checks if the block is ready
  120833. * @param mesh defines the mesh to be rendered
  120834. * @param nodeMaterial defines the node material requesting the update
  120835. * @param defines defines the material defines to update
  120836. * @param useInstances specifies that instances should be used
  120837. * @returns true if the block is ready
  120838. */
  120839. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120840. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120841. private _processBuild;
  120842. /**
  120843. * Compile the current node and generate the shader code
  120844. * @param state defines the current compilation state (uniforms, samplers, current string)
  120845. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120846. * @returns true if already built
  120847. */
  120848. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120849. protected _inputRename(name: string): string;
  120850. protected _outputRename(name: string): string;
  120851. protected _dumpPropertiesCode(): string;
  120852. /** @hidden */
  120853. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120854. /**
  120855. * Clone the current block to a new identical block
  120856. * @param scene defines the hosting scene
  120857. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120858. * @returns a copy of the current block
  120859. */
  120860. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120861. /**
  120862. * Serializes this block in a JSON representation
  120863. * @returns the serialized block object
  120864. */
  120865. serialize(): any;
  120866. /** @hidden */
  120867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120868. }
  120869. }
  120870. declare module BABYLON {
  120871. /**
  120872. * Enum defining the type of animations supported by InputBlock
  120873. */
  120874. export enum AnimatedInputBlockTypes {
  120875. /** No animation */
  120876. None = 0,
  120877. /** Time based animation. Will only work for floats */
  120878. Time = 1
  120879. }
  120880. }
  120881. declare module BABYLON {
  120882. /**
  120883. * Block used to expose an input value
  120884. */
  120885. export class InputBlock extends NodeMaterialBlock {
  120886. private _mode;
  120887. private _associatedVariableName;
  120888. private _storedValue;
  120889. private _valueCallback;
  120890. private _type;
  120891. private _animationType;
  120892. /** Gets or set a value used to limit the range of float values */
  120893. min: number;
  120894. /** Gets or set a value used to limit the range of float values */
  120895. max: number;
  120896. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120897. matrixMode: number;
  120898. /** @hidden */
  120899. _systemValue: Nullable<NodeMaterialSystemValues>;
  120900. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120901. visibleInInspector: boolean;
  120902. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120903. isConstant: boolean;
  120904. /**
  120905. * Gets or sets the connection point type (default is float)
  120906. */
  120907. readonly type: NodeMaterialBlockConnectionPointTypes;
  120908. /**
  120909. * Creates a new InputBlock
  120910. * @param name defines the block name
  120911. * @param target defines the target of that block (Vertex by default)
  120912. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120913. */
  120914. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120915. /**
  120916. * Gets the output component
  120917. */
  120918. readonly output: NodeMaterialConnectionPoint;
  120919. /**
  120920. * Set the source of this connection point to a vertex attribute
  120921. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120922. * @returns the current connection point
  120923. */
  120924. setAsAttribute(attributeName?: string): InputBlock;
  120925. /**
  120926. * Set the source of this connection point to a system value
  120927. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120928. * @returns the current connection point
  120929. */
  120930. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120931. /**
  120932. * Gets or sets the value of that point.
  120933. * Please note that this value will be ignored if valueCallback is defined
  120934. */
  120935. value: any;
  120936. /**
  120937. * Gets or sets a callback used to get the value of that point.
  120938. * Please note that setting this value will force the connection point to ignore the value property
  120939. */
  120940. valueCallback: () => any;
  120941. /**
  120942. * Gets or sets the associated variable name in the shader
  120943. */
  120944. associatedVariableName: string;
  120945. /** Gets or sets the type of animation applied to the input */
  120946. animationType: AnimatedInputBlockTypes;
  120947. /**
  120948. * Gets a boolean indicating that this connection point not defined yet
  120949. */
  120950. readonly isUndefined: boolean;
  120951. /**
  120952. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120953. * In this case the connection point name must be the name of the uniform to use.
  120954. * Can only be set on inputs
  120955. */
  120956. isUniform: boolean;
  120957. /**
  120958. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120959. * In this case the connection point name must be the name of the attribute to use
  120960. * Can only be set on inputs
  120961. */
  120962. isAttribute: boolean;
  120963. /**
  120964. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120965. * Can only be set on exit points
  120966. */
  120967. isVarying: boolean;
  120968. /**
  120969. * Gets a boolean indicating that the current connection point is a system value
  120970. */
  120971. readonly isSystemValue: boolean;
  120972. /**
  120973. * Gets or sets the current well known value or null if not defined as a system value
  120974. */
  120975. systemValue: Nullable<NodeMaterialSystemValues>;
  120976. /**
  120977. * Gets the current class name
  120978. * @returns the class name
  120979. */
  120980. getClassName(): string;
  120981. /**
  120982. * Animate the input if animationType !== None
  120983. * @param scene defines the rendering scene
  120984. */
  120985. animate(scene: Scene): void;
  120986. private _emitDefine;
  120987. initialize(state: NodeMaterialBuildState): void;
  120988. /**
  120989. * Set the input block to its default value (based on its type)
  120990. */
  120991. setDefaultValue(): void;
  120992. private _emitConstant;
  120993. private _emit;
  120994. /** @hidden */
  120995. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120996. /** @hidden */
  120997. _transmit(effect: Effect, scene: Scene): void;
  120998. protected _buildBlock(state: NodeMaterialBuildState): void;
  120999. protected _dumpPropertiesCode(): string;
  121000. serialize(): any;
  121001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121002. }
  121003. }
  121004. declare module BABYLON {
  121005. /**
  121006. * Defines a connection point for a block
  121007. */
  121008. export class NodeMaterialConnectionPoint {
  121009. /** @hidden */
  121010. _ownerBlock: NodeMaterialBlock;
  121011. /** @hidden */
  121012. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121013. private _endpoints;
  121014. private _associatedVariableName;
  121015. /** @hidden */
  121016. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121017. /** @hidden */
  121018. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121019. private _type;
  121020. /** @hidden */
  121021. _enforceAssociatedVariableName: boolean;
  121022. /**
  121023. * Gets or sets the additional types supported by this connection point
  121024. */
  121025. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121026. /**
  121027. * Gets or sets the additional types excluded by this connection point
  121028. */
  121029. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121030. /**
  121031. * Gets or sets the associated variable name in the shader
  121032. */
  121033. associatedVariableName: string;
  121034. /**
  121035. * Gets or sets the connection point type (default is float)
  121036. */
  121037. type: NodeMaterialBlockConnectionPointTypes;
  121038. /**
  121039. * Gets or sets the connection point name
  121040. */
  121041. name: string;
  121042. /**
  121043. * Gets or sets a boolean indicating that this connection point can be omitted
  121044. */
  121045. isOptional: boolean;
  121046. /**
  121047. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121048. */
  121049. define: string;
  121050. /** Gets or sets the target of that connection point */
  121051. target: NodeMaterialBlockTargets;
  121052. /**
  121053. * Gets a boolean indicating that the current point is connected
  121054. */
  121055. readonly isConnected: boolean;
  121056. /**
  121057. * Gets a boolean indicating that the current point is connected to an input block
  121058. */
  121059. readonly isConnectedToInputBlock: boolean;
  121060. /**
  121061. * Gets a the connected input block (if any)
  121062. */
  121063. readonly connectInputBlock: Nullable<InputBlock>;
  121064. /** Get the other side of the connection (if any) */
  121065. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121066. /** Get the block that owns this connection point */
  121067. readonly ownerBlock: NodeMaterialBlock;
  121068. /** Get the block connected on the other side of this connection (if any) */
  121069. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121070. /** Get the block connected on the endpoints of this connection (if any) */
  121071. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121072. /** Gets the list of connected endpoints */
  121073. readonly endpoints: NodeMaterialConnectionPoint[];
  121074. /** Gets a boolean indicating if that output point is connected to at least one input */
  121075. readonly hasEndpoints: boolean;
  121076. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121077. readonly isConnectedInVertexShader: boolean;
  121078. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121079. readonly isConnectedInFragmentShader: boolean;
  121080. /**
  121081. * Creates a new connection point
  121082. * @param name defines the connection point name
  121083. * @param ownerBlock defines the block hosting this connection point
  121084. */
  121085. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121086. /**
  121087. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121088. * @returns the class name
  121089. */
  121090. getClassName(): string;
  121091. /**
  121092. * Gets an boolean indicating if the current point can be connected to another point
  121093. * @param connectionPoint defines the other connection point
  121094. * @returns true if the connection is possible
  121095. */
  121096. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121097. /**
  121098. * Connect this point to another connection point
  121099. * @param connectionPoint defines the other connection point
  121100. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121101. * @returns the current connection point
  121102. */
  121103. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121104. /**
  121105. * Disconnect this point from one of his endpoint
  121106. * @param endpoint defines the other connection point
  121107. * @returns the current connection point
  121108. */
  121109. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121110. /**
  121111. * Serializes this point in a JSON representation
  121112. * @returns the serialized point object
  121113. */
  121114. serialize(): any;
  121115. }
  121116. }
  121117. declare module BABYLON {
  121118. /**
  121119. * Block used to add support for vertex skinning (bones)
  121120. */
  121121. export class BonesBlock extends NodeMaterialBlock {
  121122. /**
  121123. * Creates a new BonesBlock
  121124. * @param name defines the block name
  121125. */
  121126. constructor(name: string);
  121127. /**
  121128. * Initialize the block and prepare the context for build
  121129. * @param state defines the state that will be used for the build
  121130. */
  121131. initialize(state: NodeMaterialBuildState): void;
  121132. /**
  121133. * Gets the current class name
  121134. * @returns the class name
  121135. */
  121136. getClassName(): string;
  121137. /**
  121138. * Gets the matrix indices input component
  121139. */
  121140. readonly matricesIndices: NodeMaterialConnectionPoint;
  121141. /**
  121142. * Gets the matrix weights input component
  121143. */
  121144. readonly matricesWeights: NodeMaterialConnectionPoint;
  121145. /**
  121146. * Gets the extra matrix indices input component
  121147. */
  121148. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121149. /**
  121150. * Gets the extra matrix weights input component
  121151. */
  121152. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121153. /**
  121154. * Gets the world input component
  121155. */
  121156. readonly world: NodeMaterialConnectionPoint;
  121157. /**
  121158. * Gets the output component
  121159. */
  121160. readonly output: NodeMaterialConnectionPoint;
  121161. autoConfigure(material: NodeMaterial): void;
  121162. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121165. protected _buildBlock(state: NodeMaterialBuildState): this;
  121166. }
  121167. }
  121168. declare module BABYLON {
  121169. /**
  121170. * Block used to add support for instances
  121171. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121172. */
  121173. export class InstancesBlock extends NodeMaterialBlock {
  121174. /**
  121175. * Creates a new InstancesBlock
  121176. * @param name defines the block name
  121177. */
  121178. constructor(name: string);
  121179. /**
  121180. * Gets the current class name
  121181. * @returns the class name
  121182. */
  121183. getClassName(): string;
  121184. /**
  121185. * Gets the first world row input component
  121186. */
  121187. readonly world0: NodeMaterialConnectionPoint;
  121188. /**
  121189. * Gets the second world row input component
  121190. */
  121191. readonly world1: NodeMaterialConnectionPoint;
  121192. /**
  121193. * Gets the third world row input component
  121194. */
  121195. readonly world2: NodeMaterialConnectionPoint;
  121196. /**
  121197. * Gets the forth world row input component
  121198. */
  121199. readonly world3: NodeMaterialConnectionPoint;
  121200. /**
  121201. * Gets the world input component
  121202. */
  121203. readonly world: NodeMaterialConnectionPoint;
  121204. /**
  121205. * Gets the output component
  121206. */
  121207. readonly output: NodeMaterialConnectionPoint;
  121208. autoConfigure(material: NodeMaterial): void;
  121209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121210. protected _buildBlock(state: NodeMaterialBuildState): this;
  121211. }
  121212. }
  121213. declare module BABYLON {
  121214. /**
  121215. * Block used to add morph targets support to vertex shader
  121216. */
  121217. export class MorphTargetsBlock extends NodeMaterialBlock {
  121218. private _repeatableContentAnchor;
  121219. private _repeatebleContentGenerated;
  121220. /**
  121221. * Create a new MorphTargetsBlock
  121222. * @param name defines the block name
  121223. */
  121224. constructor(name: string);
  121225. /**
  121226. * Gets the current class name
  121227. * @returns the class name
  121228. */
  121229. getClassName(): string;
  121230. /**
  121231. * Gets the position input component
  121232. */
  121233. readonly position: NodeMaterialConnectionPoint;
  121234. /**
  121235. * Gets the normal input component
  121236. */
  121237. readonly normal: NodeMaterialConnectionPoint;
  121238. /**
  121239. * Gets the tangent input component
  121240. */
  121241. readonly tangent: NodeMaterialConnectionPoint;
  121242. /**
  121243. * Gets the tangent input component
  121244. */
  121245. readonly uv: NodeMaterialConnectionPoint;
  121246. /**
  121247. * Gets the position output component
  121248. */
  121249. readonly positionOutput: NodeMaterialConnectionPoint;
  121250. /**
  121251. * Gets the normal output component
  121252. */
  121253. readonly normalOutput: NodeMaterialConnectionPoint;
  121254. /**
  121255. * Gets the tangent output component
  121256. */
  121257. readonly tangentOutput: NodeMaterialConnectionPoint;
  121258. /**
  121259. * Gets the tangent output component
  121260. */
  121261. readonly uvOutput: NodeMaterialConnectionPoint;
  121262. initialize(state: NodeMaterialBuildState): void;
  121263. autoConfigure(material: NodeMaterial): void;
  121264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121266. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121267. protected _buildBlock(state: NodeMaterialBuildState): this;
  121268. }
  121269. }
  121270. declare module BABYLON {
  121271. /**
  121272. * Block used to get data information from a light
  121273. */
  121274. export class LightInformationBlock extends NodeMaterialBlock {
  121275. private _lightDataUniformName;
  121276. private _lightColorUniformName;
  121277. private _lightTypeDefineName;
  121278. /**
  121279. * Gets or sets the light associated with this block
  121280. */
  121281. light: Nullable<Light>;
  121282. /**
  121283. * Creates a new LightInformationBlock
  121284. * @param name defines the block name
  121285. */
  121286. constructor(name: string);
  121287. /**
  121288. * Gets the current class name
  121289. * @returns the class name
  121290. */
  121291. getClassName(): string;
  121292. /**
  121293. * Gets the world position input component
  121294. */
  121295. readonly worldPosition: NodeMaterialConnectionPoint;
  121296. /**
  121297. * Gets the direction output component
  121298. */
  121299. readonly direction: NodeMaterialConnectionPoint;
  121300. /**
  121301. * Gets the direction output component
  121302. */
  121303. readonly color: NodeMaterialConnectionPoint;
  121304. /**
  121305. * Gets the direction output component
  121306. */
  121307. readonly intensity: NodeMaterialConnectionPoint;
  121308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121310. protected _buildBlock(state: NodeMaterialBuildState): this;
  121311. serialize(): any;
  121312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121313. }
  121314. }
  121315. declare module BABYLON {
  121316. /**
  121317. * Block used to add image processing support to fragment shader
  121318. */
  121319. export class ImageProcessingBlock extends NodeMaterialBlock {
  121320. /**
  121321. * Create a new ImageProcessingBlock
  121322. * @param name defines the block name
  121323. */
  121324. constructor(name: string);
  121325. /**
  121326. * Gets the current class name
  121327. * @returns the class name
  121328. */
  121329. getClassName(): string;
  121330. /**
  121331. * Gets the color input component
  121332. */
  121333. readonly color: NodeMaterialConnectionPoint;
  121334. /**
  121335. * Gets the output component
  121336. */
  121337. readonly output: NodeMaterialConnectionPoint;
  121338. /**
  121339. * Initialize the block and prepare the context for build
  121340. * @param state defines the state that will be used for the build
  121341. */
  121342. initialize(state: NodeMaterialBuildState): void;
  121343. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121346. protected _buildBlock(state: NodeMaterialBuildState): this;
  121347. }
  121348. }
  121349. declare module BABYLON {
  121350. /**
  121351. * Block used to pertub normals based on a normal map
  121352. */
  121353. export class PerturbNormalBlock extends NodeMaterialBlock {
  121354. private _tangentSpaceParameterName;
  121355. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121356. invertX: boolean;
  121357. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121358. invertY: boolean;
  121359. /**
  121360. * Create a new PerturbNormalBlock
  121361. * @param name defines the block name
  121362. */
  121363. constructor(name: string);
  121364. /**
  121365. * Gets the current class name
  121366. * @returns the class name
  121367. */
  121368. getClassName(): string;
  121369. /**
  121370. * Gets the world position input component
  121371. */
  121372. readonly worldPosition: NodeMaterialConnectionPoint;
  121373. /**
  121374. * Gets the world normal input component
  121375. */
  121376. readonly worldNormal: NodeMaterialConnectionPoint;
  121377. /**
  121378. * Gets the uv input component
  121379. */
  121380. readonly uv: NodeMaterialConnectionPoint;
  121381. /**
  121382. * Gets the normal map color input component
  121383. */
  121384. readonly normalMapColor: NodeMaterialConnectionPoint;
  121385. /**
  121386. * Gets the strength input component
  121387. */
  121388. readonly strength: NodeMaterialConnectionPoint;
  121389. /**
  121390. * Gets the output component
  121391. */
  121392. readonly output: NodeMaterialConnectionPoint;
  121393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121395. autoConfigure(material: NodeMaterial): void;
  121396. protected _buildBlock(state: NodeMaterialBuildState): this;
  121397. protected _dumpPropertiesCode(): string;
  121398. serialize(): any;
  121399. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121400. }
  121401. }
  121402. declare module BABYLON {
  121403. /**
  121404. * Block used to discard a pixel if a value is smaller than a cutoff
  121405. */
  121406. export class DiscardBlock extends NodeMaterialBlock {
  121407. /**
  121408. * Create a new DiscardBlock
  121409. * @param name defines the block name
  121410. */
  121411. constructor(name: string);
  121412. /**
  121413. * Gets the current class name
  121414. * @returns the class name
  121415. */
  121416. getClassName(): string;
  121417. /**
  121418. * Gets the color input component
  121419. */
  121420. readonly value: NodeMaterialConnectionPoint;
  121421. /**
  121422. * Gets the cutoff input component
  121423. */
  121424. readonly cutoff: NodeMaterialConnectionPoint;
  121425. protected _buildBlock(state: NodeMaterialBuildState): this;
  121426. }
  121427. }
  121428. declare module BABYLON {
  121429. /**
  121430. * Block used to add support for scene fog
  121431. */
  121432. export class FogBlock extends NodeMaterialBlock {
  121433. private _fogDistanceName;
  121434. private _fogParameters;
  121435. /**
  121436. * Create a new FogBlock
  121437. * @param name defines the block name
  121438. */
  121439. constructor(name: string);
  121440. /**
  121441. * Gets the current class name
  121442. * @returns the class name
  121443. */
  121444. getClassName(): string;
  121445. /**
  121446. * Gets the world position input component
  121447. */
  121448. readonly worldPosition: NodeMaterialConnectionPoint;
  121449. /**
  121450. * Gets the view input component
  121451. */
  121452. readonly view: NodeMaterialConnectionPoint;
  121453. /**
  121454. * Gets the color input component
  121455. */
  121456. readonly input: NodeMaterialConnectionPoint;
  121457. /**
  121458. * Gets the fog color input component
  121459. */
  121460. readonly fogColor: NodeMaterialConnectionPoint;
  121461. /**
  121462. * Gets the output component
  121463. */
  121464. readonly output: NodeMaterialConnectionPoint;
  121465. autoConfigure(material: NodeMaterial): void;
  121466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121467. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121468. protected _buildBlock(state: NodeMaterialBuildState): this;
  121469. }
  121470. }
  121471. declare module BABYLON {
  121472. /**
  121473. * Block used to add light in the fragment shader
  121474. */
  121475. export class LightBlock extends NodeMaterialBlock {
  121476. private _lightId;
  121477. /**
  121478. * Gets or sets the light associated with this block
  121479. */
  121480. light: Nullable<Light>;
  121481. /**
  121482. * Create a new LightBlock
  121483. * @param name defines the block name
  121484. */
  121485. constructor(name: string);
  121486. /**
  121487. * Gets the current class name
  121488. * @returns the class name
  121489. */
  121490. getClassName(): string;
  121491. /**
  121492. * Gets the world position input component
  121493. */
  121494. readonly worldPosition: NodeMaterialConnectionPoint;
  121495. /**
  121496. * Gets the world normal input component
  121497. */
  121498. readonly worldNormal: NodeMaterialConnectionPoint;
  121499. /**
  121500. * Gets the camera (or eye) position component
  121501. */
  121502. readonly cameraPosition: NodeMaterialConnectionPoint;
  121503. /**
  121504. * Gets the glossiness component
  121505. */
  121506. readonly glossiness: NodeMaterialConnectionPoint;
  121507. /**
  121508. * Gets the glossinness power component
  121509. */
  121510. readonly glossPower: NodeMaterialConnectionPoint;
  121511. /**
  121512. * Gets the diffuse color component
  121513. */
  121514. readonly diffuseColor: NodeMaterialConnectionPoint;
  121515. /**
  121516. * Gets the specular color component
  121517. */
  121518. readonly specularColor: NodeMaterialConnectionPoint;
  121519. /**
  121520. * Gets the diffuse output component
  121521. */
  121522. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121523. /**
  121524. * Gets the specular output component
  121525. */
  121526. readonly specularOutput: NodeMaterialConnectionPoint;
  121527. autoConfigure(material: NodeMaterial): void;
  121528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121529. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121530. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121531. private _injectVertexCode;
  121532. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121533. serialize(): any;
  121534. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121535. }
  121536. }
  121537. declare module BABYLON {
  121538. /**
  121539. * Block used to multiply 2 values
  121540. */
  121541. export class MultiplyBlock extends NodeMaterialBlock {
  121542. /**
  121543. * Creates a new MultiplyBlock
  121544. * @param name defines the block name
  121545. */
  121546. constructor(name: string);
  121547. /**
  121548. * Gets the current class name
  121549. * @returns the class name
  121550. */
  121551. getClassName(): string;
  121552. /**
  121553. * Gets the left operand input component
  121554. */
  121555. readonly left: NodeMaterialConnectionPoint;
  121556. /**
  121557. * Gets the right operand input component
  121558. */
  121559. readonly right: NodeMaterialConnectionPoint;
  121560. /**
  121561. * Gets the output component
  121562. */
  121563. readonly output: NodeMaterialConnectionPoint;
  121564. protected _buildBlock(state: NodeMaterialBuildState): this;
  121565. }
  121566. }
  121567. declare module BABYLON {
  121568. /**
  121569. * Block used to add 2 vectors
  121570. */
  121571. export class AddBlock extends NodeMaterialBlock {
  121572. /**
  121573. * Creates a new AddBlock
  121574. * @param name defines the block name
  121575. */
  121576. constructor(name: string);
  121577. /**
  121578. * Gets the current class name
  121579. * @returns the class name
  121580. */
  121581. getClassName(): string;
  121582. /**
  121583. * Gets the left operand input component
  121584. */
  121585. readonly left: NodeMaterialConnectionPoint;
  121586. /**
  121587. * Gets the right operand input component
  121588. */
  121589. readonly right: NodeMaterialConnectionPoint;
  121590. /**
  121591. * Gets the output component
  121592. */
  121593. readonly output: NodeMaterialConnectionPoint;
  121594. protected _buildBlock(state: NodeMaterialBuildState): this;
  121595. }
  121596. }
  121597. declare module BABYLON {
  121598. /**
  121599. * Block used to scale a vector by a float
  121600. */
  121601. export class ScaleBlock extends NodeMaterialBlock {
  121602. /**
  121603. * Creates a new ScaleBlock
  121604. * @param name defines the block name
  121605. */
  121606. constructor(name: string);
  121607. /**
  121608. * Gets the current class name
  121609. * @returns the class name
  121610. */
  121611. getClassName(): string;
  121612. /**
  121613. * Gets the input component
  121614. */
  121615. readonly input: NodeMaterialConnectionPoint;
  121616. /**
  121617. * Gets the factor input component
  121618. */
  121619. readonly factor: NodeMaterialConnectionPoint;
  121620. /**
  121621. * Gets the output component
  121622. */
  121623. readonly output: NodeMaterialConnectionPoint;
  121624. protected _buildBlock(state: NodeMaterialBuildState): this;
  121625. }
  121626. }
  121627. declare module BABYLON {
  121628. /**
  121629. * Block used to clamp a float
  121630. */
  121631. export class ClampBlock extends NodeMaterialBlock {
  121632. /** Gets or sets the minimum range */
  121633. minimum: number;
  121634. /** Gets or sets the maximum range */
  121635. maximum: number;
  121636. /**
  121637. * Creates a new ClampBlock
  121638. * @param name defines the block name
  121639. */
  121640. constructor(name: string);
  121641. /**
  121642. * Gets the current class name
  121643. * @returns the class name
  121644. */
  121645. getClassName(): string;
  121646. /**
  121647. * Gets the value input component
  121648. */
  121649. readonly value: NodeMaterialConnectionPoint;
  121650. /**
  121651. * Gets the output component
  121652. */
  121653. readonly output: NodeMaterialConnectionPoint;
  121654. protected _buildBlock(state: NodeMaterialBuildState): this;
  121655. protected _dumpPropertiesCode(): string;
  121656. serialize(): any;
  121657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121658. }
  121659. }
  121660. declare module BABYLON {
  121661. /**
  121662. * Block used to apply a cross product between 2 vectors
  121663. */
  121664. export class CrossBlock extends NodeMaterialBlock {
  121665. /**
  121666. * Creates a new CrossBlock
  121667. * @param name defines the block name
  121668. */
  121669. constructor(name: string);
  121670. /**
  121671. * Gets the current class name
  121672. * @returns the class name
  121673. */
  121674. getClassName(): string;
  121675. /**
  121676. * Gets the left operand input component
  121677. */
  121678. readonly left: NodeMaterialConnectionPoint;
  121679. /**
  121680. * Gets the right operand input component
  121681. */
  121682. readonly right: NodeMaterialConnectionPoint;
  121683. /**
  121684. * Gets the output component
  121685. */
  121686. readonly output: NodeMaterialConnectionPoint;
  121687. protected _buildBlock(state: NodeMaterialBuildState): this;
  121688. }
  121689. }
  121690. declare module BABYLON {
  121691. /**
  121692. * Block used to apply a dot product between 2 vectors
  121693. */
  121694. export class DotBlock extends NodeMaterialBlock {
  121695. /**
  121696. * Creates a new DotBlock
  121697. * @param name defines the block name
  121698. */
  121699. constructor(name: string);
  121700. /**
  121701. * Gets the current class name
  121702. * @returns the class name
  121703. */
  121704. getClassName(): string;
  121705. /**
  121706. * Gets the left operand input component
  121707. */
  121708. readonly left: NodeMaterialConnectionPoint;
  121709. /**
  121710. * Gets the right operand input component
  121711. */
  121712. readonly right: NodeMaterialConnectionPoint;
  121713. /**
  121714. * Gets the output component
  121715. */
  121716. readonly output: NodeMaterialConnectionPoint;
  121717. protected _buildBlock(state: NodeMaterialBuildState): this;
  121718. }
  121719. }
  121720. declare module BABYLON {
  121721. /**
  121722. * Block used to remap a float from a range to a new one
  121723. */
  121724. export class RemapBlock extends NodeMaterialBlock {
  121725. /**
  121726. * Gets or sets the source range
  121727. */
  121728. sourceRange: Vector2;
  121729. /**
  121730. * Gets or sets the target range
  121731. */
  121732. targetRange: Vector2;
  121733. /**
  121734. * Creates a new RemapBlock
  121735. * @param name defines the block name
  121736. */
  121737. constructor(name: string);
  121738. /**
  121739. * Gets the current class name
  121740. * @returns the class name
  121741. */
  121742. getClassName(): string;
  121743. /**
  121744. * Gets the input component
  121745. */
  121746. readonly input: NodeMaterialConnectionPoint;
  121747. /**
  121748. * Gets the source min input component
  121749. */
  121750. readonly sourceMin: NodeMaterialConnectionPoint;
  121751. /**
  121752. * Gets the source max input component
  121753. */
  121754. readonly sourceMax: NodeMaterialConnectionPoint;
  121755. /**
  121756. * Gets the target min input component
  121757. */
  121758. readonly targetMin: NodeMaterialConnectionPoint;
  121759. /**
  121760. * Gets the target max input component
  121761. */
  121762. readonly targetMax: NodeMaterialConnectionPoint;
  121763. /**
  121764. * Gets the output component
  121765. */
  121766. readonly output: NodeMaterialConnectionPoint;
  121767. protected _buildBlock(state: NodeMaterialBuildState): this;
  121768. protected _dumpPropertiesCode(): string;
  121769. serialize(): any;
  121770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121771. }
  121772. }
  121773. declare module BABYLON {
  121774. /**
  121775. * Block used to normalize a vector
  121776. */
  121777. export class NormalizeBlock extends NodeMaterialBlock {
  121778. /**
  121779. * Creates a new NormalizeBlock
  121780. * @param name defines the block name
  121781. */
  121782. constructor(name: string);
  121783. /**
  121784. * Gets the current class name
  121785. * @returns the class name
  121786. */
  121787. getClassName(): string;
  121788. /**
  121789. * Gets the input component
  121790. */
  121791. readonly input: NodeMaterialConnectionPoint;
  121792. /**
  121793. * Gets the output component
  121794. */
  121795. readonly output: NodeMaterialConnectionPoint;
  121796. protected _buildBlock(state: NodeMaterialBuildState): this;
  121797. }
  121798. }
  121799. declare module BABYLON {
  121800. /**
  121801. * Operations supported by the Trigonometry block
  121802. */
  121803. export enum TrigonometryBlockOperations {
  121804. /** Cos */
  121805. Cos = 0,
  121806. /** Sin */
  121807. Sin = 1,
  121808. /** Abs */
  121809. Abs = 2,
  121810. /** Exp */
  121811. Exp = 3,
  121812. /** Exp2 */
  121813. Exp2 = 4,
  121814. /** Round */
  121815. Round = 5,
  121816. /** Floor */
  121817. Floor = 6,
  121818. /** Ceiling */
  121819. Ceiling = 7,
  121820. /** Square root */
  121821. Sqrt = 8,
  121822. /** Log */
  121823. Log = 9,
  121824. /** Tangent */
  121825. Tan = 10,
  121826. /** Arc tangent */
  121827. ArcTan = 11,
  121828. /** Arc cosinus */
  121829. ArcCos = 12,
  121830. /** Arc sinus */
  121831. ArcSin = 13,
  121832. /** Fraction */
  121833. Fract = 14,
  121834. /** Sign */
  121835. Sign = 15,
  121836. /** To radians (from degrees) */
  121837. Radians = 16,
  121838. /** To degrees (from radians) */
  121839. Degrees = 17
  121840. }
  121841. /**
  121842. * Block used to apply trigonometry operation to floats
  121843. */
  121844. export class TrigonometryBlock extends NodeMaterialBlock {
  121845. /**
  121846. * Gets or sets the operation applied by the block
  121847. */
  121848. operation: TrigonometryBlockOperations;
  121849. /**
  121850. * Creates a new TrigonometryBlock
  121851. * @param name defines the block name
  121852. */
  121853. constructor(name: string);
  121854. /**
  121855. * Gets the current class name
  121856. * @returns the class name
  121857. */
  121858. getClassName(): string;
  121859. /**
  121860. * Gets the input component
  121861. */
  121862. readonly input: NodeMaterialConnectionPoint;
  121863. /**
  121864. * Gets the output component
  121865. */
  121866. readonly output: NodeMaterialConnectionPoint;
  121867. protected _buildBlock(state: NodeMaterialBuildState): this;
  121868. serialize(): any;
  121869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121870. }
  121871. }
  121872. declare module BABYLON {
  121873. /**
  121874. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121875. */
  121876. export class ColorMergerBlock extends NodeMaterialBlock {
  121877. /**
  121878. * Create a new ColorMergerBlock
  121879. * @param name defines the block name
  121880. */
  121881. constructor(name: string);
  121882. /**
  121883. * Gets the current class name
  121884. * @returns the class name
  121885. */
  121886. getClassName(): string;
  121887. /**
  121888. * Gets the r component (input)
  121889. */
  121890. readonly r: NodeMaterialConnectionPoint;
  121891. /**
  121892. * Gets the g component (input)
  121893. */
  121894. readonly g: NodeMaterialConnectionPoint;
  121895. /**
  121896. * Gets the b component (input)
  121897. */
  121898. readonly b: NodeMaterialConnectionPoint;
  121899. /**
  121900. * Gets the a component (input)
  121901. */
  121902. readonly a: NodeMaterialConnectionPoint;
  121903. /**
  121904. * Gets the rgba component (output)
  121905. */
  121906. readonly rgba: NodeMaterialConnectionPoint;
  121907. /**
  121908. * Gets the rgb component (output)
  121909. */
  121910. readonly rgb: NodeMaterialConnectionPoint;
  121911. protected _buildBlock(state: NodeMaterialBuildState): this;
  121912. }
  121913. }
  121914. declare module BABYLON {
  121915. /**
  121916. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121917. */
  121918. export class VectorMergerBlock extends NodeMaterialBlock {
  121919. /**
  121920. * Create a new VectorMergerBlock
  121921. * @param name defines the block name
  121922. */
  121923. constructor(name: string);
  121924. /**
  121925. * Gets the current class name
  121926. * @returns the class name
  121927. */
  121928. getClassName(): string;
  121929. /**
  121930. * Gets the x component (input)
  121931. */
  121932. readonly x: NodeMaterialConnectionPoint;
  121933. /**
  121934. * Gets the y component (input)
  121935. */
  121936. readonly y: NodeMaterialConnectionPoint;
  121937. /**
  121938. * Gets the z component (input)
  121939. */
  121940. readonly z: NodeMaterialConnectionPoint;
  121941. /**
  121942. * Gets the w component (input)
  121943. */
  121944. readonly w: NodeMaterialConnectionPoint;
  121945. /**
  121946. * Gets the xyzw component (output)
  121947. */
  121948. readonly xyzw: NodeMaterialConnectionPoint;
  121949. /**
  121950. * Gets the xyz component (output)
  121951. */
  121952. readonly xyz: NodeMaterialConnectionPoint;
  121953. /**
  121954. * Gets the xy component (output)
  121955. */
  121956. readonly xy: NodeMaterialConnectionPoint;
  121957. protected _buildBlock(state: NodeMaterialBuildState): this;
  121958. }
  121959. }
  121960. declare module BABYLON {
  121961. /**
  121962. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121963. */
  121964. export class ColorSplitterBlock extends NodeMaterialBlock {
  121965. /**
  121966. * Create a new ColorSplitterBlock
  121967. * @param name defines the block name
  121968. */
  121969. constructor(name: string);
  121970. /**
  121971. * Gets the current class name
  121972. * @returns the class name
  121973. */
  121974. getClassName(): string;
  121975. /**
  121976. * Gets the rgba component (input)
  121977. */
  121978. readonly rgba: NodeMaterialConnectionPoint;
  121979. /**
  121980. * Gets the rgb component (input)
  121981. */
  121982. readonly rgbIn: NodeMaterialConnectionPoint;
  121983. /**
  121984. * Gets the rgb component (output)
  121985. */
  121986. readonly rgbOut: NodeMaterialConnectionPoint;
  121987. /**
  121988. * Gets the r component (output)
  121989. */
  121990. readonly r: NodeMaterialConnectionPoint;
  121991. /**
  121992. * Gets the g component (output)
  121993. */
  121994. readonly g: NodeMaterialConnectionPoint;
  121995. /**
  121996. * Gets the b component (output)
  121997. */
  121998. readonly b: NodeMaterialConnectionPoint;
  121999. /**
  122000. * Gets the a component (output)
  122001. */
  122002. readonly a: NodeMaterialConnectionPoint;
  122003. protected _inputRename(name: string): string;
  122004. protected _outputRename(name: string): string;
  122005. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122006. }
  122007. }
  122008. declare module BABYLON {
  122009. /**
  122010. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122011. */
  122012. export class VectorSplitterBlock extends NodeMaterialBlock {
  122013. /**
  122014. * Create a new VectorSplitterBlock
  122015. * @param name defines the block name
  122016. */
  122017. constructor(name: string);
  122018. /**
  122019. * Gets the current class name
  122020. * @returns the class name
  122021. */
  122022. getClassName(): string;
  122023. /**
  122024. * Gets the xyzw component (input)
  122025. */
  122026. readonly xyzw: NodeMaterialConnectionPoint;
  122027. /**
  122028. * Gets the xyz component (input)
  122029. */
  122030. readonly xyzIn: NodeMaterialConnectionPoint;
  122031. /**
  122032. * Gets the xy component (input)
  122033. */
  122034. readonly xyIn: NodeMaterialConnectionPoint;
  122035. /**
  122036. * Gets the xyz component (output)
  122037. */
  122038. readonly xyzOut: NodeMaterialConnectionPoint;
  122039. /**
  122040. * Gets the xy component (output)
  122041. */
  122042. readonly xyOut: NodeMaterialConnectionPoint;
  122043. /**
  122044. * Gets the x component (output)
  122045. */
  122046. readonly x: NodeMaterialConnectionPoint;
  122047. /**
  122048. * Gets the y component (output)
  122049. */
  122050. readonly y: NodeMaterialConnectionPoint;
  122051. /**
  122052. * Gets the z component (output)
  122053. */
  122054. readonly z: NodeMaterialConnectionPoint;
  122055. /**
  122056. * Gets the w component (output)
  122057. */
  122058. readonly w: NodeMaterialConnectionPoint;
  122059. protected _inputRename(name: string): string;
  122060. protected _outputRename(name: string): string;
  122061. protected _buildBlock(state: NodeMaterialBuildState): this;
  122062. }
  122063. }
  122064. declare module BABYLON {
  122065. /**
  122066. * Block used to lerp between 2 values
  122067. */
  122068. export class LerpBlock extends NodeMaterialBlock {
  122069. /**
  122070. * Creates a new LerpBlock
  122071. * @param name defines the block name
  122072. */
  122073. constructor(name: string);
  122074. /**
  122075. * Gets the current class name
  122076. * @returns the class name
  122077. */
  122078. getClassName(): string;
  122079. /**
  122080. * Gets the left operand input component
  122081. */
  122082. readonly left: NodeMaterialConnectionPoint;
  122083. /**
  122084. * Gets the right operand input component
  122085. */
  122086. readonly right: NodeMaterialConnectionPoint;
  122087. /**
  122088. * Gets the gradient operand input component
  122089. */
  122090. readonly gradient: NodeMaterialConnectionPoint;
  122091. /**
  122092. * Gets the output component
  122093. */
  122094. readonly output: NodeMaterialConnectionPoint;
  122095. protected _buildBlock(state: NodeMaterialBuildState): this;
  122096. }
  122097. }
  122098. declare module BABYLON {
  122099. /**
  122100. * Block used to divide 2 vectors
  122101. */
  122102. export class DivideBlock extends NodeMaterialBlock {
  122103. /**
  122104. * Creates a new DivideBlock
  122105. * @param name defines the block name
  122106. */
  122107. constructor(name: string);
  122108. /**
  122109. * Gets the current class name
  122110. * @returns the class name
  122111. */
  122112. getClassName(): string;
  122113. /**
  122114. * Gets the left operand input component
  122115. */
  122116. readonly left: NodeMaterialConnectionPoint;
  122117. /**
  122118. * Gets the right operand input component
  122119. */
  122120. readonly right: NodeMaterialConnectionPoint;
  122121. /**
  122122. * Gets the output component
  122123. */
  122124. readonly output: NodeMaterialConnectionPoint;
  122125. protected _buildBlock(state: NodeMaterialBuildState): this;
  122126. }
  122127. }
  122128. declare module BABYLON {
  122129. /**
  122130. * Block used to subtract 2 vectors
  122131. */
  122132. export class SubtractBlock extends NodeMaterialBlock {
  122133. /**
  122134. * Creates a new SubtractBlock
  122135. * @param name defines the block name
  122136. */
  122137. constructor(name: string);
  122138. /**
  122139. * Gets the current class name
  122140. * @returns the class name
  122141. */
  122142. getClassName(): string;
  122143. /**
  122144. * Gets the left operand input component
  122145. */
  122146. readonly left: NodeMaterialConnectionPoint;
  122147. /**
  122148. * Gets the right operand input component
  122149. */
  122150. readonly right: NodeMaterialConnectionPoint;
  122151. /**
  122152. * Gets the output component
  122153. */
  122154. readonly output: NodeMaterialConnectionPoint;
  122155. protected _buildBlock(state: NodeMaterialBuildState): this;
  122156. }
  122157. }
  122158. declare module BABYLON {
  122159. /**
  122160. * Block used to step a value
  122161. */
  122162. export class StepBlock extends NodeMaterialBlock {
  122163. /**
  122164. * Creates a new StepBlock
  122165. * @param name defines the block name
  122166. */
  122167. constructor(name: string);
  122168. /**
  122169. * Gets the current class name
  122170. * @returns the class name
  122171. */
  122172. getClassName(): string;
  122173. /**
  122174. * Gets the value operand input component
  122175. */
  122176. readonly value: NodeMaterialConnectionPoint;
  122177. /**
  122178. * Gets the edge operand input component
  122179. */
  122180. readonly edge: NodeMaterialConnectionPoint;
  122181. /**
  122182. * Gets the output component
  122183. */
  122184. readonly output: NodeMaterialConnectionPoint;
  122185. protected _buildBlock(state: NodeMaterialBuildState): this;
  122186. }
  122187. }
  122188. declare module BABYLON {
  122189. /**
  122190. * Block used to get the opposite (1 - x) of a value
  122191. */
  122192. export class OneMinusBlock extends NodeMaterialBlock {
  122193. /**
  122194. * Creates a new OneMinusBlock
  122195. * @param name defines the block name
  122196. */
  122197. constructor(name: string);
  122198. /**
  122199. * Gets the current class name
  122200. * @returns the class name
  122201. */
  122202. getClassName(): string;
  122203. /**
  122204. * Gets the input component
  122205. */
  122206. readonly input: NodeMaterialConnectionPoint;
  122207. /**
  122208. * Gets the output component
  122209. */
  122210. readonly output: NodeMaterialConnectionPoint;
  122211. protected _buildBlock(state: NodeMaterialBuildState): this;
  122212. }
  122213. }
  122214. declare module BABYLON {
  122215. /**
  122216. * Block used to get the view direction
  122217. */
  122218. export class ViewDirectionBlock extends NodeMaterialBlock {
  122219. /**
  122220. * Creates a new ViewDirectionBlock
  122221. * @param name defines the block name
  122222. */
  122223. constructor(name: string);
  122224. /**
  122225. * Gets the current class name
  122226. * @returns the class name
  122227. */
  122228. getClassName(): string;
  122229. /**
  122230. * Gets the world position component
  122231. */
  122232. readonly worldPosition: NodeMaterialConnectionPoint;
  122233. /**
  122234. * Gets the camera position component
  122235. */
  122236. readonly cameraPosition: NodeMaterialConnectionPoint;
  122237. /**
  122238. * Gets the output component
  122239. */
  122240. readonly output: NodeMaterialConnectionPoint;
  122241. autoConfigure(material: NodeMaterial): void;
  122242. protected _buildBlock(state: NodeMaterialBuildState): this;
  122243. }
  122244. }
  122245. declare module BABYLON {
  122246. /**
  122247. * Block used to compute fresnel value
  122248. */
  122249. export class FresnelBlock extends NodeMaterialBlock {
  122250. /**
  122251. * Create a new FresnelBlock
  122252. * @param name defines the block name
  122253. */
  122254. constructor(name: string);
  122255. /**
  122256. * Gets the current class name
  122257. * @returns the class name
  122258. */
  122259. getClassName(): string;
  122260. /**
  122261. * Gets the world normal input component
  122262. */
  122263. readonly worldNormal: NodeMaterialConnectionPoint;
  122264. /**
  122265. * Gets the view direction input component
  122266. */
  122267. readonly viewDirection: NodeMaterialConnectionPoint;
  122268. /**
  122269. * Gets the bias input component
  122270. */
  122271. readonly bias: NodeMaterialConnectionPoint;
  122272. /**
  122273. * Gets the camera (or eye) position component
  122274. */
  122275. readonly power: NodeMaterialConnectionPoint;
  122276. /**
  122277. * Gets the fresnel output component
  122278. */
  122279. readonly fresnel: NodeMaterialConnectionPoint;
  122280. autoConfigure(material: NodeMaterial): void;
  122281. protected _buildBlock(state: NodeMaterialBuildState): this;
  122282. }
  122283. }
  122284. declare module BABYLON {
  122285. /**
  122286. * Block used to get the max of 2 values
  122287. */
  122288. export class MaxBlock extends NodeMaterialBlock {
  122289. /**
  122290. * Creates a new MaxBlock
  122291. * @param name defines the block name
  122292. */
  122293. constructor(name: string);
  122294. /**
  122295. * Gets the current class name
  122296. * @returns the class name
  122297. */
  122298. getClassName(): string;
  122299. /**
  122300. * Gets the left operand input component
  122301. */
  122302. readonly left: NodeMaterialConnectionPoint;
  122303. /**
  122304. * Gets the right operand input component
  122305. */
  122306. readonly right: NodeMaterialConnectionPoint;
  122307. /**
  122308. * Gets the output component
  122309. */
  122310. readonly output: NodeMaterialConnectionPoint;
  122311. protected _buildBlock(state: NodeMaterialBuildState): this;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /**
  122316. * Block used to get the min of 2 values
  122317. */
  122318. export class MinBlock extends NodeMaterialBlock {
  122319. /**
  122320. * Creates a new MinBlock
  122321. * @param name defines the block name
  122322. */
  122323. constructor(name: string);
  122324. /**
  122325. * Gets the current class name
  122326. * @returns the class name
  122327. */
  122328. getClassName(): string;
  122329. /**
  122330. * Gets the left operand input component
  122331. */
  122332. readonly left: NodeMaterialConnectionPoint;
  122333. /**
  122334. * Gets the right operand input component
  122335. */
  122336. readonly right: NodeMaterialConnectionPoint;
  122337. /**
  122338. * Gets the output component
  122339. */
  122340. readonly output: NodeMaterialConnectionPoint;
  122341. protected _buildBlock(state: NodeMaterialBuildState): this;
  122342. }
  122343. }
  122344. declare module BABYLON {
  122345. /**
  122346. * Block used to get the distance between 2 values
  122347. */
  122348. export class DistanceBlock extends NodeMaterialBlock {
  122349. /**
  122350. * Creates a new DistanceBlock
  122351. * @param name defines the block name
  122352. */
  122353. constructor(name: string);
  122354. /**
  122355. * Gets the current class name
  122356. * @returns the class name
  122357. */
  122358. getClassName(): string;
  122359. /**
  122360. * Gets the left operand input component
  122361. */
  122362. readonly left: NodeMaterialConnectionPoint;
  122363. /**
  122364. * Gets the right operand input component
  122365. */
  122366. readonly right: NodeMaterialConnectionPoint;
  122367. /**
  122368. * Gets the output component
  122369. */
  122370. readonly output: NodeMaterialConnectionPoint;
  122371. protected _buildBlock(state: NodeMaterialBuildState): this;
  122372. }
  122373. }
  122374. declare module BABYLON {
  122375. /**
  122376. * Block used to get the length of a vector
  122377. */
  122378. export class LengthBlock extends NodeMaterialBlock {
  122379. /**
  122380. * Creates a new LengthBlock
  122381. * @param name defines the block name
  122382. */
  122383. constructor(name: string);
  122384. /**
  122385. * Gets the current class name
  122386. * @returns the class name
  122387. */
  122388. getClassName(): string;
  122389. /**
  122390. * Gets the value input component
  122391. */
  122392. readonly value: NodeMaterialConnectionPoint;
  122393. /**
  122394. * Gets the output component
  122395. */
  122396. readonly output: NodeMaterialConnectionPoint;
  122397. protected _buildBlock(state: NodeMaterialBuildState): this;
  122398. }
  122399. }
  122400. declare module BABYLON {
  122401. /**
  122402. * Block used to get negative version of a value (i.e. x * -1)
  122403. */
  122404. export class NegateBlock extends NodeMaterialBlock {
  122405. /**
  122406. * Creates a new NegateBlock
  122407. * @param name defines the block name
  122408. */
  122409. constructor(name: string);
  122410. /**
  122411. * Gets the current class name
  122412. * @returns the class name
  122413. */
  122414. getClassName(): string;
  122415. /**
  122416. * Gets the value input component
  122417. */
  122418. readonly value: NodeMaterialConnectionPoint;
  122419. /**
  122420. * Gets the output component
  122421. */
  122422. readonly output: NodeMaterialConnectionPoint;
  122423. protected _buildBlock(state: NodeMaterialBuildState): this;
  122424. }
  122425. }
  122426. declare module BABYLON {
  122427. /**
  122428. * Block used to get the value of the first parameter raised to the power of the second
  122429. */
  122430. export class PowBlock extends NodeMaterialBlock {
  122431. /**
  122432. * Creates a new PowBlock
  122433. * @param name defines the block name
  122434. */
  122435. constructor(name: string);
  122436. /**
  122437. * Gets the current class name
  122438. * @returns the class name
  122439. */
  122440. getClassName(): string;
  122441. /**
  122442. * Gets the value operand input component
  122443. */
  122444. readonly value: NodeMaterialConnectionPoint;
  122445. /**
  122446. * Gets the power operand input component
  122447. */
  122448. readonly power: NodeMaterialConnectionPoint;
  122449. /**
  122450. * Gets the output component
  122451. */
  122452. readonly output: NodeMaterialConnectionPoint;
  122453. protected _buildBlock(state: NodeMaterialBuildState): this;
  122454. }
  122455. }
  122456. declare module BABYLON {
  122457. /**
  122458. * Block used to get a random number
  122459. */
  122460. export class RandomNumberBlock extends NodeMaterialBlock {
  122461. /**
  122462. * Creates a new RandomNumberBlock
  122463. * @param name defines the block name
  122464. */
  122465. constructor(name: string);
  122466. /**
  122467. * Gets the current class name
  122468. * @returns the class name
  122469. */
  122470. getClassName(): string;
  122471. /**
  122472. * Gets the seed input component
  122473. */
  122474. readonly seed: NodeMaterialConnectionPoint;
  122475. /**
  122476. * Gets the output component
  122477. */
  122478. readonly output: NodeMaterialConnectionPoint;
  122479. protected _buildBlock(state: NodeMaterialBuildState): this;
  122480. }
  122481. }
  122482. declare module BABYLON {
  122483. /**
  122484. * Block used to compute arc tangent of 2 values
  122485. */
  122486. export class ArcTan2Block extends NodeMaterialBlock {
  122487. /**
  122488. * Creates a new ArcTan2Block
  122489. * @param name defines the block name
  122490. */
  122491. constructor(name: string);
  122492. /**
  122493. * Gets the current class name
  122494. * @returns the class name
  122495. */
  122496. getClassName(): string;
  122497. /**
  122498. * Gets the x operand input component
  122499. */
  122500. readonly x: NodeMaterialConnectionPoint;
  122501. /**
  122502. * Gets the y operand input component
  122503. */
  122504. readonly y: NodeMaterialConnectionPoint;
  122505. /**
  122506. * Gets the output component
  122507. */
  122508. readonly output: NodeMaterialConnectionPoint;
  122509. protected _buildBlock(state: NodeMaterialBuildState): this;
  122510. }
  122511. }
  122512. declare module BABYLON {
  122513. /**
  122514. * Block used to smooth step a value
  122515. */
  122516. export class SmoothStepBlock extends NodeMaterialBlock {
  122517. /**
  122518. * Creates a new SmoothStepBlock
  122519. * @param name defines the block name
  122520. */
  122521. constructor(name: string);
  122522. /**
  122523. * Gets the current class name
  122524. * @returns the class name
  122525. */
  122526. getClassName(): string;
  122527. /**
  122528. * Gets the value operand input component
  122529. */
  122530. readonly value: NodeMaterialConnectionPoint;
  122531. /**
  122532. * Gets the first edge operand input component
  122533. */
  122534. readonly edge0: NodeMaterialConnectionPoint;
  122535. /**
  122536. * Gets the second edge operand input component
  122537. */
  122538. readonly edge1: NodeMaterialConnectionPoint;
  122539. /**
  122540. * Gets the output component
  122541. */
  122542. readonly output: NodeMaterialConnectionPoint;
  122543. protected _buildBlock(state: NodeMaterialBuildState): this;
  122544. }
  122545. }
  122546. declare module BABYLON {
  122547. /**
  122548. * Block used to get the reciprocal (1 / x) of a value
  122549. */
  122550. export class ReciprocalBlock extends NodeMaterialBlock {
  122551. /**
  122552. * Creates a new ReciprocalBlock
  122553. * @param name defines the block name
  122554. */
  122555. constructor(name: string);
  122556. /**
  122557. * Gets the current class name
  122558. * @returns the class name
  122559. */
  122560. getClassName(): string;
  122561. /**
  122562. * Gets the input component
  122563. */
  122564. readonly input: NodeMaterialConnectionPoint;
  122565. /**
  122566. * Gets the output component
  122567. */
  122568. readonly output: NodeMaterialConnectionPoint;
  122569. protected _buildBlock(state: NodeMaterialBuildState): this;
  122570. }
  122571. }
  122572. declare module BABYLON {
  122573. /**
  122574. * Block used to replace a color by another one
  122575. */
  122576. export class ReplaceColorBlock extends NodeMaterialBlock {
  122577. /**
  122578. * Creates a new ReplaceColorBlock
  122579. * @param name defines the block name
  122580. */
  122581. constructor(name: string);
  122582. /**
  122583. * Gets the current class name
  122584. * @returns the class name
  122585. */
  122586. getClassName(): string;
  122587. /**
  122588. * Gets the value input component
  122589. */
  122590. readonly value: NodeMaterialConnectionPoint;
  122591. /**
  122592. * Gets the reference input component
  122593. */
  122594. readonly reference: NodeMaterialConnectionPoint;
  122595. /**
  122596. * Gets the distance input component
  122597. */
  122598. readonly distance: NodeMaterialConnectionPoint;
  122599. /**
  122600. * Gets the replacement input component
  122601. */
  122602. readonly replacement: NodeMaterialConnectionPoint;
  122603. /**
  122604. * Gets the output component
  122605. */
  122606. readonly output: NodeMaterialConnectionPoint;
  122607. protected _buildBlock(state: NodeMaterialBuildState): this;
  122608. }
  122609. }
  122610. declare module BABYLON {
  122611. /**
  122612. * Block used to posterize a value
  122613. * @see https://en.wikipedia.org/wiki/Posterization
  122614. */
  122615. export class PosterizeBlock extends NodeMaterialBlock {
  122616. /**
  122617. * Creates a new PosterizeBlock
  122618. * @param name defines the block name
  122619. */
  122620. constructor(name: string);
  122621. /**
  122622. * Gets the current class name
  122623. * @returns the class name
  122624. */
  122625. getClassName(): string;
  122626. /**
  122627. * Gets the value input component
  122628. */
  122629. readonly value: NodeMaterialConnectionPoint;
  122630. /**
  122631. * Gets the steps input component
  122632. */
  122633. readonly steps: NodeMaterialConnectionPoint;
  122634. /**
  122635. * Gets the output component
  122636. */
  122637. readonly output: NodeMaterialConnectionPoint;
  122638. protected _buildBlock(state: NodeMaterialBuildState): this;
  122639. }
  122640. }
  122641. declare module BABYLON {
  122642. /**
  122643. * Operations supported by the Wave block
  122644. */
  122645. export enum WaveBlockKind {
  122646. /** SawTooth */
  122647. SawTooth = 0,
  122648. /** Square */
  122649. Square = 1,
  122650. /** Triangle */
  122651. Triangle = 2
  122652. }
  122653. /**
  122654. * Block used to apply wave operation to floats
  122655. */
  122656. export class WaveBlock extends NodeMaterialBlock {
  122657. /**
  122658. * Gets or sets the kibnd of wave to be applied by the block
  122659. */
  122660. kind: WaveBlockKind;
  122661. /**
  122662. * Creates a new WaveBlock
  122663. * @param name defines the block name
  122664. */
  122665. constructor(name: string);
  122666. /**
  122667. * Gets the current class name
  122668. * @returns the class name
  122669. */
  122670. getClassName(): string;
  122671. /**
  122672. * Gets the input component
  122673. */
  122674. readonly input: NodeMaterialConnectionPoint;
  122675. /**
  122676. * Gets the output component
  122677. */
  122678. readonly output: NodeMaterialConnectionPoint;
  122679. protected _buildBlock(state: NodeMaterialBuildState): this;
  122680. serialize(): any;
  122681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122682. }
  122683. }
  122684. declare module BABYLON {
  122685. /**
  122686. * Class used to store a color step for the GradientBlock
  122687. */
  122688. export class GradientBlockColorStep {
  122689. /**
  122690. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122691. */
  122692. step: number;
  122693. /**
  122694. * Gets or sets the color associated with this step
  122695. */
  122696. color: Color3;
  122697. /**
  122698. * Creates a new GradientBlockColorStep
  122699. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122700. * @param color defines the color associated with this step
  122701. */
  122702. constructor(
  122703. /**
  122704. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122705. */
  122706. step: number,
  122707. /**
  122708. * Gets or sets the color associated with this step
  122709. */
  122710. color: Color3);
  122711. }
  122712. /**
  122713. * Block used to return a color from a gradient based on an input value between 0 and 1
  122714. */
  122715. export class GradientBlock extends NodeMaterialBlock {
  122716. /**
  122717. * Gets or sets the list of color steps
  122718. */
  122719. colorSteps: GradientBlockColorStep[];
  122720. /**
  122721. * Creates a new GradientBlock
  122722. * @param name defines the block name
  122723. */
  122724. constructor(name: string);
  122725. /**
  122726. * Gets the current class name
  122727. * @returns the class name
  122728. */
  122729. getClassName(): string;
  122730. /**
  122731. * Gets the gradient input component
  122732. */
  122733. readonly gradient: NodeMaterialConnectionPoint;
  122734. /**
  122735. * Gets the output component
  122736. */
  122737. readonly output: NodeMaterialConnectionPoint;
  122738. private _writeColorConstant;
  122739. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122740. serialize(): any;
  122741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122742. protected _dumpPropertiesCode(): string;
  122743. }
  122744. }
  122745. declare module BABYLON {
  122746. /**
  122747. * Block used to normalize lerp between 2 values
  122748. */
  122749. export class NLerpBlock extends NodeMaterialBlock {
  122750. /**
  122751. * Creates a new NLerpBlock
  122752. * @param name defines the block name
  122753. */
  122754. constructor(name: string);
  122755. /**
  122756. * Gets the current class name
  122757. * @returns the class name
  122758. */
  122759. getClassName(): string;
  122760. /**
  122761. * Gets the left operand input component
  122762. */
  122763. readonly left: NodeMaterialConnectionPoint;
  122764. /**
  122765. * Gets the right operand input component
  122766. */
  122767. readonly right: NodeMaterialConnectionPoint;
  122768. /**
  122769. * Gets the gradient operand input component
  122770. */
  122771. readonly gradient: NodeMaterialConnectionPoint;
  122772. /**
  122773. * Gets the output component
  122774. */
  122775. readonly output: NodeMaterialConnectionPoint;
  122776. protected _buildBlock(state: NodeMaterialBuildState): this;
  122777. }
  122778. }
  122779. declare module BABYLON {
  122780. /**
  122781. * Effect Render Options
  122782. */
  122783. export interface IEffectRendererOptions {
  122784. /**
  122785. * Defines the vertices positions.
  122786. */
  122787. positions?: number[];
  122788. /**
  122789. * Defines the indices.
  122790. */
  122791. indices?: number[];
  122792. }
  122793. /**
  122794. * Helper class to render one or more effects
  122795. */
  122796. export class EffectRenderer {
  122797. private engine;
  122798. private static _DefaultOptions;
  122799. private _vertexBuffers;
  122800. private _indexBuffer;
  122801. private _ringBufferIndex;
  122802. private _ringScreenBuffer;
  122803. private _fullscreenViewport;
  122804. private _getNextFrameBuffer;
  122805. /**
  122806. * Creates an effect renderer
  122807. * @param engine the engine to use for rendering
  122808. * @param options defines the options of the effect renderer
  122809. */
  122810. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122811. /**
  122812. * Sets the current viewport in normalized coordinates 0-1
  122813. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122814. */
  122815. setViewport(viewport?: Viewport): void;
  122816. /**
  122817. * Binds the embedded attributes buffer to the effect.
  122818. * @param effect Defines the effect to bind the attributes for
  122819. */
  122820. bindBuffers(effect: Effect): void;
  122821. /**
  122822. * Sets the current effect wrapper to use during draw.
  122823. * The effect needs to be ready before calling this api.
  122824. * This also sets the default full screen position attribute.
  122825. * @param effectWrapper Defines the effect to draw with
  122826. */
  122827. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122828. /**
  122829. * Draws a full screen quad.
  122830. */
  122831. draw(): void;
  122832. /**
  122833. * renders one or more effects to a specified texture
  122834. * @param effectWrappers list of effects to renderer
  122835. * @param outputTexture texture to draw to, if null it will render to the screen
  122836. */
  122837. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122838. /**
  122839. * Disposes of the effect renderer
  122840. */
  122841. dispose(): void;
  122842. }
  122843. /**
  122844. * Options to create an EffectWrapper
  122845. */
  122846. interface EffectWrapperCreationOptions {
  122847. /**
  122848. * Engine to use to create the effect
  122849. */
  122850. engine: ThinEngine;
  122851. /**
  122852. * Fragment shader for the effect
  122853. */
  122854. fragmentShader: string;
  122855. /**
  122856. * Vertex shader for the effect
  122857. */
  122858. vertexShader?: string;
  122859. /**
  122860. * Attributes to use in the shader
  122861. */
  122862. attributeNames?: Array<string>;
  122863. /**
  122864. * Uniforms to use in the shader
  122865. */
  122866. uniformNames?: Array<string>;
  122867. /**
  122868. * Texture sampler names to use in the shader
  122869. */
  122870. samplerNames?: Array<string>;
  122871. /**
  122872. * The friendly name of the effect displayed in Spector.
  122873. */
  122874. name?: string;
  122875. }
  122876. /**
  122877. * Wraps an effect to be used for rendering
  122878. */
  122879. export class EffectWrapper {
  122880. /**
  122881. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122882. */
  122883. onApplyObservable: Observable<{}>;
  122884. /**
  122885. * The underlying effect
  122886. */
  122887. effect: Effect;
  122888. /**
  122889. * Creates an effect to be renderer
  122890. * @param creationOptions options to create the effect
  122891. */
  122892. constructor(creationOptions: EffectWrapperCreationOptions);
  122893. /**
  122894. * Disposes of the effect wrapper
  122895. */
  122896. dispose(): void;
  122897. }
  122898. }
  122899. declare module BABYLON {
  122900. /**
  122901. * Helper class to push actions to a pool of workers.
  122902. */
  122903. export class WorkerPool implements IDisposable {
  122904. private _workerInfos;
  122905. private _pendingActions;
  122906. /**
  122907. * Constructor
  122908. * @param workers Array of workers to use for actions
  122909. */
  122910. constructor(workers: Array<Worker>);
  122911. /**
  122912. * Terminates all workers and clears any pending actions.
  122913. */
  122914. dispose(): void;
  122915. /**
  122916. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122917. * pended until a worker has completed its action.
  122918. * @param action The action to perform. Call onComplete when the action is complete.
  122919. */
  122920. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122921. private _execute;
  122922. }
  122923. }
  122924. declare module BABYLON {
  122925. /**
  122926. * Configuration for Draco compression
  122927. */
  122928. export interface IDracoCompressionConfiguration {
  122929. /**
  122930. * Configuration for the decoder.
  122931. */
  122932. decoder: {
  122933. /**
  122934. * The url to the WebAssembly module.
  122935. */
  122936. wasmUrl?: string;
  122937. /**
  122938. * The url to the WebAssembly binary.
  122939. */
  122940. wasmBinaryUrl?: string;
  122941. /**
  122942. * The url to the fallback JavaScript module.
  122943. */
  122944. fallbackUrl?: string;
  122945. };
  122946. }
  122947. /**
  122948. * Draco compression (https://google.github.io/draco/)
  122949. *
  122950. * This class wraps the Draco module.
  122951. *
  122952. * **Encoder**
  122953. *
  122954. * The encoder is not currently implemented.
  122955. *
  122956. * **Decoder**
  122957. *
  122958. * 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.
  122959. *
  122960. * To update the configuration, use the following code:
  122961. * ```javascript
  122962. * DracoCompression.Configuration = {
  122963. * decoder: {
  122964. * wasmUrl: "<url to the WebAssembly library>",
  122965. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122966. * fallbackUrl: "<url to the fallback JavaScript library>",
  122967. * }
  122968. * };
  122969. * ```
  122970. *
  122971. * 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.
  122972. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122973. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122974. *
  122975. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122976. * ```javascript
  122977. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122978. * ```
  122979. *
  122980. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122981. */
  122982. export class DracoCompression implements IDisposable {
  122983. private _workerPoolPromise?;
  122984. private _decoderModulePromise?;
  122985. /**
  122986. * The configuration. Defaults to the following urls:
  122987. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122988. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122989. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122990. */
  122991. static Configuration: IDracoCompressionConfiguration;
  122992. /**
  122993. * Returns true if the decoder configuration is available.
  122994. */
  122995. static readonly DecoderAvailable: boolean;
  122996. /**
  122997. * Default number of workers to create when creating the draco compression object.
  122998. */
  122999. static DefaultNumWorkers: number;
  123000. private static GetDefaultNumWorkers;
  123001. private static _Default;
  123002. /**
  123003. * Default instance for the draco compression object.
  123004. */
  123005. static readonly Default: DracoCompression;
  123006. /**
  123007. * Constructor
  123008. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123009. */
  123010. constructor(numWorkers?: number);
  123011. /**
  123012. * Stop all async operations and release resources.
  123013. */
  123014. dispose(): void;
  123015. /**
  123016. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123017. * @returns a promise that resolves when ready
  123018. */
  123019. whenReadyAsync(): Promise<void>;
  123020. /**
  123021. * Decode Draco compressed mesh data to vertex data.
  123022. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123023. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123024. * @returns A promise that resolves with the decoded vertex data
  123025. */
  123026. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123027. [kind: string]: number;
  123028. }): Promise<VertexData>;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. /**
  123033. * Class for building Constructive Solid Geometry
  123034. */
  123035. export class CSG {
  123036. private polygons;
  123037. /**
  123038. * The world matrix
  123039. */
  123040. matrix: Matrix;
  123041. /**
  123042. * Stores the position
  123043. */
  123044. position: Vector3;
  123045. /**
  123046. * Stores the rotation
  123047. */
  123048. rotation: Vector3;
  123049. /**
  123050. * Stores the rotation quaternion
  123051. */
  123052. rotationQuaternion: Nullable<Quaternion>;
  123053. /**
  123054. * Stores the scaling vector
  123055. */
  123056. scaling: Vector3;
  123057. /**
  123058. * Convert the Mesh to CSG
  123059. * @param mesh The Mesh to convert to CSG
  123060. * @returns A new CSG from the Mesh
  123061. */
  123062. static FromMesh(mesh: Mesh): CSG;
  123063. /**
  123064. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123065. * @param polygons Polygons used to construct a CSG solid
  123066. */
  123067. private static FromPolygons;
  123068. /**
  123069. * Clones, or makes a deep copy, of the CSG
  123070. * @returns A new CSG
  123071. */
  123072. clone(): CSG;
  123073. /**
  123074. * Unions this CSG with another CSG
  123075. * @param csg The CSG to union against this CSG
  123076. * @returns The unioned CSG
  123077. */
  123078. union(csg: CSG): CSG;
  123079. /**
  123080. * Unions this CSG with another CSG in place
  123081. * @param csg The CSG to union against this CSG
  123082. */
  123083. unionInPlace(csg: CSG): void;
  123084. /**
  123085. * Subtracts this CSG with another CSG
  123086. * @param csg The CSG to subtract against this CSG
  123087. * @returns A new CSG
  123088. */
  123089. subtract(csg: CSG): CSG;
  123090. /**
  123091. * Subtracts this CSG with another CSG in place
  123092. * @param csg The CSG to subtact against this CSG
  123093. */
  123094. subtractInPlace(csg: CSG): void;
  123095. /**
  123096. * Intersect this CSG with another CSG
  123097. * @param csg The CSG to intersect against this CSG
  123098. * @returns A new CSG
  123099. */
  123100. intersect(csg: CSG): CSG;
  123101. /**
  123102. * Intersects this CSG with another CSG in place
  123103. * @param csg The CSG to intersect against this CSG
  123104. */
  123105. intersectInPlace(csg: CSG): void;
  123106. /**
  123107. * Return a new CSG solid with solid and empty space switched. This solid is
  123108. * not modified.
  123109. * @returns A new CSG solid with solid and empty space switched
  123110. */
  123111. inverse(): CSG;
  123112. /**
  123113. * Inverses the CSG in place
  123114. */
  123115. inverseInPlace(): void;
  123116. /**
  123117. * This is used to keep meshes transformations so they can be restored
  123118. * when we build back a Babylon Mesh
  123119. * NB : All CSG operations are performed in world coordinates
  123120. * @param csg The CSG to copy the transform attributes from
  123121. * @returns This CSG
  123122. */
  123123. copyTransformAttributes(csg: CSG): CSG;
  123124. /**
  123125. * Build Raw mesh from CSG
  123126. * Coordinates here are in world space
  123127. * @param name The name of the mesh geometry
  123128. * @param scene The Scene
  123129. * @param keepSubMeshes Specifies if the submeshes should be kept
  123130. * @returns A new Mesh
  123131. */
  123132. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123133. /**
  123134. * Build Mesh from CSG taking material and transforms into account
  123135. * @param name The name of the Mesh
  123136. * @param material The material of the Mesh
  123137. * @param scene The Scene
  123138. * @param keepSubMeshes Specifies if submeshes should be kept
  123139. * @returns The new Mesh
  123140. */
  123141. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123142. }
  123143. }
  123144. declare module BABYLON {
  123145. /**
  123146. * Class used to create a trail following a mesh
  123147. */
  123148. export class TrailMesh extends Mesh {
  123149. private _generator;
  123150. private _autoStart;
  123151. private _running;
  123152. private _diameter;
  123153. private _length;
  123154. private _sectionPolygonPointsCount;
  123155. private _sectionVectors;
  123156. private _sectionNormalVectors;
  123157. private _beforeRenderObserver;
  123158. /**
  123159. * @constructor
  123160. * @param name The value used by scene.getMeshByName() to do a lookup.
  123161. * @param generator The mesh to generate a trail.
  123162. * @param scene The scene to add this mesh to.
  123163. * @param diameter Diameter of trailing mesh. Default is 1.
  123164. * @param length Length of trailing mesh. Default is 60.
  123165. * @param autoStart Automatically start trailing mesh. Default true.
  123166. */
  123167. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123168. /**
  123169. * "TrailMesh"
  123170. * @returns "TrailMesh"
  123171. */
  123172. getClassName(): string;
  123173. private _createMesh;
  123174. /**
  123175. * Start trailing mesh.
  123176. */
  123177. start(): void;
  123178. /**
  123179. * Stop trailing mesh.
  123180. */
  123181. stop(): void;
  123182. /**
  123183. * Update trailing mesh geometry.
  123184. */
  123185. update(): void;
  123186. /**
  123187. * Returns a new TrailMesh object.
  123188. * @param name is a string, the name given to the new mesh
  123189. * @param newGenerator use new generator object for cloned trail mesh
  123190. * @returns a new mesh
  123191. */
  123192. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123193. /**
  123194. * Serializes this trail mesh
  123195. * @param serializationObject object to write serialization to
  123196. */
  123197. serialize(serializationObject: any): void;
  123198. /**
  123199. * Parses a serialized trail mesh
  123200. * @param parsedMesh the serialized mesh
  123201. * @param scene the scene to create the trail mesh in
  123202. * @returns the created trail mesh
  123203. */
  123204. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123205. }
  123206. }
  123207. declare module BABYLON {
  123208. /**
  123209. * Class containing static functions to help procedurally build meshes
  123210. */
  123211. export class TiledBoxBuilder {
  123212. /**
  123213. * Creates a box mesh
  123214. * 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)
  123215. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123219. * @param name defines the name of the mesh
  123220. * @param options defines the options used to create the mesh
  123221. * @param scene defines the hosting scene
  123222. * @returns the box mesh
  123223. */
  123224. static CreateTiledBox(name: string, options: {
  123225. pattern?: number;
  123226. width?: number;
  123227. height?: number;
  123228. depth?: number;
  123229. tileSize?: number;
  123230. tileWidth?: number;
  123231. tileHeight?: number;
  123232. alignHorizontal?: number;
  123233. alignVertical?: number;
  123234. faceUV?: Vector4[];
  123235. faceColors?: Color4[];
  123236. sideOrientation?: number;
  123237. updatable?: boolean;
  123238. }, scene?: Nullable<Scene>): Mesh;
  123239. }
  123240. }
  123241. declare module BABYLON {
  123242. /**
  123243. * Class containing static functions to help procedurally build meshes
  123244. */
  123245. export class TorusKnotBuilder {
  123246. /**
  123247. * Creates a torus knot mesh
  123248. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123249. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123250. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123251. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123255. * @param name defines the name of the mesh
  123256. * @param options defines the options used to create the mesh
  123257. * @param scene defines the hosting scene
  123258. * @returns the torus knot mesh
  123259. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123260. */
  123261. static CreateTorusKnot(name: string, options: {
  123262. radius?: number;
  123263. tube?: number;
  123264. radialSegments?: number;
  123265. tubularSegments?: number;
  123266. p?: number;
  123267. q?: number;
  123268. updatable?: boolean;
  123269. sideOrientation?: number;
  123270. frontUVs?: Vector4;
  123271. backUVs?: Vector4;
  123272. }, scene: any): Mesh;
  123273. }
  123274. }
  123275. declare module BABYLON {
  123276. /**
  123277. * Polygon
  123278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123279. */
  123280. export class Polygon {
  123281. /**
  123282. * Creates a rectangle
  123283. * @param xmin bottom X coord
  123284. * @param ymin bottom Y coord
  123285. * @param xmax top X coord
  123286. * @param ymax top Y coord
  123287. * @returns points that make the resulting rectation
  123288. */
  123289. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123290. /**
  123291. * Creates a circle
  123292. * @param radius radius of circle
  123293. * @param cx scale in x
  123294. * @param cy scale in y
  123295. * @param numberOfSides number of sides that make up the circle
  123296. * @returns points that make the resulting circle
  123297. */
  123298. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123299. /**
  123300. * Creates a polygon from input string
  123301. * @param input Input polygon data
  123302. * @returns the parsed points
  123303. */
  123304. static Parse(input: string): Vector2[];
  123305. /**
  123306. * Starts building a polygon from x and y coordinates
  123307. * @param x x coordinate
  123308. * @param y y coordinate
  123309. * @returns the started path2
  123310. */
  123311. static StartingAt(x: number, y: number): Path2;
  123312. }
  123313. /**
  123314. * Builds a polygon
  123315. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123316. */
  123317. export class PolygonMeshBuilder {
  123318. private _points;
  123319. private _outlinepoints;
  123320. private _holes;
  123321. private _name;
  123322. private _scene;
  123323. private _epoints;
  123324. private _eholes;
  123325. private _addToepoint;
  123326. /**
  123327. * Babylon reference to the earcut plugin.
  123328. */
  123329. bjsEarcut: any;
  123330. /**
  123331. * Creates a PolygonMeshBuilder
  123332. * @param name name of the builder
  123333. * @param contours Path of the polygon
  123334. * @param scene scene to add to when creating the mesh
  123335. * @param earcutInjection can be used to inject your own earcut reference
  123336. */
  123337. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123338. /**
  123339. * Adds a whole within the polygon
  123340. * @param hole Array of points defining the hole
  123341. * @returns this
  123342. */
  123343. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123344. /**
  123345. * Creates the polygon
  123346. * @param updatable If the mesh should be updatable
  123347. * @param depth The depth of the mesh created
  123348. * @returns the created mesh
  123349. */
  123350. build(updatable?: boolean, depth?: number): Mesh;
  123351. /**
  123352. * Creates the polygon
  123353. * @param depth The depth of the mesh created
  123354. * @returns the created VertexData
  123355. */
  123356. buildVertexData(depth?: number): VertexData;
  123357. /**
  123358. * Adds a side to the polygon
  123359. * @param positions points that make the polygon
  123360. * @param normals normals of the polygon
  123361. * @param uvs uvs of the polygon
  123362. * @param indices indices of the polygon
  123363. * @param bounds bounds of the polygon
  123364. * @param points points of the polygon
  123365. * @param depth depth of the polygon
  123366. * @param flip flip of the polygon
  123367. */
  123368. private addSide;
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * Class containing static functions to help procedurally build meshes
  123374. */
  123375. export class PolygonBuilder {
  123376. /**
  123377. * Creates a polygon mesh
  123378. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123379. * * 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
  123380. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123383. * * Remember you can only change the shape positions, not their number when updating a polygon
  123384. * @param name defines the name of the mesh
  123385. * @param options defines the options used to create the mesh
  123386. * @param scene defines the hosting scene
  123387. * @param earcutInjection can be used to inject your own earcut reference
  123388. * @returns the polygon mesh
  123389. */
  123390. static CreatePolygon(name: string, options: {
  123391. shape: Vector3[];
  123392. holes?: Vector3[][];
  123393. depth?: number;
  123394. faceUV?: Vector4[];
  123395. faceColors?: Color4[];
  123396. updatable?: boolean;
  123397. sideOrientation?: number;
  123398. frontUVs?: Vector4;
  123399. backUVs?: Vector4;
  123400. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123401. /**
  123402. * Creates an extruded polygon mesh, with depth in the Y direction.
  123403. * * 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)
  123404. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123405. * @param name defines the name of the mesh
  123406. * @param options defines the options used to create the mesh
  123407. * @param scene defines the hosting scene
  123408. * @param earcutInjection can be used to inject your own earcut reference
  123409. * @returns the polygon mesh
  123410. */
  123411. static ExtrudePolygon(name: string, options: {
  123412. shape: Vector3[];
  123413. holes?: Vector3[][];
  123414. depth?: number;
  123415. faceUV?: Vector4[];
  123416. faceColors?: Color4[];
  123417. updatable?: boolean;
  123418. sideOrientation?: number;
  123419. frontUVs?: Vector4;
  123420. backUVs?: Vector4;
  123421. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123422. }
  123423. }
  123424. declare module BABYLON {
  123425. /**
  123426. * Class containing static functions to help procedurally build meshes
  123427. */
  123428. export class LatheBuilder {
  123429. /**
  123430. * Creates lathe mesh.
  123431. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123432. * * 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
  123433. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123434. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123435. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123436. * * 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
  123437. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123438. * * 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
  123439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123443. * @param name defines the name of the mesh
  123444. * @param options defines the options used to create the mesh
  123445. * @param scene defines the hosting scene
  123446. * @returns the lathe mesh
  123447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123448. */
  123449. static CreateLathe(name: string, options: {
  123450. shape: Vector3[];
  123451. radius?: number;
  123452. tessellation?: number;
  123453. clip?: number;
  123454. arc?: number;
  123455. closed?: boolean;
  123456. updatable?: boolean;
  123457. sideOrientation?: number;
  123458. frontUVs?: Vector4;
  123459. backUVs?: Vector4;
  123460. cap?: number;
  123461. invertUV?: boolean;
  123462. }, scene?: Nullable<Scene>): Mesh;
  123463. }
  123464. }
  123465. declare module BABYLON {
  123466. /**
  123467. * Class containing static functions to help procedurally build meshes
  123468. */
  123469. export class TiledPlaneBuilder {
  123470. /**
  123471. * Creates a tiled plane mesh
  123472. * * The parameter `pattern` will, depending on value, do nothing or
  123473. * * * flip (reflect about central vertical) alternate tiles across and up
  123474. * * * flip every tile on alternate rows
  123475. * * * rotate (180 degs) alternate tiles across and up
  123476. * * * rotate every tile on alternate rows
  123477. * * * flip and rotate alternate tiles across and up
  123478. * * * flip and rotate every tile on alternate rows
  123479. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123480. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123483. * * 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)
  123484. * * 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)
  123485. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123486. * @param name defines the name of the mesh
  123487. * @param options defines the options used to create the mesh
  123488. * @param scene defines the hosting scene
  123489. * @returns the box mesh
  123490. */
  123491. static CreateTiledPlane(name: string, options: {
  123492. pattern?: number;
  123493. tileSize?: number;
  123494. tileWidth?: number;
  123495. tileHeight?: number;
  123496. size?: number;
  123497. width?: number;
  123498. height?: number;
  123499. alignHorizontal?: number;
  123500. alignVertical?: number;
  123501. sideOrientation?: number;
  123502. frontUVs?: Vector4;
  123503. backUVs?: Vector4;
  123504. updatable?: boolean;
  123505. }, scene?: Nullable<Scene>): Mesh;
  123506. }
  123507. }
  123508. declare module BABYLON {
  123509. /**
  123510. * Class containing static functions to help procedurally build meshes
  123511. */
  123512. export class TubeBuilder {
  123513. /**
  123514. * Creates a tube mesh.
  123515. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123516. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123517. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123518. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123519. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123520. * * 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)
  123521. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123522. * * 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
  123523. * * 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
  123524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123528. * @param name defines the name of the mesh
  123529. * @param options defines the options used to create the mesh
  123530. * @param scene defines the hosting scene
  123531. * @returns the tube mesh
  123532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123533. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123534. */
  123535. static CreateTube(name: string, options: {
  123536. path: Vector3[];
  123537. radius?: number;
  123538. tessellation?: number;
  123539. radiusFunction?: {
  123540. (i: number, distance: number): number;
  123541. };
  123542. cap?: number;
  123543. arc?: number;
  123544. updatable?: boolean;
  123545. sideOrientation?: number;
  123546. frontUVs?: Vector4;
  123547. backUVs?: Vector4;
  123548. instance?: Mesh;
  123549. invertUV?: boolean;
  123550. }, scene?: Nullable<Scene>): Mesh;
  123551. }
  123552. }
  123553. declare module BABYLON {
  123554. /**
  123555. * Class containing static functions to help procedurally build meshes
  123556. */
  123557. export class IcoSphereBuilder {
  123558. /**
  123559. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123560. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123561. * * 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`)
  123562. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123563. * * 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
  123564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123567. * @param name defines the name of the mesh
  123568. * @param options defines the options used to create the mesh
  123569. * @param scene defines the hosting scene
  123570. * @returns the icosahedron mesh
  123571. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123572. */
  123573. static CreateIcoSphere(name: string, options: {
  123574. radius?: number;
  123575. radiusX?: number;
  123576. radiusY?: number;
  123577. radiusZ?: number;
  123578. flat?: boolean;
  123579. subdivisions?: number;
  123580. sideOrientation?: number;
  123581. frontUVs?: Vector4;
  123582. backUVs?: Vector4;
  123583. updatable?: boolean;
  123584. }, scene?: Nullable<Scene>): Mesh;
  123585. }
  123586. }
  123587. declare module BABYLON {
  123588. /**
  123589. * Class containing static functions to help procedurally build meshes
  123590. */
  123591. export class DecalBuilder {
  123592. /**
  123593. * Creates a decal mesh.
  123594. * 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
  123595. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123596. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123597. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123598. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123599. * @param name defines the name of the mesh
  123600. * @param sourceMesh defines the mesh where the decal must be applied
  123601. * @param options defines the options used to create the mesh
  123602. * @param scene defines the hosting scene
  123603. * @returns the decal mesh
  123604. * @see https://doc.babylonjs.com/how_to/decals
  123605. */
  123606. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123607. position?: Vector3;
  123608. normal?: Vector3;
  123609. size?: Vector3;
  123610. angle?: number;
  123611. }): Mesh;
  123612. }
  123613. }
  123614. declare module BABYLON {
  123615. /**
  123616. * Class containing static functions to help procedurally build meshes
  123617. */
  123618. export class MeshBuilder {
  123619. /**
  123620. * Creates a box mesh
  123621. * * The parameter `size` sets the size (float) of each box side (default 1)
  123622. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123623. * * 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)
  123624. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123628. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123629. * @param name defines the name of the mesh
  123630. * @param options defines the options used to create the mesh
  123631. * @param scene defines the hosting scene
  123632. * @returns the box mesh
  123633. */
  123634. static CreateBox(name: string, options: {
  123635. size?: number;
  123636. width?: number;
  123637. height?: number;
  123638. depth?: number;
  123639. faceUV?: Vector4[];
  123640. faceColors?: Color4[];
  123641. sideOrientation?: number;
  123642. frontUVs?: Vector4;
  123643. backUVs?: Vector4;
  123644. updatable?: boolean;
  123645. }, scene?: Nullable<Scene>): Mesh;
  123646. /**
  123647. * Creates a tiled box mesh
  123648. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123650. * @param name defines the name of the mesh
  123651. * @param options defines the options used to create the mesh
  123652. * @param scene defines the hosting scene
  123653. * @returns the tiled box mesh
  123654. */
  123655. static CreateTiledBox(name: string, options: {
  123656. pattern?: number;
  123657. size?: number;
  123658. width?: number;
  123659. height?: number;
  123660. depth: number;
  123661. tileSize?: number;
  123662. tileWidth?: number;
  123663. tileHeight?: number;
  123664. faceUV?: Vector4[];
  123665. faceColors?: Color4[];
  123666. alignHorizontal?: number;
  123667. alignVertical?: number;
  123668. sideOrientation?: number;
  123669. updatable?: boolean;
  123670. }, scene?: Nullable<Scene>): Mesh;
  123671. /**
  123672. * Creates a sphere mesh
  123673. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123674. * * 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`)
  123675. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123676. * * 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
  123677. * * 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)
  123678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123681. * @param name defines the name of the mesh
  123682. * @param options defines the options used to create the mesh
  123683. * @param scene defines the hosting scene
  123684. * @returns the sphere mesh
  123685. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123686. */
  123687. static CreateSphere(name: string, options: {
  123688. segments?: number;
  123689. diameter?: number;
  123690. diameterX?: number;
  123691. diameterY?: number;
  123692. diameterZ?: number;
  123693. arc?: number;
  123694. slice?: number;
  123695. sideOrientation?: number;
  123696. frontUVs?: Vector4;
  123697. backUVs?: Vector4;
  123698. updatable?: boolean;
  123699. }, scene?: Nullable<Scene>): Mesh;
  123700. /**
  123701. * Creates a plane polygonal mesh. By default, this is a disc
  123702. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123703. * * 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
  123704. * * 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
  123705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123708. * @param name defines the name of the mesh
  123709. * @param options defines the options used to create the mesh
  123710. * @param scene defines the hosting scene
  123711. * @returns the plane polygonal mesh
  123712. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123713. */
  123714. static CreateDisc(name: string, options: {
  123715. radius?: number;
  123716. tessellation?: number;
  123717. arc?: number;
  123718. updatable?: boolean;
  123719. sideOrientation?: number;
  123720. frontUVs?: Vector4;
  123721. backUVs?: Vector4;
  123722. }, scene?: Nullable<Scene>): Mesh;
  123723. /**
  123724. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123725. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123726. * * 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`)
  123727. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123728. * * 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
  123729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123732. * @param name defines the name of the mesh
  123733. * @param options defines the options used to create the mesh
  123734. * @param scene defines the hosting scene
  123735. * @returns the icosahedron mesh
  123736. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123737. */
  123738. static CreateIcoSphere(name: string, options: {
  123739. radius?: number;
  123740. radiusX?: number;
  123741. radiusY?: number;
  123742. radiusZ?: number;
  123743. flat?: boolean;
  123744. subdivisions?: number;
  123745. sideOrientation?: number;
  123746. frontUVs?: Vector4;
  123747. backUVs?: Vector4;
  123748. updatable?: boolean;
  123749. }, scene?: Nullable<Scene>): Mesh;
  123750. /**
  123751. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123752. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123753. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123754. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123755. * * 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
  123756. * * 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
  123757. * * 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
  123758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123761. * * 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
  123762. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123763. * * 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
  123764. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123766. * @param name defines the name of the mesh
  123767. * @param options defines the options used to create the mesh
  123768. * @param scene defines the hosting scene
  123769. * @returns the ribbon mesh
  123770. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123772. */
  123773. static CreateRibbon(name: string, options: {
  123774. pathArray: Vector3[][];
  123775. closeArray?: boolean;
  123776. closePath?: boolean;
  123777. offset?: number;
  123778. updatable?: boolean;
  123779. sideOrientation?: number;
  123780. frontUVs?: Vector4;
  123781. backUVs?: Vector4;
  123782. instance?: Mesh;
  123783. invertUV?: boolean;
  123784. uvs?: Vector2[];
  123785. colors?: Color4[];
  123786. }, scene?: Nullable<Scene>): Mesh;
  123787. /**
  123788. * Creates a cylinder or a cone mesh
  123789. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123790. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123791. * * 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.
  123792. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123793. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123794. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123795. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123796. * * 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).
  123797. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123798. * * 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).
  123799. * * 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
  123800. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123801. * * 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
  123802. * * 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.
  123803. * * If `enclose` is false, a ring surface is one element.
  123804. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123805. * * 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
  123806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123809. * @param name defines the name of the mesh
  123810. * @param options defines the options used to create the mesh
  123811. * @param scene defines the hosting scene
  123812. * @returns the cylinder mesh
  123813. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123814. */
  123815. static CreateCylinder(name: string, options: {
  123816. height?: number;
  123817. diameterTop?: number;
  123818. diameterBottom?: number;
  123819. diameter?: number;
  123820. tessellation?: number;
  123821. subdivisions?: number;
  123822. arc?: number;
  123823. faceColors?: Color4[];
  123824. faceUV?: Vector4[];
  123825. updatable?: boolean;
  123826. hasRings?: boolean;
  123827. enclose?: boolean;
  123828. cap?: number;
  123829. sideOrientation?: number;
  123830. frontUVs?: Vector4;
  123831. backUVs?: Vector4;
  123832. }, scene?: Nullable<Scene>): Mesh;
  123833. /**
  123834. * Creates a torus mesh
  123835. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123836. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123837. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123841. * @param name defines the name of the mesh
  123842. * @param options defines the options used to create the mesh
  123843. * @param scene defines the hosting scene
  123844. * @returns the torus mesh
  123845. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123846. */
  123847. static CreateTorus(name: string, options: {
  123848. diameter?: number;
  123849. thickness?: number;
  123850. tessellation?: number;
  123851. updatable?: boolean;
  123852. sideOrientation?: number;
  123853. frontUVs?: Vector4;
  123854. backUVs?: Vector4;
  123855. }, scene?: Nullable<Scene>): Mesh;
  123856. /**
  123857. * Creates a torus knot mesh
  123858. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123859. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123860. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123861. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123865. * @param name defines the name of the mesh
  123866. * @param options defines the options used to create the mesh
  123867. * @param scene defines the hosting scene
  123868. * @returns the torus knot mesh
  123869. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123870. */
  123871. static CreateTorusKnot(name: string, options: {
  123872. radius?: number;
  123873. tube?: number;
  123874. radialSegments?: number;
  123875. tubularSegments?: number;
  123876. p?: number;
  123877. q?: number;
  123878. updatable?: boolean;
  123879. sideOrientation?: number;
  123880. frontUVs?: Vector4;
  123881. backUVs?: Vector4;
  123882. }, scene?: Nullable<Scene>): Mesh;
  123883. /**
  123884. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123885. * * 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
  123886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123887. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123888. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123889. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123890. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123891. * * 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
  123892. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123895. * @param name defines the name of the new line system
  123896. * @param options defines the options used to create the line system
  123897. * @param scene defines the hosting scene
  123898. * @returns a new line system mesh
  123899. */
  123900. static CreateLineSystem(name: string, options: {
  123901. lines: Vector3[][];
  123902. updatable?: boolean;
  123903. instance?: Nullable<LinesMesh>;
  123904. colors?: Nullable<Color4[][]>;
  123905. useVertexAlpha?: boolean;
  123906. }, scene: Nullable<Scene>): LinesMesh;
  123907. /**
  123908. * Creates a line mesh
  123909. * 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
  123910. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123911. * * The parameter `points` is an array successive Vector3
  123912. * * 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
  123913. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123914. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123915. * * When updating an instance, remember that only point positions can change, not the number of points
  123916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123918. * @param name defines the name of the new line system
  123919. * @param options defines the options used to create the line system
  123920. * @param scene defines the hosting scene
  123921. * @returns a new line mesh
  123922. */
  123923. static CreateLines(name: string, options: {
  123924. points: Vector3[];
  123925. updatable?: boolean;
  123926. instance?: Nullable<LinesMesh>;
  123927. colors?: Color4[];
  123928. useVertexAlpha?: boolean;
  123929. }, scene?: Nullable<Scene>): LinesMesh;
  123930. /**
  123931. * Creates a dashed line mesh
  123932. * * 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
  123933. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123934. * * The parameter `points` is an array successive Vector3
  123935. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123936. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123937. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123938. * * 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
  123939. * * When updating an instance, remember that only point positions can change, not the number of points
  123940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123941. * @param name defines the name of the mesh
  123942. * @param options defines the options used to create the mesh
  123943. * @param scene defines the hosting scene
  123944. * @returns the dashed line mesh
  123945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123946. */
  123947. static CreateDashedLines(name: string, options: {
  123948. points: Vector3[];
  123949. dashSize?: number;
  123950. gapSize?: number;
  123951. dashNb?: number;
  123952. updatable?: boolean;
  123953. instance?: LinesMesh;
  123954. }, scene?: Nullable<Scene>): LinesMesh;
  123955. /**
  123956. * 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.
  123957. * * 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.
  123958. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123959. * * 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.
  123960. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123961. * * 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
  123962. * * 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
  123963. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123968. * @param name defines the name of the mesh
  123969. * @param options defines the options used to create the mesh
  123970. * @param scene defines the hosting scene
  123971. * @returns the extruded shape mesh
  123972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123974. */
  123975. static ExtrudeShape(name: string, options: {
  123976. shape: Vector3[];
  123977. path: Vector3[];
  123978. scale?: number;
  123979. rotation?: number;
  123980. cap?: number;
  123981. updatable?: boolean;
  123982. sideOrientation?: number;
  123983. frontUVs?: Vector4;
  123984. backUVs?: Vector4;
  123985. instance?: Mesh;
  123986. invertUV?: boolean;
  123987. }, scene?: Nullable<Scene>): Mesh;
  123988. /**
  123989. * Creates an custom extruded shape mesh.
  123990. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123991. * * 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.
  123992. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123993. * * 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
  123994. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123995. * * 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
  123996. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123997. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123998. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123999. * * 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
  124000. * * 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
  124001. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124006. * @param name defines the name of the mesh
  124007. * @param options defines the options used to create the mesh
  124008. * @param scene defines the hosting scene
  124009. * @returns the custom extruded shape mesh
  124010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124013. */
  124014. static ExtrudeShapeCustom(name: string, options: {
  124015. shape: Vector3[];
  124016. path: Vector3[];
  124017. scaleFunction?: any;
  124018. rotationFunction?: any;
  124019. ribbonCloseArray?: boolean;
  124020. ribbonClosePath?: boolean;
  124021. cap?: number;
  124022. updatable?: boolean;
  124023. sideOrientation?: number;
  124024. frontUVs?: Vector4;
  124025. backUVs?: Vector4;
  124026. instance?: Mesh;
  124027. invertUV?: boolean;
  124028. }, scene?: Nullable<Scene>): Mesh;
  124029. /**
  124030. * Creates lathe mesh.
  124031. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124032. * * 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
  124033. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124034. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124035. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124036. * * 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
  124037. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124038. * * 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
  124039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124043. * @param name defines the name of the mesh
  124044. * @param options defines the options used to create the mesh
  124045. * @param scene defines the hosting scene
  124046. * @returns the lathe mesh
  124047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124048. */
  124049. static CreateLathe(name: string, options: {
  124050. shape: Vector3[];
  124051. radius?: number;
  124052. tessellation?: number;
  124053. clip?: number;
  124054. arc?: number;
  124055. closed?: boolean;
  124056. updatable?: boolean;
  124057. sideOrientation?: number;
  124058. frontUVs?: Vector4;
  124059. backUVs?: Vector4;
  124060. cap?: number;
  124061. invertUV?: boolean;
  124062. }, scene?: Nullable<Scene>): Mesh;
  124063. /**
  124064. * Creates a tiled plane mesh
  124065. * * You can set a limited pattern arrangement with the tiles
  124066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124069. * @param name defines the name of the mesh
  124070. * @param options defines the options used to create the mesh
  124071. * @param scene defines the hosting scene
  124072. * @returns the plane mesh
  124073. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124074. */
  124075. static CreateTiledPlane(name: string, options: {
  124076. pattern?: number;
  124077. tileSize?: number;
  124078. tileWidth?: number;
  124079. tileHeight?: number;
  124080. size?: number;
  124081. width?: number;
  124082. height?: number;
  124083. alignHorizontal?: number;
  124084. alignVertical?: number;
  124085. sideOrientation?: number;
  124086. frontUVs?: Vector4;
  124087. backUVs?: Vector4;
  124088. updatable?: boolean;
  124089. }, scene?: Nullable<Scene>): Mesh;
  124090. /**
  124091. * Creates a plane mesh
  124092. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124093. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124094. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124098. * @param name defines the name of the mesh
  124099. * @param options defines the options used to create the mesh
  124100. * @param scene defines the hosting scene
  124101. * @returns the plane mesh
  124102. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124103. */
  124104. static CreatePlane(name: string, options: {
  124105. size?: number;
  124106. width?: number;
  124107. height?: number;
  124108. sideOrientation?: number;
  124109. frontUVs?: Vector4;
  124110. backUVs?: Vector4;
  124111. updatable?: boolean;
  124112. sourcePlane?: Plane;
  124113. }, scene?: Nullable<Scene>): Mesh;
  124114. /**
  124115. * Creates a ground mesh
  124116. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124117. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124119. * @param name defines the name of the mesh
  124120. * @param options defines the options used to create the mesh
  124121. * @param scene defines the hosting scene
  124122. * @returns the ground mesh
  124123. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124124. */
  124125. static CreateGround(name: string, options: {
  124126. width?: number;
  124127. height?: number;
  124128. subdivisions?: number;
  124129. subdivisionsX?: number;
  124130. subdivisionsY?: number;
  124131. updatable?: boolean;
  124132. }, scene?: Nullable<Scene>): Mesh;
  124133. /**
  124134. * Creates a tiled ground mesh
  124135. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124136. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124137. * * 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
  124138. * * 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
  124139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124140. * @param name defines the name of the mesh
  124141. * @param options defines the options used to create the mesh
  124142. * @param scene defines the hosting scene
  124143. * @returns the tiled ground mesh
  124144. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124145. */
  124146. static CreateTiledGround(name: string, options: {
  124147. xmin: number;
  124148. zmin: number;
  124149. xmax: number;
  124150. zmax: number;
  124151. subdivisions?: {
  124152. w: number;
  124153. h: number;
  124154. };
  124155. precision?: {
  124156. w: number;
  124157. h: number;
  124158. };
  124159. updatable?: boolean;
  124160. }, scene?: Nullable<Scene>): Mesh;
  124161. /**
  124162. * Creates a ground mesh from a height map
  124163. * * The parameter `url` sets the URL of the height map image resource.
  124164. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124165. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124166. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124167. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124168. * * 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.
  124169. * * 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).
  124170. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124172. * @param name defines the name of the mesh
  124173. * @param url defines the url to the height map
  124174. * @param options defines the options used to create the mesh
  124175. * @param scene defines the hosting scene
  124176. * @returns the ground mesh
  124177. * @see https://doc.babylonjs.com/babylon101/height_map
  124178. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124179. */
  124180. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124181. width?: number;
  124182. height?: number;
  124183. subdivisions?: number;
  124184. minHeight?: number;
  124185. maxHeight?: number;
  124186. colorFilter?: Color3;
  124187. alphaFilter?: number;
  124188. updatable?: boolean;
  124189. onReady?: (mesh: GroundMesh) => void;
  124190. }, scene?: Nullable<Scene>): GroundMesh;
  124191. /**
  124192. * Creates a polygon mesh
  124193. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124194. * * 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
  124195. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124198. * * Remember you can only change the shape positions, not their number when updating a polygon
  124199. * @param name defines the name of the mesh
  124200. * @param options defines the options used to create the mesh
  124201. * @param scene defines the hosting scene
  124202. * @param earcutInjection can be used to inject your own earcut reference
  124203. * @returns the polygon mesh
  124204. */
  124205. static CreatePolygon(name: string, options: {
  124206. shape: Vector3[];
  124207. holes?: Vector3[][];
  124208. depth?: number;
  124209. faceUV?: Vector4[];
  124210. faceColors?: Color4[];
  124211. updatable?: boolean;
  124212. sideOrientation?: number;
  124213. frontUVs?: Vector4;
  124214. backUVs?: Vector4;
  124215. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124216. /**
  124217. * Creates an extruded polygon mesh, with depth in the Y direction.
  124218. * * 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)
  124219. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124220. * @param name defines the name of the mesh
  124221. * @param options defines the options used to create the mesh
  124222. * @param scene defines the hosting scene
  124223. * @param earcutInjection can be used to inject your own earcut reference
  124224. * @returns the polygon mesh
  124225. */
  124226. static ExtrudePolygon(name: string, options: {
  124227. shape: Vector3[];
  124228. holes?: Vector3[][];
  124229. depth?: number;
  124230. faceUV?: Vector4[];
  124231. faceColors?: Color4[];
  124232. updatable?: boolean;
  124233. sideOrientation?: number;
  124234. frontUVs?: Vector4;
  124235. backUVs?: Vector4;
  124236. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124237. /**
  124238. * Creates a tube mesh.
  124239. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124240. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124241. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124242. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124243. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124244. * * 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)
  124245. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124246. * * 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
  124247. * * 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
  124248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124252. * @param name defines the name of the mesh
  124253. * @param options defines the options used to create the mesh
  124254. * @param scene defines the hosting scene
  124255. * @returns the tube mesh
  124256. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124257. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124258. */
  124259. static CreateTube(name: string, options: {
  124260. path: Vector3[];
  124261. radius?: number;
  124262. tessellation?: number;
  124263. radiusFunction?: {
  124264. (i: number, distance: number): number;
  124265. };
  124266. cap?: number;
  124267. arc?: number;
  124268. updatable?: boolean;
  124269. sideOrientation?: number;
  124270. frontUVs?: Vector4;
  124271. backUVs?: Vector4;
  124272. instance?: Mesh;
  124273. invertUV?: boolean;
  124274. }, scene?: Nullable<Scene>): Mesh;
  124275. /**
  124276. * Creates a polyhedron mesh
  124277. * * 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
  124278. * * The parameter `size` (positive float, default 1) sets the polygon size
  124279. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124280. * * 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`
  124281. * * 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
  124282. * * 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)`)
  124283. * * 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
  124284. * * 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
  124285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124288. * @param name defines the name of the mesh
  124289. * @param options defines the options used to create the mesh
  124290. * @param scene defines the hosting scene
  124291. * @returns the polyhedron mesh
  124292. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124293. */
  124294. static CreatePolyhedron(name: string, options: {
  124295. type?: number;
  124296. size?: number;
  124297. sizeX?: number;
  124298. sizeY?: number;
  124299. sizeZ?: number;
  124300. custom?: any;
  124301. faceUV?: Vector4[];
  124302. faceColors?: Color4[];
  124303. flat?: boolean;
  124304. updatable?: boolean;
  124305. sideOrientation?: number;
  124306. frontUVs?: Vector4;
  124307. backUVs?: Vector4;
  124308. }, scene?: Nullable<Scene>): Mesh;
  124309. /**
  124310. * Creates a decal mesh.
  124311. * 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
  124312. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124313. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124314. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124315. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124316. * @param name defines the name of the mesh
  124317. * @param sourceMesh defines the mesh where the decal must be applied
  124318. * @param options defines the options used to create the mesh
  124319. * @param scene defines the hosting scene
  124320. * @returns the decal mesh
  124321. * @see https://doc.babylonjs.com/how_to/decals
  124322. */
  124323. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124324. position?: Vector3;
  124325. normal?: Vector3;
  124326. size?: Vector3;
  124327. angle?: number;
  124328. }): Mesh;
  124329. }
  124330. }
  124331. declare module BABYLON {
  124332. /**
  124333. * A simplifier interface for future simplification implementations
  124334. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124335. */
  124336. export interface ISimplifier {
  124337. /**
  124338. * Simplification of a given mesh according to the given settings.
  124339. * Since this requires computation, it is assumed that the function runs async.
  124340. * @param settings The settings of the simplification, including quality and distance
  124341. * @param successCallback A callback that will be called after the mesh was simplified.
  124342. * @param errorCallback in case of an error, this callback will be called. optional.
  124343. */
  124344. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124345. }
  124346. /**
  124347. * Expected simplification settings.
  124348. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124349. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124350. */
  124351. export interface ISimplificationSettings {
  124352. /**
  124353. * Gets or sets the expected quality
  124354. */
  124355. quality: number;
  124356. /**
  124357. * Gets or sets the distance when this optimized version should be used
  124358. */
  124359. distance: number;
  124360. /**
  124361. * Gets an already optimized mesh
  124362. */
  124363. optimizeMesh?: boolean;
  124364. }
  124365. /**
  124366. * Class used to specify simplification options
  124367. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124368. */
  124369. export class SimplificationSettings implements ISimplificationSettings {
  124370. /** expected quality */
  124371. quality: number;
  124372. /** distance when this optimized version should be used */
  124373. distance: number;
  124374. /** already optimized mesh */
  124375. optimizeMesh?: boolean | undefined;
  124376. /**
  124377. * Creates a SimplificationSettings
  124378. * @param quality expected quality
  124379. * @param distance distance when this optimized version should be used
  124380. * @param optimizeMesh already optimized mesh
  124381. */
  124382. constructor(
  124383. /** expected quality */
  124384. quality: number,
  124385. /** distance when this optimized version should be used */
  124386. distance: number,
  124387. /** already optimized mesh */
  124388. optimizeMesh?: boolean | undefined);
  124389. }
  124390. /**
  124391. * Interface used to define a simplification task
  124392. */
  124393. export interface ISimplificationTask {
  124394. /**
  124395. * Array of settings
  124396. */
  124397. settings: Array<ISimplificationSettings>;
  124398. /**
  124399. * Simplification type
  124400. */
  124401. simplificationType: SimplificationType;
  124402. /**
  124403. * Mesh to simplify
  124404. */
  124405. mesh: Mesh;
  124406. /**
  124407. * Callback called on success
  124408. */
  124409. successCallback?: () => void;
  124410. /**
  124411. * Defines if parallel processing can be used
  124412. */
  124413. parallelProcessing: boolean;
  124414. }
  124415. /**
  124416. * Queue used to order the simplification tasks
  124417. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124418. */
  124419. export class SimplificationQueue {
  124420. private _simplificationArray;
  124421. /**
  124422. * Gets a boolean indicating that the process is still running
  124423. */
  124424. running: boolean;
  124425. /**
  124426. * Creates a new queue
  124427. */
  124428. constructor();
  124429. /**
  124430. * Adds a new simplification task
  124431. * @param task defines a task to add
  124432. */
  124433. addTask(task: ISimplificationTask): void;
  124434. /**
  124435. * Execute next task
  124436. */
  124437. executeNext(): void;
  124438. /**
  124439. * Execute a simplification task
  124440. * @param task defines the task to run
  124441. */
  124442. runSimplification(task: ISimplificationTask): void;
  124443. private getSimplifier;
  124444. }
  124445. /**
  124446. * The implemented types of simplification
  124447. * At the moment only Quadratic Error Decimation is implemented
  124448. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124449. */
  124450. export enum SimplificationType {
  124451. /** Quadratic error decimation */
  124452. QUADRATIC = 0
  124453. }
  124454. }
  124455. declare module BABYLON {
  124456. interface Scene {
  124457. /** @hidden (Backing field) */
  124458. _simplificationQueue: SimplificationQueue;
  124459. /**
  124460. * Gets or sets the simplification queue attached to the scene
  124461. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124462. */
  124463. simplificationQueue: SimplificationQueue;
  124464. }
  124465. interface Mesh {
  124466. /**
  124467. * Simplify the mesh according to the given array of settings.
  124468. * Function will return immediately and will simplify async
  124469. * @param settings a collection of simplification settings
  124470. * @param parallelProcessing should all levels calculate parallel or one after the other
  124471. * @param simplificationType the type of simplification to run
  124472. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124473. * @returns the current mesh
  124474. */
  124475. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124476. }
  124477. /**
  124478. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124479. * created in a scene
  124480. */
  124481. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124482. /**
  124483. * The component name helpfull to identify the component in the list of scene components.
  124484. */
  124485. readonly name: string;
  124486. /**
  124487. * The scene the component belongs to.
  124488. */
  124489. scene: Scene;
  124490. /**
  124491. * Creates a new instance of the component for the given scene
  124492. * @param scene Defines the scene to register the component in
  124493. */
  124494. constructor(scene: Scene);
  124495. /**
  124496. * Registers the component in a given scene
  124497. */
  124498. register(): void;
  124499. /**
  124500. * Rebuilds the elements related to this component in case of
  124501. * context lost for instance.
  124502. */
  124503. rebuild(): void;
  124504. /**
  124505. * Disposes the component and the associated ressources
  124506. */
  124507. dispose(): void;
  124508. private _beforeCameraUpdate;
  124509. }
  124510. }
  124511. declare module BABYLON {
  124512. /**
  124513. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124514. */
  124515. export interface INavigationEnginePlugin {
  124516. /**
  124517. * plugin name
  124518. */
  124519. name: string;
  124520. /**
  124521. * Creates a navigation mesh
  124522. * @param meshes array of all the geometry used to compute the navigatio mesh
  124523. * @param parameters bunch of parameters used to filter geometry
  124524. */
  124525. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124526. /**
  124527. * Create a navigation mesh debug mesh
  124528. * @param scene is where the mesh will be added
  124529. * @returns debug display mesh
  124530. */
  124531. createDebugNavMesh(scene: Scene): Mesh;
  124532. /**
  124533. * Get a navigation mesh constrained position, closest to the parameter position
  124534. * @param position world position
  124535. * @returns the closest point to position constrained by the navigation mesh
  124536. */
  124537. getClosestPoint(position: Vector3): Vector3;
  124538. /**
  124539. * Get a navigation mesh constrained position, within a particular radius
  124540. * @param position world position
  124541. * @param maxRadius the maximum distance to the constrained world position
  124542. * @returns the closest point to position constrained by the navigation mesh
  124543. */
  124544. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124545. /**
  124546. * Compute the final position from a segment made of destination-position
  124547. * @param position world position
  124548. * @param destination world position
  124549. * @returns the resulting point along the navmesh
  124550. */
  124551. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124552. /**
  124553. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124554. * @param start world position
  124555. * @param end world position
  124556. * @returns array containing world position composing the path
  124557. */
  124558. computePath(start: Vector3, end: Vector3): Vector3[];
  124559. /**
  124560. * If this plugin is supported
  124561. * @returns true if plugin is supported
  124562. */
  124563. isSupported(): boolean;
  124564. /**
  124565. * Create a new Crowd so you can add agents
  124566. * @param maxAgents the maximum agent count in the crowd
  124567. * @param maxAgentRadius the maximum radius an agent can have
  124568. * @param scene to attach the crowd to
  124569. * @returns the crowd you can add agents to
  124570. */
  124571. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124572. /**
  124573. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124574. * The queries will try to find a solution within those bounds
  124575. * default is (1,1,1)
  124576. * @param extent x,y,z value that define the extent around the queries point of reference
  124577. */
  124578. setDefaultQueryExtent(extent: Vector3): void;
  124579. /**
  124580. * Get the Bounding box extent specified by setDefaultQueryExtent
  124581. * @returns the box extent values
  124582. */
  124583. getDefaultQueryExtent(): Vector3;
  124584. /**
  124585. * Release all resources
  124586. */
  124587. dispose(): void;
  124588. }
  124589. /**
  124590. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124591. */
  124592. export interface ICrowd {
  124593. /**
  124594. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124595. * You can attach anything to that node. The node position is updated in the scene update tick.
  124596. * @param pos world position that will be constrained by the navigation mesh
  124597. * @param parameters agent parameters
  124598. * @param transform hooked to the agent that will be update by the scene
  124599. * @returns agent index
  124600. */
  124601. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124602. /**
  124603. * Returns the agent position in world space
  124604. * @param index agent index returned by addAgent
  124605. * @returns world space position
  124606. */
  124607. getAgentPosition(index: number): Vector3;
  124608. /**
  124609. * Gets the agent velocity in world space
  124610. * @param index agent index returned by addAgent
  124611. * @returns world space velocity
  124612. */
  124613. getAgentVelocity(index: number): Vector3;
  124614. /**
  124615. * remove a particular agent previously created
  124616. * @param index agent index returned by addAgent
  124617. */
  124618. removeAgent(index: number): void;
  124619. /**
  124620. * get the list of all agents attached to this crowd
  124621. * @returns list of agent indices
  124622. */
  124623. getAgents(): number[];
  124624. /**
  124625. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124626. * @param deltaTime in seconds
  124627. */
  124628. update(deltaTime: number): void;
  124629. /**
  124630. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124631. * @param index agent index returned by addAgent
  124632. * @param destination targeted world position
  124633. */
  124634. agentGoto(index: number, destination: Vector3): void;
  124635. /**
  124636. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124637. * The queries will try to find a solution within those bounds
  124638. * default is (1,1,1)
  124639. * @param extent x,y,z value that define the extent around the queries point of reference
  124640. */
  124641. setDefaultQueryExtent(extent: Vector3): void;
  124642. /**
  124643. * Get the Bounding box extent specified by setDefaultQueryExtent
  124644. * @returns the box extent values
  124645. */
  124646. getDefaultQueryExtent(): Vector3;
  124647. /**
  124648. * Release all resources
  124649. */
  124650. dispose(): void;
  124651. }
  124652. /**
  124653. * Configures an agent
  124654. */
  124655. export interface IAgentParameters {
  124656. /**
  124657. * Agent radius. [Limit: >= 0]
  124658. */
  124659. radius: number;
  124660. /**
  124661. * Agent height. [Limit: > 0]
  124662. */
  124663. height: number;
  124664. /**
  124665. * Maximum allowed acceleration. [Limit: >= 0]
  124666. */
  124667. maxAcceleration: number;
  124668. /**
  124669. * Maximum allowed speed. [Limit: >= 0]
  124670. */
  124671. maxSpeed: number;
  124672. /**
  124673. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124674. */
  124675. collisionQueryRange: number;
  124676. /**
  124677. * The path visibility optimization range. [Limit: > 0]
  124678. */
  124679. pathOptimizationRange: number;
  124680. /**
  124681. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124682. */
  124683. separationWeight: number;
  124684. }
  124685. /**
  124686. * Configures the navigation mesh creation
  124687. */
  124688. export interface INavMeshParameters {
  124689. /**
  124690. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124691. */
  124692. cs: number;
  124693. /**
  124694. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124695. */
  124696. ch: number;
  124697. /**
  124698. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124699. */
  124700. walkableSlopeAngle: number;
  124701. /**
  124702. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124703. * be considered walkable. [Limit: >= 3] [Units: vx]
  124704. */
  124705. walkableHeight: number;
  124706. /**
  124707. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124708. */
  124709. walkableClimb: number;
  124710. /**
  124711. * The distance to erode/shrink the walkable area of the heightfield away from
  124712. * obstructions. [Limit: >=0] [Units: vx]
  124713. */
  124714. walkableRadius: number;
  124715. /**
  124716. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124717. */
  124718. maxEdgeLen: number;
  124719. /**
  124720. * The maximum distance a simplfied contour's border edges should deviate
  124721. * the original raw contour. [Limit: >=0] [Units: vx]
  124722. */
  124723. maxSimplificationError: number;
  124724. /**
  124725. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124726. */
  124727. minRegionArea: number;
  124728. /**
  124729. * Any regions with a span count smaller than this value will, if possible,
  124730. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124731. */
  124732. mergeRegionArea: number;
  124733. /**
  124734. * The maximum number of vertices allowed for polygons generated during the
  124735. * contour to polygon conversion process. [Limit: >= 3]
  124736. */
  124737. maxVertsPerPoly: number;
  124738. /**
  124739. * Sets the sampling distance to use when generating the detail mesh.
  124740. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124741. */
  124742. detailSampleDist: number;
  124743. /**
  124744. * The maximum distance the detail mesh surface should deviate from heightfield
  124745. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124746. */
  124747. detailSampleMaxError: number;
  124748. }
  124749. }
  124750. declare module BABYLON {
  124751. /**
  124752. * RecastJS navigation plugin
  124753. */
  124754. export class RecastJSPlugin implements INavigationEnginePlugin {
  124755. /**
  124756. * Reference to the Recast library
  124757. */
  124758. bjsRECAST: any;
  124759. /**
  124760. * plugin name
  124761. */
  124762. name: string;
  124763. /**
  124764. * the first navmesh created. We might extend this to support multiple navmeshes
  124765. */
  124766. navMesh: any;
  124767. /**
  124768. * Initializes the recastJS plugin
  124769. * @param recastInjection can be used to inject your own recast reference
  124770. */
  124771. constructor(recastInjection?: any);
  124772. /**
  124773. * Creates a navigation mesh
  124774. * @param meshes array of all the geometry used to compute the navigatio mesh
  124775. * @param parameters bunch of parameters used to filter geometry
  124776. */
  124777. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124778. /**
  124779. * Create a navigation mesh debug mesh
  124780. * @param scene is where the mesh will be added
  124781. * @returns debug display mesh
  124782. */
  124783. createDebugNavMesh(scene: Scene): Mesh;
  124784. /**
  124785. * Get a navigation mesh constrained position, closest to the parameter position
  124786. * @param position world position
  124787. * @returns the closest point to position constrained by the navigation mesh
  124788. */
  124789. getClosestPoint(position: Vector3): Vector3;
  124790. /**
  124791. * Get a navigation mesh constrained position, within a particular radius
  124792. * @param position world position
  124793. * @param maxRadius the maximum distance to the constrained world position
  124794. * @returns the closest point to position constrained by the navigation mesh
  124795. */
  124796. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124797. /**
  124798. * Compute the final position from a segment made of destination-position
  124799. * @param position world position
  124800. * @param destination world position
  124801. * @returns the resulting point along the navmesh
  124802. */
  124803. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124804. /**
  124805. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124806. * @param start world position
  124807. * @param end world position
  124808. * @returns array containing world position composing the path
  124809. */
  124810. computePath(start: Vector3, end: Vector3): Vector3[];
  124811. /**
  124812. * Create a new Crowd so you can add agents
  124813. * @param maxAgents the maximum agent count in the crowd
  124814. * @param maxAgentRadius the maximum radius an agent can have
  124815. * @param scene to attach the crowd to
  124816. * @returns the crowd you can add agents to
  124817. */
  124818. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124819. /**
  124820. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124821. * The queries will try to find a solution within those bounds
  124822. * default is (1,1,1)
  124823. * @param extent x,y,z value that define the extent around the queries point of reference
  124824. */
  124825. setDefaultQueryExtent(extent: Vector3): void;
  124826. /**
  124827. * Get the Bounding box extent specified by setDefaultQueryExtent
  124828. * @returns the box extent values
  124829. */
  124830. getDefaultQueryExtent(): Vector3;
  124831. /**
  124832. * Disposes
  124833. */
  124834. dispose(): void;
  124835. /**
  124836. * If this plugin is supported
  124837. * @returns true if plugin is supported
  124838. */
  124839. isSupported(): boolean;
  124840. }
  124841. /**
  124842. * Recast detour crowd implementation
  124843. */
  124844. export class RecastJSCrowd implements ICrowd {
  124845. /**
  124846. * Recast/detour plugin
  124847. */
  124848. bjsRECASTPlugin: RecastJSPlugin;
  124849. /**
  124850. * Link to the detour crowd
  124851. */
  124852. recastCrowd: any;
  124853. /**
  124854. * One transform per agent
  124855. */
  124856. transforms: TransformNode[];
  124857. /**
  124858. * All agents created
  124859. */
  124860. agents: number[];
  124861. /**
  124862. * Link to the scene is kept to unregister the crowd from the scene
  124863. */
  124864. private _scene;
  124865. /**
  124866. * Observer for crowd updates
  124867. */
  124868. private _onBeforeAnimationsObserver;
  124869. /**
  124870. * Constructor
  124871. * @param plugin recastJS plugin
  124872. * @param maxAgents the maximum agent count in the crowd
  124873. * @param maxAgentRadius the maximum radius an agent can have
  124874. * @param scene to attach the crowd to
  124875. * @returns the crowd you can add agents to
  124876. */
  124877. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124878. /**
  124879. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124880. * You can attach anything to that node. The node position is updated in the scene update tick.
  124881. * @param pos world position that will be constrained by the navigation mesh
  124882. * @param parameters agent parameters
  124883. * @param transform hooked to the agent that will be update by the scene
  124884. * @returns agent index
  124885. */
  124886. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124887. /**
  124888. * Returns the agent position in world space
  124889. * @param index agent index returned by addAgent
  124890. * @returns world space position
  124891. */
  124892. getAgentPosition(index: number): Vector3;
  124893. /**
  124894. * Returns the agent velocity in world space
  124895. * @param index agent index returned by addAgent
  124896. * @returns world space velocity
  124897. */
  124898. getAgentVelocity(index: number): Vector3;
  124899. /**
  124900. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124901. * @param index agent index returned by addAgent
  124902. * @param destination targeted world position
  124903. */
  124904. agentGoto(index: number, destination: Vector3): void;
  124905. /**
  124906. * remove a particular agent previously created
  124907. * @param index agent index returned by addAgent
  124908. */
  124909. removeAgent(index: number): void;
  124910. /**
  124911. * get the list of all agents attached to this crowd
  124912. * @returns list of agent indices
  124913. */
  124914. getAgents(): number[];
  124915. /**
  124916. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124917. * @param deltaTime in seconds
  124918. */
  124919. update(deltaTime: number): void;
  124920. /**
  124921. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124922. * The queries will try to find a solution within those bounds
  124923. * default is (1,1,1)
  124924. * @param extent x,y,z value that define the extent around the queries point of reference
  124925. */
  124926. setDefaultQueryExtent(extent: Vector3): void;
  124927. /**
  124928. * Get the Bounding box extent specified by setDefaultQueryExtent
  124929. * @returns the box extent values
  124930. */
  124931. getDefaultQueryExtent(): Vector3;
  124932. /**
  124933. * Release all resources
  124934. */
  124935. dispose(): void;
  124936. }
  124937. }
  124938. declare module BABYLON {
  124939. /**
  124940. * Class used to enable access to IndexedDB
  124941. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124942. */
  124943. export class Database implements IOfflineProvider {
  124944. private _callbackManifestChecked;
  124945. private _currentSceneUrl;
  124946. private _db;
  124947. private _enableSceneOffline;
  124948. private _enableTexturesOffline;
  124949. private _manifestVersionFound;
  124950. private _mustUpdateRessources;
  124951. private _hasReachedQuota;
  124952. private _isSupported;
  124953. private _idbFactory;
  124954. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124955. private static IsUASupportingBlobStorage;
  124956. /**
  124957. * Gets a boolean indicating if Database storate is enabled (off by default)
  124958. */
  124959. static IDBStorageEnabled: boolean;
  124960. /**
  124961. * Gets a boolean indicating if scene must be saved in the database
  124962. */
  124963. readonly enableSceneOffline: boolean;
  124964. /**
  124965. * Gets a boolean indicating if textures must be saved in the database
  124966. */
  124967. readonly enableTexturesOffline: boolean;
  124968. /**
  124969. * Creates a new Database
  124970. * @param urlToScene defines the url to load the scene
  124971. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124972. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124973. */
  124974. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124975. private static _ParseURL;
  124976. private static _ReturnFullUrlLocation;
  124977. private _checkManifestFile;
  124978. /**
  124979. * Open the database and make it available
  124980. * @param successCallback defines the callback to call on success
  124981. * @param errorCallback defines the callback to call on error
  124982. */
  124983. open(successCallback: () => void, errorCallback: () => void): void;
  124984. /**
  124985. * Loads an image from the database
  124986. * @param url defines the url to load from
  124987. * @param image defines the target DOM image
  124988. */
  124989. loadImage(url: string, image: HTMLImageElement): void;
  124990. private _loadImageFromDBAsync;
  124991. private _saveImageIntoDBAsync;
  124992. private _checkVersionFromDB;
  124993. private _loadVersionFromDBAsync;
  124994. private _saveVersionIntoDBAsync;
  124995. /**
  124996. * Loads a file from database
  124997. * @param url defines the URL to load from
  124998. * @param sceneLoaded defines a callback to call on success
  124999. * @param progressCallBack defines a callback to call when progress changed
  125000. * @param errorCallback defines a callback to call on error
  125001. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125002. */
  125003. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125004. private _loadFileAsync;
  125005. private _saveFileAsync;
  125006. /**
  125007. * Validates if xhr data is correct
  125008. * @param xhr defines the request to validate
  125009. * @param dataType defines the expected data type
  125010. * @returns true if data is correct
  125011. */
  125012. private static _ValidateXHRData;
  125013. }
  125014. }
  125015. declare module BABYLON {
  125016. /** @hidden */
  125017. export var gpuUpdateParticlesPixelShader: {
  125018. name: string;
  125019. shader: string;
  125020. };
  125021. }
  125022. declare module BABYLON {
  125023. /** @hidden */
  125024. export var gpuUpdateParticlesVertexShader: {
  125025. name: string;
  125026. shader: string;
  125027. };
  125028. }
  125029. declare module BABYLON {
  125030. /** @hidden */
  125031. export var clipPlaneFragmentDeclaration2: {
  125032. name: string;
  125033. shader: string;
  125034. };
  125035. }
  125036. declare module BABYLON {
  125037. /** @hidden */
  125038. export var gpuRenderParticlesPixelShader: {
  125039. name: string;
  125040. shader: string;
  125041. };
  125042. }
  125043. declare module BABYLON {
  125044. /** @hidden */
  125045. export var clipPlaneVertexDeclaration2: {
  125046. name: string;
  125047. shader: string;
  125048. };
  125049. }
  125050. declare module BABYLON {
  125051. /** @hidden */
  125052. export var gpuRenderParticlesVertexShader: {
  125053. name: string;
  125054. shader: string;
  125055. };
  125056. }
  125057. declare module BABYLON {
  125058. /**
  125059. * This represents a GPU particle system in Babylon
  125060. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125061. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125062. */
  125063. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125064. /**
  125065. * The layer mask we are rendering the particles through.
  125066. */
  125067. layerMask: number;
  125068. private _capacity;
  125069. private _activeCount;
  125070. private _currentActiveCount;
  125071. private _accumulatedCount;
  125072. private _renderEffect;
  125073. private _updateEffect;
  125074. private _buffer0;
  125075. private _buffer1;
  125076. private _spriteBuffer;
  125077. private _updateVAO;
  125078. private _renderVAO;
  125079. private _targetIndex;
  125080. private _sourceBuffer;
  125081. private _targetBuffer;
  125082. private _engine;
  125083. private _currentRenderId;
  125084. private _started;
  125085. private _stopped;
  125086. private _timeDelta;
  125087. private _randomTexture;
  125088. private _randomTexture2;
  125089. private _attributesStrideSize;
  125090. private _updateEffectOptions;
  125091. private _randomTextureSize;
  125092. private _actualFrame;
  125093. private readonly _rawTextureWidth;
  125094. /**
  125095. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125096. */
  125097. static readonly IsSupported: boolean;
  125098. /**
  125099. * An event triggered when the system is disposed.
  125100. */
  125101. onDisposeObservable: Observable<GPUParticleSystem>;
  125102. /**
  125103. * Gets the maximum number of particles active at the same time.
  125104. * @returns The max number of active particles.
  125105. */
  125106. getCapacity(): number;
  125107. /**
  125108. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125109. * to override the particles.
  125110. */
  125111. forceDepthWrite: boolean;
  125112. /**
  125113. * Gets or set the number of active particles
  125114. */
  125115. activeParticleCount: number;
  125116. private _preWarmDone;
  125117. /**
  125118. * Is this system ready to be used/rendered
  125119. * @return true if the system is ready
  125120. */
  125121. isReady(): boolean;
  125122. /**
  125123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125124. * @returns True if it has been started, otherwise false.
  125125. */
  125126. isStarted(): boolean;
  125127. /**
  125128. * Starts the particle system and begins to emit
  125129. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125130. */
  125131. start(delay?: number): void;
  125132. /**
  125133. * Stops the particle system.
  125134. */
  125135. stop(): void;
  125136. /**
  125137. * Remove all active particles
  125138. */
  125139. reset(): void;
  125140. /**
  125141. * Returns the string "GPUParticleSystem"
  125142. * @returns a string containing the class name
  125143. */
  125144. getClassName(): string;
  125145. private _colorGradientsTexture;
  125146. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125147. /**
  125148. * Adds a new color gradient
  125149. * @param gradient defines the gradient to use (between 0 and 1)
  125150. * @param color1 defines the color to affect to the specified gradient
  125151. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125152. * @returns the current particle system
  125153. */
  125154. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125155. /**
  125156. * Remove a specific color gradient
  125157. * @param gradient defines the gradient to remove
  125158. * @returns the current particle system
  125159. */
  125160. removeColorGradient(gradient: number): GPUParticleSystem;
  125161. private _angularSpeedGradientsTexture;
  125162. private _sizeGradientsTexture;
  125163. private _velocityGradientsTexture;
  125164. private _limitVelocityGradientsTexture;
  125165. private _dragGradientsTexture;
  125166. private _addFactorGradient;
  125167. /**
  125168. * Adds a new size gradient
  125169. * @param gradient defines the gradient to use (between 0 and 1)
  125170. * @param factor defines the size factor to affect to the specified gradient
  125171. * @returns the current particle system
  125172. */
  125173. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125174. /**
  125175. * Remove a specific size gradient
  125176. * @param gradient defines the gradient to remove
  125177. * @returns the current particle system
  125178. */
  125179. removeSizeGradient(gradient: number): GPUParticleSystem;
  125180. /**
  125181. * Adds a new angular speed gradient
  125182. * @param gradient defines the gradient to use (between 0 and 1)
  125183. * @param factor defines the angular speed to affect to the specified gradient
  125184. * @returns the current particle system
  125185. */
  125186. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125187. /**
  125188. * Remove a specific angular speed gradient
  125189. * @param gradient defines the gradient to remove
  125190. * @returns the current particle system
  125191. */
  125192. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125193. /**
  125194. * Adds a new velocity gradient
  125195. * @param gradient defines the gradient to use (between 0 and 1)
  125196. * @param factor defines the velocity to affect to the specified gradient
  125197. * @returns the current particle system
  125198. */
  125199. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125200. /**
  125201. * Remove a specific velocity gradient
  125202. * @param gradient defines the gradient to remove
  125203. * @returns the current particle system
  125204. */
  125205. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125206. /**
  125207. * Adds a new limit velocity gradient
  125208. * @param gradient defines the gradient to use (between 0 and 1)
  125209. * @param factor defines the limit velocity value to affect to the specified gradient
  125210. * @returns the current particle system
  125211. */
  125212. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125213. /**
  125214. * Remove a specific limit velocity gradient
  125215. * @param gradient defines the gradient to remove
  125216. * @returns the current particle system
  125217. */
  125218. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125219. /**
  125220. * Adds a new drag gradient
  125221. * @param gradient defines the gradient to use (between 0 and 1)
  125222. * @param factor defines the drag value to affect to the specified gradient
  125223. * @returns the current particle system
  125224. */
  125225. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125226. /**
  125227. * Remove a specific drag gradient
  125228. * @param gradient defines the gradient to remove
  125229. * @returns the current particle system
  125230. */
  125231. removeDragGradient(gradient: number): GPUParticleSystem;
  125232. /**
  125233. * Not supported by GPUParticleSystem
  125234. * @param gradient defines the gradient to use (between 0 and 1)
  125235. * @param factor defines the emit rate value to affect to the specified gradient
  125236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125237. * @returns the current particle system
  125238. */
  125239. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125240. /**
  125241. * Not supported by GPUParticleSystem
  125242. * @param gradient defines the gradient to remove
  125243. * @returns the current particle system
  125244. */
  125245. removeEmitRateGradient(gradient: number): IParticleSystem;
  125246. /**
  125247. * Not supported by GPUParticleSystem
  125248. * @param gradient defines the gradient to use (between 0 and 1)
  125249. * @param factor defines the start size value to affect to the specified gradient
  125250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125251. * @returns the current particle system
  125252. */
  125253. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125254. /**
  125255. * Not supported by GPUParticleSystem
  125256. * @param gradient defines the gradient to remove
  125257. * @returns the current particle system
  125258. */
  125259. removeStartSizeGradient(gradient: number): IParticleSystem;
  125260. /**
  125261. * Not supported by GPUParticleSystem
  125262. * @param gradient defines the gradient to use (between 0 and 1)
  125263. * @param min defines the color remap minimal range
  125264. * @param max defines the color remap maximal range
  125265. * @returns the current particle system
  125266. */
  125267. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125268. /**
  125269. * Not supported by GPUParticleSystem
  125270. * @param gradient defines the gradient to remove
  125271. * @returns the current particle system
  125272. */
  125273. removeColorRemapGradient(): IParticleSystem;
  125274. /**
  125275. * Not supported by GPUParticleSystem
  125276. * @param gradient defines the gradient to use (between 0 and 1)
  125277. * @param min defines the alpha remap minimal range
  125278. * @param max defines the alpha remap maximal range
  125279. * @returns the current particle system
  125280. */
  125281. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125282. /**
  125283. * Not supported by GPUParticleSystem
  125284. * @param gradient defines the gradient to remove
  125285. * @returns the current particle system
  125286. */
  125287. removeAlphaRemapGradient(): IParticleSystem;
  125288. /**
  125289. * Not supported by GPUParticleSystem
  125290. * @param gradient defines the gradient to use (between 0 and 1)
  125291. * @param color defines the color to affect to the specified gradient
  125292. * @returns the current particle system
  125293. */
  125294. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125295. /**
  125296. * Not supported by GPUParticleSystem
  125297. * @param gradient defines the gradient to remove
  125298. * @returns the current particle system
  125299. */
  125300. removeRampGradient(): IParticleSystem;
  125301. /**
  125302. * Not supported by GPUParticleSystem
  125303. * @returns the list of ramp gradients
  125304. */
  125305. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125306. /**
  125307. * Not supported by GPUParticleSystem
  125308. * Gets or sets a boolean indicating that ramp gradients must be used
  125309. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125310. */
  125311. useRampGradients: boolean;
  125312. /**
  125313. * Not supported by GPUParticleSystem
  125314. * @param gradient defines the gradient to use (between 0 and 1)
  125315. * @param factor defines the life time factor to affect to the specified gradient
  125316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125317. * @returns the current particle system
  125318. */
  125319. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125320. /**
  125321. * Not supported by GPUParticleSystem
  125322. * @param gradient defines the gradient to remove
  125323. * @returns the current particle system
  125324. */
  125325. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125326. /**
  125327. * Instantiates a GPU particle system.
  125328. * 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.
  125329. * @param name The name of the particle system
  125330. * @param options The options used to create the system
  125331. * @param scene The scene the particle system belongs to
  125332. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125333. */
  125334. constructor(name: string, options: Partial<{
  125335. capacity: number;
  125336. randomTextureSize: number;
  125337. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125338. protected _reset(): void;
  125339. private _createUpdateVAO;
  125340. private _createRenderVAO;
  125341. private _initialize;
  125342. /** @hidden */
  125343. _recreateUpdateEffect(): void;
  125344. /** @hidden */
  125345. _recreateRenderEffect(): void;
  125346. /**
  125347. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125348. * @param preWarm defines if we are in the pre-warmimg phase
  125349. */
  125350. animate(preWarm?: boolean): void;
  125351. private _createFactorGradientTexture;
  125352. private _createSizeGradientTexture;
  125353. private _createAngularSpeedGradientTexture;
  125354. private _createVelocityGradientTexture;
  125355. private _createLimitVelocityGradientTexture;
  125356. private _createDragGradientTexture;
  125357. private _createColorGradientTexture;
  125358. /**
  125359. * Renders the particle system in its current state
  125360. * @param preWarm defines if the system should only update the particles but not render them
  125361. * @returns the current number of particles
  125362. */
  125363. render(preWarm?: boolean): number;
  125364. /**
  125365. * Rebuilds the particle system
  125366. */
  125367. rebuild(): void;
  125368. private _releaseBuffers;
  125369. private _releaseVAOs;
  125370. /**
  125371. * Disposes the particle system and free the associated resources
  125372. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125373. */
  125374. dispose(disposeTexture?: boolean): void;
  125375. /**
  125376. * Clones the particle system.
  125377. * @param name The name of the cloned object
  125378. * @param newEmitter The new emitter to use
  125379. * @returns the cloned particle system
  125380. */
  125381. clone(name: string, newEmitter: any): GPUParticleSystem;
  125382. /**
  125383. * Serializes the particle system to a JSON object.
  125384. * @returns the JSON object
  125385. */
  125386. serialize(): any;
  125387. /**
  125388. * Parses a JSON object to create a GPU particle system.
  125389. * @param parsedParticleSystem The JSON object to parse
  125390. * @param scene The scene to create the particle system in
  125391. * @param rootUrl The root url to use to load external dependencies like texture
  125392. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125393. * @returns the parsed GPU particle system
  125394. */
  125395. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125396. }
  125397. }
  125398. declare module BABYLON {
  125399. /**
  125400. * Represents a set of particle systems working together to create a specific effect
  125401. */
  125402. export class ParticleSystemSet implements IDisposable {
  125403. private _emitterCreationOptions;
  125404. private _emitterNode;
  125405. /**
  125406. * Gets the particle system list
  125407. */
  125408. systems: IParticleSystem[];
  125409. /**
  125410. * Gets the emitter node used with this set
  125411. */
  125412. readonly emitterNode: Nullable<TransformNode>;
  125413. /**
  125414. * Creates a new emitter mesh as a sphere
  125415. * @param options defines the options used to create the sphere
  125416. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125417. * @param scene defines the hosting scene
  125418. */
  125419. setEmitterAsSphere(options: {
  125420. diameter: number;
  125421. segments: number;
  125422. color: Color3;
  125423. }, renderingGroupId: number, scene: Scene): void;
  125424. /**
  125425. * Starts all particle systems of the set
  125426. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125427. */
  125428. start(emitter?: AbstractMesh): void;
  125429. /**
  125430. * Release all associated resources
  125431. */
  125432. dispose(): void;
  125433. /**
  125434. * Serialize the set into a JSON compatible object
  125435. * @returns a JSON compatible representation of the set
  125436. */
  125437. serialize(): any;
  125438. /**
  125439. * Parse a new ParticleSystemSet from a serialized source
  125440. * @param data defines a JSON compatible representation of the set
  125441. * @param scene defines the hosting scene
  125442. * @param gpu defines if we want GPU particles or CPU particles
  125443. * @returns a new ParticleSystemSet
  125444. */
  125445. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125446. }
  125447. }
  125448. declare module BABYLON {
  125449. /**
  125450. * This class is made for on one-liner static method to help creating particle system set.
  125451. */
  125452. export class ParticleHelper {
  125453. /**
  125454. * Gets or sets base Assets URL
  125455. */
  125456. static BaseAssetsUrl: string;
  125457. /**
  125458. * Create a default particle system that you can tweak
  125459. * @param emitter defines the emitter to use
  125460. * @param capacity defines the system capacity (default is 500 particles)
  125461. * @param scene defines the hosting scene
  125462. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125463. * @returns the new Particle system
  125464. */
  125465. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125466. /**
  125467. * This is the main static method (one-liner) of this helper to create different particle systems
  125468. * @param type This string represents the type to the particle system to create
  125469. * @param scene The scene where the particle system should live
  125470. * @param gpu If the system will use gpu
  125471. * @returns the ParticleSystemSet created
  125472. */
  125473. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125474. /**
  125475. * Static function used to export a particle system to a ParticleSystemSet variable.
  125476. * Please note that the emitter shape is not exported
  125477. * @param systems defines the particle systems to export
  125478. * @returns the created particle system set
  125479. */
  125480. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125481. }
  125482. }
  125483. declare module BABYLON {
  125484. interface Engine {
  125485. /**
  125486. * Create an effect to use with particle systems.
  125487. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125488. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125489. * @param uniformsNames defines a list of attribute names
  125490. * @param samplers defines an array of string used to represent textures
  125491. * @param defines defines the string containing the defines to use to compile the shaders
  125492. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125493. * @param onCompiled defines a function to call when the effect creation is successful
  125494. * @param onError defines a function to call when the effect creation has failed
  125495. * @returns the new Effect
  125496. */
  125497. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125498. }
  125499. interface Mesh {
  125500. /**
  125501. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125502. * @returns an array of IParticleSystem
  125503. */
  125504. getEmittedParticleSystems(): IParticleSystem[];
  125505. /**
  125506. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125507. * @returns an array of IParticleSystem
  125508. */
  125509. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125510. }
  125511. /**
  125512. * @hidden
  125513. */
  125514. export var _IDoNeedToBeInTheBuild: number;
  125515. }
  125516. declare module BABYLON {
  125517. /** Defines the 4 color options */
  125518. export enum PointColor {
  125519. /** color value */
  125520. Color = 2,
  125521. /** uv value */
  125522. UV = 1,
  125523. /** random value */
  125524. Random = 0,
  125525. /** stated value */
  125526. Stated = 3
  125527. }
  125528. /**
  125529. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125530. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  125531. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125532. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125533. *
  125534. * Full documentation here : TO BE ENTERED
  125535. */
  125536. export class PointsCloudSystem implements IDisposable {
  125537. /**
  125538. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125539. * Example : var p = SPS.particles[i];
  125540. */
  125541. particles: CloudPoint[];
  125542. /**
  125543. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125544. */
  125545. nbParticles: number;
  125546. /**
  125547. * This a counter for your own usage. It's not set by any SPS functions.
  125548. */
  125549. counter: number;
  125550. /**
  125551. * The PCS name. This name is also given to the underlying mesh.
  125552. */
  125553. name: string;
  125554. /**
  125555. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125556. */
  125557. mesh: Mesh;
  125558. /**
  125559. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125560. * Please read :
  125561. */
  125562. vars: any;
  125563. /**
  125564. * @hidden
  125565. */
  125566. _size: number;
  125567. private _scene;
  125568. private _promises;
  125569. private _positions;
  125570. private _indices;
  125571. private _normals;
  125572. private _colors;
  125573. private _uvs;
  125574. private _indices32;
  125575. private _positions32;
  125576. private _colors32;
  125577. private _uvs32;
  125578. private _updatable;
  125579. private _isVisibilityBoxLocked;
  125580. private _alwaysVisible;
  125581. private _groups;
  125582. private _groupCounter;
  125583. private _computeParticleColor;
  125584. private _computeParticleTexture;
  125585. private _computeParticleRotation;
  125586. private _computeBoundingBox;
  125587. private _isReady;
  125588. /**
  125589. * Creates a PCS (Points Cloud System) object
  125590. * @param name (String) is the PCS name, this will be the underlying mesh name
  125591. * @param pointSize (number) is the size for each point
  125592. * @param scene (Scene) is the scene in which the PCS is added
  125593. * @param options defines the options of the PCS e.g.
  125594. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  125595. */
  125596. constructor(name: string, pointSize: number, scene: Scene, options?: {
  125597. updatable?: boolean;
  125598. });
  125599. /**
  125600. * Builds the PCS underlying mesh. Returns a standard Mesh.
  125601. * If no points were added to the PCS, the returned mesh is just a single point.
  125602. * @returns a promise for the created mesh
  125603. */
  125604. buildMeshAsync(): Promise<Mesh>;
  125605. /**
  125606. * @hidden
  125607. */
  125608. private _buildMesh;
  125609. private _addParticle;
  125610. private _randomUnitVector;
  125611. private _getColorIndicesForCoord;
  125612. private _setPointsColorOrUV;
  125613. private _colorFromTexture;
  125614. private _calculateDensity;
  125615. /**
  125616. * Adds points to the PCS in random positions within a unit sphere
  125617. * @param nb (positive integer) the number of particles to be created from this model
  125618. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  125619. * @returns the number of groups in the system
  125620. */
  125621. addPoints(nb: number, pointFunction?: any): number;
  125622. /**
  125623. * Adds points to the PCS from the surface of the model shape
  125624. * @param mesh is any Mesh object that will be used as a surface model for the points
  125625. * @param nb (positive integer) the number of particles to be created from this model
  125626. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  125627. * @param color (color3) to be used when colorWith is stated
  125628. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125629. * @returns the number of groups in the system
  125630. */
  125631. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125632. /**
  125633. * Adds points to the PCS inside the model shape
  125634. * @param mesh is any Mesh object that will be used as a surface model for the points
  125635. * @param nb (positive integer) the number of particles to be created from this model
  125636. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  125637. * @param color (color4) to be used when colorWith is stated
  125638. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125639. * @returns the number of groups in the system
  125640. */
  125641. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125642. /**
  125643. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  125644. * This method calls `updateParticle()` for each particle of the SPS.
  125645. * For an animated SPS, it is usually called within the render loop.
  125646. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  125647. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  125648. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  125649. * @returns the PCS.
  125650. */
  125651. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  125652. /**
  125653. * Disposes the PCS.
  125654. */
  125655. dispose(): void;
  125656. /**
  125657. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  125658. * doc :
  125659. * @returns the PCS.
  125660. */
  125661. refreshVisibleSize(): PointsCloudSystem;
  125662. /**
  125663. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  125664. * @param size the size (float) of the visibility box
  125665. * note : this doesn't lock the PCS mesh bounding box.
  125666. * doc :
  125667. */
  125668. setVisibilityBox(size: number): void;
  125669. /**
  125670. * Gets whether the PCS is always visible or not
  125671. * doc :
  125672. */
  125673. /**
  125674. * Sets the PCS as always visible or not
  125675. * doc :
  125676. */
  125677. isAlwaysVisible: boolean;
  125678. /**
  125679. * Tells to `setParticles()` to compute the particle rotations or not
  125680. * Default value : false. The PCS is faster when it's set to false
  125681. * Note : particle rotations are only applied to parent particles
  125682. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  125683. */
  125684. computeParticleRotation: boolean;
  125685. /**
  125686. * Tells to `setParticles()` to compute the particle colors or not.
  125687. * Default value : true. The PCS is faster when it's set to false.
  125688. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125689. */
  125690. /**
  125691. * Gets if `setParticles()` computes the particle colors or not.
  125692. * Default value : false. The PCS is faster when it's set to false.
  125693. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125694. */
  125695. computeParticleColor: boolean;
  125696. /**
  125697. * Gets if `setParticles()` computes the particle textures or not.
  125698. * Default value : false. The PCS is faster when it's set to false.
  125699. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  125700. */
  125701. computeParticleTexture: boolean;
  125702. /**
  125703. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  125704. */
  125705. /**
  125706. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  125707. */
  125708. computeBoundingBox: boolean;
  125709. /**
  125710. * This function does nothing. It may be overwritten to set all the particle first values.
  125711. * The PCS doesn't call this function, you may have to call it by your own.
  125712. * doc :
  125713. */
  125714. initParticles(): void;
  125715. /**
  125716. * This function does nothing. It may be overwritten to recycle a particle
  125717. * The PCS doesn't call this function, you can to call it
  125718. * doc :
  125719. * @param particle The particle to recycle
  125720. * @returns the recycled particle
  125721. */
  125722. recycleParticle(particle: CloudPoint): CloudPoint;
  125723. /**
  125724. * Updates a particle : this function should be overwritten by the user.
  125725. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  125726. * doc :
  125727. * @example : just set a particle position or velocity and recycle conditions
  125728. * @param particle The particle to update
  125729. * @returns the updated particle
  125730. */
  125731. updateParticle(particle: CloudPoint): CloudPoint;
  125732. /**
  125733. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  125734. * This does nothing and may be overwritten by the user.
  125735. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  125736. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  125737. * @param update the boolean update value actually passed to setParticles()
  125738. */
  125739. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  125740. /**
  125741. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  125742. * This will be passed three parameters.
  125743. * This does nothing and may be overwritten by the user.
  125744. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  125745. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  125746. * @param update the boolean update value actually passed to setParticles()
  125747. */
  125748. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  125749. }
  125750. }
  125751. declare module BABYLON {
  125752. /**
  125753. * Represents one particle of a points cloud system.
  125754. */
  125755. export class CloudPoint {
  125756. /**
  125757. * particle global index
  125758. */
  125759. idx: number;
  125760. /**
  125761. * The color of the particle
  125762. */
  125763. color: Nullable<Color4>;
  125764. /**
  125765. * The world space position of the particle.
  125766. */
  125767. position: Vector3;
  125768. /**
  125769. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  125770. */
  125771. rotation: Vector3;
  125772. /**
  125773. * The world space rotation quaternion of the particle.
  125774. */
  125775. rotationQuaternion: Nullable<Quaternion>;
  125776. /**
  125777. * The uv of the particle.
  125778. */
  125779. uv: Nullable<Vector2>;
  125780. /**
  125781. * The current speed of the particle.
  125782. */
  125783. velocity: Vector3;
  125784. /**
  125785. * The pivot point in the particle local space.
  125786. */
  125787. pivot: Vector3;
  125788. /**
  125789. * Must the particle be translated from its pivot point in its local space ?
  125790. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  125791. * Default : false
  125792. */
  125793. translateFromPivot: boolean;
  125794. /**
  125795. * Index of this particle in the global "positions" array (Internal use)
  125796. * @hidden
  125797. */
  125798. _pos: number;
  125799. /**
  125800. * @hidden Index of this particle in the global "indices" array (Internal use)
  125801. */
  125802. _ind: number;
  125803. /**
  125804. * Group this particle belongs to
  125805. */
  125806. _group: PointsGroup;
  125807. /**
  125808. * Group id of this particle
  125809. */
  125810. groupId: number;
  125811. /**
  125812. * Index of the particle in its group id (Internal use)
  125813. */
  125814. idxInGroup: number;
  125815. /**
  125816. * @hidden Particle BoundingInfo object (Internal use)
  125817. */
  125818. _boundingInfo: BoundingInfo;
  125819. /**
  125820. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  125821. */
  125822. _pcs: PointsCloudSystem;
  125823. /**
  125824. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  125825. */
  125826. _stillInvisible: boolean;
  125827. /**
  125828. * @hidden Last computed particle rotation matrix
  125829. */
  125830. _rotationMatrix: number[];
  125831. /**
  125832. * Parent particle Id, if any.
  125833. * Default null.
  125834. */
  125835. parentId: Nullable<number>;
  125836. /**
  125837. * @hidden Internal global position in the PCS.
  125838. */
  125839. _globalPosition: Vector3;
  125840. /**
  125841. * Creates a Point Cloud object.
  125842. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  125843. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  125844. * @param group (PointsGroup) is the group the particle belongs to
  125845. * @param groupId (integer) is the group identifier in the PCS.
  125846. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  125847. * @param pcs defines the PCS it is associated to
  125848. */
  125849. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  125850. /**
  125851. * get point size
  125852. */
  125853. /**
  125854. * Set point size
  125855. */
  125856. size: Vector3;
  125857. /**
  125858. * Legacy support, changed quaternion to rotationQuaternion
  125859. */
  125860. /**
  125861. * Legacy support, changed quaternion to rotationQuaternion
  125862. */
  125863. quaternion: Nullable<Quaternion>;
  125864. /**
  125865. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  125866. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  125867. * @param target is the object (point or mesh) what the intersection is computed against.
  125868. * @returns true if it intersects
  125869. */
  125870. intersectsMesh(target: Mesh | CloudPoint): boolean;
  125871. /**
  125872. * get the rotation matrix of the particle
  125873. * @hidden
  125874. */
  125875. getRotationMatrix(m: Matrix): void;
  125876. }
  125877. /**
  125878. * Represents a group of points in a points cloud system
  125879. * * PCS internal tool, don't use it manually.
  125880. */
  125881. export class PointsGroup {
  125882. /**
  125883. * The group id
  125884. * @hidden
  125885. */
  125886. groupID: number;
  125887. /**
  125888. * image data for group (internal use)
  125889. * @hidden
  125890. */
  125891. _groupImageData: Nullable<ArrayBufferView>;
  125892. /**
  125893. * Image Width (internal use)
  125894. * @hidden
  125895. */
  125896. _groupImgWidth: number;
  125897. /**
  125898. * Image Height (internal use)
  125899. * @hidden
  125900. */
  125901. _groupImgHeight: number;
  125902. /**
  125903. * Custom position function (internal use)
  125904. * @hidden
  125905. */
  125906. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  125907. /**
  125908. * density per facet for surface points
  125909. * @hidden
  125910. */
  125911. _groupDensity: number[];
  125912. /**
  125913. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  125914. * PCS internal tool, don't use it manually.
  125915. * @hidden
  125916. */
  125917. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  125918. }
  125919. }
  125920. declare module BABYLON {
  125921. interface Scene {
  125922. /** @hidden (Backing field) */
  125923. _physicsEngine: Nullable<IPhysicsEngine>;
  125924. /**
  125925. * Gets the current physics engine
  125926. * @returns a IPhysicsEngine or null if none attached
  125927. */
  125928. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125929. /**
  125930. * Enables physics to the current scene
  125931. * @param gravity defines the scene's gravity for the physics engine
  125932. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125933. * @return a boolean indicating if the physics engine was initialized
  125934. */
  125935. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125936. /**
  125937. * Disables and disposes the physics engine associated with the scene
  125938. */
  125939. disablePhysicsEngine(): void;
  125940. /**
  125941. * Gets a boolean indicating if there is an active physics engine
  125942. * @returns a boolean indicating if there is an active physics engine
  125943. */
  125944. isPhysicsEnabled(): boolean;
  125945. /**
  125946. * Deletes a physics compound impostor
  125947. * @param compound defines the compound to delete
  125948. */
  125949. deleteCompoundImpostor(compound: any): void;
  125950. /**
  125951. * An event triggered when physic simulation is about to be run
  125952. */
  125953. onBeforePhysicsObservable: Observable<Scene>;
  125954. /**
  125955. * An event triggered when physic simulation has been done
  125956. */
  125957. onAfterPhysicsObservable: Observable<Scene>;
  125958. }
  125959. interface AbstractMesh {
  125960. /** @hidden */
  125961. _physicsImpostor: Nullable<PhysicsImpostor>;
  125962. /**
  125963. * Gets or sets impostor used for physic simulation
  125964. * @see http://doc.babylonjs.com/features/physics_engine
  125965. */
  125966. physicsImpostor: Nullable<PhysicsImpostor>;
  125967. /**
  125968. * Gets the current physics impostor
  125969. * @see http://doc.babylonjs.com/features/physics_engine
  125970. * @returns a physics impostor or null
  125971. */
  125972. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125973. /** Apply a physic impulse to the mesh
  125974. * @param force defines the force to apply
  125975. * @param contactPoint defines where to apply the force
  125976. * @returns the current mesh
  125977. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125978. */
  125979. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125980. /**
  125981. * Creates a physic joint between two meshes
  125982. * @param otherMesh defines the other mesh to use
  125983. * @param pivot1 defines the pivot to use on this mesh
  125984. * @param pivot2 defines the pivot to use on the other mesh
  125985. * @param options defines additional options (can be plugin dependent)
  125986. * @returns the current mesh
  125987. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125988. */
  125989. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125990. /** @hidden */
  125991. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125992. }
  125993. /**
  125994. * Defines the physics engine scene component responsible to manage a physics engine
  125995. */
  125996. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125997. /**
  125998. * The component name helpful to identify the component in the list of scene components.
  125999. */
  126000. readonly name: string;
  126001. /**
  126002. * The scene the component belongs to.
  126003. */
  126004. scene: Scene;
  126005. /**
  126006. * Creates a new instance of the component for the given scene
  126007. * @param scene Defines the scene to register the component in
  126008. */
  126009. constructor(scene: Scene);
  126010. /**
  126011. * Registers the component in a given scene
  126012. */
  126013. register(): void;
  126014. /**
  126015. * Rebuilds the elements related to this component in case of
  126016. * context lost for instance.
  126017. */
  126018. rebuild(): void;
  126019. /**
  126020. * Disposes the component and the associated ressources
  126021. */
  126022. dispose(): void;
  126023. }
  126024. }
  126025. declare module BABYLON {
  126026. /**
  126027. * A helper for physics simulations
  126028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126029. */
  126030. export class PhysicsHelper {
  126031. private _scene;
  126032. private _physicsEngine;
  126033. /**
  126034. * Initializes the Physics helper
  126035. * @param scene Babylon.js scene
  126036. */
  126037. constructor(scene: Scene);
  126038. /**
  126039. * Applies a radial explosion impulse
  126040. * @param origin the origin of the explosion
  126041. * @param radiusOrEventOptions the radius or the options of radial explosion
  126042. * @param strength the explosion strength
  126043. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126044. * @returns A physics radial explosion event, or null
  126045. */
  126046. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126047. /**
  126048. * Applies a radial explosion force
  126049. * @param origin the origin of the explosion
  126050. * @param radiusOrEventOptions the radius or the options of radial explosion
  126051. * @param strength the explosion strength
  126052. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126053. * @returns A physics radial explosion event, or null
  126054. */
  126055. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126056. /**
  126057. * Creates a gravitational field
  126058. * @param origin the origin of the explosion
  126059. * @param radiusOrEventOptions the radius or the options of radial explosion
  126060. * @param strength the explosion strength
  126061. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126062. * @returns A physics gravitational field event, or null
  126063. */
  126064. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126065. /**
  126066. * Creates a physics updraft event
  126067. * @param origin the origin of the updraft
  126068. * @param radiusOrEventOptions the radius or the options of the updraft
  126069. * @param strength the strength of the updraft
  126070. * @param height the height of the updraft
  126071. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126072. * @returns A physics updraft event, or null
  126073. */
  126074. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126075. /**
  126076. * Creates a physics vortex event
  126077. * @param origin the of the vortex
  126078. * @param radiusOrEventOptions the radius or the options of the vortex
  126079. * @param strength the strength of the vortex
  126080. * @param height the height of the vortex
  126081. * @returns a Physics vortex event, or null
  126082. * A physics vortex event or null
  126083. */
  126084. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126085. }
  126086. /**
  126087. * Represents a physics radial explosion event
  126088. */
  126089. class PhysicsRadialExplosionEvent {
  126090. private _scene;
  126091. private _options;
  126092. private _sphere;
  126093. private _dataFetched;
  126094. /**
  126095. * Initializes a radial explosioin event
  126096. * @param _scene BabylonJS scene
  126097. * @param _options The options for the vortex event
  126098. */
  126099. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126100. /**
  126101. * Returns the data related to the radial explosion event (sphere).
  126102. * @returns The radial explosion event data
  126103. */
  126104. getData(): PhysicsRadialExplosionEventData;
  126105. /**
  126106. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126107. * @param impostor A physics imposter
  126108. * @param origin the origin of the explosion
  126109. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126110. */
  126111. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126112. /**
  126113. * Triggers affecterd impostors callbacks
  126114. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126115. */
  126116. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126117. /**
  126118. * Disposes the sphere.
  126119. * @param force Specifies if the sphere should be disposed by force
  126120. */
  126121. dispose(force?: boolean): void;
  126122. /*** Helpers ***/
  126123. private _prepareSphere;
  126124. private _intersectsWithSphere;
  126125. }
  126126. /**
  126127. * Represents a gravitational field event
  126128. */
  126129. class PhysicsGravitationalFieldEvent {
  126130. private _physicsHelper;
  126131. private _scene;
  126132. private _origin;
  126133. private _options;
  126134. private _tickCallback;
  126135. private _sphere;
  126136. private _dataFetched;
  126137. /**
  126138. * Initializes the physics gravitational field event
  126139. * @param _physicsHelper A physics helper
  126140. * @param _scene BabylonJS scene
  126141. * @param _origin The origin position of the gravitational field event
  126142. * @param _options The options for the vortex event
  126143. */
  126144. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126145. /**
  126146. * Returns the data related to the gravitational field event (sphere).
  126147. * @returns A gravitational field event
  126148. */
  126149. getData(): PhysicsGravitationalFieldEventData;
  126150. /**
  126151. * Enables the gravitational field.
  126152. */
  126153. enable(): void;
  126154. /**
  126155. * Disables the gravitational field.
  126156. */
  126157. disable(): void;
  126158. /**
  126159. * Disposes the sphere.
  126160. * @param force The force to dispose from the gravitational field event
  126161. */
  126162. dispose(force?: boolean): void;
  126163. private _tick;
  126164. }
  126165. /**
  126166. * Represents a physics updraft event
  126167. */
  126168. class PhysicsUpdraftEvent {
  126169. private _scene;
  126170. private _origin;
  126171. private _options;
  126172. private _physicsEngine;
  126173. private _originTop;
  126174. private _originDirection;
  126175. private _tickCallback;
  126176. private _cylinder;
  126177. private _cylinderPosition;
  126178. private _dataFetched;
  126179. /**
  126180. * Initializes the physics updraft event
  126181. * @param _scene BabylonJS scene
  126182. * @param _origin The origin position of the updraft
  126183. * @param _options The options for the updraft event
  126184. */
  126185. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126186. /**
  126187. * Returns the data related to the updraft event (cylinder).
  126188. * @returns A physics updraft event
  126189. */
  126190. getData(): PhysicsUpdraftEventData;
  126191. /**
  126192. * Enables the updraft.
  126193. */
  126194. enable(): void;
  126195. /**
  126196. * Disables the updraft.
  126197. */
  126198. disable(): void;
  126199. /**
  126200. * Disposes the cylinder.
  126201. * @param force Specifies if the updraft should be disposed by force
  126202. */
  126203. dispose(force?: boolean): void;
  126204. private getImpostorHitData;
  126205. private _tick;
  126206. /*** Helpers ***/
  126207. private _prepareCylinder;
  126208. private _intersectsWithCylinder;
  126209. }
  126210. /**
  126211. * Represents a physics vortex event
  126212. */
  126213. class PhysicsVortexEvent {
  126214. private _scene;
  126215. private _origin;
  126216. private _options;
  126217. private _physicsEngine;
  126218. private _originTop;
  126219. private _tickCallback;
  126220. private _cylinder;
  126221. private _cylinderPosition;
  126222. private _dataFetched;
  126223. /**
  126224. * Initializes the physics vortex event
  126225. * @param _scene The BabylonJS scene
  126226. * @param _origin The origin position of the vortex
  126227. * @param _options The options for the vortex event
  126228. */
  126229. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126230. /**
  126231. * Returns the data related to the vortex event (cylinder).
  126232. * @returns The physics vortex event data
  126233. */
  126234. getData(): PhysicsVortexEventData;
  126235. /**
  126236. * Enables the vortex.
  126237. */
  126238. enable(): void;
  126239. /**
  126240. * Disables the cortex.
  126241. */
  126242. disable(): void;
  126243. /**
  126244. * Disposes the sphere.
  126245. * @param force
  126246. */
  126247. dispose(force?: boolean): void;
  126248. private getImpostorHitData;
  126249. private _tick;
  126250. /*** Helpers ***/
  126251. private _prepareCylinder;
  126252. private _intersectsWithCylinder;
  126253. }
  126254. /**
  126255. * Options fot the radial explosion event
  126256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126257. */
  126258. export class PhysicsRadialExplosionEventOptions {
  126259. /**
  126260. * The radius of the sphere for the radial explosion.
  126261. */
  126262. radius: number;
  126263. /**
  126264. * The strenth of the explosion.
  126265. */
  126266. strength: number;
  126267. /**
  126268. * The strenght of the force in correspondence to the distance of the affected object
  126269. */
  126270. falloff: PhysicsRadialImpulseFalloff;
  126271. /**
  126272. * Sphere options for the radial explosion.
  126273. */
  126274. sphere: {
  126275. segments: number;
  126276. diameter: number;
  126277. };
  126278. /**
  126279. * Sphere options for the radial explosion.
  126280. */
  126281. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126282. }
  126283. /**
  126284. * Options fot the updraft event
  126285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126286. */
  126287. export class PhysicsUpdraftEventOptions {
  126288. /**
  126289. * The radius of the cylinder for the vortex
  126290. */
  126291. radius: number;
  126292. /**
  126293. * The strenth of the updraft.
  126294. */
  126295. strength: number;
  126296. /**
  126297. * The height of the cylinder for the updraft.
  126298. */
  126299. height: number;
  126300. /**
  126301. * The mode for the the updraft.
  126302. */
  126303. updraftMode: PhysicsUpdraftMode;
  126304. }
  126305. /**
  126306. * Options fot the vortex event
  126307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126308. */
  126309. export class PhysicsVortexEventOptions {
  126310. /**
  126311. * The radius of the cylinder for the vortex
  126312. */
  126313. radius: number;
  126314. /**
  126315. * The strenth of the vortex.
  126316. */
  126317. strength: number;
  126318. /**
  126319. * The height of the cylinder for the vortex.
  126320. */
  126321. height: number;
  126322. /**
  126323. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126324. */
  126325. centripetalForceThreshold: number;
  126326. /**
  126327. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126328. */
  126329. centripetalForceMultiplier: number;
  126330. /**
  126331. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126332. */
  126333. centrifugalForceMultiplier: number;
  126334. /**
  126335. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126336. */
  126337. updraftForceMultiplier: number;
  126338. }
  126339. /**
  126340. * The strenght of the force in correspondence to the distance of the affected object
  126341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126342. */
  126343. export enum PhysicsRadialImpulseFalloff {
  126344. /** Defines that impulse is constant in strength across it's whole radius */
  126345. Constant = 0,
  126346. /** Defines that impulse gets weaker if it's further from the origin */
  126347. Linear = 1
  126348. }
  126349. /**
  126350. * The strength of the force in correspondence to the distance of the affected object
  126351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126352. */
  126353. export enum PhysicsUpdraftMode {
  126354. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126355. Center = 0,
  126356. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126357. Perpendicular = 1
  126358. }
  126359. /**
  126360. * Interface for a physics hit data
  126361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126362. */
  126363. export interface PhysicsHitData {
  126364. /**
  126365. * The force applied at the contact point
  126366. */
  126367. force: Vector3;
  126368. /**
  126369. * The contact point
  126370. */
  126371. contactPoint: Vector3;
  126372. /**
  126373. * The distance from the origin to the contact point
  126374. */
  126375. distanceFromOrigin: number;
  126376. }
  126377. /**
  126378. * Interface for radial explosion event data
  126379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126380. */
  126381. export interface PhysicsRadialExplosionEventData {
  126382. /**
  126383. * A sphere used for the radial explosion event
  126384. */
  126385. sphere: Mesh;
  126386. }
  126387. /**
  126388. * Interface for gravitational field event data
  126389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126390. */
  126391. export interface PhysicsGravitationalFieldEventData {
  126392. /**
  126393. * A sphere mesh used for the gravitational field event
  126394. */
  126395. sphere: Mesh;
  126396. }
  126397. /**
  126398. * Interface for updraft event data
  126399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126400. */
  126401. export interface PhysicsUpdraftEventData {
  126402. /**
  126403. * A cylinder used for the updraft event
  126404. */
  126405. cylinder: Mesh;
  126406. }
  126407. /**
  126408. * Interface for vortex event data
  126409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126410. */
  126411. export interface PhysicsVortexEventData {
  126412. /**
  126413. * A cylinder used for the vortex event
  126414. */
  126415. cylinder: Mesh;
  126416. }
  126417. /**
  126418. * Interface for an affected physics impostor
  126419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126420. */
  126421. export interface PhysicsAffectedImpostorWithData {
  126422. /**
  126423. * The impostor affected by the effect
  126424. */
  126425. impostor: PhysicsImpostor;
  126426. /**
  126427. * The data about the hit/horce from the explosion
  126428. */
  126429. hitData: PhysicsHitData;
  126430. }
  126431. }
  126432. declare module BABYLON {
  126433. /** @hidden */
  126434. export var blackAndWhitePixelShader: {
  126435. name: string;
  126436. shader: string;
  126437. };
  126438. }
  126439. declare module BABYLON {
  126440. /**
  126441. * Post process used to render in black and white
  126442. */
  126443. export class BlackAndWhitePostProcess extends PostProcess {
  126444. /**
  126445. * Linear about to convert he result to black and white (default: 1)
  126446. */
  126447. degree: number;
  126448. /**
  126449. * Creates a black and white post process
  126450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126451. * @param name The name of the effect.
  126452. * @param options The required width/height ratio to downsize to before computing the render pass.
  126453. * @param camera The camera to apply the render pass to.
  126454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126455. * @param engine The engine which the post process will be applied. (default: current engine)
  126456. * @param reusable If the post process can be reused on the same frame. (default: false)
  126457. */
  126458. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126459. }
  126460. }
  126461. declare module BABYLON {
  126462. /**
  126463. * This represents a set of one or more post processes in Babylon.
  126464. * A post process can be used to apply a shader to a texture after it is rendered.
  126465. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126466. */
  126467. export class PostProcessRenderEffect {
  126468. private _postProcesses;
  126469. private _getPostProcesses;
  126470. private _singleInstance;
  126471. private _cameras;
  126472. private _indicesForCamera;
  126473. /**
  126474. * Name of the effect
  126475. * @hidden
  126476. */
  126477. _name: string;
  126478. /**
  126479. * Instantiates a post process render effect.
  126480. * A post process can be used to apply a shader to a texture after it is rendered.
  126481. * @param engine The engine the effect is tied to
  126482. * @param name The name of the effect
  126483. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126484. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126485. */
  126486. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126487. /**
  126488. * Checks if all the post processes in the effect are supported.
  126489. */
  126490. readonly isSupported: boolean;
  126491. /**
  126492. * Updates the current state of the effect
  126493. * @hidden
  126494. */
  126495. _update(): void;
  126496. /**
  126497. * Attaches the effect on cameras
  126498. * @param cameras The camera to attach to.
  126499. * @hidden
  126500. */
  126501. _attachCameras(cameras: Camera): void;
  126502. /**
  126503. * Attaches the effect on cameras
  126504. * @param cameras The camera to attach to.
  126505. * @hidden
  126506. */
  126507. _attachCameras(cameras: Camera[]): void;
  126508. /**
  126509. * Detaches the effect on cameras
  126510. * @param cameras The camera to detatch from.
  126511. * @hidden
  126512. */
  126513. _detachCameras(cameras: Camera): void;
  126514. /**
  126515. * Detatches the effect on cameras
  126516. * @param cameras The camera to detatch from.
  126517. * @hidden
  126518. */
  126519. _detachCameras(cameras: Camera[]): void;
  126520. /**
  126521. * Enables the effect on given cameras
  126522. * @param cameras The camera to enable.
  126523. * @hidden
  126524. */
  126525. _enable(cameras: Camera): void;
  126526. /**
  126527. * Enables the effect on given cameras
  126528. * @param cameras The camera to enable.
  126529. * @hidden
  126530. */
  126531. _enable(cameras: Nullable<Camera[]>): void;
  126532. /**
  126533. * Disables the effect on the given cameras
  126534. * @param cameras The camera to disable.
  126535. * @hidden
  126536. */
  126537. _disable(cameras: Camera): void;
  126538. /**
  126539. * Disables the effect on the given cameras
  126540. * @param cameras The camera to disable.
  126541. * @hidden
  126542. */
  126543. _disable(cameras: Nullable<Camera[]>): void;
  126544. /**
  126545. * Gets a list of the post processes contained in the effect.
  126546. * @param camera The camera to get the post processes on.
  126547. * @returns The list of the post processes in the effect.
  126548. */
  126549. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126550. }
  126551. }
  126552. declare module BABYLON {
  126553. /** @hidden */
  126554. export var extractHighlightsPixelShader: {
  126555. name: string;
  126556. shader: string;
  126557. };
  126558. }
  126559. declare module BABYLON {
  126560. /**
  126561. * 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.
  126562. */
  126563. export class ExtractHighlightsPostProcess extends PostProcess {
  126564. /**
  126565. * The luminance threshold, pixels below this value will be set to black.
  126566. */
  126567. threshold: number;
  126568. /** @hidden */
  126569. _exposure: number;
  126570. /**
  126571. * Post process which has the input texture to be used when performing highlight extraction
  126572. * @hidden
  126573. */
  126574. _inputPostProcess: Nullable<PostProcess>;
  126575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126576. }
  126577. }
  126578. declare module BABYLON {
  126579. /** @hidden */
  126580. export var bloomMergePixelShader: {
  126581. name: string;
  126582. shader: string;
  126583. };
  126584. }
  126585. declare module BABYLON {
  126586. /**
  126587. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126588. */
  126589. export class BloomMergePostProcess extends PostProcess {
  126590. /** Weight of the bloom to be added to the original input. */
  126591. weight: number;
  126592. /**
  126593. * Creates a new instance of @see BloomMergePostProcess
  126594. * @param name The name of the effect.
  126595. * @param originalFromInput Post process which's input will be used for the merge.
  126596. * @param blurred Blurred highlights post process which's output will be used.
  126597. * @param weight Weight of the bloom to be added to the original input.
  126598. * @param options The required width/height ratio to downsize to before computing the render pass.
  126599. * @param camera The camera to apply the render pass to.
  126600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126601. * @param engine The engine which the post process will be applied. (default: current engine)
  126602. * @param reusable If the post process can be reused on the same frame. (default: false)
  126603. * @param textureType Type of textures used when performing the post process. (default: 0)
  126604. * @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)
  126605. */
  126606. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  126607. /** Weight of the bloom to be added to the original input. */
  126608. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126609. }
  126610. }
  126611. declare module BABYLON {
  126612. /**
  126613. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  126614. */
  126615. export class BloomEffect extends PostProcessRenderEffect {
  126616. private bloomScale;
  126617. /**
  126618. * @hidden Internal
  126619. */
  126620. _effects: Array<PostProcess>;
  126621. /**
  126622. * @hidden Internal
  126623. */
  126624. _downscale: ExtractHighlightsPostProcess;
  126625. private _blurX;
  126626. private _blurY;
  126627. private _merge;
  126628. /**
  126629. * The luminance threshold to find bright areas of the image to bloom.
  126630. */
  126631. threshold: number;
  126632. /**
  126633. * The strength of the bloom.
  126634. */
  126635. weight: number;
  126636. /**
  126637. * Specifies the size of the bloom blur kernel, relative to the final output size
  126638. */
  126639. kernel: number;
  126640. /**
  126641. * Creates a new instance of @see BloomEffect
  126642. * @param scene The scene the effect belongs to.
  126643. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  126644. * @param bloomKernel The size of the kernel to be used when applying the blur.
  126645. * @param bloomWeight The the strength of bloom.
  126646. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126647. * @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)
  126648. */
  126649. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  126650. /**
  126651. * Disposes each of the internal effects for a given camera.
  126652. * @param camera The camera to dispose the effect on.
  126653. */
  126654. disposeEffects(camera: Camera): void;
  126655. /**
  126656. * @hidden Internal
  126657. */
  126658. _updateEffects(): void;
  126659. /**
  126660. * Internal
  126661. * @returns if all the contained post processes are ready.
  126662. * @hidden
  126663. */
  126664. _isReady(): boolean;
  126665. }
  126666. }
  126667. declare module BABYLON {
  126668. /** @hidden */
  126669. export var chromaticAberrationPixelShader: {
  126670. name: string;
  126671. shader: string;
  126672. };
  126673. }
  126674. declare module BABYLON {
  126675. /**
  126676. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  126677. */
  126678. export class ChromaticAberrationPostProcess extends PostProcess {
  126679. /**
  126680. * The amount of seperation of rgb channels (default: 30)
  126681. */
  126682. aberrationAmount: number;
  126683. /**
  126684. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  126685. */
  126686. radialIntensity: number;
  126687. /**
  126688. * 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))
  126689. */
  126690. direction: Vector2;
  126691. /**
  126692. * 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))
  126693. */
  126694. centerPosition: Vector2;
  126695. /**
  126696. * Creates a new instance ChromaticAberrationPostProcess
  126697. * @param name The name of the effect.
  126698. * @param screenWidth The width of the screen to apply the effect on.
  126699. * @param screenHeight The height of the screen to apply the effect on.
  126700. * @param options The required width/height ratio to downsize to before computing the render pass.
  126701. * @param camera The camera to apply the render pass to.
  126702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126703. * @param engine The engine which the post process will be applied. (default: current engine)
  126704. * @param reusable If the post process can be reused on the same frame. (default: false)
  126705. * @param textureType Type of textures used when performing the post process. (default: 0)
  126706. * @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)
  126707. */
  126708. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126709. }
  126710. }
  126711. declare module BABYLON {
  126712. /** @hidden */
  126713. export var circleOfConfusionPixelShader: {
  126714. name: string;
  126715. shader: string;
  126716. };
  126717. }
  126718. declare module BABYLON {
  126719. /**
  126720. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  126721. */
  126722. export class CircleOfConfusionPostProcess extends PostProcess {
  126723. /**
  126724. * 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.
  126725. */
  126726. lensSize: number;
  126727. /**
  126728. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126729. */
  126730. fStop: number;
  126731. /**
  126732. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126733. */
  126734. focusDistance: number;
  126735. /**
  126736. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  126737. */
  126738. focalLength: number;
  126739. private _depthTexture;
  126740. /**
  126741. * Creates a new instance CircleOfConfusionPostProcess
  126742. * @param name The name of the effect.
  126743. * @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.
  126744. * @param options The required width/height ratio to downsize to before computing the render pass.
  126745. * @param camera The camera to apply the render pass to.
  126746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126747. * @param engine The engine which the post process will be applied. (default: current engine)
  126748. * @param reusable If the post process can be reused on the same frame. (default: false)
  126749. * @param textureType Type of textures used when performing the post process. (default: 0)
  126750. * @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)
  126751. */
  126752. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126753. /**
  126754. * 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.
  126755. */
  126756. depthTexture: RenderTargetTexture;
  126757. }
  126758. }
  126759. declare module BABYLON {
  126760. /** @hidden */
  126761. export var colorCorrectionPixelShader: {
  126762. name: string;
  126763. shader: string;
  126764. };
  126765. }
  126766. declare module BABYLON {
  126767. /**
  126768. *
  126769. * This post-process allows the modification of rendered colors by using
  126770. * a 'look-up table' (LUT). This effect is also called Color Grading.
  126771. *
  126772. * The object needs to be provided an url to a texture containing the color
  126773. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  126774. * Use an image editing software to tweak the LUT to match your needs.
  126775. *
  126776. * For an example of a color LUT, see here:
  126777. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  126778. * For explanations on color grading, see here:
  126779. * @see http://udn.epicgames.com/Three/ColorGrading.html
  126780. *
  126781. */
  126782. export class ColorCorrectionPostProcess extends PostProcess {
  126783. private _colorTableTexture;
  126784. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126785. }
  126786. }
  126787. declare module BABYLON {
  126788. /** @hidden */
  126789. export var convolutionPixelShader: {
  126790. name: string;
  126791. shader: string;
  126792. };
  126793. }
  126794. declare module BABYLON {
  126795. /**
  126796. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  126797. * input texture to perform effects such as edge detection or sharpening
  126798. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126799. */
  126800. export class ConvolutionPostProcess extends PostProcess {
  126801. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  126802. kernel: number[];
  126803. /**
  126804. * Creates a new instance ConvolutionPostProcess
  126805. * @param name The name of the effect.
  126806. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  126807. * @param options The required width/height ratio to downsize to before computing the render pass.
  126808. * @param camera The camera to apply the render pass to.
  126809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126810. * @param engine The engine which the post process will be applied. (default: current engine)
  126811. * @param reusable If the post process can be reused on the same frame. (default: false)
  126812. * @param textureType Type of textures used when performing the post process. (default: 0)
  126813. */
  126814. constructor(name: string,
  126815. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  126816. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126817. /**
  126818. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126819. */
  126820. static EdgeDetect0Kernel: number[];
  126821. /**
  126822. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126823. */
  126824. static EdgeDetect1Kernel: number[];
  126825. /**
  126826. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126827. */
  126828. static EdgeDetect2Kernel: number[];
  126829. /**
  126830. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126831. */
  126832. static SharpenKernel: number[];
  126833. /**
  126834. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126835. */
  126836. static EmbossKernel: number[];
  126837. /**
  126838. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126839. */
  126840. static GaussianKernel: number[];
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. /**
  126845. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126846. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126847. * based on samples that have a large difference in distance than the center pixel.
  126848. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126849. */
  126850. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126851. direction: Vector2;
  126852. /**
  126853. * Creates a new instance CircleOfConfusionPostProcess
  126854. * @param name The name of the effect.
  126855. * @param scene The scene the effect belongs to.
  126856. * @param direction The direction the blur should be applied.
  126857. * @param kernel The size of the kernel used to blur.
  126858. * @param options The required width/height ratio to downsize to before computing the render pass.
  126859. * @param camera The camera to apply the render pass to.
  126860. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126861. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126863. * @param engine The engine which the post process will be applied. (default: current engine)
  126864. * @param reusable If the post process can be reused on the same frame. (default: false)
  126865. * @param textureType Type of textures used when performing the post process. (default: 0)
  126866. * @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)
  126867. */
  126868. 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);
  126869. }
  126870. }
  126871. declare module BABYLON {
  126872. /** @hidden */
  126873. export var depthOfFieldMergePixelShader: {
  126874. name: string;
  126875. shader: string;
  126876. };
  126877. }
  126878. declare module BABYLON {
  126879. /**
  126880. * Options to be set when merging outputs from the default pipeline.
  126881. */
  126882. export class DepthOfFieldMergePostProcessOptions {
  126883. /**
  126884. * The original image to merge on top of
  126885. */
  126886. originalFromInput: PostProcess;
  126887. /**
  126888. * Parameters to perform the merge of the depth of field effect
  126889. */
  126890. depthOfField?: {
  126891. circleOfConfusion: PostProcess;
  126892. blurSteps: Array<PostProcess>;
  126893. };
  126894. /**
  126895. * Parameters to perform the merge of bloom effect
  126896. */
  126897. bloom?: {
  126898. blurred: PostProcess;
  126899. weight: number;
  126900. };
  126901. }
  126902. /**
  126903. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126904. */
  126905. export class DepthOfFieldMergePostProcess extends PostProcess {
  126906. private blurSteps;
  126907. /**
  126908. * Creates a new instance of DepthOfFieldMergePostProcess
  126909. * @param name The name of the effect.
  126910. * @param originalFromInput Post process which's input will be used for the merge.
  126911. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126912. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126913. * @param options The required width/height ratio to downsize to before computing the render pass.
  126914. * @param camera The camera to apply the render pass to.
  126915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126916. * @param engine The engine which the post process will be applied. (default: current engine)
  126917. * @param reusable If the post process can be reused on the same frame. (default: false)
  126918. * @param textureType Type of textures used when performing the post process. (default: 0)
  126919. * @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)
  126920. */
  126921. 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);
  126922. /**
  126923. * Updates the effect with the current post process compile time values and recompiles the shader.
  126924. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126925. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126926. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126927. * @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
  126928. * @param onCompiled Called when the shader has been compiled.
  126929. * @param onError Called if there is an error when compiling a shader.
  126930. */
  126931. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126932. }
  126933. }
  126934. declare module BABYLON {
  126935. /**
  126936. * Specifies the level of max blur that should be applied when using the depth of field effect
  126937. */
  126938. export enum DepthOfFieldEffectBlurLevel {
  126939. /**
  126940. * Subtle blur
  126941. */
  126942. Low = 0,
  126943. /**
  126944. * Medium blur
  126945. */
  126946. Medium = 1,
  126947. /**
  126948. * Large blur
  126949. */
  126950. High = 2
  126951. }
  126952. /**
  126953. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126954. */
  126955. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126956. private _circleOfConfusion;
  126957. /**
  126958. * @hidden Internal, blurs from high to low
  126959. */
  126960. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126961. private _depthOfFieldBlurY;
  126962. private _dofMerge;
  126963. /**
  126964. * @hidden Internal post processes in depth of field effect
  126965. */
  126966. _effects: Array<PostProcess>;
  126967. /**
  126968. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126969. */
  126970. focalLength: number;
  126971. /**
  126972. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126973. */
  126974. fStop: number;
  126975. /**
  126976. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126977. */
  126978. focusDistance: number;
  126979. /**
  126980. * 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.
  126981. */
  126982. lensSize: number;
  126983. /**
  126984. * Creates a new instance DepthOfFieldEffect
  126985. * @param scene The scene the effect belongs to.
  126986. * @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.
  126987. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126988. * @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)
  126989. */
  126990. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126991. /**
  126992. * Get the current class name of the current effet
  126993. * @returns "DepthOfFieldEffect"
  126994. */
  126995. getClassName(): string;
  126996. /**
  126997. * 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.
  126998. */
  126999. depthTexture: RenderTargetTexture;
  127000. /**
  127001. * Disposes each of the internal effects for a given camera.
  127002. * @param camera The camera to dispose the effect on.
  127003. */
  127004. disposeEffects(camera: Camera): void;
  127005. /**
  127006. * @hidden Internal
  127007. */
  127008. _updateEffects(): void;
  127009. /**
  127010. * Internal
  127011. * @returns if all the contained post processes are ready.
  127012. * @hidden
  127013. */
  127014. _isReady(): boolean;
  127015. }
  127016. }
  127017. declare module BABYLON {
  127018. /** @hidden */
  127019. export var displayPassPixelShader: {
  127020. name: string;
  127021. shader: string;
  127022. };
  127023. }
  127024. declare module BABYLON {
  127025. /**
  127026. * DisplayPassPostProcess which produces an output the same as it's input
  127027. */
  127028. export class DisplayPassPostProcess extends PostProcess {
  127029. /**
  127030. * Creates the DisplayPassPostProcess
  127031. * @param name The name of the effect.
  127032. * @param options The required width/height ratio to downsize to before computing the render pass.
  127033. * @param camera The camera to apply the render pass to.
  127034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127035. * @param engine The engine which the post process will be applied. (default: current engine)
  127036. * @param reusable If the post process can be reused on the same frame. (default: false)
  127037. */
  127038. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127039. }
  127040. }
  127041. declare module BABYLON {
  127042. /** @hidden */
  127043. export var filterPixelShader: {
  127044. name: string;
  127045. shader: string;
  127046. };
  127047. }
  127048. declare module BABYLON {
  127049. /**
  127050. * Applies a kernel filter to the image
  127051. */
  127052. export class FilterPostProcess extends PostProcess {
  127053. /** The matrix to be applied to the image */
  127054. kernelMatrix: Matrix;
  127055. /**
  127056. *
  127057. * @param name The name of the effect.
  127058. * @param kernelMatrix The matrix to be applied to the image
  127059. * @param options The required width/height ratio to downsize to before computing the render pass.
  127060. * @param camera The camera to apply the render pass to.
  127061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127062. * @param engine The engine which the post process will be applied. (default: current engine)
  127063. * @param reusable If the post process can be reused on the same frame. (default: false)
  127064. */
  127065. constructor(name: string,
  127066. /** The matrix to be applied to the image */
  127067. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127068. }
  127069. }
  127070. declare module BABYLON {
  127071. /** @hidden */
  127072. export var fxaaPixelShader: {
  127073. name: string;
  127074. shader: string;
  127075. };
  127076. }
  127077. declare module BABYLON {
  127078. /** @hidden */
  127079. export var fxaaVertexShader: {
  127080. name: string;
  127081. shader: string;
  127082. };
  127083. }
  127084. declare module BABYLON {
  127085. /**
  127086. * Fxaa post process
  127087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127088. */
  127089. export class FxaaPostProcess extends PostProcess {
  127090. /** @hidden */
  127091. texelWidth: number;
  127092. /** @hidden */
  127093. texelHeight: number;
  127094. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127095. private _getDefines;
  127096. }
  127097. }
  127098. declare module BABYLON {
  127099. /** @hidden */
  127100. export var grainPixelShader: {
  127101. name: string;
  127102. shader: string;
  127103. };
  127104. }
  127105. declare module BABYLON {
  127106. /**
  127107. * The GrainPostProcess adds noise to the image at mid luminance levels
  127108. */
  127109. export class GrainPostProcess extends PostProcess {
  127110. /**
  127111. * The intensity of the grain added (default: 30)
  127112. */
  127113. intensity: number;
  127114. /**
  127115. * If the grain should be randomized on every frame
  127116. */
  127117. animated: boolean;
  127118. /**
  127119. * Creates a new instance of @see GrainPostProcess
  127120. * @param name The name of the effect.
  127121. * @param options The required width/height ratio to downsize to before computing the render pass.
  127122. * @param camera The camera to apply the render pass to.
  127123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127124. * @param engine The engine which the post process will be applied. (default: current engine)
  127125. * @param reusable If the post process can be reused on the same frame. (default: false)
  127126. * @param textureType Type of textures used when performing the post process. (default: 0)
  127127. * @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)
  127128. */
  127129. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127130. }
  127131. }
  127132. declare module BABYLON {
  127133. /** @hidden */
  127134. export var highlightsPixelShader: {
  127135. name: string;
  127136. shader: string;
  127137. };
  127138. }
  127139. declare module BABYLON {
  127140. /**
  127141. * Extracts highlights from the image
  127142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127143. */
  127144. export class HighlightsPostProcess extends PostProcess {
  127145. /**
  127146. * Extracts highlights from the image
  127147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127148. * @param name The name of the effect.
  127149. * @param options The required width/height ratio to downsize to before computing the render pass.
  127150. * @param camera The camera to apply the render pass to.
  127151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127152. * @param engine The engine which the post process will be applied. (default: current engine)
  127153. * @param reusable If the post process can be reused on the same frame. (default: false)
  127154. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127155. */
  127156. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127157. }
  127158. }
  127159. declare module BABYLON {
  127160. /** @hidden */
  127161. export var mrtFragmentDeclaration: {
  127162. name: string;
  127163. shader: string;
  127164. };
  127165. }
  127166. declare module BABYLON {
  127167. /** @hidden */
  127168. export var geometryPixelShader: {
  127169. name: string;
  127170. shader: string;
  127171. };
  127172. }
  127173. declare module BABYLON {
  127174. /** @hidden */
  127175. export var geometryVertexShader: {
  127176. name: string;
  127177. shader: string;
  127178. };
  127179. }
  127180. declare module BABYLON {
  127181. /** @hidden */
  127182. interface ISavedTransformationMatrix {
  127183. world: Matrix;
  127184. viewProjection: Matrix;
  127185. }
  127186. /**
  127187. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127188. */
  127189. export class GeometryBufferRenderer {
  127190. /**
  127191. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127192. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127193. */
  127194. static readonly POSITION_TEXTURE_TYPE: number;
  127195. /**
  127196. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127197. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127198. */
  127199. static readonly VELOCITY_TEXTURE_TYPE: number;
  127200. /**
  127201. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127202. * in order to compute objects velocities when enableVelocity is set to "true"
  127203. * @hidden
  127204. */
  127205. _previousTransformationMatrices: {
  127206. [index: number]: ISavedTransformationMatrix;
  127207. };
  127208. /**
  127209. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127210. * in order to compute objects velocities when enableVelocity is set to "true"
  127211. * @hidden
  127212. */
  127213. _previousBonesTransformationMatrices: {
  127214. [index: number]: Float32Array;
  127215. };
  127216. /**
  127217. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127218. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127219. */
  127220. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127221. private _scene;
  127222. private _multiRenderTarget;
  127223. private _ratio;
  127224. private _enablePosition;
  127225. private _enableVelocity;
  127226. private _positionIndex;
  127227. private _velocityIndex;
  127228. protected _effect: Effect;
  127229. protected _cachedDefines: string;
  127230. /**
  127231. * Set the render list (meshes to be rendered) used in the G buffer.
  127232. */
  127233. renderList: Mesh[];
  127234. /**
  127235. * Gets wether or not G buffer are supported by the running hardware.
  127236. * This requires draw buffer supports
  127237. */
  127238. readonly isSupported: boolean;
  127239. /**
  127240. * Returns the index of the given texture type in the G-Buffer textures array
  127241. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127242. * @returns the index of the given texture type in the G-Buffer textures array
  127243. */
  127244. getTextureIndex(textureType: number): number;
  127245. /**
  127246. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127247. */
  127248. /**
  127249. * Sets whether or not objects positions are enabled for the G buffer.
  127250. */
  127251. enablePosition: boolean;
  127252. /**
  127253. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127254. */
  127255. /**
  127256. * Sets wether or not objects velocities are enabled for the G buffer.
  127257. */
  127258. enableVelocity: boolean;
  127259. /**
  127260. * Gets the scene associated with the buffer.
  127261. */
  127262. readonly scene: Scene;
  127263. /**
  127264. * Gets the ratio used by the buffer during its creation.
  127265. * How big is the buffer related to the main canvas.
  127266. */
  127267. readonly ratio: number;
  127268. /** @hidden */
  127269. static _SceneComponentInitialization: (scene: Scene) => void;
  127270. /**
  127271. * Creates a new G Buffer for the scene
  127272. * @param scene The scene the buffer belongs to
  127273. * @param ratio How big is the buffer related to the main canvas.
  127274. */
  127275. constructor(scene: Scene, ratio?: number);
  127276. /**
  127277. * Checks wether everything is ready to render a submesh to the G buffer.
  127278. * @param subMesh the submesh to check readiness for
  127279. * @param useInstances is the mesh drawn using instance or not
  127280. * @returns true if ready otherwise false
  127281. */
  127282. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127283. /**
  127284. * Gets the current underlying G Buffer.
  127285. * @returns the buffer
  127286. */
  127287. getGBuffer(): MultiRenderTarget;
  127288. /**
  127289. * Gets the number of samples used to render the buffer (anti aliasing).
  127290. */
  127291. /**
  127292. * Sets the number of samples used to render the buffer (anti aliasing).
  127293. */
  127294. samples: number;
  127295. /**
  127296. * Disposes the renderer and frees up associated resources.
  127297. */
  127298. dispose(): void;
  127299. protected _createRenderTargets(): void;
  127300. private _copyBonesTransformationMatrices;
  127301. }
  127302. }
  127303. declare module BABYLON {
  127304. interface Scene {
  127305. /** @hidden (Backing field) */
  127306. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127307. /**
  127308. * Gets or Sets the current geometry buffer associated to the scene.
  127309. */
  127310. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127311. /**
  127312. * Enables a GeometryBufferRender and associates it with the scene
  127313. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127314. * @returns the GeometryBufferRenderer
  127315. */
  127316. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127317. /**
  127318. * Disables the GeometryBufferRender associated with the scene
  127319. */
  127320. disableGeometryBufferRenderer(): void;
  127321. }
  127322. /**
  127323. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127324. * in several rendering techniques.
  127325. */
  127326. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127327. /**
  127328. * The component name helpful to identify the component in the list of scene components.
  127329. */
  127330. readonly name: string;
  127331. /**
  127332. * The scene the component belongs to.
  127333. */
  127334. scene: Scene;
  127335. /**
  127336. * Creates a new instance of the component for the given scene
  127337. * @param scene Defines the scene to register the component in
  127338. */
  127339. constructor(scene: Scene);
  127340. /**
  127341. * Registers the component in a given scene
  127342. */
  127343. register(): void;
  127344. /**
  127345. * Rebuilds the elements related to this component in case of
  127346. * context lost for instance.
  127347. */
  127348. rebuild(): void;
  127349. /**
  127350. * Disposes the component and the associated ressources
  127351. */
  127352. dispose(): void;
  127353. private _gatherRenderTargets;
  127354. }
  127355. }
  127356. declare module BABYLON {
  127357. /** @hidden */
  127358. export var motionBlurPixelShader: {
  127359. name: string;
  127360. shader: string;
  127361. };
  127362. }
  127363. declare module BABYLON {
  127364. /**
  127365. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127366. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127367. * As an example, all you have to do is to create the post-process:
  127368. * var mb = new BABYLON.MotionBlurPostProcess(
  127369. * 'mb', // The name of the effect.
  127370. * scene, // The scene containing the objects to blur according to their velocity.
  127371. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127372. * camera // The camera to apply the render pass to.
  127373. * );
  127374. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127375. */
  127376. export class MotionBlurPostProcess extends PostProcess {
  127377. /**
  127378. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127379. */
  127380. motionStrength: number;
  127381. /**
  127382. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127383. */
  127384. /**
  127385. * Sets the number of iterations to be used for motion blur quality
  127386. */
  127387. motionBlurSamples: number;
  127388. private _motionBlurSamples;
  127389. private _geometryBufferRenderer;
  127390. /**
  127391. * Creates a new instance MotionBlurPostProcess
  127392. * @param name The name of the effect.
  127393. * @param scene The scene containing the objects to blur according to their velocity.
  127394. * @param options The required width/height ratio to downsize to before computing the render pass.
  127395. * @param camera The camera to apply the render pass to.
  127396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127397. * @param engine The engine which the post process will be applied. (default: current engine)
  127398. * @param reusable If the post process can be reused on the same frame. (default: false)
  127399. * @param textureType Type of textures used when performing the post process. (default: 0)
  127400. * @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)
  127401. */
  127402. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127403. /**
  127404. * Excludes the given skinned mesh from computing bones velocities.
  127405. * 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.
  127406. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127407. */
  127408. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127409. /**
  127410. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127411. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127412. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127413. */
  127414. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127415. /**
  127416. * Disposes the post process.
  127417. * @param camera The camera to dispose the post process on.
  127418. */
  127419. dispose(camera?: Camera): void;
  127420. }
  127421. }
  127422. declare module BABYLON {
  127423. /** @hidden */
  127424. export var refractionPixelShader: {
  127425. name: string;
  127426. shader: string;
  127427. };
  127428. }
  127429. declare module BABYLON {
  127430. /**
  127431. * Post process which applies a refractin texture
  127432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127433. */
  127434. export class RefractionPostProcess extends PostProcess {
  127435. /** the base color of the refraction (used to taint the rendering) */
  127436. color: Color3;
  127437. /** simulated refraction depth */
  127438. depth: number;
  127439. /** the coefficient of the base color (0 to remove base color tainting) */
  127440. colorLevel: number;
  127441. private _refTexture;
  127442. private _ownRefractionTexture;
  127443. /**
  127444. * Gets or sets the refraction texture
  127445. * Please note that you are responsible for disposing the texture if you set it manually
  127446. */
  127447. refractionTexture: Texture;
  127448. /**
  127449. * Initializes the RefractionPostProcess
  127450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127451. * @param name The name of the effect.
  127452. * @param refractionTextureUrl Url of the refraction texture to use
  127453. * @param color the base color of the refraction (used to taint the rendering)
  127454. * @param depth simulated refraction depth
  127455. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127456. * @param camera The camera to apply the render pass to.
  127457. * @param options The required width/height ratio to downsize to before computing the render pass.
  127458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127459. * @param engine The engine which the post process will be applied. (default: current engine)
  127460. * @param reusable If the post process can be reused on the same frame. (default: false)
  127461. */
  127462. constructor(name: string, refractionTextureUrl: string,
  127463. /** the base color of the refraction (used to taint the rendering) */
  127464. color: Color3,
  127465. /** simulated refraction depth */
  127466. depth: number,
  127467. /** the coefficient of the base color (0 to remove base color tainting) */
  127468. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127469. /**
  127470. * Disposes of the post process
  127471. * @param camera Camera to dispose post process on
  127472. */
  127473. dispose(camera: Camera): void;
  127474. }
  127475. }
  127476. declare module BABYLON {
  127477. /** @hidden */
  127478. export var sharpenPixelShader: {
  127479. name: string;
  127480. shader: string;
  127481. };
  127482. }
  127483. declare module BABYLON {
  127484. /**
  127485. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127486. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127487. */
  127488. export class SharpenPostProcess extends PostProcess {
  127489. /**
  127490. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127491. */
  127492. colorAmount: number;
  127493. /**
  127494. * How much sharpness should be applied (default: 0.3)
  127495. */
  127496. edgeAmount: number;
  127497. /**
  127498. * Creates a new instance ConvolutionPostProcess
  127499. * @param name The name of the effect.
  127500. * @param options The required width/height ratio to downsize to before computing the render pass.
  127501. * @param camera The camera to apply the render pass to.
  127502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127503. * @param engine The engine which the post process will be applied. (default: current engine)
  127504. * @param reusable If the post process can be reused on the same frame. (default: false)
  127505. * @param textureType Type of textures used when performing the post process. (default: 0)
  127506. * @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)
  127507. */
  127508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127509. }
  127510. }
  127511. declare module BABYLON {
  127512. /**
  127513. * PostProcessRenderPipeline
  127514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127515. */
  127516. export class PostProcessRenderPipeline {
  127517. private engine;
  127518. private _renderEffects;
  127519. private _renderEffectsForIsolatedPass;
  127520. /**
  127521. * List of inspectable custom properties (used by the Inspector)
  127522. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127523. */
  127524. inspectableCustomProperties: IInspectable[];
  127525. /**
  127526. * @hidden
  127527. */
  127528. protected _cameras: Camera[];
  127529. /** @hidden */
  127530. _name: string;
  127531. /**
  127532. * Gets pipeline name
  127533. */
  127534. readonly name: string;
  127535. /**
  127536. * Initializes a PostProcessRenderPipeline
  127537. * @param engine engine to add the pipeline to
  127538. * @param name name of the pipeline
  127539. */
  127540. constructor(engine: Engine, name: string);
  127541. /**
  127542. * Gets the class name
  127543. * @returns "PostProcessRenderPipeline"
  127544. */
  127545. getClassName(): string;
  127546. /**
  127547. * If all the render effects in the pipeline are supported
  127548. */
  127549. readonly isSupported: boolean;
  127550. /**
  127551. * Adds an effect to the pipeline
  127552. * @param renderEffect the effect to add
  127553. */
  127554. addEffect(renderEffect: PostProcessRenderEffect): void;
  127555. /** @hidden */
  127556. _rebuild(): void;
  127557. /** @hidden */
  127558. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127559. /** @hidden */
  127560. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127561. /** @hidden */
  127562. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127563. /** @hidden */
  127564. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127565. /** @hidden */
  127566. _attachCameras(cameras: Camera, unique: boolean): void;
  127567. /** @hidden */
  127568. _attachCameras(cameras: Camera[], unique: boolean): void;
  127569. /** @hidden */
  127570. _detachCameras(cameras: Camera): void;
  127571. /** @hidden */
  127572. _detachCameras(cameras: Nullable<Camera[]>): void;
  127573. /** @hidden */
  127574. _update(): void;
  127575. /** @hidden */
  127576. _reset(): void;
  127577. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127578. /**
  127579. * Disposes of the pipeline
  127580. */
  127581. dispose(): void;
  127582. }
  127583. }
  127584. declare module BABYLON {
  127585. /**
  127586. * PostProcessRenderPipelineManager class
  127587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127588. */
  127589. export class PostProcessRenderPipelineManager {
  127590. private _renderPipelines;
  127591. /**
  127592. * Initializes a PostProcessRenderPipelineManager
  127593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127594. */
  127595. constructor();
  127596. /**
  127597. * Gets the list of supported render pipelines
  127598. */
  127599. readonly supportedPipelines: PostProcessRenderPipeline[];
  127600. /**
  127601. * Adds a pipeline to the manager
  127602. * @param renderPipeline The pipeline to add
  127603. */
  127604. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  127605. /**
  127606. * Attaches a camera to the pipeline
  127607. * @param renderPipelineName The name of the pipeline to attach to
  127608. * @param cameras the camera to attach
  127609. * @param unique if the camera can be attached multiple times to the pipeline
  127610. */
  127611. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  127612. /**
  127613. * Detaches a camera from the pipeline
  127614. * @param renderPipelineName The name of the pipeline to detach from
  127615. * @param cameras the camera to detach
  127616. */
  127617. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  127618. /**
  127619. * Enables an effect by name on a pipeline
  127620. * @param renderPipelineName the name of the pipeline to enable the effect in
  127621. * @param renderEffectName the name of the effect to enable
  127622. * @param cameras the cameras that the effect should be enabled on
  127623. */
  127624. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127625. /**
  127626. * Disables an effect by name on a pipeline
  127627. * @param renderPipelineName the name of the pipeline to disable the effect in
  127628. * @param renderEffectName the name of the effect to disable
  127629. * @param cameras the cameras that the effect should be disabled on
  127630. */
  127631. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127632. /**
  127633. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  127634. */
  127635. update(): void;
  127636. /** @hidden */
  127637. _rebuild(): void;
  127638. /**
  127639. * Disposes of the manager and pipelines
  127640. */
  127641. dispose(): void;
  127642. }
  127643. }
  127644. declare module BABYLON {
  127645. interface Scene {
  127646. /** @hidden (Backing field) */
  127647. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127648. /**
  127649. * Gets the postprocess render pipeline manager
  127650. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127651. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127652. */
  127653. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127654. }
  127655. /**
  127656. * Defines the Render Pipeline scene component responsible to rendering pipelines
  127657. */
  127658. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  127659. /**
  127660. * The component name helpfull to identify the component in the list of scene components.
  127661. */
  127662. readonly name: string;
  127663. /**
  127664. * The scene the component belongs to.
  127665. */
  127666. scene: Scene;
  127667. /**
  127668. * Creates a new instance of the component for the given scene
  127669. * @param scene Defines the scene to register the component in
  127670. */
  127671. constructor(scene: Scene);
  127672. /**
  127673. * Registers the component in a given scene
  127674. */
  127675. register(): void;
  127676. /**
  127677. * Rebuilds the elements related to this component in case of
  127678. * context lost for instance.
  127679. */
  127680. rebuild(): void;
  127681. /**
  127682. * Disposes the component and the associated ressources
  127683. */
  127684. dispose(): void;
  127685. private _gatherRenderTargets;
  127686. }
  127687. }
  127688. declare module BABYLON {
  127689. /**
  127690. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  127691. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127692. */
  127693. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127694. private _scene;
  127695. private _camerasToBeAttached;
  127696. /**
  127697. * ID of the sharpen post process,
  127698. */
  127699. private readonly SharpenPostProcessId;
  127700. /**
  127701. * @ignore
  127702. * ID of the image processing post process;
  127703. */
  127704. readonly ImageProcessingPostProcessId: string;
  127705. /**
  127706. * @ignore
  127707. * ID of the Fast Approximate Anti-Aliasing post process;
  127708. */
  127709. readonly FxaaPostProcessId: string;
  127710. /**
  127711. * ID of the chromatic aberration post process,
  127712. */
  127713. private readonly ChromaticAberrationPostProcessId;
  127714. /**
  127715. * ID of the grain post process
  127716. */
  127717. private readonly GrainPostProcessId;
  127718. /**
  127719. * Sharpen post process which will apply a sharpen convolution to enhance edges
  127720. */
  127721. sharpen: SharpenPostProcess;
  127722. private _sharpenEffect;
  127723. private bloom;
  127724. /**
  127725. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  127726. */
  127727. depthOfField: DepthOfFieldEffect;
  127728. /**
  127729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127730. */
  127731. fxaa: FxaaPostProcess;
  127732. /**
  127733. * Image post processing pass used to perform operations such as tone mapping or color grading.
  127734. */
  127735. imageProcessing: ImageProcessingPostProcess;
  127736. /**
  127737. * Chromatic aberration post process which will shift rgb colors in the image
  127738. */
  127739. chromaticAberration: ChromaticAberrationPostProcess;
  127740. private _chromaticAberrationEffect;
  127741. /**
  127742. * Grain post process which add noise to the image
  127743. */
  127744. grain: GrainPostProcess;
  127745. private _grainEffect;
  127746. /**
  127747. * Glow post process which adds a glow to emissive areas of the image
  127748. */
  127749. private _glowLayer;
  127750. /**
  127751. * Animations which can be used to tweak settings over a period of time
  127752. */
  127753. animations: Animation[];
  127754. private _imageProcessingConfigurationObserver;
  127755. private _sharpenEnabled;
  127756. private _bloomEnabled;
  127757. private _depthOfFieldEnabled;
  127758. private _depthOfFieldBlurLevel;
  127759. private _fxaaEnabled;
  127760. private _imageProcessingEnabled;
  127761. private _defaultPipelineTextureType;
  127762. private _bloomScale;
  127763. private _chromaticAberrationEnabled;
  127764. private _grainEnabled;
  127765. private _buildAllowed;
  127766. /**
  127767. * Gets active scene
  127768. */
  127769. readonly scene: Scene;
  127770. /**
  127771. * Enable or disable the sharpen process from the pipeline
  127772. */
  127773. sharpenEnabled: boolean;
  127774. private _resizeObserver;
  127775. private _hardwareScaleLevel;
  127776. private _bloomKernel;
  127777. /**
  127778. * Specifies the size of the bloom blur kernel, relative to the final output size
  127779. */
  127780. bloomKernel: number;
  127781. /**
  127782. * Specifies the weight of the bloom in the final rendering
  127783. */
  127784. private _bloomWeight;
  127785. /**
  127786. * Specifies the luma threshold for the area that will be blurred by the bloom
  127787. */
  127788. private _bloomThreshold;
  127789. private _hdr;
  127790. /**
  127791. * The strength of the bloom.
  127792. */
  127793. bloomWeight: number;
  127794. /**
  127795. * The strength of the bloom.
  127796. */
  127797. bloomThreshold: number;
  127798. /**
  127799. * The scale of the bloom, lower value will provide better performance.
  127800. */
  127801. bloomScale: number;
  127802. /**
  127803. * Enable or disable the bloom from the pipeline
  127804. */
  127805. bloomEnabled: boolean;
  127806. private _rebuildBloom;
  127807. /**
  127808. * If the depth of field is enabled.
  127809. */
  127810. depthOfFieldEnabled: boolean;
  127811. /**
  127812. * Blur level of the depth of field effect. (Higher blur will effect performance)
  127813. */
  127814. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  127815. /**
  127816. * If the anti aliasing is enabled.
  127817. */
  127818. fxaaEnabled: boolean;
  127819. private _samples;
  127820. /**
  127821. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127822. */
  127823. samples: number;
  127824. /**
  127825. * If image processing is enabled.
  127826. */
  127827. imageProcessingEnabled: boolean;
  127828. /**
  127829. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  127830. */
  127831. glowLayerEnabled: boolean;
  127832. /**
  127833. * Gets the glow layer (or null if not defined)
  127834. */
  127835. readonly glowLayer: Nullable<GlowLayer>;
  127836. /**
  127837. * Enable or disable the chromaticAberration process from the pipeline
  127838. */
  127839. chromaticAberrationEnabled: boolean;
  127840. /**
  127841. * Enable or disable the grain process from the pipeline
  127842. */
  127843. grainEnabled: boolean;
  127844. /**
  127845. * @constructor
  127846. * @param name - The rendering pipeline name (default: "")
  127847. * @param hdr - If high dynamic range textures should be used (default: true)
  127848. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127849. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127850. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127851. */
  127852. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127853. /**
  127854. * Get the class name
  127855. * @returns "DefaultRenderingPipeline"
  127856. */
  127857. getClassName(): string;
  127858. /**
  127859. * Force the compilation of the entire pipeline.
  127860. */
  127861. prepare(): void;
  127862. private _hasCleared;
  127863. private _prevPostProcess;
  127864. private _prevPrevPostProcess;
  127865. private _setAutoClearAndTextureSharing;
  127866. private _depthOfFieldSceneObserver;
  127867. private _buildPipeline;
  127868. private _disposePostProcesses;
  127869. /**
  127870. * Adds a camera to the pipeline
  127871. * @param camera the camera to be added
  127872. */
  127873. addCamera(camera: Camera): void;
  127874. /**
  127875. * Removes a camera from the pipeline
  127876. * @param camera the camera to remove
  127877. */
  127878. removeCamera(camera: Camera): void;
  127879. /**
  127880. * Dispose of the pipeline and stop all post processes
  127881. */
  127882. dispose(): void;
  127883. /**
  127884. * Serialize the rendering pipeline (Used when exporting)
  127885. * @returns the serialized object
  127886. */
  127887. serialize(): any;
  127888. /**
  127889. * Parse the serialized pipeline
  127890. * @param source Source pipeline.
  127891. * @param scene The scene to load the pipeline to.
  127892. * @param rootUrl The URL of the serialized pipeline.
  127893. * @returns An instantiated pipeline from the serialized object.
  127894. */
  127895. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127896. }
  127897. }
  127898. declare module BABYLON {
  127899. /** @hidden */
  127900. export var lensHighlightsPixelShader: {
  127901. name: string;
  127902. shader: string;
  127903. };
  127904. }
  127905. declare module BABYLON {
  127906. /** @hidden */
  127907. export var depthOfFieldPixelShader: {
  127908. name: string;
  127909. shader: string;
  127910. };
  127911. }
  127912. declare module BABYLON {
  127913. /**
  127914. * BABYLON.JS Chromatic Aberration GLSL Shader
  127915. * Author: Olivier Guyot
  127916. * Separates very slightly R, G and B colors on the edges of the screen
  127917. * Inspired by Francois Tarlier & Martins Upitis
  127918. */
  127919. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127920. /**
  127921. * @ignore
  127922. * The chromatic aberration PostProcess id in the pipeline
  127923. */
  127924. LensChromaticAberrationEffect: string;
  127925. /**
  127926. * @ignore
  127927. * The highlights enhancing PostProcess id in the pipeline
  127928. */
  127929. HighlightsEnhancingEffect: string;
  127930. /**
  127931. * @ignore
  127932. * The depth-of-field PostProcess id in the pipeline
  127933. */
  127934. LensDepthOfFieldEffect: string;
  127935. private _scene;
  127936. private _depthTexture;
  127937. private _grainTexture;
  127938. private _chromaticAberrationPostProcess;
  127939. private _highlightsPostProcess;
  127940. private _depthOfFieldPostProcess;
  127941. private _edgeBlur;
  127942. private _grainAmount;
  127943. private _chromaticAberration;
  127944. private _distortion;
  127945. private _highlightsGain;
  127946. private _highlightsThreshold;
  127947. private _dofDistance;
  127948. private _dofAperture;
  127949. private _dofDarken;
  127950. private _dofPentagon;
  127951. private _blurNoise;
  127952. /**
  127953. * @constructor
  127954. *
  127955. * Effect parameters are as follow:
  127956. * {
  127957. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127958. * edge_blur: number; // from 0 to x (1 for realism)
  127959. * distortion: number; // from 0 to x (1 for realism)
  127960. * grain_amount: number; // from 0 to 1
  127961. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127962. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127963. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127964. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127965. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127966. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127967. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127968. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127969. * }
  127970. * Note: if an effect parameter is unset, effect is disabled
  127971. *
  127972. * @param name The rendering pipeline name
  127973. * @param parameters - An object containing all parameters (see above)
  127974. * @param scene The scene linked to this pipeline
  127975. * @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)
  127976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127977. */
  127978. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127979. /**
  127980. * Get the class name
  127981. * @returns "LensRenderingPipeline"
  127982. */
  127983. getClassName(): string;
  127984. /**
  127985. * Gets associated scene
  127986. */
  127987. readonly scene: Scene;
  127988. /**
  127989. * Gets or sets the edge blur
  127990. */
  127991. edgeBlur: number;
  127992. /**
  127993. * Gets or sets the grain amount
  127994. */
  127995. grainAmount: number;
  127996. /**
  127997. * Gets or sets the chromatic aberration amount
  127998. */
  127999. chromaticAberration: number;
  128000. /**
  128001. * Gets or sets the depth of field aperture
  128002. */
  128003. dofAperture: number;
  128004. /**
  128005. * Gets or sets the edge distortion
  128006. */
  128007. edgeDistortion: number;
  128008. /**
  128009. * Gets or sets the depth of field distortion
  128010. */
  128011. dofDistortion: number;
  128012. /**
  128013. * Gets or sets the darken out of focus amount
  128014. */
  128015. darkenOutOfFocus: number;
  128016. /**
  128017. * Gets or sets a boolean indicating if blur noise is enabled
  128018. */
  128019. blurNoise: boolean;
  128020. /**
  128021. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128022. */
  128023. pentagonBokeh: boolean;
  128024. /**
  128025. * Gets or sets the highlight grain amount
  128026. */
  128027. highlightsGain: number;
  128028. /**
  128029. * Gets or sets the highlight threshold
  128030. */
  128031. highlightsThreshold: number;
  128032. /**
  128033. * Sets the amount of blur at the edges
  128034. * @param amount blur amount
  128035. */
  128036. setEdgeBlur(amount: number): void;
  128037. /**
  128038. * Sets edge blur to 0
  128039. */
  128040. disableEdgeBlur(): void;
  128041. /**
  128042. * Sets the amout of grain
  128043. * @param amount Amount of grain
  128044. */
  128045. setGrainAmount(amount: number): void;
  128046. /**
  128047. * Set grain amount to 0
  128048. */
  128049. disableGrain(): void;
  128050. /**
  128051. * Sets the chromatic aberration amount
  128052. * @param amount amount of chromatic aberration
  128053. */
  128054. setChromaticAberration(amount: number): void;
  128055. /**
  128056. * Sets chromatic aberration amount to 0
  128057. */
  128058. disableChromaticAberration(): void;
  128059. /**
  128060. * Sets the EdgeDistortion amount
  128061. * @param amount amount of EdgeDistortion
  128062. */
  128063. setEdgeDistortion(amount: number): void;
  128064. /**
  128065. * Sets edge distortion to 0
  128066. */
  128067. disableEdgeDistortion(): void;
  128068. /**
  128069. * Sets the FocusDistance amount
  128070. * @param amount amount of FocusDistance
  128071. */
  128072. setFocusDistance(amount: number): void;
  128073. /**
  128074. * Disables depth of field
  128075. */
  128076. disableDepthOfField(): void;
  128077. /**
  128078. * Sets the Aperture amount
  128079. * @param amount amount of Aperture
  128080. */
  128081. setAperture(amount: number): void;
  128082. /**
  128083. * Sets the DarkenOutOfFocus amount
  128084. * @param amount amount of DarkenOutOfFocus
  128085. */
  128086. setDarkenOutOfFocus(amount: number): void;
  128087. private _pentagonBokehIsEnabled;
  128088. /**
  128089. * Creates a pentagon bokeh effect
  128090. */
  128091. enablePentagonBokeh(): void;
  128092. /**
  128093. * Disables the pentagon bokeh effect
  128094. */
  128095. disablePentagonBokeh(): void;
  128096. /**
  128097. * Enables noise blur
  128098. */
  128099. enableNoiseBlur(): void;
  128100. /**
  128101. * Disables noise blur
  128102. */
  128103. disableNoiseBlur(): void;
  128104. /**
  128105. * Sets the HighlightsGain amount
  128106. * @param amount amount of HighlightsGain
  128107. */
  128108. setHighlightsGain(amount: number): void;
  128109. /**
  128110. * Sets the HighlightsThreshold amount
  128111. * @param amount amount of HighlightsThreshold
  128112. */
  128113. setHighlightsThreshold(amount: number): void;
  128114. /**
  128115. * Disables highlights
  128116. */
  128117. disableHighlights(): void;
  128118. /**
  128119. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128120. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128121. */
  128122. dispose(disableDepthRender?: boolean): void;
  128123. private _createChromaticAberrationPostProcess;
  128124. private _createHighlightsPostProcess;
  128125. private _createDepthOfFieldPostProcess;
  128126. private _createGrainTexture;
  128127. }
  128128. }
  128129. declare module BABYLON {
  128130. /** @hidden */
  128131. export var ssao2PixelShader: {
  128132. name: string;
  128133. shader: string;
  128134. };
  128135. }
  128136. declare module BABYLON {
  128137. /** @hidden */
  128138. export var ssaoCombinePixelShader: {
  128139. name: string;
  128140. shader: string;
  128141. };
  128142. }
  128143. declare module BABYLON {
  128144. /**
  128145. * Render pipeline to produce ssao effect
  128146. */
  128147. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128148. /**
  128149. * @ignore
  128150. * The PassPostProcess id in the pipeline that contains the original scene color
  128151. */
  128152. SSAOOriginalSceneColorEffect: string;
  128153. /**
  128154. * @ignore
  128155. * The SSAO PostProcess id in the pipeline
  128156. */
  128157. SSAORenderEffect: string;
  128158. /**
  128159. * @ignore
  128160. * The horizontal blur PostProcess id in the pipeline
  128161. */
  128162. SSAOBlurHRenderEffect: string;
  128163. /**
  128164. * @ignore
  128165. * The vertical blur PostProcess id in the pipeline
  128166. */
  128167. SSAOBlurVRenderEffect: string;
  128168. /**
  128169. * @ignore
  128170. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128171. */
  128172. SSAOCombineRenderEffect: string;
  128173. /**
  128174. * The output strength of the SSAO post-process. Default value is 1.0.
  128175. */
  128176. totalStrength: number;
  128177. /**
  128178. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128179. */
  128180. maxZ: number;
  128181. /**
  128182. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128183. */
  128184. minZAspect: number;
  128185. private _samples;
  128186. /**
  128187. * Number of samples used for the SSAO calculations. Default value is 8
  128188. */
  128189. samples: number;
  128190. private _textureSamples;
  128191. /**
  128192. * Number of samples to use for antialiasing
  128193. */
  128194. textureSamples: number;
  128195. /**
  128196. * Ratio object used for SSAO ratio and blur ratio
  128197. */
  128198. private _ratio;
  128199. /**
  128200. * Dynamically generated sphere sampler.
  128201. */
  128202. private _sampleSphere;
  128203. /**
  128204. * Blur filter offsets
  128205. */
  128206. private _samplerOffsets;
  128207. private _expensiveBlur;
  128208. /**
  128209. * If bilateral blur should be used
  128210. */
  128211. expensiveBlur: boolean;
  128212. /**
  128213. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128214. */
  128215. radius: number;
  128216. /**
  128217. * The base color of the SSAO post-process
  128218. * The final result is "base + ssao" between [0, 1]
  128219. */
  128220. base: number;
  128221. /**
  128222. * Support test.
  128223. */
  128224. static readonly IsSupported: boolean;
  128225. private _scene;
  128226. private _depthTexture;
  128227. private _normalTexture;
  128228. private _randomTexture;
  128229. private _originalColorPostProcess;
  128230. private _ssaoPostProcess;
  128231. private _blurHPostProcess;
  128232. private _blurVPostProcess;
  128233. private _ssaoCombinePostProcess;
  128234. private _firstUpdate;
  128235. /**
  128236. * Gets active scene
  128237. */
  128238. readonly scene: Scene;
  128239. /**
  128240. * @constructor
  128241. * @param name The rendering pipeline name
  128242. * @param scene The scene linked to this pipeline
  128243. * @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 }
  128244. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128245. */
  128246. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128247. /**
  128248. * Get the class name
  128249. * @returns "SSAO2RenderingPipeline"
  128250. */
  128251. getClassName(): string;
  128252. /**
  128253. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128254. */
  128255. dispose(disableGeometryBufferRenderer?: boolean): void;
  128256. private _createBlurPostProcess;
  128257. /** @hidden */
  128258. _rebuild(): void;
  128259. private _bits;
  128260. private _radicalInverse_VdC;
  128261. private _hammersley;
  128262. private _hemisphereSample_uniform;
  128263. private _generateHemisphere;
  128264. private _createSSAOPostProcess;
  128265. private _createSSAOCombinePostProcess;
  128266. private _createRandomTexture;
  128267. /**
  128268. * Serialize the rendering pipeline (Used when exporting)
  128269. * @returns the serialized object
  128270. */
  128271. serialize(): any;
  128272. /**
  128273. * Parse the serialized pipeline
  128274. * @param source Source pipeline.
  128275. * @param scene The scene to load the pipeline to.
  128276. * @param rootUrl The URL of the serialized pipeline.
  128277. * @returns An instantiated pipeline from the serialized object.
  128278. */
  128279. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /** @hidden */
  128284. export var ssaoPixelShader: {
  128285. name: string;
  128286. shader: string;
  128287. };
  128288. }
  128289. declare module BABYLON {
  128290. /**
  128291. * Render pipeline to produce ssao effect
  128292. */
  128293. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128294. /**
  128295. * @ignore
  128296. * The PassPostProcess id in the pipeline that contains the original scene color
  128297. */
  128298. SSAOOriginalSceneColorEffect: string;
  128299. /**
  128300. * @ignore
  128301. * The SSAO PostProcess id in the pipeline
  128302. */
  128303. SSAORenderEffect: string;
  128304. /**
  128305. * @ignore
  128306. * The horizontal blur PostProcess id in the pipeline
  128307. */
  128308. SSAOBlurHRenderEffect: string;
  128309. /**
  128310. * @ignore
  128311. * The vertical blur PostProcess id in the pipeline
  128312. */
  128313. SSAOBlurVRenderEffect: string;
  128314. /**
  128315. * @ignore
  128316. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128317. */
  128318. SSAOCombineRenderEffect: string;
  128319. /**
  128320. * The output strength of the SSAO post-process. Default value is 1.0.
  128321. */
  128322. totalStrength: number;
  128323. /**
  128324. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128325. */
  128326. radius: number;
  128327. /**
  128328. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128329. * Must not be equal to fallOff and superior to fallOff.
  128330. * Default value is 0.0075
  128331. */
  128332. area: number;
  128333. /**
  128334. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128335. * Must not be equal to area and inferior to area.
  128336. * Default value is 0.000001
  128337. */
  128338. fallOff: number;
  128339. /**
  128340. * The base color of the SSAO post-process
  128341. * The final result is "base + ssao" between [0, 1]
  128342. */
  128343. base: number;
  128344. private _scene;
  128345. private _depthTexture;
  128346. private _randomTexture;
  128347. private _originalColorPostProcess;
  128348. private _ssaoPostProcess;
  128349. private _blurHPostProcess;
  128350. private _blurVPostProcess;
  128351. private _ssaoCombinePostProcess;
  128352. private _firstUpdate;
  128353. /**
  128354. * Gets active scene
  128355. */
  128356. readonly scene: Scene;
  128357. /**
  128358. * @constructor
  128359. * @param name - The rendering pipeline name
  128360. * @param scene - The scene linked to this pipeline
  128361. * @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 }
  128362. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128363. */
  128364. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128365. /**
  128366. * Get the class name
  128367. * @returns "SSAORenderingPipeline"
  128368. */
  128369. getClassName(): string;
  128370. /**
  128371. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128372. */
  128373. dispose(disableDepthRender?: boolean): void;
  128374. private _createBlurPostProcess;
  128375. /** @hidden */
  128376. _rebuild(): void;
  128377. private _createSSAOPostProcess;
  128378. private _createSSAOCombinePostProcess;
  128379. private _createRandomTexture;
  128380. }
  128381. }
  128382. declare module BABYLON {
  128383. /** @hidden */
  128384. export var standardPixelShader: {
  128385. name: string;
  128386. shader: string;
  128387. };
  128388. }
  128389. declare module BABYLON {
  128390. /**
  128391. * Standard rendering pipeline
  128392. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128393. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128394. */
  128395. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128396. /**
  128397. * Public members
  128398. */
  128399. /**
  128400. * Post-process which contains the original scene color before the pipeline applies all the effects
  128401. */
  128402. originalPostProcess: Nullable<PostProcess>;
  128403. /**
  128404. * Post-process used to down scale an image x4
  128405. */
  128406. downSampleX4PostProcess: Nullable<PostProcess>;
  128407. /**
  128408. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128409. */
  128410. brightPassPostProcess: Nullable<PostProcess>;
  128411. /**
  128412. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128413. */
  128414. blurHPostProcesses: PostProcess[];
  128415. /**
  128416. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128417. */
  128418. blurVPostProcesses: PostProcess[];
  128419. /**
  128420. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128421. */
  128422. textureAdderPostProcess: Nullable<PostProcess>;
  128423. /**
  128424. * Post-process used to create volumetric lighting effect
  128425. */
  128426. volumetricLightPostProcess: Nullable<PostProcess>;
  128427. /**
  128428. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128429. */
  128430. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128431. /**
  128432. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128433. */
  128434. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128435. /**
  128436. * Post-process used to merge the volumetric light effect and the real scene color
  128437. */
  128438. volumetricLightMergePostProces: Nullable<PostProcess>;
  128439. /**
  128440. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128441. */
  128442. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128443. /**
  128444. * Base post-process used to calculate the average luminance of the final image for HDR
  128445. */
  128446. luminancePostProcess: Nullable<PostProcess>;
  128447. /**
  128448. * Post-processes used to create down sample post-processes in order to get
  128449. * the average luminance of the final image for HDR
  128450. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128451. */
  128452. luminanceDownSamplePostProcesses: PostProcess[];
  128453. /**
  128454. * Post-process used to create a HDR effect (light adaptation)
  128455. */
  128456. hdrPostProcess: Nullable<PostProcess>;
  128457. /**
  128458. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128459. */
  128460. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128461. /**
  128462. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128463. */
  128464. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128465. /**
  128466. * Post-process used to merge the final HDR post-process and the real scene color
  128467. */
  128468. hdrFinalPostProcess: Nullable<PostProcess>;
  128469. /**
  128470. * Post-process used to create a lens flare effect
  128471. */
  128472. lensFlarePostProcess: Nullable<PostProcess>;
  128473. /**
  128474. * Post-process that merges the result of the lens flare post-process and the real scene color
  128475. */
  128476. lensFlareComposePostProcess: Nullable<PostProcess>;
  128477. /**
  128478. * Post-process used to create a motion blur effect
  128479. */
  128480. motionBlurPostProcess: Nullable<PostProcess>;
  128481. /**
  128482. * Post-process used to create a depth of field effect
  128483. */
  128484. depthOfFieldPostProcess: Nullable<PostProcess>;
  128485. /**
  128486. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128487. */
  128488. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128489. /**
  128490. * Represents the brightness threshold in order to configure the illuminated surfaces
  128491. */
  128492. brightThreshold: number;
  128493. /**
  128494. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128495. */
  128496. blurWidth: number;
  128497. /**
  128498. * Sets if the blur for highlighted surfaces must be only horizontal
  128499. */
  128500. horizontalBlur: boolean;
  128501. /**
  128502. * Gets the overall exposure used by the pipeline
  128503. */
  128504. /**
  128505. * Sets the overall exposure used by the pipeline
  128506. */
  128507. exposure: number;
  128508. /**
  128509. * Texture used typically to simulate "dirty" on camera lens
  128510. */
  128511. lensTexture: Nullable<Texture>;
  128512. /**
  128513. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128514. */
  128515. volumetricLightCoefficient: number;
  128516. /**
  128517. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128518. */
  128519. volumetricLightPower: number;
  128520. /**
  128521. * Used the set the blur intensity to smooth the volumetric lights
  128522. */
  128523. volumetricLightBlurScale: number;
  128524. /**
  128525. * Light (spot or directional) used to generate the volumetric lights rays
  128526. * The source light must have a shadow generate so the pipeline can get its
  128527. * depth map
  128528. */
  128529. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128530. /**
  128531. * For eye adaptation, represents the minimum luminance the eye can see
  128532. */
  128533. hdrMinimumLuminance: number;
  128534. /**
  128535. * For eye adaptation, represents the decrease luminance speed
  128536. */
  128537. hdrDecreaseRate: number;
  128538. /**
  128539. * For eye adaptation, represents the increase luminance speed
  128540. */
  128541. hdrIncreaseRate: number;
  128542. /**
  128543. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128544. */
  128545. /**
  128546. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128547. */
  128548. hdrAutoExposure: boolean;
  128549. /**
  128550. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128551. */
  128552. lensColorTexture: Nullable<Texture>;
  128553. /**
  128554. * The overall strengh for the lens flare effect
  128555. */
  128556. lensFlareStrength: number;
  128557. /**
  128558. * Dispersion coefficient for lens flare ghosts
  128559. */
  128560. lensFlareGhostDispersal: number;
  128561. /**
  128562. * Main lens flare halo width
  128563. */
  128564. lensFlareHaloWidth: number;
  128565. /**
  128566. * Based on the lens distortion effect, defines how much the lens flare result
  128567. * is distorted
  128568. */
  128569. lensFlareDistortionStrength: number;
  128570. /**
  128571. * Configures the blur intensity used for for lens flare (halo)
  128572. */
  128573. lensFlareBlurWidth: number;
  128574. /**
  128575. * Lens star texture must be used to simulate rays on the flares and is available
  128576. * in the documentation
  128577. */
  128578. lensStarTexture: Nullable<Texture>;
  128579. /**
  128580. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128581. * flare effect by taking account of the dirt texture
  128582. */
  128583. lensFlareDirtTexture: Nullable<Texture>;
  128584. /**
  128585. * Represents the focal length for the depth of field effect
  128586. */
  128587. depthOfFieldDistance: number;
  128588. /**
  128589. * Represents the blur intensity for the blurred part of the depth of field effect
  128590. */
  128591. depthOfFieldBlurWidth: number;
  128592. /**
  128593. * Gets how much the image is blurred by the movement while using the motion blur post-process
  128594. */
  128595. /**
  128596. * Sets how much the image is blurred by the movement while using the motion blur post-process
  128597. */
  128598. motionStrength: number;
  128599. /**
  128600. * Gets wether or not the motion blur post-process is object based or screen based.
  128601. */
  128602. /**
  128603. * Sets wether or not the motion blur post-process should be object based or screen based
  128604. */
  128605. objectBasedMotionBlur: boolean;
  128606. /**
  128607. * List of animations for the pipeline (IAnimatable implementation)
  128608. */
  128609. animations: Animation[];
  128610. /**
  128611. * Private members
  128612. */
  128613. private _scene;
  128614. private _currentDepthOfFieldSource;
  128615. private _basePostProcess;
  128616. private _fixedExposure;
  128617. private _currentExposure;
  128618. private _hdrAutoExposure;
  128619. private _hdrCurrentLuminance;
  128620. private _motionStrength;
  128621. private _isObjectBasedMotionBlur;
  128622. private _floatTextureType;
  128623. private _camerasToBeAttached;
  128624. private _ratio;
  128625. private _bloomEnabled;
  128626. private _depthOfFieldEnabled;
  128627. private _vlsEnabled;
  128628. private _lensFlareEnabled;
  128629. private _hdrEnabled;
  128630. private _motionBlurEnabled;
  128631. private _fxaaEnabled;
  128632. private _motionBlurSamples;
  128633. private _volumetricLightStepsCount;
  128634. private _samples;
  128635. /**
  128636. * @ignore
  128637. * Specifies if the bloom pipeline is enabled
  128638. */
  128639. BloomEnabled: boolean;
  128640. /**
  128641. * @ignore
  128642. * Specifies if the depth of field pipeline is enabed
  128643. */
  128644. DepthOfFieldEnabled: boolean;
  128645. /**
  128646. * @ignore
  128647. * Specifies if the lens flare pipeline is enabed
  128648. */
  128649. LensFlareEnabled: boolean;
  128650. /**
  128651. * @ignore
  128652. * Specifies if the HDR pipeline is enabled
  128653. */
  128654. HDREnabled: boolean;
  128655. /**
  128656. * @ignore
  128657. * Specifies if the volumetric lights scattering effect is enabled
  128658. */
  128659. VLSEnabled: boolean;
  128660. /**
  128661. * @ignore
  128662. * Specifies if the motion blur effect is enabled
  128663. */
  128664. MotionBlurEnabled: boolean;
  128665. /**
  128666. * Specifies if anti-aliasing is enabled
  128667. */
  128668. fxaaEnabled: boolean;
  128669. /**
  128670. * Specifies the number of steps used to calculate the volumetric lights
  128671. * Typically in interval [50, 200]
  128672. */
  128673. volumetricLightStepsCount: number;
  128674. /**
  128675. * Specifies the number of samples used for the motion blur effect
  128676. * Typically in interval [16, 64]
  128677. */
  128678. motionBlurSamples: number;
  128679. /**
  128680. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128681. */
  128682. samples: number;
  128683. /**
  128684. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128685. * @constructor
  128686. * @param name The rendering pipeline name
  128687. * @param scene The scene linked to this pipeline
  128688. * @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)
  128689. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  128690. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128691. */
  128692. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  128693. private _buildPipeline;
  128694. private _createDownSampleX4PostProcess;
  128695. private _createBrightPassPostProcess;
  128696. private _createBlurPostProcesses;
  128697. private _createTextureAdderPostProcess;
  128698. private _createVolumetricLightPostProcess;
  128699. private _createLuminancePostProcesses;
  128700. private _createHdrPostProcess;
  128701. private _createLensFlarePostProcess;
  128702. private _createDepthOfFieldPostProcess;
  128703. private _createMotionBlurPostProcess;
  128704. private _getDepthTexture;
  128705. private _disposePostProcesses;
  128706. /**
  128707. * Dispose of the pipeline and stop all post processes
  128708. */
  128709. dispose(): void;
  128710. /**
  128711. * Serialize the rendering pipeline (Used when exporting)
  128712. * @returns the serialized object
  128713. */
  128714. serialize(): any;
  128715. /**
  128716. * Parse the serialized pipeline
  128717. * @param source Source pipeline.
  128718. * @param scene The scene to load the pipeline to.
  128719. * @param rootUrl The URL of the serialized pipeline.
  128720. * @returns An instantiated pipeline from the serialized object.
  128721. */
  128722. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  128723. /**
  128724. * Luminance steps
  128725. */
  128726. static LuminanceSteps: number;
  128727. }
  128728. }
  128729. declare module BABYLON {
  128730. /** @hidden */
  128731. export var tonemapPixelShader: {
  128732. name: string;
  128733. shader: string;
  128734. };
  128735. }
  128736. declare module BABYLON {
  128737. /** Defines operator used for tonemapping */
  128738. export enum TonemappingOperator {
  128739. /** Hable */
  128740. Hable = 0,
  128741. /** Reinhard */
  128742. Reinhard = 1,
  128743. /** HejiDawson */
  128744. HejiDawson = 2,
  128745. /** Photographic */
  128746. Photographic = 3
  128747. }
  128748. /**
  128749. * Defines a post process to apply tone mapping
  128750. */
  128751. export class TonemapPostProcess extends PostProcess {
  128752. private _operator;
  128753. /** Defines the required exposure adjustement */
  128754. exposureAdjustment: number;
  128755. /**
  128756. * Creates a new TonemapPostProcess
  128757. * @param name defines the name of the postprocess
  128758. * @param _operator defines the operator to use
  128759. * @param exposureAdjustment defines the required exposure adjustement
  128760. * @param camera defines the camera to use (can be null)
  128761. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  128762. * @param engine defines the hosting engine (can be ignore if camera is set)
  128763. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128764. */
  128765. constructor(name: string, _operator: TonemappingOperator,
  128766. /** Defines the required exposure adjustement */
  128767. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  128768. }
  128769. }
  128770. declare module BABYLON {
  128771. /** @hidden */
  128772. export var depthVertexShader: {
  128773. name: string;
  128774. shader: string;
  128775. };
  128776. }
  128777. declare module BABYLON {
  128778. /** @hidden */
  128779. export var volumetricLightScatteringPixelShader: {
  128780. name: string;
  128781. shader: string;
  128782. };
  128783. }
  128784. declare module BABYLON {
  128785. /** @hidden */
  128786. export var volumetricLightScatteringPassVertexShader: {
  128787. name: string;
  128788. shader: string;
  128789. };
  128790. }
  128791. declare module BABYLON {
  128792. /** @hidden */
  128793. export var volumetricLightScatteringPassPixelShader: {
  128794. name: string;
  128795. shader: string;
  128796. };
  128797. }
  128798. declare module BABYLON {
  128799. /**
  128800. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  128801. */
  128802. export class VolumetricLightScatteringPostProcess extends PostProcess {
  128803. private _volumetricLightScatteringPass;
  128804. private _volumetricLightScatteringRTT;
  128805. private _viewPort;
  128806. private _screenCoordinates;
  128807. private _cachedDefines;
  128808. /**
  128809. * If not undefined, the mesh position is computed from the attached node position
  128810. */
  128811. attachedNode: {
  128812. position: Vector3;
  128813. };
  128814. /**
  128815. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  128816. */
  128817. customMeshPosition: Vector3;
  128818. /**
  128819. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  128820. */
  128821. useCustomMeshPosition: boolean;
  128822. /**
  128823. * If the post-process should inverse the light scattering direction
  128824. */
  128825. invert: boolean;
  128826. /**
  128827. * The internal mesh used by the post-process
  128828. */
  128829. mesh: Mesh;
  128830. /**
  128831. * @hidden
  128832. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  128833. */
  128834. useDiffuseColor: boolean;
  128835. /**
  128836. * Array containing the excluded meshes not rendered in the internal pass
  128837. */
  128838. excludedMeshes: AbstractMesh[];
  128839. /**
  128840. * Controls the overall intensity of the post-process
  128841. */
  128842. exposure: number;
  128843. /**
  128844. * Dissipates each sample's contribution in range [0, 1]
  128845. */
  128846. decay: number;
  128847. /**
  128848. * Controls the overall intensity of each sample
  128849. */
  128850. weight: number;
  128851. /**
  128852. * Controls the density of each sample
  128853. */
  128854. density: number;
  128855. /**
  128856. * @constructor
  128857. * @param name The post-process name
  128858. * @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)
  128859. * @param camera The camera that the post-process will be attached to
  128860. * @param mesh The mesh used to create the light scattering
  128861. * @param samples The post-process quality, default 100
  128862. * @param samplingModeThe post-process filtering mode
  128863. * @param engine The babylon engine
  128864. * @param reusable If the post-process is reusable
  128865. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128866. */
  128867. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128868. /**
  128869. * Returns the string "VolumetricLightScatteringPostProcess"
  128870. * @returns "VolumetricLightScatteringPostProcess"
  128871. */
  128872. getClassName(): string;
  128873. private _isReady;
  128874. /**
  128875. * Sets the new light position for light scattering effect
  128876. * @param position The new custom light position
  128877. */
  128878. setCustomMeshPosition(position: Vector3): void;
  128879. /**
  128880. * Returns the light position for light scattering effect
  128881. * @return Vector3 The custom light position
  128882. */
  128883. getCustomMeshPosition(): Vector3;
  128884. /**
  128885. * Disposes the internal assets and detaches the post-process from the camera
  128886. */
  128887. dispose(camera: Camera): void;
  128888. /**
  128889. * Returns the render target texture used by the post-process
  128890. * @return the render target texture used by the post-process
  128891. */
  128892. getPass(): RenderTargetTexture;
  128893. private _meshExcluded;
  128894. private _createPass;
  128895. private _updateMeshScreenCoordinates;
  128896. /**
  128897. * Creates a default mesh for the Volumeric Light Scattering post-process
  128898. * @param name The mesh name
  128899. * @param scene The scene where to create the mesh
  128900. * @return the default mesh
  128901. */
  128902. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128903. }
  128904. }
  128905. declare module BABYLON {
  128906. interface Scene {
  128907. /** @hidden (Backing field) */
  128908. _boundingBoxRenderer: BoundingBoxRenderer;
  128909. /** @hidden (Backing field) */
  128910. _forceShowBoundingBoxes: boolean;
  128911. /**
  128912. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128913. */
  128914. forceShowBoundingBoxes: boolean;
  128915. /**
  128916. * Gets the bounding box renderer associated with the scene
  128917. * @returns a BoundingBoxRenderer
  128918. */
  128919. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128920. }
  128921. interface AbstractMesh {
  128922. /** @hidden (Backing field) */
  128923. _showBoundingBox: boolean;
  128924. /**
  128925. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128926. */
  128927. showBoundingBox: boolean;
  128928. }
  128929. /**
  128930. * Component responsible of rendering the bounding box of the meshes in a scene.
  128931. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128932. */
  128933. export class BoundingBoxRenderer implements ISceneComponent {
  128934. /**
  128935. * The component name helpfull to identify the component in the list of scene components.
  128936. */
  128937. readonly name: string;
  128938. /**
  128939. * The scene the component belongs to.
  128940. */
  128941. scene: Scene;
  128942. /**
  128943. * Color of the bounding box lines placed in front of an object
  128944. */
  128945. frontColor: Color3;
  128946. /**
  128947. * Color of the bounding box lines placed behind an object
  128948. */
  128949. backColor: Color3;
  128950. /**
  128951. * Defines if the renderer should show the back lines or not
  128952. */
  128953. showBackLines: boolean;
  128954. /**
  128955. * @hidden
  128956. */
  128957. renderList: SmartArray<BoundingBox>;
  128958. private _colorShader;
  128959. private _vertexBuffers;
  128960. private _indexBuffer;
  128961. private _fillIndexBuffer;
  128962. private _fillIndexData;
  128963. /**
  128964. * Instantiates a new bounding box renderer in a scene.
  128965. * @param scene the scene the renderer renders in
  128966. */
  128967. constructor(scene: Scene);
  128968. /**
  128969. * Registers the component in a given scene
  128970. */
  128971. register(): void;
  128972. private _evaluateSubMesh;
  128973. private _activeMesh;
  128974. private _prepareRessources;
  128975. private _createIndexBuffer;
  128976. /**
  128977. * Rebuilds the elements related to this component in case of
  128978. * context lost for instance.
  128979. */
  128980. rebuild(): void;
  128981. /**
  128982. * @hidden
  128983. */
  128984. reset(): void;
  128985. /**
  128986. * Render the bounding boxes of a specific rendering group
  128987. * @param renderingGroupId defines the rendering group to render
  128988. */
  128989. render(renderingGroupId: number): void;
  128990. /**
  128991. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128992. * @param mesh Define the mesh to render the occlusion bounding box for
  128993. */
  128994. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128995. /**
  128996. * Dispose and release the resources attached to this renderer.
  128997. */
  128998. dispose(): void;
  128999. }
  129000. }
  129001. declare module BABYLON {
  129002. /** @hidden */
  129003. export var depthPixelShader: {
  129004. name: string;
  129005. shader: string;
  129006. };
  129007. }
  129008. declare module BABYLON {
  129009. /**
  129010. * This represents a depth renderer in Babylon.
  129011. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129012. */
  129013. export class DepthRenderer {
  129014. private _scene;
  129015. private _depthMap;
  129016. private _effect;
  129017. private readonly _storeNonLinearDepth;
  129018. private readonly _clearColor;
  129019. /** Get if the depth renderer is using packed depth or not */
  129020. readonly isPacked: boolean;
  129021. private _cachedDefines;
  129022. private _camera;
  129023. /**
  129024. * Specifiess that the depth renderer will only be used within
  129025. * the camera it is created for.
  129026. * This can help forcing its rendering during the camera processing.
  129027. */
  129028. useOnlyInActiveCamera: boolean;
  129029. /** @hidden */
  129030. static _SceneComponentInitialization: (scene: Scene) => void;
  129031. /**
  129032. * Instantiates a depth renderer
  129033. * @param scene The scene the renderer belongs to
  129034. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129035. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129036. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129037. */
  129038. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129039. /**
  129040. * Creates the depth rendering effect and checks if the effect is ready.
  129041. * @param subMesh The submesh to be used to render the depth map of
  129042. * @param useInstances If multiple world instances should be used
  129043. * @returns if the depth renderer is ready to render the depth map
  129044. */
  129045. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129046. /**
  129047. * Gets the texture which the depth map will be written to.
  129048. * @returns The depth map texture
  129049. */
  129050. getDepthMap(): RenderTargetTexture;
  129051. /**
  129052. * Disposes of the depth renderer.
  129053. */
  129054. dispose(): void;
  129055. }
  129056. }
  129057. declare module BABYLON {
  129058. interface Scene {
  129059. /** @hidden (Backing field) */
  129060. _depthRenderer: {
  129061. [id: string]: DepthRenderer;
  129062. };
  129063. /**
  129064. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129065. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129066. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129067. * @returns the created depth renderer
  129068. */
  129069. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129070. /**
  129071. * Disables a depth renderer for a given camera
  129072. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129073. */
  129074. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129075. }
  129076. /**
  129077. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129078. * in several rendering techniques.
  129079. */
  129080. export class DepthRendererSceneComponent implements ISceneComponent {
  129081. /**
  129082. * The component name helpfull to identify the component in the list of scene components.
  129083. */
  129084. readonly name: string;
  129085. /**
  129086. * The scene the component belongs to.
  129087. */
  129088. scene: Scene;
  129089. /**
  129090. * Creates a new instance of the component for the given scene
  129091. * @param scene Defines the scene to register the component in
  129092. */
  129093. constructor(scene: Scene);
  129094. /**
  129095. * Registers the component in a given scene
  129096. */
  129097. register(): void;
  129098. /**
  129099. * Rebuilds the elements related to this component in case of
  129100. * context lost for instance.
  129101. */
  129102. rebuild(): void;
  129103. /**
  129104. * Disposes the component and the associated ressources
  129105. */
  129106. dispose(): void;
  129107. private _gatherRenderTargets;
  129108. private _gatherActiveCameraRenderTargets;
  129109. }
  129110. }
  129111. declare module BABYLON {
  129112. /** @hidden */
  129113. export var outlinePixelShader: {
  129114. name: string;
  129115. shader: string;
  129116. };
  129117. }
  129118. declare module BABYLON {
  129119. /** @hidden */
  129120. export var outlineVertexShader: {
  129121. name: string;
  129122. shader: string;
  129123. };
  129124. }
  129125. declare module BABYLON {
  129126. interface Scene {
  129127. /** @hidden */
  129128. _outlineRenderer: OutlineRenderer;
  129129. /**
  129130. * Gets the outline renderer associated with the scene
  129131. * @returns a OutlineRenderer
  129132. */
  129133. getOutlineRenderer(): OutlineRenderer;
  129134. }
  129135. interface AbstractMesh {
  129136. /** @hidden (Backing field) */
  129137. _renderOutline: boolean;
  129138. /**
  129139. * Gets or sets a boolean indicating if the outline must be rendered as well
  129140. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129141. */
  129142. renderOutline: boolean;
  129143. /** @hidden (Backing field) */
  129144. _renderOverlay: boolean;
  129145. /**
  129146. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129147. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129148. */
  129149. renderOverlay: boolean;
  129150. }
  129151. /**
  129152. * This class is responsible to draw bothe outline/overlay of meshes.
  129153. * It should not be used directly but through the available method on mesh.
  129154. */
  129155. export class OutlineRenderer implements ISceneComponent {
  129156. /**
  129157. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129158. */
  129159. private static _StencilReference;
  129160. /**
  129161. * The name of the component. Each component must have a unique name.
  129162. */
  129163. name: string;
  129164. /**
  129165. * The scene the component belongs to.
  129166. */
  129167. scene: Scene;
  129168. /**
  129169. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129170. */
  129171. zOffset: number;
  129172. private _engine;
  129173. private _effect;
  129174. private _cachedDefines;
  129175. private _savedDepthWrite;
  129176. /**
  129177. * Instantiates a new outline renderer. (There could be only one per scene).
  129178. * @param scene Defines the scene it belongs to
  129179. */
  129180. constructor(scene: Scene);
  129181. /**
  129182. * Register the component to one instance of a scene.
  129183. */
  129184. register(): void;
  129185. /**
  129186. * Rebuilds the elements related to this component in case of
  129187. * context lost for instance.
  129188. */
  129189. rebuild(): void;
  129190. /**
  129191. * Disposes the component and the associated ressources.
  129192. */
  129193. dispose(): void;
  129194. /**
  129195. * Renders the outline in the canvas.
  129196. * @param subMesh Defines the sumesh to render
  129197. * @param batch Defines the batch of meshes in case of instances
  129198. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129199. */
  129200. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129201. /**
  129202. * Returns whether or not the outline renderer is ready for a given submesh.
  129203. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129204. * @param subMesh Defines the submesh to check readyness for
  129205. * @param useInstances Defines wheter wee are trying to render instances or not
  129206. * @returns true if ready otherwise false
  129207. */
  129208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129209. private _beforeRenderingMesh;
  129210. private _afterRenderingMesh;
  129211. }
  129212. }
  129213. declare module BABYLON {
  129214. /**
  129215. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129216. * @see http://doc.babylonjs.com/babylon101/sprites
  129217. */
  129218. export class SpritePackedManager extends SpriteManager {
  129219. /** defines the packed manager's name */
  129220. name: string;
  129221. /**
  129222. * Creates a new sprite manager from a packed sprite sheet
  129223. * @param name defines the manager's name
  129224. * @param imgUrl defines the sprite sheet url
  129225. * @param capacity defines the maximum allowed number of sprites
  129226. * @param scene defines the hosting scene
  129227. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129228. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129229. * @param samplingMode defines the smapling mode to use with spritesheet
  129230. * @param fromPacked set to true; do not alter
  129231. */
  129232. constructor(
  129233. /** defines the packed manager's name */
  129234. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129235. }
  129236. }
  129237. declare module BABYLON {
  129238. /**
  129239. * Defines the list of states available for a task inside a AssetsManager
  129240. */
  129241. export enum AssetTaskState {
  129242. /**
  129243. * Initialization
  129244. */
  129245. INIT = 0,
  129246. /**
  129247. * Running
  129248. */
  129249. RUNNING = 1,
  129250. /**
  129251. * Done
  129252. */
  129253. DONE = 2,
  129254. /**
  129255. * Error
  129256. */
  129257. ERROR = 3
  129258. }
  129259. /**
  129260. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129261. */
  129262. export abstract class AbstractAssetTask {
  129263. /**
  129264. * Task name
  129265. */ name: string;
  129266. /**
  129267. * Callback called when the task is successful
  129268. */
  129269. onSuccess: (task: any) => void;
  129270. /**
  129271. * Callback called when the task is not successful
  129272. */
  129273. onError: (task: any, message?: string, exception?: any) => void;
  129274. /**
  129275. * Creates a new AssetsManager
  129276. * @param name defines the name of the task
  129277. */
  129278. constructor(
  129279. /**
  129280. * Task name
  129281. */ name: string);
  129282. private _isCompleted;
  129283. private _taskState;
  129284. private _errorObject;
  129285. /**
  129286. * Get if the task is completed
  129287. */
  129288. readonly isCompleted: boolean;
  129289. /**
  129290. * Gets the current state of the task
  129291. */
  129292. readonly taskState: AssetTaskState;
  129293. /**
  129294. * Gets the current error object (if task is in error)
  129295. */
  129296. readonly errorObject: {
  129297. message?: string;
  129298. exception?: any;
  129299. };
  129300. /**
  129301. * Internal only
  129302. * @hidden
  129303. */
  129304. _setErrorObject(message?: string, exception?: any): void;
  129305. /**
  129306. * Execute the current task
  129307. * @param scene defines the scene where you want your assets to be loaded
  129308. * @param onSuccess is a callback called when the task is successfully executed
  129309. * @param onError is a callback called if an error occurs
  129310. */
  129311. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129312. /**
  129313. * Execute the current task
  129314. * @param scene defines the scene where you want your assets to be loaded
  129315. * @param onSuccess is a callback called when the task is successfully executed
  129316. * @param onError is a callback called if an error occurs
  129317. */
  129318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129319. /**
  129320. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129321. * This can be used with failed tasks that have the reason for failure fixed.
  129322. */
  129323. reset(): void;
  129324. private onErrorCallback;
  129325. private onDoneCallback;
  129326. }
  129327. /**
  129328. * Define the interface used by progress events raised during assets loading
  129329. */
  129330. export interface IAssetsProgressEvent {
  129331. /**
  129332. * Defines the number of remaining tasks to process
  129333. */
  129334. remainingCount: number;
  129335. /**
  129336. * Defines the total number of tasks
  129337. */
  129338. totalCount: number;
  129339. /**
  129340. * Defines the task that was just processed
  129341. */
  129342. task: AbstractAssetTask;
  129343. }
  129344. /**
  129345. * Class used to share progress information about assets loading
  129346. */
  129347. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129348. /**
  129349. * Defines the number of remaining tasks to process
  129350. */
  129351. remainingCount: number;
  129352. /**
  129353. * Defines the total number of tasks
  129354. */
  129355. totalCount: number;
  129356. /**
  129357. * Defines the task that was just processed
  129358. */
  129359. task: AbstractAssetTask;
  129360. /**
  129361. * Creates a AssetsProgressEvent
  129362. * @param remainingCount defines the number of remaining tasks to process
  129363. * @param totalCount defines the total number of tasks
  129364. * @param task defines the task that was just processed
  129365. */
  129366. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129367. }
  129368. /**
  129369. * Define a task used by AssetsManager to load meshes
  129370. */
  129371. export class MeshAssetTask extends AbstractAssetTask {
  129372. /**
  129373. * Defines the name of the task
  129374. */
  129375. name: string;
  129376. /**
  129377. * Defines the list of mesh's names you want to load
  129378. */
  129379. meshesNames: any;
  129380. /**
  129381. * Defines the root url to use as a base to load your meshes and associated resources
  129382. */
  129383. rootUrl: string;
  129384. /**
  129385. * Defines the filename of the scene to load from
  129386. */
  129387. sceneFilename: string;
  129388. /**
  129389. * Gets the list of loaded meshes
  129390. */
  129391. loadedMeshes: Array<AbstractMesh>;
  129392. /**
  129393. * Gets the list of loaded particle systems
  129394. */
  129395. loadedParticleSystems: Array<IParticleSystem>;
  129396. /**
  129397. * Gets the list of loaded skeletons
  129398. */
  129399. loadedSkeletons: Array<Skeleton>;
  129400. /**
  129401. * Gets the list of loaded animation groups
  129402. */
  129403. loadedAnimationGroups: Array<AnimationGroup>;
  129404. /**
  129405. * Callback called when the task is successful
  129406. */
  129407. onSuccess: (task: MeshAssetTask) => void;
  129408. /**
  129409. * Callback called when the task is successful
  129410. */
  129411. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129412. /**
  129413. * Creates a new MeshAssetTask
  129414. * @param name defines the name of the task
  129415. * @param meshesNames defines the list of mesh's names you want to load
  129416. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129417. * @param sceneFilename defines the filename of the scene to load from
  129418. */
  129419. constructor(
  129420. /**
  129421. * Defines the name of the task
  129422. */
  129423. name: string,
  129424. /**
  129425. * Defines the list of mesh's names you want to load
  129426. */
  129427. meshesNames: any,
  129428. /**
  129429. * Defines the root url to use as a base to load your meshes and associated resources
  129430. */
  129431. rootUrl: string,
  129432. /**
  129433. * Defines the filename of the scene to load from
  129434. */
  129435. sceneFilename: string);
  129436. /**
  129437. * Execute the current task
  129438. * @param scene defines the scene where you want your assets to be loaded
  129439. * @param onSuccess is a callback called when the task is successfully executed
  129440. * @param onError is a callback called if an error occurs
  129441. */
  129442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129443. }
  129444. /**
  129445. * Define a task used by AssetsManager to load text content
  129446. */
  129447. export class TextFileAssetTask extends AbstractAssetTask {
  129448. /**
  129449. * Defines the name of the task
  129450. */
  129451. name: string;
  129452. /**
  129453. * Defines the location of the file to load
  129454. */
  129455. url: string;
  129456. /**
  129457. * Gets the loaded text string
  129458. */
  129459. text: string;
  129460. /**
  129461. * Callback called when the task is successful
  129462. */
  129463. onSuccess: (task: TextFileAssetTask) => void;
  129464. /**
  129465. * Callback called when the task is successful
  129466. */
  129467. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129468. /**
  129469. * Creates a new TextFileAssetTask object
  129470. * @param name defines the name of the task
  129471. * @param url defines the location of the file to load
  129472. */
  129473. constructor(
  129474. /**
  129475. * Defines the name of the task
  129476. */
  129477. name: string,
  129478. /**
  129479. * Defines the location of the file to load
  129480. */
  129481. url: string);
  129482. /**
  129483. * Execute the current task
  129484. * @param scene defines the scene where you want your assets to be loaded
  129485. * @param onSuccess is a callback called when the task is successfully executed
  129486. * @param onError is a callback called if an error occurs
  129487. */
  129488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129489. }
  129490. /**
  129491. * Define a task used by AssetsManager to load binary data
  129492. */
  129493. export class BinaryFileAssetTask extends AbstractAssetTask {
  129494. /**
  129495. * Defines the name of the task
  129496. */
  129497. name: string;
  129498. /**
  129499. * Defines the location of the file to load
  129500. */
  129501. url: string;
  129502. /**
  129503. * Gets the lodaded data (as an array buffer)
  129504. */
  129505. data: ArrayBuffer;
  129506. /**
  129507. * Callback called when the task is successful
  129508. */
  129509. onSuccess: (task: BinaryFileAssetTask) => void;
  129510. /**
  129511. * Callback called when the task is successful
  129512. */
  129513. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129514. /**
  129515. * Creates a new BinaryFileAssetTask object
  129516. * @param name defines the name of the new task
  129517. * @param url defines the location of the file to load
  129518. */
  129519. constructor(
  129520. /**
  129521. * Defines the name of the task
  129522. */
  129523. name: string,
  129524. /**
  129525. * Defines the location of the file to load
  129526. */
  129527. url: string);
  129528. /**
  129529. * Execute the current task
  129530. * @param scene defines the scene where you want your assets to be loaded
  129531. * @param onSuccess is a callback called when the task is successfully executed
  129532. * @param onError is a callback called if an error occurs
  129533. */
  129534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129535. }
  129536. /**
  129537. * Define a task used by AssetsManager to load images
  129538. */
  129539. export class ImageAssetTask extends AbstractAssetTask {
  129540. /**
  129541. * Defines the name of the task
  129542. */
  129543. name: string;
  129544. /**
  129545. * Defines the location of the image to load
  129546. */
  129547. url: string;
  129548. /**
  129549. * Gets the loaded images
  129550. */
  129551. image: HTMLImageElement;
  129552. /**
  129553. * Callback called when the task is successful
  129554. */
  129555. onSuccess: (task: ImageAssetTask) => void;
  129556. /**
  129557. * Callback called when the task is successful
  129558. */
  129559. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129560. /**
  129561. * Creates a new ImageAssetTask
  129562. * @param name defines the name of the task
  129563. * @param url defines the location of the image to load
  129564. */
  129565. constructor(
  129566. /**
  129567. * Defines the name of the task
  129568. */
  129569. name: string,
  129570. /**
  129571. * Defines the location of the image to load
  129572. */
  129573. url: string);
  129574. /**
  129575. * Execute the current task
  129576. * @param scene defines the scene where you want your assets to be loaded
  129577. * @param onSuccess is a callback called when the task is successfully executed
  129578. * @param onError is a callback called if an error occurs
  129579. */
  129580. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129581. }
  129582. /**
  129583. * Defines the interface used by texture loading tasks
  129584. */
  129585. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129586. /**
  129587. * Gets the loaded texture
  129588. */
  129589. texture: TEX;
  129590. }
  129591. /**
  129592. * Define a task used by AssetsManager to load 2D textures
  129593. */
  129594. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  129595. /**
  129596. * Defines the name of the task
  129597. */
  129598. name: string;
  129599. /**
  129600. * Defines the location of the file to load
  129601. */
  129602. url: string;
  129603. /**
  129604. * Defines if mipmap should not be generated (default is false)
  129605. */
  129606. noMipmap?: boolean | undefined;
  129607. /**
  129608. * Defines if texture must be inverted on Y axis (default is false)
  129609. */
  129610. invertY?: boolean | undefined;
  129611. /**
  129612. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129613. */
  129614. samplingMode: number;
  129615. /**
  129616. * Gets the loaded texture
  129617. */
  129618. texture: Texture;
  129619. /**
  129620. * Callback called when the task is successful
  129621. */
  129622. onSuccess: (task: TextureAssetTask) => void;
  129623. /**
  129624. * Callback called when the task is successful
  129625. */
  129626. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  129627. /**
  129628. * Creates a new TextureAssetTask object
  129629. * @param name defines the name of the task
  129630. * @param url defines the location of the file to load
  129631. * @param noMipmap defines if mipmap should not be generated (default is false)
  129632. * @param invertY defines if texture must be inverted on Y axis (default is false)
  129633. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129634. */
  129635. constructor(
  129636. /**
  129637. * Defines the name of the task
  129638. */
  129639. name: string,
  129640. /**
  129641. * Defines the location of the file to load
  129642. */
  129643. url: string,
  129644. /**
  129645. * Defines if mipmap should not be generated (default is false)
  129646. */
  129647. noMipmap?: boolean | undefined,
  129648. /**
  129649. * Defines if texture must be inverted on Y axis (default is false)
  129650. */
  129651. invertY?: boolean | undefined,
  129652. /**
  129653. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129654. */
  129655. samplingMode?: number);
  129656. /**
  129657. * Execute the current task
  129658. * @param scene defines the scene where you want your assets to be loaded
  129659. * @param onSuccess is a callback called when the task is successfully executed
  129660. * @param onError is a callback called if an error occurs
  129661. */
  129662. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129663. }
  129664. /**
  129665. * Define a task used by AssetsManager to load cube textures
  129666. */
  129667. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  129668. /**
  129669. * Defines the name of the task
  129670. */
  129671. name: string;
  129672. /**
  129673. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129674. */
  129675. url: string;
  129676. /**
  129677. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129678. */
  129679. extensions?: string[] | undefined;
  129680. /**
  129681. * Defines if mipmaps should not be generated (default is false)
  129682. */
  129683. noMipmap?: boolean | undefined;
  129684. /**
  129685. * Defines the explicit list of files (undefined by default)
  129686. */
  129687. files?: string[] | undefined;
  129688. /**
  129689. * Gets the loaded texture
  129690. */
  129691. texture: CubeTexture;
  129692. /**
  129693. * Callback called when the task is successful
  129694. */
  129695. onSuccess: (task: CubeTextureAssetTask) => void;
  129696. /**
  129697. * Callback called when the task is successful
  129698. */
  129699. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  129700. /**
  129701. * Creates a new CubeTextureAssetTask
  129702. * @param name defines the name of the task
  129703. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129704. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129705. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129706. * @param files defines the explicit list of files (undefined by default)
  129707. */
  129708. constructor(
  129709. /**
  129710. * Defines the name of the task
  129711. */
  129712. name: string,
  129713. /**
  129714. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129715. */
  129716. url: string,
  129717. /**
  129718. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129719. */
  129720. extensions?: string[] | undefined,
  129721. /**
  129722. * Defines if mipmaps should not be generated (default is false)
  129723. */
  129724. noMipmap?: boolean | undefined,
  129725. /**
  129726. * Defines the explicit list of files (undefined by default)
  129727. */
  129728. files?: string[] | undefined);
  129729. /**
  129730. * Execute the current task
  129731. * @param scene defines the scene where you want your assets to be loaded
  129732. * @param onSuccess is a callback called when the task is successfully executed
  129733. * @param onError is a callback called if an error occurs
  129734. */
  129735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129736. }
  129737. /**
  129738. * Define a task used by AssetsManager to load HDR cube textures
  129739. */
  129740. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  129741. /**
  129742. * Defines the name of the task
  129743. */
  129744. name: string;
  129745. /**
  129746. * Defines the location of the file to load
  129747. */
  129748. url: string;
  129749. /**
  129750. * Defines the desired size (the more it increases the longer the generation will be)
  129751. */
  129752. size: number;
  129753. /**
  129754. * Defines if mipmaps should not be generated (default is false)
  129755. */
  129756. noMipmap: boolean;
  129757. /**
  129758. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129759. */
  129760. generateHarmonics: boolean;
  129761. /**
  129762. * 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)
  129763. */
  129764. gammaSpace: boolean;
  129765. /**
  129766. * Internal Use Only
  129767. */
  129768. reserved: boolean;
  129769. /**
  129770. * Gets the loaded texture
  129771. */
  129772. texture: HDRCubeTexture;
  129773. /**
  129774. * Callback called when the task is successful
  129775. */
  129776. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  129777. /**
  129778. * Callback called when the task is successful
  129779. */
  129780. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  129781. /**
  129782. * Creates a new HDRCubeTextureAssetTask object
  129783. * @param name defines the name of the task
  129784. * @param url defines the location of the file to load
  129785. * @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.
  129786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129787. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129788. * @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)
  129789. * @param reserved Internal use only
  129790. */
  129791. constructor(
  129792. /**
  129793. * Defines the name of the task
  129794. */
  129795. name: string,
  129796. /**
  129797. * Defines the location of the file to load
  129798. */
  129799. url: string,
  129800. /**
  129801. * Defines the desired size (the more it increases the longer the generation will be)
  129802. */
  129803. size: number,
  129804. /**
  129805. * Defines if mipmaps should not be generated (default is false)
  129806. */
  129807. noMipmap?: boolean,
  129808. /**
  129809. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129810. */
  129811. generateHarmonics?: boolean,
  129812. /**
  129813. * 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)
  129814. */
  129815. gammaSpace?: boolean,
  129816. /**
  129817. * Internal Use Only
  129818. */
  129819. reserved?: boolean);
  129820. /**
  129821. * Execute the current task
  129822. * @param scene defines the scene where you want your assets to be loaded
  129823. * @param onSuccess is a callback called when the task is successfully executed
  129824. * @param onError is a callback called if an error occurs
  129825. */
  129826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129827. }
  129828. /**
  129829. * Define a task used by AssetsManager to load Equirectangular cube textures
  129830. */
  129831. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  129832. /**
  129833. * Defines the name of the task
  129834. */
  129835. name: string;
  129836. /**
  129837. * Defines the location of the file to load
  129838. */
  129839. url: string;
  129840. /**
  129841. * Defines the desired size (the more it increases the longer the generation will be)
  129842. */
  129843. size: number;
  129844. /**
  129845. * Defines if mipmaps should not be generated (default is false)
  129846. */
  129847. noMipmap: boolean;
  129848. /**
  129849. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129850. * but the standard material would require them in Gamma space) (default is true)
  129851. */
  129852. gammaSpace: boolean;
  129853. /**
  129854. * Gets the loaded texture
  129855. */
  129856. texture: EquiRectangularCubeTexture;
  129857. /**
  129858. * Callback called when the task is successful
  129859. */
  129860. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129861. /**
  129862. * Callback called when the task is successful
  129863. */
  129864. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129865. /**
  129866. * Creates a new EquiRectangularCubeTextureAssetTask object
  129867. * @param name defines the name of the task
  129868. * @param url defines the location of the file to load
  129869. * @param size defines the desired size (the more it increases the longer the generation will be)
  129870. * If the size is omitted this implies you are using a preprocessed cubemap.
  129871. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129872. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129873. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129874. * (default is true)
  129875. */
  129876. constructor(
  129877. /**
  129878. * Defines the name of the task
  129879. */
  129880. name: string,
  129881. /**
  129882. * Defines the location of the file to load
  129883. */
  129884. url: string,
  129885. /**
  129886. * Defines the desired size (the more it increases the longer the generation will be)
  129887. */
  129888. size: number,
  129889. /**
  129890. * Defines if mipmaps should not be generated (default is false)
  129891. */
  129892. noMipmap?: boolean,
  129893. /**
  129894. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129895. * but the standard material would require them in Gamma space) (default is true)
  129896. */
  129897. gammaSpace?: boolean);
  129898. /**
  129899. * Execute the current task
  129900. * @param scene defines the scene where you want your assets to be loaded
  129901. * @param onSuccess is a callback called when the task is successfully executed
  129902. * @param onError is a callback called if an error occurs
  129903. */
  129904. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129905. }
  129906. /**
  129907. * This class can be used to easily import assets into a scene
  129908. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129909. */
  129910. export class AssetsManager {
  129911. private _scene;
  129912. private _isLoading;
  129913. protected _tasks: AbstractAssetTask[];
  129914. protected _waitingTasksCount: number;
  129915. protected _totalTasksCount: number;
  129916. /**
  129917. * Callback called when all tasks are processed
  129918. */
  129919. onFinish: (tasks: AbstractAssetTask[]) => void;
  129920. /**
  129921. * Callback called when a task is successful
  129922. */
  129923. onTaskSuccess: (task: AbstractAssetTask) => void;
  129924. /**
  129925. * Callback called when a task had an error
  129926. */
  129927. onTaskError: (task: AbstractAssetTask) => void;
  129928. /**
  129929. * Callback called when a task is done (whatever the result is)
  129930. */
  129931. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129932. /**
  129933. * Observable called when all tasks are processed
  129934. */
  129935. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129936. /**
  129937. * Observable called when a task had an error
  129938. */
  129939. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129940. /**
  129941. * Observable called when all tasks were executed
  129942. */
  129943. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129944. /**
  129945. * Observable called when a task is done (whatever the result is)
  129946. */
  129947. onProgressObservable: Observable<IAssetsProgressEvent>;
  129948. /**
  129949. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129950. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129951. */
  129952. useDefaultLoadingScreen: boolean;
  129953. /**
  129954. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129955. * when all assets have been downloaded.
  129956. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129957. */
  129958. autoHideLoadingUI: boolean;
  129959. /**
  129960. * Creates a new AssetsManager
  129961. * @param scene defines the scene to work on
  129962. */
  129963. constructor(scene: Scene);
  129964. /**
  129965. * Add a MeshAssetTask to the list of active tasks
  129966. * @param taskName defines the name of the new task
  129967. * @param meshesNames defines the name of meshes to load
  129968. * @param rootUrl defines the root url to use to locate files
  129969. * @param sceneFilename defines the filename of the scene file
  129970. * @returns a new MeshAssetTask object
  129971. */
  129972. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129973. /**
  129974. * Add a TextFileAssetTask to the list of active tasks
  129975. * @param taskName defines the name of the new task
  129976. * @param url defines the url of the file to load
  129977. * @returns a new TextFileAssetTask object
  129978. */
  129979. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129980. /**
  129981. * Add a BinaryFileAssetTask to the list of active tasks
  129982. * @param taskName defines the name of the new task
  129983. * @param url defines the url of the file to load
  129984. * @returns a new BinaryFileAssetTask object
  129985. */
  129986. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129987. /**
  129988. * Add a ImageAssetTask to the list of active tasks
  129989. * @param taskName defines the name of the new task
  129990. * @param url defines the url of the file to load
  129991. * @returns a new ImageAssetTask object
  129992. */
  129993. addImageTask(taskName: string, url: string): ImageAssetTask;
  129994. /**
  129995. * Add a TextureAssetTask to the list of active tasks
  129996. * @param taskName defines the name of the new task
  129997. * @param url defines the url of the file to load
  129998. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129999. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130000. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130001. * @returns a new TextureAssetTask object
  130002. */
  130003. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130004. /**
  130005. * Add a CubeTextureAssetTask to the list of active tasks
  130006. * @param taskName defines the name of the new task
  130007. * @param url defines the url of the file to load
  130008. * @param extensions defines the extension to use to load the cube map (can be null)
  130009. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130010. * @param files defines the list of files to load (can be null)
  130011. * @returns a new CubeTextureAssetTask object
  130012. */
  130013. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130014. /**
  130015. *
  130016. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130017. * @param taskName defines the name of the new task
  130018. * @param url defines the url of the file to load
  130019. * @param size defines the size you want for the cubemap (can be null)
  130020. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130021. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130022. * @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)
  130023. * @param reserved Internal use only
  130024. * @returns a new HDRCubeTextureAssetTask object
  130025. */
  130026. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130027. /**
  130028. *
  130029. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130030. * @param taskName defines the name of the new task
  130031. * @param url defines the url of the file to load
  130032. * @param size defines the size you want for the cubemap (can be null)
  130033. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130034. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130035. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130036. * @returns a new EquiRectangularCubeTextureAssetTask object
  130037. */
  130038. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130039. /**
  130040. * Remove a task from the assets manager.
  130041. * @param task the task to remove
  130042. */
  130043. removeTask(task: AbstractAssetTask): void;
  130044. private _decreaseWaitingTasksCount;
  130045. private _runTask;
  130046. /**
  130047. * Reset the AssetsManager and remove all tasks
  130048. * @return the current instance of the AssetsManager
  130049. */
  130050. reset(): AssetsManager;
  130051. /**
  130052. * Start the loading process
  130053. * @return the current instance of the AssetsManager
  130054. */
  130055. load(): AssetsManager;
  130056. /**
  130057. * Start the loading process as an async operation
  130058. * @return a promise returning the list of failed tasks
  130059. */
  130060. loadAsync(): Promise<void>;
  130061. }
  130062. }
  130063. declare module BABYLON {
  130064. /**
  130065. * Wrapper class for promise with external resolve and reject.
  130066. */
  130067. export class Deferred<T> {
  130068. /**
  130069. * The promise associated with this deferred object.
  130070. */
  130071. readonly promise: Promise<T>;
  130072. private _resolve;
  130073. private _reject;
  130074. /**
  130075. * The resolve method of the promise associated with this deferred object.
  130076. */
  130077. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130078. /**
  130079. * The reject method of the promise associated with this deferred object.
  130080. */
  130081. readonly reject: (reason?: any) => void;
  130082. /**
  130083. * Constructor for this deferred object.
  130084. */
  130085. constructor();
  130086. }
  130087. }
  130088. declare module BABYLON {
  130089. /**
  130090. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130091. */
  130092. export class MeshExploder {
  130093. private _centerMesh;
  130094. private _meshes;
  130095. private _meshesOrigins;
  130096. private _toCenterVectors;
  130097. private _scaledDirection;
  130098. private _newPosition;
  130099. private _centerPosition;
  130100. /**
  130101. * Explodes meshes from a center mesh.
  130102. * @param meshes The meshes to explode.
  130103. * @param centerMesh The mesh to be center of explosion.
  130104. */
  130105. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130106. private _setCenterMesh;
  130107. /**
  130108. * Get class name
  130109. * @returns "MeshExploder"
  130110. */
  130111. getClassName(): string;
  130112. /**
  130113. * "Exploded meshes"
  130114. * @returns Array of meshes with the centerMesh at index 0.
  130115. */
  130116. getMeshes(): Array<Mesh>;
  130117. /**
  130118. * Explodes meshes giving a specific direction
  130119. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130120. */
  130121. explode(direction?: number): void;
  130122. }
  130123. }
  130124. declare module BABYLON {
  130125. /**
  130126. * Class used to help managing file picking and drag'n'drop
  130127. */
  130128. export class FilesInput {
  130129. /**
  130130. * List of files ready to be loaded
  130131. */
  130132. static readonly FilesToLoad: {
  130133. [key: string]: File;
  130134. };
  130135. /**
  130136. * Callback called when a file is processed
  130137. */
  130138. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130139. private _engine;
  130140. private _currentScene;
  130141. private _sceneLoadedCallback;
  130142. private _progressCallback;
  130143. private _additionalRenderLoopLogicCallback;
  130144. private _textureLoadingCallback;
  130145. private _startingProcessingFilesCallback;
  130146. private _onReloadCallback;
  130147. private _errorCallback;
  130148. private _elementToMonitor;
  130149. private _sceneFileToLoad;
  130150. private _filesToLoad;
  130151. /**
  130152. * Creates a new FilesInput
  130153. * @param engine defines the rendering engine
  130154. * @param scene defines the hosting scene
  130155. * @param sceneLoadedCallback callback called when scene is loaded
  130156. * @param progressCallback callback called to track progress
  130157. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130158. * @param textureLoadingCallback callback called when a texture is loading
  130159. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130160. * @param onReloadCallback callback called when a reload is requested
  130161. * @param errorCallback callback call if an error occurs
  130162. */
  130163. 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);
  130164. private _dragEnterHandler;
  130165. private _dragOverHandler;
  130166. private _dropHandler;
  130167. /**
  130168. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130169. * @param elementToMonitor defines the DOM element to track
  130170. */
  130171. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130172. /**
  130173. * Release all associated resources
  130174. */
  130175. dispose(): void;
  130176. private renderFunction;
  130177. private drag;
  130178. private drop;
  130179. private _traverseFolder;
  130180. private _processFiles;
  130181. /**
  130182. * Load files from a drop event
  130183. * @param event defines the drop event to use as source
  130184. */
  130185. loadFiles(event: any): void;
  130186. private _processReload;
  130187. /**
  130188. * Reload the current scene from the loaded files
  130189. */
  130190. reload(): void;
  130191. }
  130192. }
  130193. declare module BABYLON {
  130194. /**
  130195. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130196. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130197. */
  130198. export class SceneOptimization {
  130199. /**
  130200. * Defines the priority of this optimization (0 by default which means first in the list)
  130201. */
  130202. priority: number;
  130203. /**
  130204. * Gets a string describing the action executed by the current optimization
  130205. * @returns description string
  130206. */
  130207. getDescription(): string;
  130208. /**
  130209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130210. * @param scene defines the current scene where to apply this optimization
  130211. * @param optimizer defines the current optimizer
  130212. * @returns true if everything that can be done was applied
  130213. */
  130214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130215. /**
  130216. * Creates the SceneOptimization object
  130217. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130218. * @param desc defines the description associated with the optimization
  130219. */
  130220. constructor(
  130221. /**
  130222. * Defines the priority of this optimization (0 by default which means first in the list)
  130223. */
  130224. priority?: number);
  130225. }
  130226. /**
  130227. * Defines an optimization used to reduce the size of render target textures
  130228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130229. */
  130230. export class TextureOptimization extends SceneOptimization {
  130231. /**
  130232. * Defines the priority of this optimization (0 by default which means first in the list)
  130233. */
  130234. priority: number;
  130235. /**
  130236. * 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
  130237. */
  130238. maximumSize: number;
  130239. /**
  130240. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130241. */
  130242. step: number;
  130243. /**
  130244. * Gets a string describing the action executed by the current optimization
  130245. * @returns description string
  130246. */
  130247. getDescription(): string;
  130248. /**
  130249. * Creates the TextureOptimization object
  130250. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130251. * @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
  130252. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130253. */
  130254. constructor(
  130255. /**
  130256. * Defines the priority of this optimization (0 by default which means first in the list)
  130257. */
  130258. priority?: number,
  130259. /**
  130260. * 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
  130261. */
  130262. maximumSize?: number,
  130263. /**
  130264. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130265. */
  130266. step?: number);
  130267. /**
  130268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130269. * @param scene defines the current scene where to apply this optimization
  130270. * @param optimizer defines the current optimizer
  130271. * @returns true if everything that can be done was applied
  130272. */
  130273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130274. }
  130275. /**
  130276. * Defines an optimization used to increase or decrease the rendering resolution
  130277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130278. */
  130279. export class HardwareScalingOptimization extends SceneOptimization {
  130280. /**
  130281. * Defines the priority of this optimization (0 by default which means first in the list)
  130282. */
  130283. priority: number;
  130284. /**
  130285. * Defines the maximum scale to use (2 by default)
  130286. */
  130287. maximumScale: number;
  130288. /**
  130289. * Defines the step to use between two passes (0.5 by default)
  130290. */
  130291. step: number;
  130292. private _currentScale;
  130293. private _directionOffset;
  130294. /**
  130295. * Gets a string describing the action executed by the current optimization
  130296. * @return description string
  130297. */
  130298. getDescription(): string;
  130299. /**
  130300. * Creates the HardwareScalingOptimization object
  130301. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130302. * @param maximumScale defines the maximum scale to use (2 by default)
  130303. * @param step defines the step to use between two passes (0.5 by default)
  130304. */
  130305. constructor(
  130306. /**
  130307. * Defines the priority of this optimization (0 by default which means first in the list)
  130308. */
  130309. priority?: number,
  130310. /**
  130311. * Defines the maximum scale to use (2 by default)
  130312. */
  130313. maximumScale?: number,
  130314. /**
  130315. * Defines the step to use between two passes (0.5 by default)
  130316. */
  130317. step?: number);
  130318. /**
  130319. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130320. * @param scene defines the current scene where to apply this optimization
  130321. * @param optimizer defines the current optimizer
  130322. * @returns true if everything that can be done was applied
  130323. */
  130324. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130325. }
  130326. /**
  130327. * Defines an optimization used to remove shadows
  130328. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130329. */
  130330. export class ShadowsOptimization extends SceneOptimization {
  130331. /**
  130332. * Gets a string describing the action executed by the current optimization
  130333. * @return description string
  130334. */
  130335. getDescription(): string;
  130336. /**
  130337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130338. * @param scene defines the current scene where to apply this optimization
  130339. * @param optimizer defines the current optimizer
  130340. * @returns true if everything that can be done was applied
  130341. */
  130342. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130343. }
  130344. /**
  130345. * Defines an optimization used to turn post-processes off
  130346. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130347. */
  130348. export class PostProcessesOptimization extends SceneOptimization {
  130349. /**
  130350. * Gets a string describing the action executed by the current optimization
  130351. * @return description string
  130352. */
  130353. getDescription(): string;
  130354. /**
  130355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130356. * @param scene defines the current scene where to apply this optimization
  130357. * @param optimizer defines the current optimizer
  130358. * @returns true if everything that can be done was applied
  130359. */
  130360. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130361. }
  130362. /**
  130363. * Defines an optimization used to turn lens flares off
  130364. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130365. */
  130366. export class LensFlaresOptimization extends SceneOptimization {
  130367. /**
  130368. * Gets a string describing the action executed by the current optimization
  130369. * @return description string
  130370. */
  130371. getDescription(): string;
  130372. /**
  130373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130374. * @param scene defines the current scene where to apply this optimization
  130375. * @param optimizer defines the current optimizer
  130376. * @returns true if everything that can be done was applied
  130377. */
  130378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130379. }
  130380. /**
  130381. * Defines an optimization based on user defined callback.
  130382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130383. */
  130384. export class CustomOptimization extends SceneOptimization {
  130385. /**
  130386. * Callback called to apply the custom optimization.
  130387. */
  130388. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130389. /**
  130390. * Callback called to get custom description
  130391. */
  130392. onGetDescription: () => string;
  130393. /**
  130394. * Gets a string describing the action executed by the current optimization
  130395. * @returns description string
  130396. */
  130397. getDescription(): string;
  130398. /**
  130399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130400. * @param scene defines the current scene where to apply this optimization
  130401. * @param optimizer defines the current optimizer
  130402. * @returns true if everything that can be done was applied
  130403. */
  130404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130405. }
  130406. /**
  130407. * Defines an optimization used to turn particles off
  130408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130409. */
  130410. export class ParticlesOptimization extends SceneOptimization {
  130411. /**
  130412. * Gets a string describing the action executed by the current optimization
  130413. * @return description string
  130414. */
  130415. getDescription(): string;
  130416. /**
  130417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130418. * @param scene defines the current scene where to apply this optimization
  130419. * @param optimizer defines the current optimizer
  130420. * @returns true if everything that can be done was applied
  130421. */
  130422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130423. }
  130424. /**
  130425. * Defines an optimization used to turn render targets off
  130426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130427. */
  130428. export class RenderTargetsOptimization extends SceneOptimization {
  130429. /**
  130430. * Gets a string describing the action executed by the current optimization
  130431. * @return description string
  130432. */
  130433. getDescription(): string;
  130434. /**
  130435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130436. * @param scene defines the current scene where to apply this optimization
  130437. * @param optimizer defines the current optimizer
  130438. * @returns true if everything that can be done was applied
  130439. */
  130440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130441. }
  130442. /**
  130443. * Defines an optimization used to merge meshes with compatible materials
  130444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130445. */
  130446. export class MergeMeshesOptimization extends SceneOptimization {
  130447. private static _UpdateSelectionTree;
  130448. /**
  130449. * Gets or sets a boolean which defines if optimization octree has to be updated
  130450. */
  130451. /**
  130452. * Gets or sets a boolean which defines if optimization octree has to be updated
  130453. */
  130454. static UpdateSelectionTree: boolean;
  130455. /**
  130456. * Gets a string describing the action executed by the current optimization
  130457. * @return description string
  130458. */
  130459. getDescription(): string;
  130460. private _canBeMerged;
  130461. /**
  130462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130463. * @param scene defines the current scene where to apply this optimization
  130464. * @param optimizer defines the current optimizer
  130465. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130466. * @returns true if everything that can be done was applied
  130467. */
  130468. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130469. }
  130470. /**
  130471. * Defines a list of options used by SceneOptimizer
  130472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130473. */
  130474. export class SceneOptimizerOptions {
  130475. /**
  130476. * Defines the target frame rate to reach (60 by default)
  130477. */
  130478. targetFrameRate: number;
  130479. /**
  130480. * Defines the interval between two checkes (2000ms by default)
  130481. */
  130482. trackerDuration: number;
  130483. /**
  130484. * Gets the list of optimizations to apply
  130485. */
  130486. optimizations: SceneOptimization[];
  130487. /**
  130488. * Creates a new list of options used by SceneOptimizer
  130489. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130490. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130491. */
  130492. constructor(
  130493. /**
  130494. * Defines the target frame rate to reach (60 by default)
  130495. */
  130496. targetFrameRate?: number,
  130497. /**
  130498. * Defines the interval between two checkes (2000ms by default)
  130499. */
  130500. trackerDuration?: number);
  130501. /**
  130502. * Add a new optimization
  130503. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130504. * @returns the current SceneOptimizerOptions
  130505. */
  130506. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130507. /**
  130508. * Add a new custom optimization
  130509. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130510. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130511. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130512. * @returns the current SceneOptimizerOptions
  130513. */
  130514. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130515. /**
  130516. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130517. * @param targetFrameRate defines the target frame rate (60 by default)
  130518. * @returns a SceneOptimizerOptions object
  130519. */
  130520. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130521. /**
  130522. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130523. * @param targetFrameRate defines the target frame rate (60 by default)
  130524. * @returns a SceneOptimizerOptions object
  130525. */
  130526. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130527. /**
  130528. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130529. * @param targetFrameRate defines the target frame rate (60 by default)
  130530. * @returns a SceneOptimizerOptions object
  130531. */
  130532. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130533. }
  130534. /**
  130535. * Class used to run optimizations in order to reach a target frame rate
  130536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130537. */
  130538. export class SceneOptimizer implements IDisposable {
  130539. private _isRunning;
  130540. private _options;
  130541. private _scene;
  130542. private _currentPriorityLevel;
  130543. private _targetFrameRate;
  130544. private _trackerDuration;
  130545. private _currentFrameRate;
  130546. private _sceneDisposeObserver;
  130547. private _improvementMode;
  130548. /**
  130549. * Defines an observable called when the optimizer reaches the target frame rate
  130550. */
  130551. onSuccessObservable: Observable<SceneOptimizer>;
  130552. /**
  130553. * Defines an observable called when the optimizer enables an optimization
  130554. */
  130555. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130556. /**
  130557. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130558. */
  130559. onFailureObservable: Observable<SceneOptimizer>;
  130560. /**
  130561. * Gets a boolean indicating if the optimizer is in improvement mode
  130562. */
  130563. readonly isInImprovementMode: boolean;
  130564. /**
  130565. * Gets the current priority level (0 at start)
  130566. */
  130567. readonly currentPriorityLevel: number;
  130568. /**
  130569. * Gets the current frame rate checked by the SceneOptimizer
  130570. */
  130571. readonly currentFrameRate: number;
  130572. /**
  130573. * Gets or sets the current target frame rate (60 by default)
  130574. */
  130575. /**
  130576. * Gets or sets the current target frame rate (60 by default)
  130577. */
  130578. targetFrameRate: number;
  130579. /**
  130580. * Gets or sets the current interval between two checks (every 2000ms by default)
  130581. */
  130582. /**
  130583. * Gets or sets the current interval between two checks (every 2000ms by default)
  130584. */
  130585. trackerDuration: number;
  130586. /**
  130587. * Gets the list of active optimizations
  130588. */
  130589. readonly optimizations: SceneOptimization[];
  130590. /**
  130591. * Creates a new SceneOptimizer
  130592. * @param scene defines the scene to work on
  130593. * @param options defines the options to use with the SceneOptimizer
  130594. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  130595. * @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)
  130596. */
  130597. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  130598. /**
  130599. * Stops the current optimizer
  130600. */
  130601. stop(): void;
  130602. /**
  130603. * Reset the optimizer to initial step (current priority level = 0)
  130604. */
  130605. reset(): void;
  130606. /**
  130607. * Start the optimizer. By default it will try to reach a specific framerate
  130608. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  130609. */
  130610. start(): void;
  130611. private _checkCurrentState;
  130612. /**
  130613. * Release all resources
  130614. */
  130615. dispose(): void;
  130616. /**
  130617. * Helper function to create a SceneOptimizer with one single line of code
  130618. * @param scene defines the scene to work on
  130619. * @param options defines the options to use with the SceneOptimizer
  130620. * @param onSuccess defines a callback to call on success
  130621. * @param onFailure defines a callback to call on failure
  130622. * @returns the new SceneOptimizer object
  130623. */
  130624. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  130625. }
  130626. }
  130627. declare module BABYLON {
  130628. /**
  130629. * Class used to serialize a scene into a string
  130630. */
  130631. export class SceneSerializer {
  130632. /**
  130633. * Clear cache used by a previous serialization
  130634. */
  130635. static ClearCache(): void;
  130636. /**
  130637. * Serialize a scene into a JSON compatible object
  130638. * @param scene defines the scene to serialize
  130639. * @returns a JSON compatible object
  130640. */
  130641. static Serialize(scene: Scene): any;
  130642. /**
  130643. * Serialize a mesh into a JSON compatible object
  130644. * @param toSerialize defines the mesh to serialize
  130645. * @param withParents defines if parents must be serialized as well
  130646. * @param withChildren defines if children must be serialized as well
  130647. * @returns a JSON compatible object
  130648. */
  130649. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  130650. }
  130651. }
  130652. declare module BABYLON {
  130653. /**
  130654. * Class used to host texture specific utilities
  130655. */
  130656. export class TextureTools {
  130657. /**
  130658. * Uses the GPU to create a copy texture rescaled at a given size
  130659. * @param texture Texture to copy from
  130660. * @param width defines the desired width
  130661. * @param height defines the desired height
  130662. * @param useBilinearMode defines if bilinear mode has to be used
  130663. * @return the generated texture
  130664. */
  130665. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  130666. }
  130667. }
  130668. declare module BABYLON {
  130669. /**
  130670. * This represents the different options available for the video capture.
  130671. */
  130672. export interface VideoRecorderOptions {
  130673. /** Defines the mime type of the video. */
  130674. mimeType: string;
  130675. /** Defines the FPS the video should be recorded at. */
  130676. fps: number;
  130677. /** Defines the chunk size for the recording data. */
  130678. recordChunckSize: number;
  130679. /** The audio tracks to attach to the recording. */
  130680. audioTracks?: MediaStreamTrack[];
  130681. }
  130682. /**
  130683. * This can help with recording videos from BabylonJS.
  130684. * This is based on the available WebRTC functionalities of the browser.
  130685. *
  130686. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  130687. */
  130688. export class VideoRecorder {
  130689. private static readonly _defaultOptions;
  130690. /**
  130691. * Returns whether or not the VideoRecorder is available in your browser.
  130692. * @param engine Defines the Babylon Engine.
  130693. * @returns true if supported otherwise false.
  130694. */
  130695. static IsSupported(engine: Engine): boolean;
  130696. private readonly _options;
  130697. private _canvas;
  130698. private _mediaRecorder;
  130699. private _recordedChunks;
  130700. private _fileName;
  130701. private _resolve;
  130702. private _reject;
  130703. /**
  130704. * True when a recording is already in progress.
  130705. */
  130706. readonly isRecording: boolean;
  130707. /**
  130708. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  130709. * @param engine Defines the BabylonJS Engine you wish to record.
  130710. * @param options Defines options that can be used to customize the capture.
  130711. */
  130712. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  130713. /**
  130714. * Stops the current recording before the default capture timeout passed in the startRecording function.
  130715. */
  130716. stopRecording(): void;
  130717. /**
  130718. * Starts recording the canvas for a max duration specified in parameters.
  130719. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  130720. * If null no automatic download will start and you can rely on the promise to get the data back.
  130721. * @param maxDuration Defines the maximum recording time in seconds.
  130722. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  130723. * @return A promise callback at the end of the recording with the video data in Blob.
  130724. */
  130725. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  130726. /**
  130727. * Releases internal resources used during the recording.
  130728. */
  130729. dispose(): void;
  130730. private _handleDataAvailable;
  130731. private _handleError;
  130732. private _handleStop;
  130733. }
  130734. }
  130735. declare module BABYLON {
  130736. /**
  130737. * Class containing a set of static utilities functions for screenshots
  130738. */
  130739. export class ScreenshotTools {
  130740. /**
  130741. * Captures a screenshot of the current rendering
  130742. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130743. * @param engine defines the rendering engine
  130744. * @param camera defines the source camera
  130745. * @param size This parameter can be set to a single number or to an object with the
  130746. * following (optional) properties: precision, width, height. If a single number is passed,
  130747. * it will be used for both width and height. If an object is passed, the screenshot size
  130748. * will be derived from the parameters. The precision property is a multiplier allowing
  130749. * rendering at a higher or lower resolution
  130750. * @param successCallback defines the callback receives a single parameter which contains the
  130751. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  130752. * src parameter of an <img> to display it
  130753. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  130754. * Check your browser for supported MIME types
  130755. */
  130756. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  130757. /**
  130758. * Captures a screenshot of the current rendering
  130759. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130760. * @param engine defines the rendering engine
  130761. * @param camera defines the source camera
  130762. * @param size This parameter can be set to a single number or to an object with the
  130763. * following (optional) properties: precision, width, height. If a single number is passed,
  130764. * it will be used for both width and height. If an object is passed, the screenshot size
  130765. * will be derived from the parameters. The precision property is a multiplier allowing
  130766. * rendering at a higher or lower resolution
  130767. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  130768. * Check your browser for supported MIME types
  130769. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  130770. * to the src parameter of an <img> to display it
  130771. */
  130772. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  130773. /**
  130774. * Generates an image screenshot from the specified camera.
  130775. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130776. * @param engine The engine to use for rendering
  130777. * @param camera The camera to use for rendering
  130778. * @param size This parameter can be set to a single number or to an object with the
  130779. * following (optional) properties: precision, width, height. If a single number is passed,
  130780. * it will be used for both width and height. If an object is passed, the screenshot size
  130781. * will be derived from the parameters. The precision property is a multiplier allowing
  130782. * rendering at a higher or lower resolution
  130783. * @param successCallback The callback receives a single parameter which contains the
  130784. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  130785. * src parameter of an <img> to display it
  130786. * @param mimeType The MIME type of the screenshot image (default: image/png).
  130787. * Check your browser for supported MIME types
  130788. * @param samples Texture samples (default: 1)
  130789. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  130790. * @param fileName A name for for the downloaded file.
  130791. */
  130792. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  130793. /**
  130794. * Generates an image screenshot from the specified camera.
  130795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130796. * @param engine The engine to use for rendering
  130797. * @param camera The camera to use for rendering
  130798. * @param size This parameter can be set to a single number or to an object with the
  130799. * following (optional) properties: precision, width, height. If a single number is passed,
  130800. * it will be used for both width and height. If an object is passed, the screenshot size
  130801. * will be derived from the parameters. The precision property is a multiplier allowing
  130802. * rendering at a higher or lower resolution
  130803. * @param mimeType The MIME type of the screenshot image (default: image/png).
  130804. * Check your browser for supported MIME types
  130805. * @param samples Texture samples (default: 1)
  130806. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  130807. * @param fileName A name for for the downloaded file.
  130808. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  130809. * to the src parameter of an <img> to display it
  130810. */
  130811. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  130812. /**
  130813. * Gets height and width for screenshot size
  130814. * @private
  130815. */
  130816. private static _getScreenshotSize;
  130817. }
  130818. }
  130819. declare module BABYLON {
  130820. /**
  130821. * A cursor which tracks a point on a path
  130822. */
  130823. export class PathCursor {
  130824. private path;
  130825. /**
  130826. * Stores path cursor callbacks for when an onchange event is triggered
  130827. */
  130828. private _onchange;
  130829. /**
  130830. * The value of the path cursor
  130831. */
  130832. value: number;
  130833. /**
  130834. * The animation array of the path cursor
  130835. */
  130836. animations: Animation[];
  130837. /**
  130838. * Initializes the path cursor
  130839. * @param path The path to track
  130840. */
  130841. constructor(path: Path2);
  130842. /**
  130843. * Gets the cursor point on the path
  130844. * @returns A point on the path cursor at the cursor location
  130845. */
  130846. getPoint(): Vector3;
  130847. /**
  130848. * Moves the cursor ahead by the step amount
  130849. * @param step The amount to move the cursor forward
  130850. * @returns This path cursor
  130851. */
  130852. moveAhead(step?: number): PathCursor;
  130853. /**
  130854. * Moves the cursor behind by the step amount
  130855. * @param step The amount to move the cursor back
  130856. * @returns This path cursor
  130857. */
  130858. moveBack(step?: number): PathCursor;
  130859. /**
  130860. * Moves the cursor by the step amount
  130861. * If the step amount is greater than one, an exception is thrown
  130862. * @param step The amount to move the cursor
  130863. * @returns This path cursor
  130864. */
  130865. move(step: number): PathCursor;
  130866. /**
  130867. * Ensures that the value is limited between zero and one
  130868. * @returns This path cursor
  130869. */
  130870. private ensureLimits;
  130871. /**
  130872. * Runs onchange callbacks on change (used by the animation engine)
  130873. * @returns This path cursor
  130874. */
  130875. private raiseOnChange;
  130876. /**
  130877. * Executes a function on change
  130878. * @param f A path cursor onchange callback
  130879. * @returns This path cursor
  130880. */
  130881. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130882. }
  130883. }
  130884. declare module BABYLON {
  130885. /** @hidden */
  130886. export var blurPixelShader: {
  130887. name: string;
  130888. shader: string;
  130889. };
  130890. }
  130891. declare module BABYLON {
  130892. /** @hidden */
  130893. export var pointCloudVertexDeclaration: {
  130894. name: string;
  130895. shader: string;
  130896. };
  130897. }
  130898. // Mixins
  130899. interface Window {
  130900. mozIndexedDB: IDBFactory;
  130901. webkitIndexedDB: IDBFactory;
  130902. msIndexedDB: IDBFactory;
  130903. webkitURL: typeof URL;
  130904. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130905. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130906. WebGLRenderingContext: WebGLRenderingContext;
  130907. MSGesture: MSGesture;
  130908. CANNON: any;
  130909. AudioContext: AudioContext;
  130910. webkitAudioContext: AudioContext;
  130911. PointerEvent: any;
  130912. Math: Math;
  130913. Uint8Array: Uint8ArrayConstructor;
  130914. Float32Array: Float32ArrayConstructor;
  130915. mozURL: typeof URL;
  130916. msURL: typeof URL;
  130917. VRFrameData: any; // WebVR, from specs 1.1
  130918. DracoDecoderModule: any;
  130919. setImmediate(handler: (...args: any[]) => void): number;
  130920. }
  130921. interface HTMLCanvasElement {
  130922. requestPointerLock(): void;
  130923. msRequestPointerLock?(): void;
  130924. mozRequestPointerLock?(): void;
  130925. webkitRequestPointerLock?(): void;
  130926. /** Track wether a record is in progress */
  130927. isRecording: boolean;
  130928. /** Capture Stream method defined by some browsers */
  130929. captureStream(fps?: number): MediaStream;
  130930. }
  130931. interface CanvasRenderingContext2D {
  130932. msImageSmoothingEnabled: boolean;
  130933. }
  130934. interface MouseEvent {
  130935. mozMovementX: number;
  130936. mozMovementY: number;
  130937. webkitMovementX: number;
  130938. webkitMovementY: number;
  130939. msMovementX: number;
  130940. msMovementY: number;
  130941. }
  130942. interface Navigator {
  130943. mozGetVRDevices: (any: any) => any;
  130944. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130945. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130946. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130947. webkitGetGamepads(): Gamepad[];
  130948. msGetGamepads(): Gamepad[];
  130949. webkitGamepads(): Gamepad[];
  130950. }
  130951. interface HTMLVideoElement {
  130952. mozSrcObject: any;
  130953. }
  130954. interface Math {
  130955. fround(x: number): number;
  130956. imul(a: number, b: number): number;
  130957. }
  130958. interface WebGLRenderingContext {
  130959. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130960. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130961. vertexAttribDivisor(index: number, divisor: number): void;
  130962. createVertexArray(): any;
  130963. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130964. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130965. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130966. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130967. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130968. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130969. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130970. // Queries
  130971. createQuery(): WebGLQuery;
  130972. deleteQuery(query: WebGLQuery): void;
  130973. beginQuery(target: number, query: WebGLQuery): void;
  130974. endQuery(target: number): void;
  130975. getQueryParameter(query: WebGLQuery, pname: number): any;
  130976. getQuery(target: number, pname: number): any;
  130977. MAX_SAMPLES: number;
  130978. RGBA8: number;
  130979. READ_FRAMEBUFFER: number;
  130980. DRAW_FRAMEBUFFER: number;
  130981. UNIFORM_BUFFER: number;
  130982. HALF_FLOAT_OES: number;
  130983. RGBA16F: number;
  130984. RGBA32F: number;
  130985. R32F: number;
  130986. RG32F: number;
  130987. RGB32F: number;
  130988. R16F: number;
  130989. RG16F: number;
  130990. RGB16F: number;
  130991. RED: number;
  130992. RG: number;
  130993. R8: number;
  130994. RG8: number;
  130995. UNSIGNED_INT_24_8: number;
  130996. DEPTH24_STENCIL8: number;
  130997. MIN: number;
  130998. MAX: number;
  130999. /* Multiple Render Targets */
  131000. drawBuffers(buffers: number[]): void;
  131001. readBuffer(src: number): void;
  131002. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131003. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131004. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131005. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131006. // Occlusion Query
  131007. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131008. ANY_SAMPLES_PASSED: number;
  131009. QUERY_RESULT_AVAILABLE: number;
  131010. QUERY_RESULT: number;
  131011. }
  131012. interface WebGLProgram {
  131013. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131014. }
  131015. interface EXT_disjoint_timer_query {
  131016. QUERY_COUNTER_BITS_EXT: number;
  131017. TIME_ELAPSED_EXT: number;
  131018. TIMESTAMP_EXT: number;
  131019. GPU_DISJOINT_EXT: number;
  131020. QUERY_RESULT_EXT: number;
  131021. QUERY_RESULT_AVAILABLE_EXT: number;
  131022. queryCounterEXT(query: WebGLQuery, target: number): void;
  131023. createQueryEXT(): WebGLQuery;
  131024. beginQueryEXT(target: number, query: WebGLQuery): void;
  131025. endQueryEXT(target: number): void;
  131026. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131027. deleteQueryEXT(query: WebGLQuery): void;
  131028. }
  131029. interface WebGLUniformLocation {
  131030. _currentState: any;
  131031. }
  131032. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131033. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131034. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131035. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131036. interface WebGLRenderingContext {
  131037. readonly RASTERIZER_DISCARD: number;
  131038. readonly DEPTH_COMPONENT24: number;
  131039. readonly TEXTURE_3D: number;
  131040. readonly TEXTURE_2D_ARRAY: number;
  131041. readonly TEXTURE_COMPARE_FUNC: number;
  131042. readonly TEXTURE_COMPARE_MODE: number;
  131043. readonly COMPARE_REF_TO_TEXTURE: number;
  131044. readonly TEXTURE_WRAP_R: number;
  131045. readonly HALF_FLOAT: number;
  131046. readonly RGB8: number;
  131047. readonly RED_INTEGER: number;
  131048. readonly RG_INTEGER: number;
  131049. readonly RGB_INTEGER: number;
  131050. readonly RGBA_INTEGER: number;
  131051. readonly R8_SNORM: number;
  131052. readonly RG8_SNORM: number;
  131053. readonly RGB8_SNORM: number;
  131054. readonly RGBA8_SNORM: number;
  131055. readonly R8I: number;
  131056. readonly RG8I: number;
  131057. readonly RGB8I: number;
  131058. readonly RGBA8I: number;
  131059. readonly R8UI: number;
  131060. readonly RG8UI: number;
  131061. readonly RGB8UI: number;
  131062. readonly RGBA8UI: number;
  131063. readonly R16I: number;
  131064. readonly RG16I: number;
  131065. readonly RGB16I: number;
  131066. readonly RGBA16I: number;
  131067. readonly R16UI: number;
  131068. readonly RG16UI: number;
  131069. readonly RGB16UI: number;
  131070. readonly RGBA16UI: number;
  131071. readonly R32I: number;
  131072. readonly RG32I: number;
  131073. readonly RGB32I: number;
  131074. readonly RGBA32I: number;
  131075. readonly R32UI: number;
  131076. readonly RG32UI: number;
  131077. readonly RGB32UI: number;
  131078. readonly RGBA32UI: number;
  131079. readonly RGB10_A2UI: number;
  131080. readonly R11F_G11F_B10F: number;
  131081. readonly RGB9_E5: number;
  131082. readonly RGB10_A2: number;
  131083. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131084. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131085. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131086. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131087. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131088. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131089. 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;
  131090. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131091. readonly TRANSFORM_FEEDBACK: number;
  131092. readonly INTERLEAVED_ATTRIBS: number;
  131093. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131094. createTransformFeedback(): WebGLTransformFeedback;
  131095. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131096. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131097. beginTransformFeedback(primitiveMode: number): void;
  131098. endTransformFeedback(): void;
  131099. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131100. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131101. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131102. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131103. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131104. }
  131105. interface ImageBitmap {
  131106. readonly width: number;
  131107. readonly height: number;
  131108. close(): void;
  131109. }
  131110. interface WebGLQuery extends WebGLObject {
  131111. }
  131112. declare var WebGLQuery: {
  131113. prototype: WebGLQuery;
  131114. new(): WebGLQuery;
  131115. };
  131116. interface WebGLSampler extends WebGLObject {
  131117. }
  131118. declare var WebGLSampler: {
  131119. prototype: WebGLSampler;
  131120. new(): WebGLSampler;
  131121. };
  131122. interface WebGLSync extends WebGLObject {
  131123. }
  131124. declare var WebGLSync: {
  131125. prototype: WebGLSync;
  131126. new(): WebGLSync;
  131127. };
  131128. interface WebGLTransformFeedback extends WebGLObject {
  131129. }
  131130. declare var WebGLTransformFeedback: {
  131131. prototype: WebGLTransformFeedback;
  131132. new(): WebGLTransformFeedback;
  131133. };
  131134. interface WebGLVertexArrayObject extends WebGLObject {
  131135. }
  131136. declare var WebGLVertexArrayObject: {
  131137. prototype: WebGLVertexArrayObject;
  131138. new(): WebGLVertexArrayObject;
  131139. };
  131140. // Type definitions for WebVR API
  131141. // Project: https://w3c.github.io/webvr/
  131142. // Definitions by: six a <https://github.com/lostfictions>
  131143. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131144. interface VRDisplay extends EventTarget {
  131145. /**
  131146. * Dictionary of capabilities describing the VRDisplay.
  131147. */
  131148. readonly capabilities: VRDisplayCapabilities;
  131149. /**
  131150. * z-depth defining the far plane of the eye view frustum
  131151. * enables mapping of values in the render target depth
  131152. * attachment to scene coordinates. Initially set to 10000.0.
  131153. */
  131154. depthFar: number;
  131155. /**
  131156. * z-depth defining the near plane of the eye view frustum
  131157. * enables mapping of values in the render target depth
  131158. * attachment to scene coordinates. Initially set to 0.01.
  131159. */
  131160. depthNear: number;
  131161. /**
  131162. * An identifier for this distinct VRDisplay. Used as an
  131163. * association point in the Gamepad API.
  131164. */
  131165. readonly displayId: number;
  131166. /**
  131167. * A display name, a user-readable name identifying it.
  131168. */
  131169. readonly displayName: string;
  131170. readonly isConnected: boolean;
  131171. readonly isPresenting: boolean;
  131172. /**
  131173. * If this VRDisplay supports room-scale experiences, the optional
  131174. * stage attribute contains details on the room-scale parameters.
  131175. */
  131176. readonly stageParameters: VRStageParameters | null;
  131177. /**
  131178. * Passing the value returned by `requestAnimationFrame` to
  131179. * `cancelAnimationFrame` will unregister the callback.
  131180. * @param handle Define the hanle of the request to cancel
  131181. */
  131182. cancelAnimationFrame(handle: number): void;
  131183. /**
  131184. * Stops presenting to the VRDisplay.
  131185. * @returns a promise to know when it stopped
  131186. */
  131187. exitPresent(): Promise<void>;
  131188. /**
  131189. * Return the current VREyeParameters for the given eye.
  131190. * @param whichEye Define the eye we want the parameter for
  131191. * @returns the eye parameters
  131192. */
  131193. getEyeParameters(whichEye: string): VREyeParameters;
  131194. /**
  131195. * Populates the passed VRFrameData with the information required to render
  131196. * the current frame.
  131197. * @param frameData Define the data structure to populate
  131198. * @returns true if ok otherwise false
  131199. */
  131200. getFrameData(frameData: VRFrameData): boolean;
  131201. /**
  131202. * Get the layers currently being presented.
  131203. * @returns the list of VR layers
  131204. */
  131205. getLayers(): VRLayer[];
  131206. /**
  131207. * Return a VRPose containing the future predicted pose of the VRDisplay
  131208. * when the current frame will be presented. The value returned will not
  131209. * change until JavaScript has returned control to the browser.
  131210. *
  131211. * The VRPose will contain the position, orientation, velocity,
  131212. * and acceleration of each of these properties.
  131213. * @returns the pose object
  131214. */
  131215. getPose(): VRPose;
  131216. /**
  131217. * Return the current instantaneous pose of the VRDisplay, with no
  131218. * prediction applied.
  131219. * @returns the current instantaneous pose
  131220. */
  131221. getImmediatePose(): VRPose;
  131222. /**
  131223. * The callback passed to `requestAnimationFrame` will be called
  131224. * any time a new frame should be rendered. When the VRDisplay is
  131225. * presenting the callback will be called at the native refresh
  131226. * rate of the HMD. When not presenting this function acts
  131227. * identically to how window.requestAnimationFrame acts. Content should
  131228. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131229. * asynchronously from other displays and at differing refresh rates.
  131230. * @param callback Define the eaction to run next frame
  131231. * @returns the request handle it
  131232. */
  131233. requestAnimationFrame(callback: FrameRequestCallback): number;
  131234. /**
  131235. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131236. * Repeat calls while already presenting will update the VRLayers being displayed.
  131237. * @param layers Define the list of layer to present
  131238. * @returns a promise to know when the request has been fulfilled
  131239. */
  131240. requestPresent(layers: VRLayer[]): Promise<void>;
  131241. /**
  131242. * Reset the pose for this display, treating its current position and
  131243. * orientation as the "origin/zero" values. VRPose.position,
  131244. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131245. * updated when calling resetPose(). This should be called in only
  131246. * sitting-space experiences.
  131247. */
  131248. resetPose(): void;
  131249. /**
  131250. * The VRLayer provided to the VRDisplay will be captured and presented
  131251. * in the HMD. Calling this function has the same effect on the source
  131252. * canvas as any other operation that uses its source image, and canvases
  131253. * created without preserveDrawingBuffer set to true will be cleared.
  131254. * @param pose Define the pose to submit
  131255. */
  131256. submitFrame(pose?: VRPose): void;
  131257. }
  131258. declare var VRDisplay: {
  131259. prototype: VRDisplay;
  131260. new(): VRDisplay;
  131261. };
  131262. interface VRLayer {
  131263. leftBounds?: number[] | Float32Array | null;
  131264. rightBounds?: number[] | Float32Array | null;
  131265. source?: HTMLCanvasElement | null;
  131266. }
  131267. interface VRDisplayCapabilities {
  131268. readonly canPresent: boolean;
  131269. readonly hasExternalDisplay: boolean;
  131270. readonly hasOrientation: boolean;
  131271. readonly hasPosition: boolean;
  131272. readonly maxLayers: number;
  131273. }
  131274. interface VREyeParameters {
  131275. /** @deprecated */
  131276. readonly fieldOfView: VRFieldOfView;
  131277. readonly offset: Float32Array;
  131278. readonly renderHeight: number;
  131279. readonly renderWidth: number;
  131280. }
  131281. interface VRFieldOfView {
  131282. readonly downDegrees: number;
  131283. readonly leftDegrees: number;
  131284. readonly rightDegrees: number;
  131285. readonly upDegrees: number;
  131286. }
  131287. interface VRFrameData {
  131288. readonly leftProjectionMatrix: Float32Array;
  131289. readonly leftViewMatrix: Float32Array;
  131290. readonly pose: VRPose;
  131291. readonly rightProjectionMatrix: Float32Array;
  131292. readonly rightViewMatrix: Float32Array;
  131293. readonly timestamp: number;
  131294. }
  131295. interface VRPose {
  131296. readonly angularAcceleration: Float32Array | null;
  131297. readonly angularVelocity: Float32Array | null;
  131298. readonly linearAcceleration: Float32Array | null;
  131299. readonly linearVelocity: Float32Array | null;
  131300. readonly orientation: Float32Array | null;
  131301. readonly position: Float32Array | null;
  131302. readonly timestamp: number;
  131303. }
  131304. interface VRStageParameters {
  131305. sittingToStandingTransform?: Float32Array;
  131306. sizeX?: number;
  131307. sizeY?: number;
  131308. }
  131309. interface Navigator {
  131310. getVRDisplays(): Promise<VRDisplay[]>;
  131311. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131312. }
  131313. interface Window {
  131314. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131315. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131316. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131317. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131318. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131319. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131320. }
  131321. interface Gamepad {
  131322. readonly displayId: number;
  131323. }
  131324. type XRSessionMode =
  131325. | "inline"
  131326. | "immersive-vr"
  131327. | "immersive-ar";
  131328. type XRReferenceSpaceType =
  131329. | "viewer"
  131330. | "local"
  131331. | "local-floor"
  131332. | "bounded-floor"
  131333. | "unbounded";
  131334. type XREnvironmentBlendMode =
  131335. | "opaque"
  131336. | "additive"
  131337. | "alpha-blend";
  131338. type XRVisibilityState =
  131339. | "visible"
  131340. | "visible-blurred"
  131341. | "hidden";
  131342. type XRHandedness =
  131343. | "none"
  131344. | "left"
  131345. | "right";
  131346. type XRTargetRayMode =
  131347. | "gaze"
  131348. | "tracked-pointer"
  131349. | "screen";
  131350. type XREye =
  131351. | "none"
  131352. | "left"
  131353. | "right";
  131354. interface XRSpace extends EventTarget {
  131355. }
  131356. interface XRRenderState {
  131357. depthNear?: number;
  131358. depthFar?: number;
  131359. inlineVerticalFieldOfView?: number;
  131360. baseLayer?: XRWebGLLayer;
  131361. }
  131362. interface XRInputSource {
  131363. handedness: XRHandedness;
  131364. targetRayMode: XRTargetRayMode;
  131365. targetRaySpace: XRSpace;
  131366. gripSpace: XRSpace | undefined;
  131367. gamepad: Gamepad | undefined;
  131368. profiles: Array<string>;
  131369. }
  131370. interface XRSession {
  131371. addEventListener: Function;
  131372. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131373. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131374. requestAnimationFrame: Function;
  131375. end(): Promise<void>;
  131376. renderState: XRRenderState;
  131377. inputSources: Array<XRInputSource>;
  131378. }
  131379. interface XRReferenceSpace extends XRSpace {
  131380. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131381. onreset: any;
  131382. }
  131383. interface XRFrame {
  131384. session: XRSession;
  131385. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131386. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131387. }
  131388. interface XRViewerPose extends XRPose {
  131389. views: Array<XRView>;
  131390. }
  131391. interface XRPose {
  131392. transform: XRRigidTransform;
  131393. emulatedPosition: boolean;
  131394. }
  131395. declare var XRWebGLLayer: {
  131396. prototype: XRWebGLLayer;
  131397. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131398. };
  131399. interface XRWebGLLayer {
  131400. framebuffer: WebGLFramebuffer;
  131401. framebufferWidth: number;
  131402. framebufferHeight: number;
  131403. getViewport: Function;
  131404. }
  131405. interface XRRigidTransform {
  131406. position: DOMPointReadOnly;
  131407. orientation: DOMPointReadOnly;
  131408. matrix: Float32Array;
  131409. inverse: XRRigidTransform;
  131410. }
  131411. interface XRView {
  131412. eye: XREye;
  131413. projectionMatrix: Float32Array;
  131414. transform: XRRigidTransform;
  131415. }
  131416. interface XRInputSourceChangeEvent {
  131417. session: XRSession;
  131418. removed: Array<XRInputSource>;
  131419. added: Array<XRInputSource>;
  131420. }